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.
I know this post is from a while ago, but I’ve been going back through your posts (being interested myself in programming language differences, benchmarks, etc.). This post caught my eye, because it reminded me of the first blog post that announced the Julia language (http://julialang.org/blog/2012/02/why-we-created-julia/). I’ve been playing with Julia for a good 6 months now and have really come to love it. While it’s still very young (semi-officially at v0.2), it already has killer performance and some of the best syntax around (pythonesque with a little C and Matlab). In short, I just find myself popping into Julia to code because it’s extremely easy and quick from idea to a fast implementation. Some of the other features I think would be attractive to others are:
-Crazy simple integration with C; there’s even a Clang.jl package that wraps C header files into Julia files
-1st class meta-programming; not entirely essential for everyone, but comes in handy sometimes and in general helps you understand what’s going on
-Best shell integration of any language, IMO (http://julialang.org/blog/2012/03/shelling-out-sucks/)
Anyway…….check it out and feel free to speak up in the community, it’s very welcoming and open to new-comers (https://groups.google.com/forum/?fromgroups#!forum/julia-users)
Cheers,
-Jacob
Thanks for the heads-up and for the Julia implementation of Sudoku. I have noticed Julia for some time. I have not spent much on Julia because it is too similar to LuaJIT. It has the advantages of LuaJIT – speed and C integration – but also shares the disadvantages of LuaJIT (my personal opinion only) – 1-indexed arrays and using “end” as the end of a code block.
Anyway, I wholeheartedly wish Julia could replace R, which is in my view the worst popular programming language all-around…
I would argue that Julia takes speed more seriously than any other dynamic language and has fashioned a lot of its language design with performance in mind. Just on the Sudoku benchmark, Julia was 2x LuaJIT and other dynamic languages, and on par with Go. I’ve had a hand in implementing Julia versions of the “Shootout” benchmarks and the results are consistent, Julia tends to come in 1.3x-2x the fastest C/C++/Fortran and 3x-100x all other dynamic languages. And the greatest part is that it doesn’t take hours and hours of optimizing, tweaking, etc. to achieve the performance! I’m able to simply take a C/js/Python implementation, copy it over, and the performance is there! I can usually do a single benchmark during my work lunch break.
I’ll say again that I think it’s because Julia has been a performance-minded language from the beginning. No special subset or VM of the language has to be used, it all “just works” (compared to CPython, asm.js, or LuaJIT).
It’s been fun for me to be apart of the Julia development community for several months and see C/C++ coder after C/C++ coder join and after spending a few weeks, express how thrilled they are that such a straightforward, concise language can achieve the performance they need.
Anyway, that’s my nonprofit sales pitch for Julia. For such a young language (only just hit version 0.2), I think it has huge potential. Hopefully you’ll give it another shot. I’m planning on writing up a few blog posts soon about my experience benchmarking Julia vs. other languages. I’d love to see your analysis of Julia as well.
On my machine, Julia takes ~19.5sec including vm startup time (I was using 0.1.2 binary as 0.2 is not available yet). This puts it on par with Dart, another language designed for speed. Nonetheless, I have been disappointed by Dart developers’ ignorance of command line applications. I will give Julia more serious thoughts.
On Julia vs. LuaJIT, LuaJIT is only 50% slower. It has faster startup, arguably more convenient associative arrays and much more lightweight code base. Porting C code to Luajit is also straightforward. Luajit is pretty good overall.
I found Lua to be extremely [1] fast if not using any of its own data storage and manipulation mechanisms, i.e. only its business logic if() {…} else{…} etc. Maybe Lua could be generally faster if it wasn’t weighed down by its own data storage mechanisms? What if the business logic part of Lua was made to work with klib?
[1] http://simonhf.wordpress.com/2010/10/23/node-js-versus-lua-hello-world-postmortem/
My idea of an ideal programming language is just put here
Would be glad to hear reasonable comments:-)