12 ms·
Show HN: Write code using natural language
- deleted 7y ago[deleted]
- king_magic 7y agoThis looks pretty neat. Thought about something sort of like this awhile back but never built it out, glad to see someone’s giving a try! Good luck!
- matchbok 7y agoCool experiment. Really shows how poorly conceived/verbose Auto Layout is. The first thing I do in any iOS project is add some sort of wrapper around all that constraint nonsense.
- tannerc 7y agoCan you elaborate your approach? I've been making iOS apps for a decade now but auto layout and constraints scare the bajesus out of me.
- tshepom 7y agoOf course: the app draws from a database of thousands of snippets that are cleaned up and generalized with some scripting. Natural language queries are handled like search, with semantic matching over both natural language and code structures. Content within the snippet like naming, "subject"/"target", and values are dynamic (use # to modify those values) – but it still needs work. As for auto layout, I actually have a feature for that on the roadmap but wasn't sure it was a common problem – bumping up its priority!
- zapzupnz 7y agoWhen GP asked for GGP to elaborate on their approach, I think they meant for GGP to discuss their wrapper around constraints.
- matchbok 7y agohttps://snapkit.io/ https://snapkit.io/ Makes life easy.
- runyonave 7y agoThis seems more like a novelty than a good idea. No thanks.
- tshepom 7y agoI'm very committed to the project and use it myself everyday, but I understand that point of view – it's a bit of a moonshot. Please let me know if you have any specific criticisms
- zapzupnz 7y agoAnd it seems like you created an account just to slag off somebody's work without providing any real constructive criticism; no, thanks. Are you an iOS or macOS app developer? Then you'll see the benefit of being able to look things like this up, especially in view of how Apple has deprecated a lot of their developer documentation without providing adequate replacements. Tools like this can seriously help ease the pain for a lot of developers who just want something that should be simple done but don't want to scour Stack Overflow looking at other peoples' terrible code examples from years back. If you're not an iOS or macOS app developer, then perhaps you don't see the usefulness, but that would only lead to the conclusion that you're giving unhelpfully besmirching something that has little to nothing to do with you.
- injidup 7y agoThis will just converge to some kind of lisp and then pragmatically end up as XML and then be thrown away when it is realised it is a poor imitation html.
- Tehchops 7y agoIs all "code of code" inevitably destined for a Lisp dialect?
- imglorp 7y ago"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp." - Greenspun's Tenth Rule
- cleansy 7y agoIMHO: There is a good chance that Lisp is pretty close to expressing "natural language" in code. I would argue that written text / prose is even a bad starting point. I'd rather think about having an UML Activity Diagram, add a way to add parameters / variables to it. Then visually imagine that you take away the full bubbles around the commands and just leave the sides. They look like brackets, right? Now fiddle in a syntax for having parameters, maybe place them next to the text that describes what the program wants to achieve. The next step is to define what the program or routine is actually doing, so think about step one again. ... Every time I think about a non-graphical way of writing a program as intuitive as possible I usually end up with some sort of Lisp. EDIT: several edits for wording
- tigershark 7y ago(Not (I think (really that (speak we (like this))))
- codr7 7y agoIt's more uniform, we use other forms of punctuation in writing. Spoken programming languages is a different can of worms.
- swlkr 7y agoWow I really like this! My main problem when programming against mac/iOS APIs is constantly looking up how to do the little things shown in the demo video. I don't look forward to writing macOS/iOS apps but this makes me think differently.
- epberry 7y agoI think you've nailed it. Getting all the constructs right can be tough - Metacode solves that.
- seisvelas 7y agoThis seems more like a helpful glue between documentation and code than "write code using natural language". Nevertheless, very cool!
- carlmr 7y agoI was thinking more along the lines of natural language snippet creation. I think one of the key problems here remains that you go from a ~30 word (+your own identifiers) vocabulary to a English language vocabulary where you're not sure how to express something. The example says constrain x. I wouldn't have searched for constrain, but for saturation, min-max, limit, or something along those lines. I'm not sure this will work as well if you don't use the right vocab.
- guiltygods 7y agoOnly Swift or it can handle any language ?
- tshepom 7y agoYup, just Swift right now, but collecting requested languages here: https://forms.gle/Yfgxn3yi4JHvjmD17 https://forms.gle/Yfgxn3yi4JHvjmD17
- matchbok 7y agoMore evidence that iOS really just needs a declarative UI format. Storyboards/IB are trash and doing it programmatically is fine, but slow and error-prone.
- Grustaf 7y agoIf you think it’s trash it’s probably that you don’t know how to use them. I’ve been making glorious UIs in IB for half a decade.
- matchbok 7y agoI know how to use them just fine, thanks. Anything that cannot be viewed/compared in version control or tested easily is trash. You cannot easily collaborate on complex IB or storyboards.
- DanielBMarkham 7y agoIn a tightly-scoped domain like "write code in Vue.js" it might be really cool. Looking forward to seeing how this evolves! But just like self-driving cars, once you start expanding the scope, and only just a little bit, it doesn't look so cool anymore. I would love to see how far they can take this. Programming in the purest sense is taking problems that real people have, expressed in their own words, and creating a logical symbolic construct that automates a sequence of interactions that pleases them. Human language is an extremely fuzzy and messy affair involving all sorts of things like body language that don't transfer to writing. Programming is not like that. These are not just different things. These are completely different domains of things. Neat. Best of luck, guys!
- MuffinFlavored 7y agoI toyed with the idea that corporate business analysts (who write requirements for products then hand to developers) could just write in a different syntax and pass them to a compiler that makes: 1. database tables 1. API CRUD endpoints with validation / sanitation 1. screens with input fields Most of the corporate work I did was very similar to this. It was either a batch job, a UI screen, or an API that talks to some other service.
- barbecue_sauce 7y agoIsn't that what UML was supposed to be for?
- MuffinFlavored 7y agodid UML not work out? why not?
- barbecue_sauce 7y agoMany people still use UML. It will always be there to use, whether or not it "worked out".
- 7y ago
- throwaway55554 7y agoNatural language is ambiguous. Grammars for computer languages are designed to remove ambiguity. A natural language that is used to program a computer, too, will have to remove ambiguity, thus only using a severely constricted subset of a natural language. Is it worth it beyond curiosity? If a person can't grok a computer language are they going to grok such a terse natural language?
- The_rationalist 7y agoOnly a Subset of features of natural langage introduce ambiguities, equivocations, etc. It is perfectly doable to force one and only one meaning per keyword (just like do programming keywords already (if, while, etc), removing the ability to use coreferences, etc I would love to see a great constrained English, formal without the readability and expressivity loss of formal symbolic grammars / formal maths
- SilasX 7y ago>Only a Subset of features of natural langage introduce ambiguities, equivocations, et I wish! People won't even use "literally" consistently, despite it existing to prevent you having to guess which sense a speaker means. Edit: Toned down.
- _emacsomancer_ 7y agoPeople love to pick on the intensive meaning of "literally", perhaps because it is more recent, but it's really not much different from the range of uses of "really", which also can mean both 'in fact, truly' as well as an intensifier sense like 'very'. E.g. "I was really shocked", "I was literally shocked" have similar ambiguities. Competent human speaker generally provide enough context that potential ambiguities aren't too problematic -- for other human beings, if not for machines. Human languages are more ambiguous than you might imagine, and lexical things like 'what meaning of "literally" is the speaker using' are pretty tip-of-the-iceberg stuff. (Think about what "Every man wants to read some book" or "the girl saw the man with the binoculars" (can) mean.)
- 7y ago
- jason_zig 7y agoNice landing page, it made it extremely clear what your product was and how I might use it. I'm usually skeptical about programming language abstractions but from the demo it looks like this is more of a "helpful addition" then something you need to fully commit to which is interesting. I don't do a lot of Swift but will keep this in mind if I do. Best of luck!
- faissaloo 7y agoIf you want to understand why this is bad just look at AppleScript, probably the closest thing I've ever seen to natural language, the only problem is that it's impossible to just figure something out if there isn't a tutorial, because there's no real convention you can make guesses based on.
- JadeNB 7y agoAppleScript (and COBOL before it) was my first thought, too. Gruber calls the problem it exemplifies the "English-likeness monster" (https://daringfireball.net/2005/09/english-likeness_monster https://daringfireball.net/2005/09/english-likeness_monster).
- tshepom 7y agoAh, interesting! The difference between Metacode and something like AppleScript is that the artifact left over from using Metacode is still the rigorous programming language you're used to. If we retain a query log, you could even convert your natural language queries into code comments alongside your code to actually improve clarity.
- pvg 7y agoYou're going to get a lot of comments like these because when you say 'natural language' and 'programming' or 'code' in the same sentence people think coding directly in some 'natural'-like language. Also people often don't click on the actual links and many don't necessarily watch endlessly looping video clips when they do. A little bit of verbiage on the site might help that and head off the more obvious-but-inaccurate critiques. .
- abecedarius 7y agoIs there a summary in text? I don't watch videos without a reason.
- tshepom 7y agoI wrote a comment about how it works: https://news.ycombinator.com/item?id=19985482 https://news.ycombinator.com/item?id=19985482. Will do a short blog post sometime soon.
- abecedarius 7y agoThanks!
- NikkiA 7y agoIt searches stack overflow and inserts the top answer in your chosen language as code
- deleted 7y ago[deleted]
- carhartt 7y agoIt's actually kind of cool to watch the animation, the tool maybe can help teach people how to code in a much faster time-lapse way. I personally don't know how to code in Swift but I think I learned a lot just watching the animation and the different snippets. Maybe you can livestream your Metacode app on Twitch for a learning channel.
- AdmiralAsshat 7y agoProject will end when it discovers it has reinvented HyperCard.
- zapzupnz 7y agoIt's a snippet program. It's not trying to reinvent anything.
- mistersys 7y agoReally awesome stuff for dealing with verbose frameworks. In the code builder demo, it strikes me that all that code in swift could be replaced with a declarative format: let TestVC = viewController( button( padding: { left: 5 }, width: 100, height: 200 ) ) And probably be easier to type than these snippet demos. Has there emerged a good declarative API for iOS? As a web developer, as much as I hate the insanity of the javascript tooling ecosystem it's hard to imagine going back to the spaghetti I see with swift/iOS apps.
- llamataboot 7y agoMy "first" programming language other than BASIC as a kid was probably learning Inform to create interactive fiction with http://inform7.com/ http://inform7.com/ It was a pretty complex language, and meant to use English syntax to mix both the fiction writing and the coding. So you can end up with code that looks like the following, for example --- "Stage is a room. The old lady is a woman in the Stage. Understand "mother" or "stepmother" as the old lady. The old lady is active. The description of the lady is "She looks plucked: thin neck with folds of skin exposed, nose beaky, lips white. Perhaps when her fortunes are mended her cosmetics too will improve."" --- And it obviously gets more complex as you create things like objects with weights and inventory limits etc. My experience of it is that when it worked it was pretty magical, but when it didn't it was utterly maddening to figure out how to get it to parse. Kinda felt like a voice help that barely works. Best of luck with this, I like where it looks like it is going, but it simply has to be /really good/ to be value-added and not frustration-added
- pvg 7y agoThis tool is almost, but not quite, entirely unlike Inform, though. The 'programming' part is still done in a regular old language like Swift. The tool finds and/or generates snippets for you and plonks them into the Swift code you're actually writing.
- llamataboot 7y agoyes, I see that, I should have been more clear that I knew it was a separate domain. This looks more like extended and interesting macros. My only point was that when you move towards being able to express things in natural language - whether as programming or even getting Siri to call your friend, the frustration level can be much higher if it doesn't work as expected. There is something about getting to talk in "natural lanaguge" some of the time, and otherwise having to repeat yourself while trying variations in syntax that just feels bad. Since I was talking about Inform, probably analogous is the text adventure issue where you know /how/ to solve the riddle, but you don't know how to tell the machine that you know. "Give lantern to crocodile" "Offer lantern to crocodile" "Put lantern on crocodile" etc
- _bxg1 7y agoUsing NL as a macro system for quickly inserting code, instead of as a way to hide actual code, seems like a good use-case. I wish the website was more informative about how much you can do with it, how far it goes to automatically generate snippets, and what kind of language support it's planned to have.
- scotty79 7y agoNormally I'd be very sceptical but this just seems like a shortcut to googling the thing you need from stackoverflow and shortcuts are nice.
- deleted 7y ago[deleted]
- jasode 7y agoOne way to look at Stackoverflow is that it's a gigantic index that maps "intuitive plain English" to "non-intuitive exact syntax". A good exampe of bridging this mismatch is "git" commands. A lot of questions about Git are just translating natural English into the "secret decoder ring" lingo of Git.[0] E.g. "How do I undo a commit?" isn't something obvious like "git undo". Instead, it's the more cryptic "git reset HEAD~"[1] A lot of the programming grind is like that. You know the English words for what you want to accomplish but don't know the exact programming syntax to make it happen. So this app is sort of like putting Stackoverflow lookups with copy&paste directly into the IDE. In contrast, the existing "insert snippets" functionality in Visual Studio[1] or IntelliJ have abbreviations to help find templates of code but not quite the rich natural language of Stackoverflow. I wouldn't be surprised if future versions of those IDEs incorporate something like Metacode. [0] so many "How to...?" in the most-upvoted questions tagged [git] : https://stackoverflow.com/questions/tagged/git?sort=votes&pageSize=15 https://stackoverflow.com/questions/tagged/git?sort=votes&pa... [1] https://stackoverflow.com/questions/927358/how-do-i-undo-the-most-recent-local-commits-in-git https://stackoverflow.com/questions/927358/how-do-i-undo-the... [2] https://docs.microsoft.com/en-us/visualstudio/ide/code-snippets?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/ide/code-snipp...
- Wump 7y ago100% agree with this take. I mentioned it in another comment, but I've actually been working on a project which is essentially a better search engine for programming questions that's integrated in your IDE. When possible, you try to pull out code snippets from SO/github/reference sites/etc that answer the query with high confidence. (Essentially like "instant answers" in google, but making it better by focusing on programming questions.) The challenge is the level of noise and ambiguity that you get back in search results, and actually sorting through that to surface the right answers.
- SilasX 7y agoI agree that a lot of the unremovable difficulty in programming is translating natural English into something precise. But I also think git often makes the problem worse by splitting similar operations unnaturally across different commands. I believe that was the motivation behind mercurial.
- scotty79 7y agoI'd prefer it to be "Show HN: Communicate with humans by writing code instead of using natural language"
- bawllz 7y agoVery cool! Do you have any ideas for how to document the tool well? Thank you for the smile this brought to my face :). Really imaginative and cool tool.
- tshepom 7y agoNot yet, right now I just have a tutorial window that shows up the first time you use the code builder feature, and the videos on the home page. Open to suggestions!
- Wump 7y agoI gave it a try; love how fast and simple it is! You probably already know this, but the set of snippets are somewhat limited at the moment (though pretty good for a first launch). Also, it would probably be helpful to have more descriptions/metadata around each snippet, so that you can use some NLP goodness to make search better. I've been working on a related idea, which is sort of a search engine for programming questions integrated into your IDE (starting with JS in VSCode). The idea is to give you fast, relevant answers (code snippets when possible), and reduce context switching to the browser to keep you in flow. Similar in spirit though; would love to chat more! (my contact info in profile; I didn't see a way to contact you)
- aatharuv 7y agoCool. For an older implementation of programming using a natural language, there's Lingua::Romana::Perligata http://users.monash.edu/~damian/papers/HTML/Perligata.html http://users.monash.edu/~damian/papers/HTML/Perligata.html Unfortunately for probably most people here, the natural language in question is Latin.
- GorgeRonde 7y agonexto stringum reperimentum da. # $next = pos $ nextum stringo reperimento da. # pos $string = $next; inserto stringum tum unum tum duo excerpementum da. # $insert = substr($string,1,2); insertum stringo unum tum duo excerpemento da. # substr($string,1,2) = $insert; keyis hashus nominamentum da # @keys = keys %hash; keya hashibus nominamento da # keys %hash = @keys;
- Wowfunhappy 7y agoOne of the things I really like about Applescript is that, at least for simple tasks, the code reads as standard english. This isn't to say you can type anything in english and Applescript will interpret it, just that the correct syntax also happens to form real sentences. Here is how I tell QuickTime to play NPR: set WNYCAddress to "http://www.wnyc.org/stream/wnyc-fm939/aac.pls" tell application "QuickTime Player" to open URL WNYCAddress Here is how to tell if the file you've highlighted in Finder is on a specific drive: set theNameOfTheDrive to "Archive" tell application "Finder" to set theSelectedFile to the target of the front Finder window as text if theSelectedFile starts with theNameOfTheDrive then log "that file is on the right drive!" Unfortunately, it all starts to break down when you get to more complicated stuff, but in the right situations it's kind of beautiful. I wish Apple had taken it a bit further...
- microtherion 7y agoWicked tongues have called AppleScript "Visual COBOL".
- Wowfunhappy 7y agoAre we just comparing any old-ish languages we don't like to COBOL now? Applescript has its problems but it's one of my favorite features in macOS. Maybe not the language itself, but the Apple Events capability. There's no equivalent in Windows other than AutoHotKey type stuff.
- microtherion 7y agoFor AppleScript, the analogy seemed apt, as both AppleScript and COBOL set out to design a syntax resembling conversational English more than a typical programming language would.
- Wowfunhappy 7y agoThank you, I've never actually seen COBOL code (presumably a good thing...)
- max0563 7y agoThe problem with this kind of stuff is that by due to the ambiguity of natural language, it becomes more complicated to actually do this at scale. Also, you are essentially creating another programming language that I have to learn and I don't want to learn it. "Writing code using natural language" should mean that I can write code without having to follow any kind of format. I should be able to say "find the smallest item in the list" and "give me the smallest element in the list" and that should work the same way. Right now these natural language programming languages are still just that - programming languages.
- marknadal 7y agoSo this seems to be more like a natural search for code components? Does anyone know if it is dynamic or using preset templates with adjustable variables? I did a talk out in Italy[1] where I showcased an evolutionary programming language, one could take either symbolic input or fuzzy language input and it would "reduce" it to a symbolic interpretation - which would be really powerful for a non-programmer to slowly "learn" through interaction how to speak / write code more precisely. I'd love to see other demos people have, too! [1] https://vimeo.com/208899228/b9bc9eaaa4#t=23m27s https://vimeo.com/208899228/b9bc9eaaa4#t=23m27s (re-recorded for a webcast)
- TBF-RnD 7y agoOkay so I came here expecring something different. Turns out that this is a stack overflow search engine. So ever since I read a book on AI I have been pondering on when and how computers will steal our jobs. I do have an idea on the subject though if anybody is interested in working with me on this please comment: So with github and loads and loads of other open source repos don't we have enough training data. Couldn't throwing loads and loads of processing power on training an AI on commits create an intelligence with an "actual" understanding of day to day programming problems. Love to discuss this please comment! Crazy idea but huge if it works!
- YeGoblynQueenne 7y ago>> Couldn't throwing loads and loads of processing power on training an AI on commits create an intelligence with an "actual" understanding of day to day programming problems. I'm curious to know why you think it's possible to create "an intelligence" with "actual understanding" thanks to lots of processing power and data. What makes you think this is actually doable? Do you think that this has been done before, for example?
- TBF-RnD 7y agoOkay so seeing how a brain is made up from 86 billion neurons. 16 of those in the most recently developed cerebral cortex. Randomly creating a set of random configuration of billions of neurons and then subjecting them to simulated evolutionary evolutionary preasure on the basis of how close they come to A) the correct solution B) compiling code that runs C) tests if available* Kill of the worst performing networks. Mate the most succesful and have the offspring replace those who where not fit enough for survival. How would it work exactly, I wouldn't know which is sort of the point. But sooner or later representations of abstractions within the code would appear within the graphs. I get that this is not either trivial and cheap. Let alone hosting the wast amount of source code and parse it would require computing power weighing in at quite a hefty sum. Human beings probably have the advantage of having built in functionallity that we are born with encoded in our DNA. I suppose that a fair bit of "intelligent design" would be required. That is having coded parses that breaks down the source code into input signals that would help speed up the evolution. Even reaching halfway there could be useful. Say by providing useful analysis, maybe warn if something seem stupid. To some extent I believe that for a natural language programming language to be viable some understanding of abstract concepts have to be present in the algorithm. That's why I don't think we'll ever program via speech recognition for example. Whenever Siri is smart enough to parse what we are trying to do, why bother with programming. Why not cut the middle man and plug her directly into Jira. but I'd love to be proven wrong regarding this though. I am by no means saying that it would be easy or even viable within the forseable future. Thank God for that because that would means unemployment for quite a few of us. * As I am writing this it struck me that test driven development just happens to make this easier.
- dugluak 7y agoVisual Basic did something similar to Basic with drag and drop controls and writing most of the UI code for you. This seems like a command line version of same thing.