Live data from Hacker News

Show HN: Write code using natural language

metacode.app

71–80 of 118 posts

Re: Show HN: Write code using natural language

#71
post #59
post #42

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.

I thought git and hg both started around the same time, didn't they?

Re: Show HN: Write code using natural language

#72
One 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...

Re: Show HN: Write code using natural language

#73
post #14

Earlier 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))))

It's more uniform, we use other forms of punctuation in writing.

Spoken programming languages is a different can of worms.

Re: Show HN: Write code using natural language

#74

One 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…

Wicked tongues have called AppleScript "Visual COBOL".

Re: Show HN: Write code using natural language

#75
post #59

Earlier 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?

Yes, within days.

Re: Show HN: Write code using natural language

#76
post #42

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…

> "How do I undo a commit?" isn't something obvious like "git undo". Instead, it's the more cryptic "git reset HEAD~"[1]

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

#77
The 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.

Re: Show HN: Write code using natural language

#78
So 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 (re-recorded for a webcast)

Re: Show HN: Write code using natural language

#79
post #42

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…

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.

But those are two options of the same command. You can have a -keep-changes argument for undo and it wouldn't be weird or incompatible with the plain -language description.

Re: Show HN: Write code using natural language

#80
post #20
post #9

Earlier 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…

When GP asked for GGP to elaborate on their approach, I think they meant for GGP to discuss their wrapper around constraints.
Post reply on HN