8 ms·
Show HN: How to X with Y. Engineering questions, answered
- alex_portabella 6y agoHey HN, I started this project last Tuesday to scratch my own itch. It's basically copy/pasteable code snippets for common tasks in many languages. Like many developers I work in different languages and often forget syntax or how to do simple things. I find if I'm working in a big codebase I can usually get comfortable quickly, but it's when I'm faced with a blank page in my editor I think... err how do I do this again?
- junon 6y agoI've had this idea but with libraries instead. Neat to see some similar lines of thinking. Some questions: - Is the project open-source? - Why no github signin? - How do you search for X but only in Y language? - How are you going to deal with duplication? - Will you be doing a full 2D spread of combinations? E.g. writing to a file is pretty common - perhaps you can create a relationship between languages so that you can see how it's done in other languages from the same page. - How will you handle cases where there are multiple ways of doing things? - Is search broken? "Write to a file" is the first entry there without searching, but searching for "write to a file" shows no entries. - How will you handle cases where environment matters? E.g. writing a file in Javascript is going to be different between web browsers and Node.js, and force-inlining a function is going to be different between clang and msvc, etc.
- alex_portabella 6y agoCool! Yeah that's another good use case. With ecosystems like NPM (ie. ones that have so many packages) it can be really hard to know which library to use. - Is the project open-source? Not open source yet but no reason why it can't be. - Why no github signin? Good point. I recently mulled over which O Auth providers to support and for an MVP I decided Google was enough. - How do you search for X but only in Y language? - Will you be doing a full 2D spread of combinations? The idea is the page "How to write to a file" has all the language examples - How are you going to deal with duplication? If it gets popular I will deal with that issue then. - How will you handle cases where there are multiple ways of doing things? - How will you handle cases where environment matters? You can have multiple examples per language. The one with the most votes will be most prominently displayed.
- junon 6y agoSorry, updated my post slower than you answered :D I had a few other questions
- alex_portabella 6y agoNo worries! I just updated too. Hope your questions have been answered
- dpryden 6y agoMy first reaction to the page was: how do I know who wrote these? How do I know whether they are right or wrong? How do I correct ones that I can see are incorrect (or at least misleading)? I don't see any "about this site", "who created this site", etc. I don't see any information about who authored a particular snippet. Perhaps more information is available if you log in? But it seems like it should be possible to evaluate the trustworthiness of a site _before_ sharing information with it, so I don't feel comfortable interacting with the site as it is.
- alex_portabella 6y agoGood points, thanks for posting. I stated elsewhere in this thread but the project is only 6 days old. I haven't had time to code up an /about page, reputation system and user profile pages just yet.
- _ix 6y agoHey, this is kind of like a deeper hyperpolyglot.com! I appreciate the nod to learnxinyminutes.com, intentional or otherwise. Could be pretty neat, but it won’t let me proceed to login with Google. I was curious how categories and languages were managed. How do you prevent the inevitable “How do I hack The Gibson with Visual Basic 3” if they’re all fully crowd sourced? Edit: mobile typos
- alex_portabella 6y agoWow that's pretty sweet, another commenter mentioned learnxinyminutes but hyperpolyglot looks awesome as well. I guess for now while it's small I have to heavily moderate, which I have no problem with. If something is detracting from the platform I will remove it, but it's a fine line where I cross into S/O territory where they mark everything as off topic.
- alex_portabella 6y agoI'm unsure what's going wrong with your Google login unfortunately. A lot of others have managed to register with no issues. It's possible your Google email is not verified?
- insomniacity 6y ago403?
- alex_portabella 6y agoSeems up to me?
- insomniacity 6y ago8 hours later, still: 403 ERROR The request could not be satisfied. Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation. Generated by cloudfront (CloudFront) Request ID: CYfM2liDaLwK2Mu8q7vnSE5rn89Fg8HmUSY6jIrL_5iTxe2dU1ADyw==
- maccard 6y agoWhy is this better than stackoverflow? For example, [0] vs [1] (writing to a file with python). If I want to write to a file in python, I do'nt care what options there are in ruby or JS. Is there a way for me to flag something as incorrect? As an example, in [0] the python implementation should really be the SO link (using `with open() as f` rather than manually closing it) Finally, and most importantly, there is no mention of the licensing of the code snippets here. StackOverflow [2] makes it excruciatiangly clear what the license is. Anyone who is using this for work purposes shouldn't touch this with a barge pole without a very clear disclaimer on the license of the code. [0] https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d64522fdd5d https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d645... [1] https://stackoverflow.com/questions/34204523/how-to-write-to-file-with-python https://stackoverflow.com/questions/34204523/how-to-write-to... [2] https://stackoverflow.com/help/licensing https://stackoverflow.com/help/licensing
- alex_portabella 6y agoOf course Stack Overflow is great. It has a wealth of information, experts and allows for larger questions to be asked than "How do I write to a file", like, "how would you design this database schema". The idea is that anyone can submit alternatives, the one with the highest number of votes will be most prominently displayed. I personally am not a Python developer and just seeded some initial snippets, but hopefully someone who is submits new ones. That's a great point re. the licensing, I will have to look into it.
- maccard 6y ago> Of course Stack Overflow is great. It has a wealth of information, experts and allows for larger questions to be asked than "How do I write to a file", like, "how would you design this database schema". Googling questions brings me to stack overflow which has years worth of information, and answers to all of these how do I do X with Y questions, along with links to the documentation. Why would I want to use this site rather than stack overflow, what does it do differently? If SO has everything your site has plus more, (and lets be honest, SO has answers for those questions), I don't see the benefit here. > I personally am not a Python developer and just seeded some initial snippets While I understand why this is done, this is exactly the issue. The code you have right now is wrong, but stack overflow's is correct.
- tluse 6y agoHmm. I logged on thru Google OAuth, and now I'm logged on as Alex. I've done the List Comprehension Python list filtering here: https://howtoxwithy.com/how-to/615701ba-4707-423d-a012-479431ae5a86 https://howtoxwithy.com/how-to/615701ba-4707-423d-a012-47943... but that one's written by "Alex", i.e. you.
- reportgunner 6y agoDid you know lists have a .remove() ? >>> my_array = [1, 2, 3, 4, 5] >>> my_array.remove(1) >>> my_array [2, 3, 4, 5]
- reallydontask 6y agoSeems that if you register with google Oauth the username is always Alex ... or at least for the two of us
- alex_portabella 6y agoThat was an oversight on my part. If you sign out and sign back in I can edit the database to give you credit.
- junon 6y agoSorry for the double post - but editing a snippet causes the snippet to disappear entirely. A bug tracker would be really helpful here :)
- alex_portabella 6y agoDefinitely. I am tracking that here https://app.portabella.io/projects/daa40d3e-655f-4cb4-b4f4-628c29133ddb/edit/e5ccfb07-356d-4105-8723-08b37933a493 https://app.portabella.io/projects/daa40d3e-655f-4cb4-b4f4-6... Thanks for the bug report!
- junon 6y agoHaha that website is also annoying. They're using the history API to manage the modals. So if you click that link directly, then click the X or simply click out of it, you end up back here. EDIT: I literally can't even click on the site's logo to go to their front page without being kicked out of their site entirely. EDIT2: Oh you made that site. Don't use the history API to go backwards (: it's a UX nightmare.
- alex_portabella 6y agoYeah that's my other project, but good to know. I will sort that out.
- junon 6y agoDidn't mean to unleash a shotgun of criticisms on multiple of your projects, my apologies :D way more effort put into these than I normal put into side projects :) I would actually like to try portabella, hence why I was trying to click the logo :D
- alex_portabella 6y agoNo worries, I don't take it personally. Like I said in another comment, Portabella is my main side project. I whipped this up quick because I thought it was a cool idea. I'll be launching Portabella on Product Hunt and Hacker News next week, this was kind of a trial run for that. Any questions or issues shoot me at alex@portabella.io
- zarathustreal 6y agoHow will this be monetized?
- Kiro 6y agoWhy do you presume it will be monetized?
- alex_portabella 6y agoI guess because earning money is nice. This project serves a few purposes: - scratch my own itch. I am missing something like this - test launch on Product Hunt/Hacker News. I developed this in 6 days and I have a larger product I want to launch soon (https://portabella.io https://portabella.io) but I want that to go perfectly. This served as a kind of dry run I beefed up the servers for today but day to day I only expect this to cost me a few bucks a month, so keeping it running is no issue. It can also be nice to point to something and say, I made that, so I'm happy to have it up and running.
- zarathustreal 6y agoI assume by your question that you presumed it to be run indefinitely at a loss? If that’s the case may I ask why you presumed that it wouldn’t be monetized? If that’s not the case and you’re asking a scholarly question for the sake of knowledge my answer is “because it’s not otherwise sustainable”
- Kiro 6y agoI've built close to 30 free small sites that are all running at a loss. Costs me about $100 a month in total. It's fun, rewarding and worth every penny.
- boltzmannbrain 6y agoI get it, this is supposed to more usable than Stack Overflow, where pedantic discussions can obstruct usability by occluding the simple Q&A. But right away I see the simplicity of "How to X with Y" yields solutions that are not entirely correct (which is different from incorrect). For example, the current solution for reading a file in Python is unsafe, yet there is no way of seeing how or why; sure it works, but it also proliferates dirty code.
- alex_portabella 6y agoTotally agree with you. The idea is that you can have multiple examples per language, the highest upvoted one is displayed first, then you can page through the others. You can also comment on examples. But yes, care needs to be taken for sure.
- why_only_15 6y agoWhy is the python one unsafe? Lack of with-block?
- riezebos 6y agoWhen I look at the website I currently only see "No items", but if you are using Python 3.6+ the pathlib[0] library has a very nice way of reading/writing files: from pathlib import Path p = Path("my_file.txt") p.write_text("thing that needs to go into a file") [0]https://docs.python.org/3/library/pathlib.html#pathlib.Path.write_text https://docs.python.org/3/library/pathlib.html#pathlib.Path....
- alex_portabella 6y agoIt seems up to me https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d64522fdd5d https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d645... That's the "Write to a file" item, I can see two Python examples there.
- riezebos 6y ago
- chiefalchemist 6y agoIt would be cool to see a solution to some problem written out step by step not in code but in English (or the language of your choice). Then from there link to the code example that solves that bit. Having to grasp logical problem solving _and_ code syntax at the same time can be overwhelming when just starting.
- alex_portabella 6y agoCan you expand a little on your suggestion? How deep into semantics would you go when describing something? ie. making an http request, do you include DNS, headers, TLS or is it simpler to just say `https.get(url)`
- chiefalchemist 6y agoOff the top of my head, I envisioned trying to teach someone. First, I'd write out the problem. Then I'd break that down, again and again. All in English (read: no code). Then I'd say: Now that we've dissected the problem, let's write the code. Yeah. High level. But I can see it making learning simpler as it separates the problem solving, from the implementation (code). And the same problem could be demo'ed across multple languages.
- chrisbrauns 6y agoInteresting idea. Just a note that the first answer I saw[0] is not correct. This is given as how to write to a file in Javascript. const {fs} = require('fs') fs.writeFileSync('/tmp/myfile.txt', Buffer.from('hello')); But you can't just do this in plain old JS. It needs to be Node running ES6+ [0]: https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d64522fdd5d https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d645...
- alex_portabella 6y agoThat's true. Definitely need a way to distinguish between the two (browser vs. server) sometimes
- user5994461 6y agoI love how in the very first example, how to open a file in python, the example forgot to close the file! Cherry on top. It's not as if python had a special syntax to use a resource and close it automatically at the end of the block, precisely to avoid this sort of issues. /s
- reportgunner 6y agoYeah it should be using a context manager.
- hardwaresofton 6y agoWhile this project is very young and is narrow in scope, I'm really excited by the somewhat parallel idea of building a good enough rosetta stone for practical computing such that one could power a programming platform with human language syntax. Imperative programming and natural writing have an overlap I think is under-appreciated -- the amount of people that could grok computer programming if programs became essays, functions became paragraphs and such is large I reckon. Has anyone seen anything like this before? This submission seems like it could be a first step, but it's not the authors' goal. Somewhat more on-topic, learnxinyminutes[0] is fantastic for jogging my memory on languages I use rarely. [EDIT] - Oh also, I think that this kind of project could have some enterprise viability -- having private instances sharable by tech teams could make it much easier to on-board and share code snippets/best practices with team-members and keep tech-debt knowledge fresh. [0]: https://learnxinyminutes.com https://learnxinyminutes.com
- Swizec 6y agoWhat you describe is legalese. The precision of programming with the syntax of natural language. Programmers of legalese are ... special. Even fewer people get into that field than get into programming. Because expressing your thoughts and modeling reality precisely is the hard part. Not the syntax.
- hardwaresofton 6y agoBut the domains are drastically different. I assume you mean legalese as is used in Law -- modeling reality of law is hard, but modeling reality for computers is not hard, we've worked hard to make things very deterministic and demonstrably so. All we do is send instructions to computers all day that are mostly executed perfectly, changing the language you use to speak to the computers is the point of higher level languages, and I strongly consider english to be just another frontend (in the LLVM sense), just one that is a lot harder to encode the semantics of fully. But the thing is, you don't need to encode the semantics fully -- just make paths one at a time for certain functionality (ex. `read_file(path: string): string` can have it's first "call sentence" be "read file from <path on disk: var> and store the contents in <new const var>")
- jessehorne 6y agoI can see that the project is very early in development but honestly this is great. I hope you use all the feedback here to improve it. You have a winner of an app, in my opinion!
- alex_portabella 6y agoCheers! I really appreciate it Jesse
- whitten 6y agoCould you create a github or gitlab, at least to track issues? For example: When I try to verify my account, (using https://backend.howtoxwithy.com/auth/confirm/BIGHEXNUMBER https://backend.howtoxwithy.com/auth/confirm/BIGHEXNUMBER) I get a message: No webpage was found for the web address: https://backend.howtoxwithy.com/auth/confirm/BIGHEXNUMBER https://backend.howtoxwithy.com/auth/confirm/BIGHEXNUMBER Also when I used https://howtoxwithy.com/how-to/615701ba-4707-423d-a012-479431ae5a86 https://howtoxwithy.com/how-to/615701ba-4707-423d-a012-47943... It let me login as David Whitten but when I used the NEW Button, two things: 1) I can't put in the language name I use. This increases the pain of using an obscure language. Since I use a very niche language, it is frustrating that languages that I know have significantly smaller worldwide code bases are there, but M is not. The page https://github.com/csurfer/gitlang/blob/master/languages.txt https://github.com/csurfer/gitlang/blob/master/languages.txt lists all the languages accepted on github as of 2016 (it is a simple list, suitable for a dropdown list). The page https://github.com/github/linguist/blob/master/lib/linguist/languages.yml https://github.com/github/linguist/blob/master/lib/linguist/... gives more details about the languages recognized by linguist. 2) Not reproducible: When I choose a language (like JavaScript) the dropdown list is blank for that item. I expect it is just that the text color is the same as the background, actually)
- alex_portabella 6y agoHey Dave Thanks for that report. I've fixed that issue with the drop down. I'll need to look into the account verification issues. I'm having no problems on my end. I have a the development/bug tracking board here https://app.portabella.io/projects/daa40d3e-655f-4cb4-b4f4-628c29133ddb https://app.portabella.io/projects/daa40d3e-655f-4cb4-b4f4-6..., it's read only for the public right now. I'll get on to using a different list of programming languages shortly
- pwinnski 6y agoThis seems like a really bizarre interface. When I first opened it in Safari, I was shown exactly two examples, and despite the underlined coloring of things like Python and Go as they rotated through the header, they're not clickable. I'd given up on the site as broken before I saw other comments here suggesting I missed something, so I tried loading it again, this time in Chrome, and there I saw more examples, but still all JS. with no other obvious options or way to find other languages. Finally I noticed "5 other examples" in what is literally the least-highlighted text on the screen, and that led to me other languages. Discoverability: 1 out of 10 As the header text rotates, it shifts the rest of the content up and down which is not helpful for reading or targeting. All in all, I won't be back.
- alex_portabella 6y agoHey, thanks for the honest feedback. Looks alright for me in Safari, the snippets shown are just the ones with the most votes, right now those are all JS. I do agree that the interface isn't 100% intuitive, I'm not much of a designer and I whipped this together in the last week. It will get better.
- pwinnski 6y agoThanks for your response. I pooped on your effort pretty directly, and you responded with grace. Maybe I'll check back in a few weeks after all!
- c22 6y agoSpeaking of the UI, is there any way for it to show something when loaded without JavaScript enabled? Right now I just see a black screen. When I load Stack Overflow I see text and code snippets, so I will probably keep using that for the time-being.
- alex_portabella 6y agoYeah. Definitely I need to get on the server side rendering train. It's a React app because I know React and wanted to get it out the door quickly (read 6 days) which is overkill for the functionality provided.
- catchmeifyoucan 6y agoI just submitted a code block, and I didn't get any feedback after my response. Is there a manual approval process? I like the interface, though it could benefit from organization better. This is actually really cool - imagine that you could go from pseudo-code to working program using this library.
- alex_portabella 6y agoNo approval process. I can see your example here https://howtoxwithy.com/how-to/0b04d75d-e929-4daf-9c0a-57bfa785d824 https://howtoxwithy.com/how-to/0b04d75d-e929-4daf-9c0a-57bfa..., just click the arrow button on the JavaScript panel. Definitely agreed on organising better.
- joshspankit 6y agoQuick request: Can you make the question a link? “Oh perfect, how to append an array in Java is what I’m looking for. Tap. nothing. question rotated out already. Ok.. Do I have to type the whole thing in search to find it now?“
- alex_portabella 6y agoHey, great idea! I will definitely do that