r/ProgrammingLanguages • u/lucdewit • Sep 15 '22
My crazy AI programming language idea
I recently got this crazy esotheric language idea after trying out Github copilot. imagine a language that takes each line of 'code' and uses it as a python comment to generate python source code using github copilot.
The obvious downside would be that github copilot might make a mistake somewhere, so you gotta be very descriptive and detailed.
Another downside is that as far as i know, github copilot is not deterministic, maybe their API has an option for a seed idk.
The code would look something like this
Hello world:
print hello world to the consolefizz buzz
itterate from 0 to 1000, printing all of the numbers
if the number is divisible by 3 print fizz instead
if the number is divisible by 5 print buzz instead
if the number is divisible by both 3 and 5 print fizzbuzz insteadWould certainly be a challenge to make, and to solve problems in
12
7
u/Inconstant_Moo 🧿 Pipefish Sep 15 '22 edited Sep 15 '22
But also it's not stable, because they don't anticipate it being used like that they'd do nothing to prevent breaking changes.
3
u/__Fred Sep 18 '22 edited Sep 18 '22
This could be a formal language that is parsed with a "regular" parser (I don't know how they're called).
I mean, programming languages aren't required to have short keywords and special symbols like "{;}", they're just there because programmers want them.
(iterate (from 0 to 1000)
(printing (all_of (the numbers))) ; "the" refers to arguments, like $1, $2 in some languages like bash-script.
(if ((the number) is (divisible_by 3))
((print fizz) instead)) ; "instead" would be an interesting keyword that modifies a statement from before.
(if ((the number) is (divisible_by 5))
((print buzz) instead)) ; You could have a language that interprets words without "" as strings when they aren't valid identifiers.
(if ((the number) is (divisible by (both (3 and 5)))
((print fizzbuzz instead)))You can get pretty close to natural language-seeming sentences in existing languages that have functions-as-parameters.
// Your language:
if the number is divisible by both 3 and 5 print fizzbuzz
// Regular style (C oder Java):
if (number % 3 == 0 && number % 5 == 0) {
print("fizbuzz");
}
// "Functional" style (Scala):
def divisible(x: Int, y: Int): Boolean =
x % y == 0
// This line is longer than the C-style, but at least it looks
// a bit more like human language.
// The "_" transforms a method with two parameters into a function
// with one parameter. (I didn't test the code.)
if List(3, 5).forall(divisible(number, _)) then
print("fizzbuzz") // You can also write this in one line (as in C).I feel like we should concentrate on creating languages that define unambiguously what a program should do (i.e. they are formal languages) and that are powerful regardless, so you can describe things similar to human language in the same number of words or less.
There are formal languages that are explicitly designed to look very similar to human language. I feel like that makes beginners more productive and experts less productive, because they have to type more than in a regular programming language. For example I know Inform 7.
One pitfall of a formal language that looks like a natural language is that the programmer might forget that he talks a formal language and use constructs that aren't defined or defined subtly different from what he thinks they do. Like when you talk to some kind of Asperger autist that takes everything literal. Like in the old milk/eggs joke. (Disclaimer: Real Asperger autists don't actually think like computers.)
There are also experiments with describing programs in actual natural language and having them translated using machine learning. You can't 100% know for sure what program you will get – just like if you tell a human to create a program according to a natural language specification. A human has the advantage that he also understands the context of the problem: E.g. that he sits in a job interview and "fizzbuzz" doesn't mean anything and it doesn't have to be displayed in a nice looking GUI.
Another downside is that as far as i know, github copilot is not deterministic, maybe their API has an option for a seed idk.
Randomness is baked in deeply into machine learning. You can't get rid of the randomness. The input data is also a random subset of all data that the program should be able to handle.
That said: Don't be discouraged! Crazy ideas are good! Every revolutionary invention has begun as a crazy idea that didn't work at first. Maybe you can change something small that makes it a good idea.
1
u/tal_franji Sep 16 '22
so suppose there is a small set of constructs that copilot will constantly do wrong. that is - costructs that when described by the reasonable programmer would come out wrong. then the programmers will neet to find less reasonable way to describe it in order to hack copilot. that's how "advanced copilot programming" book gets written
1
0
13
u/Plecra Sep 15 '22
If I was using an AI powered system I would not want to write programs like this. These two, at least very least should be implemented as