Show HN: Write code using natural language
metacode.app
metacode.app
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!
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?
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.
Sorry to be mean but all this sounds awfully confused and terribly hand-wavy. It sounds like you think that stuff would just magically work like you want it, if only you mix up enough ingredients (data, computation, neural networks, evolution, abstractions, representations, graphs...).
Well, stuff doesn't just magickally work. Lots of people (like, literally thousands) are training machine learning models and not a single model has ever come close to "understanding" anything. I'd start from trying to figure out why that is the case, and then see if something can be done about it.
Otherwise -and, sorry again, but- all these are mere time-wasting fantasies.
You’re post is unnecessarily pessimistic and generally bad faith.
And maybe ops vision can’t be realized today, but if someone is thinking beyond the current state of the art, it’s short sighted and incredibly ignorant to dismiss them as time wasting fantasies.
Your comment, on the other hand, seems to be confusing good faith with indulgence. Just saying "yes" to people and being nice to them does them no favours.
You failed spectacularly by your own definition of a good faith discussion by dismissing ops post as “fantasy”. You give no explanation of why it is unachievable today or why it would continue to be impossible in the future.
My previous team had a member who outright dismissed ideas and criticized things for the sake of sounding intelligent without proposing solutions to further the discussion or solve the problem. We let him go.
Good luck.
Couldn't have written it better myself.
Maybe there is an minimal test case that could demonstrate deeper understanding. Sort of a fizz-buzz for AI, to separate the parrots from the thinkers so to speak. Food for thought. Meanwhile I am to busy on other grandiose plans to give it to much attention ATM.
Disclaimer: I work at Google.
At a closer look I don't think that mapping up correlations in a vector space is good enough for the task of fixing bugs based on an issue tracker description though.
The way I see it word2vec is basically statistical connections. So if you compare it to google translate which also works via statistical correlation. Which explains the errors it might do. At some point to get a good translation you'd need human intelligence.
To continue with the google translate analogy. Imagine a translator trying to translate Fyodor Dostoyevski's The Karamazov Brothers to English. That person have to have a tremendous understanding of Russian and English culture not only now but also when it was written along with ideoms and so forth. Along with a deep understanding of politics and religion not to botch the job completely. Or imagine entering a greek epos written in hexameter into google translate and publishing the book.
So you see just as translation and translation might be two totally different things, search and making changes to source code might be different beasts.
Then again you are totally right in that they are doing it. Getting access to this datasource for minining is probably a huge factor in microsoft's purchase of github, so I'd think it would be a safe bet to say that they are working on it...
At least originally, I am sure it's an incredible complicated piece of software by now applying multiple heuresstics.
Anyway already part od programming work is deciding what you really want. Maybe that's where machines might help - with discoverability.
I actually think that more likely is some CRUD maker as an expert system? (you put what you vaguely need, answer questions and it comes with solution), doesn't need ML.
I remember seing a talk on youtube about a lisp program finding every program that would fit a certain solution. So reasoning about things like this is what a lot of lisp's gurus are doing all day long basically.
You are probably right about AI being used in an assitive part at first. I imagine it'll be a while until people dare putting their business logic in the hands of an AI.
Probably CRUD applications would be the first to be automated. Boring tedious work that has been done a million times. And unhappy coders are probably more prone to create bugs make bad decisions. Also there are litteraly thousands and thousands of implementations doing the same thing with variantions that are more or less just flavour.
Then again if you are at analyzing all open source software ever written. Why not plow through all open source issue trackers at the same time. If you found the top 20% bugs that cause 80% of the issues and have get an AI that solves 20% you'll be a very very rich man if you feel like it.
So don't expect to tell a computer to figure out the best way to create top off the line lossless video codec anytime soon or anything else. Then again it's hard to find a coder that you could tell that and get back the results you wanted either...
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.
Makes life easy.
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)
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)
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.
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.For an older implementation of programming using a natural language, there's Lingua::Romana::Perligata http://users.monash.edu/~damian/papers/HTML/Perligata.html
Unfortunately for probably most people here, the natural language in question is Latin.
nexto 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;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!
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!
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.
It's beautiful the way you balance the pessimism of hard experience with an optimism borne of real natural language understanding being still an amazing possibility.
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.
That's rock such hopes founder on, sadly. Of course, there's always a chance someone will the passage between things that others have missed.
A more hopefully way to put is that natural language is a stream of symbols that where the unnecessary parts are removed, the other parts are actively interpreted by context and by the intent of the speaker, and where any ambiguity is sorted out by dialog. If you can create a system that can let you program similarly, you may have something.
Good Luck again!
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.
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
Spoken programming languages is a different can of worms.
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.
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&pa...
[1] https://stackoverflow.com/questions/927358/how-do-i-undo-the...
[2] https://docs.microsoft.com/en-us/visualstudio/ide/code-snipp...
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.
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.
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.
When I start using anything new I really only check that it can do what I need it to, not everything that’s possible.
It's not that syntax itself isn't intuitive; there's after all nothing more intuitive than, say, FORTH, LISP or Haskell syntax - surely it handily beats the weird idiosyncratics of "more English-like" FORTRAN or COBOL! It's actually the semantics of what you're interacting with, that, while simple, might be initially unintuitive to a naïve user. I don't think that I'm actually disagreeing with what you're saying; it's just that "not knowing the exact syntax for X" generally unpacks to something slightly different, namely "not knowing the relevant semantics to the extent that one can figure out how to do X". This, I think, is a better explanation of how StackOverflow might end up being quite helpful.
Of course, natural language itself does involve some semantics-related facets of its own, that might well end up being more intuitive than the programming-language semantics we normally use. But even then, we can (and should) use devices like Montague-semantics to give them an "intuitive", compositional syntax reminiscent of the lambda-calculus, Haskell or FORTH. I think this is the better way towards the goal of "using natural language to make programming more intuitive".
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".
I shortened the question in my comment for brevity. The full question I cited on StackOverflow was worded as: "How do I undo the most recent local commits in Git?"
> It will also cause push and merge conflicts if the commit you're "undoing" was public,
Yes, and StackOverflow answers also warned of that scenario. Again, the full SO question did ask about "_local_ commits".
>It's also not anymore cryptic than any other industry's jargon.
In my comment, "cryptic" doesn't mean the syntax doesn't have its own internal logic that makes sense once one "groks it". It's just non-intuitive for someone who has a goal in their head but the only know plain English for describing that goal.
> Yes, and StackOverflow answers also warned of that scenario.
So the answer isn't git reset, but git reset + a whole lot more natural language, even for the more narrow question asked.
> In my comment, "cryptic" doesn't mean the syntax doesn't have its own internal logic that makes sense once one "groks it". It's just non-intuitive for someone who has a goal in their head but the only know plain English for describing that goal.
Isn't the true of anything? Everything has their own jargon to express precisely what they mean. Would you tell machinist they're being cryptic if they told you to make a bolt-hole pattern? Is an accountant cryptic if they talk about something being a liability and not an asset? A ham if they ask for fsk31 and to call them on 6m? Complex things require precise language to talk about precisely. That isn't being cryptic, it's a feature of natural language that it becomes more ridgid and precise with a specialized vocabulary when things require it.
Yes, and like you confirmed, all of that was in the SO answers. I'm not exactly sure what you're debating here. I deliberately put an abbreviated SO question (some words elided) in my parent comment. I also put an abbreviated answer (some words elided). I cited the full SO answers that explained all the caveats, qualifications, in a footnote. Are you complaining that I didn't copy & paste the entire ~5000 words of StackOverflow answers into my comment instead of just typing "git reset"?
>Isn't the true of anything?
Yes! And that truism is why StackOverflow is so useful.
I think the root issue is that you think I'm making a claim I didn't actually make. I never claimed that natural language English is good enough for precise programming or that it didn't have ambiguities. I also think you misunderstood my blurb about git as if I was making an all-encompassing definitive answer for "git undo" instead of using it as a lead-in to a larger point about the tool discussed in this thread.
To hopefully convince you I know what you're talking about, we can also say that non-English programming languages themselves are also fuzzy and imprecise when trying to translate to another programming language. There's always a hidden underlying semantic layer that's not visible in the surface-level text of the code. E.g. converting Javascript to C++.
Javascript: var x = y + z;
But numbers in Javascript are always 64bit doubles. But we don't know if the programmer truly used them as doubles or whether all the runtime values were actually 32bit integers. That hidden semantic layer requires more analysis.Therefore we don't know if the correct translation to C/C++ is:
int x = y + z;
... or ... double x = y + z;
So even trying to perfectly translate non-English programminglanguage_A to non-English programminglanguage_B runs into The Halting Problem.Here's the key, even though programming language conversion is imperfect, the programmers still have a real-world need to translate them and that's why Google and StackOverflow are useful for attempting to convert Javascript to C++.[1] Again to emphasize: Not perfect, but useful.
You seem to be working bottom-up from some Platonic ideal of perfect precision. My parent comment was working backward from the existence of thousands of real-world questions on StackOverflow that translates natural (sometimes fuzzy) English to non-obvious answers about syntax. It's about why do those Git questions exist and why were they useful. The tool that this thread is about takes advantage of that phenomenon.
[1] https://www.google.com/search?q=C%2B%2B+for+javascript+progr...
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
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
Kudos for actually being able to use it.
However, what really shines are the tremendously well documented full games. You can literally load them in Inform and play the game in one pane and walk through the code in the other.
I'm still not sure what to think of it as a language, I think now as a full-fledged programmer, I would pick an interactive fiction framework that looks a lot more like a programming language and less like fiction. However as a beautiful experiment in being able to use the English language to write a story and make it playable at the same time, it is still pretty amazing to me.
It /is/ a full-fledged language. You can implement weather or tides or magical systems or inventory systems or health points or anything else you can thing of, but it all reads pretty English-y...until it doesn't!
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.
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.)
"Cookies set? Oh, that must be the plural of Cooky" -> actually happened in live coding demonstration before.
My response is always (some diplomatic, lay version of), "No, it's correctly refusing to involve us in the game of guessing how the framework developers modeled plurals."
Alternatively, as you said, use a non-ambiguous subset. But then it's no longer a natural language, I wouldn't mind betting they're all ambiguous.
I can see how this would be useful to quickly get the right incantation in certain verbose APIs, as opposed to copy-pasting code from API docs or Stackoverflow.
For instance `new Object` - we're all going to read that as "create a new object that hasn't existed before" but within english a `new Object` could also be an antique you happen to have recently acquired, so `new` could be comprehended to be an acquisition action - like copying an Object - rather than creating a new one... But in our fancy computer language jargon we have forever banished the "new to me" meaning from `new`.
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...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.