I read an interesting article about google’s new dart. This makes me thinking what is the ideal programming language in my mind. I am not simply thinking to have the fastest, smallest and simplest thing, which is impossible. I am trying to be a little practical.
I will start by explaining why the existing languages are not ideal, to me.
- C/C++. Lack of garbage collector (thus having segmentation fault). Too verbose.
- Java. Memory hog. Too many restrictions. Another reason I do not like Java is that I always feel delays when launching the VM or when using GUIs. Java is fast enough, but I do not know where the delay comes from.
- C#. I do not use Windows. I heard that the C# GUI is much more responsive than Java in Windows. The bad thing is we do not have a good cross-platform VM. Mono falls far behind the Microsoft VM in terms of efficiency.
- D and Go. They are closer to my expectation, but still too verbose as they are compiled languages.
- Javascript and Lua. They are closer to my expectation in another direction, but for real-world applications, they are still too slow in comparison to C.
- Python, Perl and Ruby. They are simply too sloooow most of time.
Then what is in my mind?
- Have C/C++ like syntax (mainly because I am a C programmer).
- Do not require to be explicitly compiled into native or byte code.
- Garbage collected.
- Allow to write very simple/short programs (not “main(){}” which is unnecessary for simple things).
- Allow dynamic typing.
- Up to here, many existing languages meet my requirements. Then comes the requirement of speed: I hope the ideal programming language should not be over three times as slow in comparison to C for real-world applications (not microbenchmarks). An immediate question is if this is possible at all. I think it is. In my fairly naive view, LuaJIT and V8 are still much slower than C mainly because Lua and Javascript were not designed to achieve a speed comparable to Java and not designed for JIT from the beginning. It is hard to change something that is not designed for. With a careful design focusing on speed and closely coupled with the modern theory on JIT compilation, I think it should be possible to achieve a speed far ahead of LuaJIT and V8, two of the best JIT compilers so far.
- Optional static typing. This may be necessary to guarantee high performance when we really need that.
- Mutable strings or byte array. This request is more for my own work. I work with mutable strings a lot.
Why was I thinking of my ideal programming language when I read an article about Dart? Because if Dart turns out to be something real, it may be the right programming language in my mind. There are things I do not like (e.g. requiring semi-colon; requiring main(); lack of a File class), but it seems closer than others. To get an efficient implementation, we need a fresh start.
Good thought to start a list. I wish I felt there were an ideal language for most of my work, but there isn’t.
C/C++ lack of GC doesn’t bother me so much as trying to debug memory issues. You accidentally deallocate something twice and then have to figure out where the first one happened. Or tracking down memory leaks, etc. Otherwise, I rather like having control over when deallocation happens. More real issues with C/C++ is that the API has been lacking for a long time, which is finally being addressed in C++ ’11. Though it’ll be decades before you can be sure to have that everywhere (example – I still don’t have all STL on Android). My biggest complaint is having to deal with compiler-specific crap like field alignment or the way friend functions, class-inline functions, templates, and separate compilation interact.
Totally agree about Java. I love the API and ease of development for most things, but the VM startup is frustrating. As for memory use, I know some of that comes from UTF-16 (which is bigger for English, but more compact for many languages)
I can’t say whether Perl has performed way worse than other languages for me or not, but the syntax is annoying at times. I’d add to the list for that the lack of nice object-oriented programming.
Optional static typing for speed would be awesome. In a sense, you can do that in C++ by using templates to get weaker types, but it’s really awkward.
I’d add to the wishlist something like CPAN – if I want a good command-line args module, I can hop on CPAN and take my pick (Getopt::Declare is what I use). Or say if you don’t know how to code some math algorithm efficiently, it’s up there. I remember having to find an eps renderer for Java was more of a pain than perl -mCPAN -e”install blah”
I was hoping for something with prototypical inheritance, but with a cleaner syntax. I also would like to see multiple inheritance – doesn’t work well with vtable-based languages, but those issues don’t apply to dynamic languages, and it really is a lot more expressive (c.f. Self).
We also, I guess, lose object literals, which is one of the best bits of JavaScript.
To be honest, I’m a bit underwhelmed. Especially given the pedigree of the two lead designers I was hoping for a scripting language done right, we just got a scripting language done better than JS, I doubt if they’ve made enough of an improvement for it to be compelling to other browser vendors.
Looks like we’re stuck with JS for another generation. Dang.
I don’t completely agree about languages like python being slow “most of the time”. — though I’m not writing aligners.
For most cases, I think those languages work fine and often improving the algorithm is enough for cases when things are too slow. For python, there’s also Cython, in which you can write entire programs or just bottleneck functions (you can also do this with shedskin–which as your benchmark shows, puts python close to C speed for Fibonacci-like stuff).
LuaJIT is interesting because it’s so fast–and the FFI stuff makes it trivial to interact with C libraries. Though there aren’t many libraries available for lua–you can’t even split a string without writing your own function.
In terms of languages without any traction, I like the syntax of Rust over Dart, but both look pretty usable.
I’d check out the “clay” programming language. It is most ‘c’ like and just avoids doing traditional inheritance stuff.
I disagree with you about automatic garbage collection in that simple reference counting gets most everything you need. Anything more complex can be provided by a non-built in utility.