One 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…
I 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.
Show HN: Write code using natural language
71–80 of 118 posts
Re: Show HN: Write code using natural language
#72Here 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...Re: Show HN: Write code using natural language
#73Earlier quoted context omitted.
IMHO: 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…
(Not (I think (really that (speak we (like this))))
Spoken programming languages is a different can of worms.
Re: Show HN: Write code using natural language
#74One 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" t…
Re: Show HN: Write code using natural language
#75Earlier quoted context omitted.
I 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.
I thought git and hg both started around the same time, didn't they?
Re: Show HN: Write code using natural language
#76One 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…
The issue with this example is that `git reset HEAD~` doesn't undo anything, and it doesn't undo _any_ commit, just the last one. It will also cause push and merge conflicts if the commit you're "undoing" was public, which may end up with you not really having "undoing" anything at all.
It's also not anymore cryptic than any other industry's jargon. It's a sentence that means something specific. It's somewhat, but not entirely, what someone _could_ mean when they say "undo a commit".
Re: Show HN: Write code using natural language
#77Also, 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.
Re: Show HN: Write code using natural language
#78I 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 (re-recorded for a webcast)
Re: Show HN: Write code using natural language
#79One 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…
Except languages are ambiguous. When you say you want to undo a commit, do you mean undo like pretend nothing had happened or undo but please keep track of the change. That's why the first thing I do when I'm learning something new is to read the documentation to find out what capabilities are available.
Re: Show HN: Write code using natural language
#80Earlier quoted context omitted.
Can 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.
Of 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…