What would your own (I assume perfect) programming language look like? Give a small example and explain your novel ideas!
I'm really interested in the syntax.
What would your own (I assume perfect) programming language look like? Give a small example and explain your novel ideas!
I'm really interested in the syntax.
I have no concept of a "perfect" programming language because there isn't just one task to be performed.
Different tasks suit different languages and paradigms.
Perfect programming languages tend to be found in science fiction novels. For example:
It all still comes down to the same basic quandary. Any programming language that does not force the human to learn a skill tends to limit the freedom of thought. Natural language is not good either since it has many ambiguities.
I wouldn't mind one that combines freedom with power and minimal syntax. I've recently started learning lisp, and it seems very good so far.
My optimal language would look a whole lot like Nemerle (minus the arbitrary restrictions). Really it comes down to metaprogramming facilities; I should be able to arbitrarily extend or modify the language in any way I see fit (period) to fit the domain perfectly.
Give me macros that allow me to work on the AST of all of the code as I wish and I can build my perfect language.
Massive parallelism empowered by Amazon Mechanical Turk.
job = "Upvote this answer"
@price = "$0.01"
fork(10000, job, @price)
A language that features no structure or variables, just one function.
doEverything();//automatic generation of all content based on already predicted input
I envision a language that must be told precise restrictions on input and variables and execution order, and so can be compiled into fast multithreaded (or clusterable) software.
And here's an interesting idea: imagine that all the "statements" within a "function" could be executed in any order at all. If something depends on something else, you need to "call" the dependency explicitly. This would make design for parallelism an integral component of the language.
Unfortunately I haven't invested enough imagination to come up with anything more specific.
I'm a big fan of C macros, but I thought it might be nice if you could write macros or "meta-code" in the same language you're using. (C is a bad example; this could be good in scripting languages.)
In these examples I'm using braces to identify the meta-code. You would be able to run the source through a "preprocessor" to expand the meta-code out. Otherwise it would just be expanded once at runtime.
print "Your product ID is: ", { print '"', generateGUID(), '"' }
or
lookupTable[] = {
/* insert code to generate table here
*
* This lets you modify the algorithm easily
* but speeds up the final program.
*
* This would be especially appropriate in
* cases where you would otherwise type out
* the table as a literal (yuck)
*/
}
Now and then we have to write several lines of very repetitive code; can't think of a good example right now but this kind of think would also be very helpful in such situations.
My ideal programming language, the code would be smart, it would tell me if it had a problem with another piece of code, we would sit down and talk and it would tell me what its problem was so we could work it out... I call it "EmotionPeople++"
I would imagine mine would be somewhere between Brainf*ck and LOLCODE except with A LOT more parentheses.
My perfect language would allow me to ratchet up the functionality as I need it. If I need to write a small straight forward utility program without classes I could. If I needed to use classes I could do that also, and if I wanted to write a completely object oriented solution I would be able to do that too. The linker would be smart enough to let me create small fast command line utilities (with no runtime dependencies) or the largest bloated OOP GUI app I could imagine.
The problem is that what I like has opposing goals and thus I've always been forced into using completely different languages. I currently use in no particular order PowerShell, VBScript, PowerBasic, Java, and C# (and sometimes VB .NET, VB 6, C++, Python, and Perl).
Now if I could do it all with one C# like language that had global functions with no runtime dependencies when creating those small apps, but let me make full use of the power of the .NET Framework and Java SDK when I needed to, I'd be happy.
Multi-media.
I want to be able to scribble some graphical symbols, quickly sketch connections and then flip to other modes such as typing where precision is needed.
I also think programmming languages should support people who don't think in English (yes, even Americans ..... joking!). I've studied enough Japanese and tried to pick up some Indonesian - I would like to see a language support people with different grammatical constructs and orders.
I raised a question at a recent forum I attended on the future of the web, asking a visiting Chinese professor if he thought Chinese written language would be more likely to enable a workable semantic web than English. He was intrigued by the notion.
A lot of SF I read talks about future UI's for computer interaction:
I am not sure what my dream language would look like, but I have a little improvement for C-style languages. How many times have I written something like this:
Node foundNode = null; // need stupid null value here to keep track if it was not found
foreach (Node testNode in nodes) {
if (testNode.YesItsMe) {
foundNode = testNode;
break;
}
}
if (foundNode == null) {
// create new instance
foundNode = new Node(blabla);
}
I know there are more elegant functional ways for this, but sometimes you still end up with code like this. A simple "guard" statement would help here:
Node foundNode; // no need to initialize anymore
foreach (Node testNode in nodes) {
if (testNode.YesItsMe) {
foundNode = testNode;
break;
}
} guard { // we get here if break was never called
// create new instance
foundNode = new Node(blabla);
}
I would like a programming language that makes tools really easy to write correctly. Extract method, colorization, autocomplete, compilation, etc.
I want this to happen while still being easy to write and easy to read.
It would be machine readable/writeable, and it would be written by intelligent software that takes instructions by voice.
Jon is right in saying that “[d]ifferent tasks suit different languages and paradigms.” However, there are a few considerations that are largely independent of the domain. These mostly concern syntax but since code is read more often than written, I actually think that syntax matters.
For one thing, and something that many languages do wrong, it's completely arbitrary to base the syntax off C. C actually has an exceptionally bad syntax. I'll just pick two examples.
The first is quite uncontroversial: semicolons are unnecessary. Take the following code; the grammar is completely unambiguous and easy to parse for a compiler. Neither semicolons nor explicit line continuations are necessary.
answer = 42
fraction = answer * 2 /
(answer + 1)
Console.WriteLine(
"Some funny number: {0}",
fraction
)
This is actually quite similar to Python but even more permissive: the definition of fraction
spans multiple lines. This is logical since the first line isn't yet complete.
Another bone I've got to pick with C-like syntaxes are their largely implicit variable declarations. Instead of announcing clearly “I'm declaring a variable
of type Foo
,” all they whisper shyly is “Foo var
”. Since Foo
isn't even a reserved word in most cases, the programmer isn't offered a single visual hint here. I prefer VB's explicit Dim var As Foo
, even thought he keyword used here is, well, quite dim.
(C++ actually makes matters much, much worse by introducing a lot of nearly identical and often ambiguous syntaxes that mean completely different things, from variable initializations to function declarations).
Another thing my language would have to have is static typing. It's true that dynamic typing has its uses but they are surprisingly rare. Even most “scripting languages” wouldn't really need them. I think that this is often confused with implicit typing which has rather more uses. Take (again) the example of Python. Why doesn't it offer static typing? It's already strongly typed, statical type checking would only be consequent, and would cut down on debugging quite a bit. The same goes for explicit variable declaration. I fail to see what advantages implied variable declaration offers.
So there we've already got an outline for a language:
Furthermore, I'm a huge fan of certain C++ concepts, such as general-purpose templates, RAII (i.e. avoiding garbage rather than collecting it), immutability and the concept of value ranges defined via iterators. I've stated elsewhere that I believe iterators to be one of the most fundamental innovations ever. Give'em a little lipstick and you won't even recognize the ugly beast that is C++:
for i in MyVector:
print(i)
rather than
for (typename vector<T>::const_iterator i = MyVector.begin();
i != MyVector.end();
++i)
cout << *i << endl;
Of course I'm aware that the above syntax is offered by many languages. But they all only offer watered-down versions of C++' powerful iterator concept (to use C++ terminology, the only kind of iterators that most languages know are input iterators, which are basically the least powerful iterators).
At this point I should probably say that the sole copyright for all these ideas is mine, patents pending (in particular for the MayOrMayNotBe
operator that doesn't really compare object references).
Python is pretty close to ideal for me... I would just get rid of some annoyances like having the self keyword... but with a good editor, Python can do amazing things very quickly...
It would look exactly like Scheme. Only it would compile to both IL and Java bytecode, and assembly so I could use all those libraries.
It wouldn't be very different from taking the best ideas of Eiffel and C# (because, plainly, I don't have the knowledge to come up with anything better - I haven't studied CS in the first place).
However, my main practical concern would be go to one step beyond the classical "source code text" approach. I know this is (or sounds like) an IDE thing, but why can't I have a configurable code view with columns such as preconditions/body/postconditions instead of a "linear" form (i):
function f
// f's preconditions
// f's body
// f's postconditions
end
function g
// g's preconditions
// g's body
// g's postconditions
end
Why not (ii) - imagine this is a table (with borders):
f f's parameters f's prec f's body f's postc f's comments
g g's parameters g's prec g's body g's postc g's comments
And also, why can't I choose how functions "begin" and "end" (braces, keywords...) in style (i)? Why can't I instantly show or hide private or protected members? Why can't I instantly see the "flat version" with all the inherited functions inside? etc.
The point would not be to have one holy code file where you edit and then multiple "cool views", but to be able to edit and add code in both (i), (ii) and whatever form is most useful to you.
In a way, talking about "IDE" may seem off-topic here. But OTOH I think this is going to change the way we write and read code, sooner or later. And this will ultimately influence the way languages evolve. The future goals would be to enhance not only readability but also "understandability" and interactivity.
One designs languages to meet specific goals. Syntax and semantics should follow desired function.
In my case, I wanted a language with fine-grain parallelism, that is, very low overhead per grain to allow small chunks of code to be parallelized.
I've designed and implemented it on x86 SMP systems, and it has been in use for about 10 years as the foundation for a large-scale software analysis tools.
The main point was to allow me (us) to specify parallelism easily:
(|| A B)
does A and B in parallel, and let the compiler generate all the crud that makes this possible. We didn't care about whether the syntax was infix or not, so we went LISP style to avoid arguments.
A paper describing the language and a number of parallel applications can be found at http://www.semanticdesigns.com/Company/Publications/parallelism-in-symbolic-computation.pdf
The paper briefly discusses how we didn't succeed in avoiding arguments over syntax in spite of our decision.
Hmm. this is a tough one. My tastes run towards the easily human understandable, and light scripting-style languages (though i do believe this could work for larger apps). See code snippet:
function Foo takes x as string, y as boolean //can add returns [return type] if one wishes to be explicit
//explicit variable declaration
z as number
//explicit cast from boolean to number
z is y as number
//implicit variable declaration
bar is 3 * 5
//function call
print x
return z / bar //since we casted z to a number, it returns a number