News for hackers. Stuff that matters.
Re:Cringely predicts the second coming of Java by Zak on Wednesday October 12, 2011 @03:29PM (#3104154)
I think Cringley is setting up a false dilemma here: that you can have fast or high-level but not both.

Lisp has been fast for decades, and modern Common Lisps are roughly the same speed as Java. Lua is a lot like Ruby or Python but about an order of magnitude faster. LuaJIT is another order of magnitude faster, putting it on the same level as Lisp and Java. Haskell is a very different sort of high-level language, but it's fast too.

I think he's right that we'll see more people caring about the speed of the implementation language's runtime, but I suspect we'll see more startups picking fast high-level languages or fast runtimes for already-popular high-level languages than going for Java.

Re:Cringely predicts the second coming of Java by ArbitraryLimits on Wednesday October 12, 2011 @06:17PM (#3104874)
> Lua is a lot like Ruby or Python but about an order of magnitude faster

I'm surprised to hear either of those statements, both that Lua is a lot like Python and that it's an order of magnitude faster. Now, the last time I seriously looked at Lua was for my master's thesis work about four years ago, so I'm willing to believe that my impression of Lua is out of date. However, my experience on using it for a medium-sized project was that it is nothing like Python. My procedure for programming is

  1) think of semantic construct,

  2) think of how to express this construct in this language

  3) type it in
My experience with Python is that step (2) is almost automatic - for whatever reason, every construct I'm used to using has a clear, terse expression in Python. And I've never spent an extended period writing Python, so I don't think it's because Python has really shaped the way I think. (The closest analogue to Python programming is using the STL in C++, in my experience.)

With Lua I had exactly the opposite experience. Every time it came to step (2), it felt like what I wanted to say was almost expressible in idiomatic Lua, but not quite. It just felt like I was running a race with a 50 pound backpack the whole time. Every time I tried to write a Lua script, I'd eventually throw up my hands and write my program in Python instead.

Now, it's certainly possible that I just never really understood Lua's paradigm that well, and that if I'd kept going I would eventually have reached enlightenment. I don't think so, though - tables just aren't that hard, oonceptually. However, the point is that, out of the box, Python gives me by far the least cognitive friction and Lua by far the most of any programming language I've ever used. I therefore have to strongly disagree that Python and Lua have much in common other than a small overlap in the niche they each fill.

And as for the order of magnitude speed difference, I find that hard to believe. Again, my information may be out of date, but when I looked at it Lua converted all numbers to double precision floating point numbers internally, which dragged its integer benchmarks down quite a bit. (In fairness, I think that was the same time frame where Python could only use primitive integers for the numbers 0-99, and had to box everything else.)

Re:Cringely predicts the second coming of Java by andolanra on Wednesday October 12, 2011 @08:01PM (#3105288)
Lua is much faster than Ruby/Python/Perl/&c. It still doesn't get close even to the higher-level compiled languages like Common Lisp and Haskell, but e.g. the programming language shootout [1] makes it pretty clear that Lua is still a league above the other dynamic languages. For just a quick result, I tried timing just the Hello World program in Python, Ruby, and Lua, and while startup time isn't going to be the bottleneck of the world of modern web development, it's still a telling result:

    $ time python2.7 -c "print 'Hello, world'"
    
    real        0m0.107s
    user        0m0.080s
    sys         0m0.023s
    $ time ruby -e "puts 'Hello, world'"
    Hello, world
    
    real        0m0.338s
    user        0m0.030s
    sys	        0m0.013s
    $ time lua -e "print('Hello, world')"
    Hello, world
    
    real        0m0.008s
    user        0m0.000s
    sys         0m0.003s
That said, I kneejerk-ly agree with you about Lua being an awkward medium for expressing programs. I personally haven't ever gotten to the status where Lua was as natural as Python, but I have also used Python a great deal more, so I don't know if my attitude is attributable to Lua's design, or Python's plenitude of libraries, or merely the experience differential between the two.

[1]: http://shootout.alioth.debian.org/

EDIT: Converted some tabs to spaces. (Nitpicky, I know.)

Re:Cringely predicts the second coming of Java by jebblue on Thursday October 13, 2011 @12:14AM (#3106038)
My timings where different on my 6 yr old Pentium D dual core, Ubuntu 64 bit:

  time python2.7 -c "print 'Hello, world'" && time ruby -e     
  "puts 'Hello, world'" && time lua -e "print('Hello, 
  world')"

  Hello, world

   real	0m0.056s
   user	0m0.040s
   sys	0m0.000s

  Hello, world

   real	0m0.008s
   user	0m0.000s
   sys	0m0.000s
 
  Hello, world

   real	0m0.061s
   user	0m0.000s
   sys	0m0.010s
Re:Cringely predicts the second coming of Java by mnutt on Thursday October 13, 2011 @02:01PM (#3108072)
My guess is that your ruby is loading rubygems on startup. It shouldn't take nearly that long if you don't.

That said, startup times are often not as important as other metrics.

Re:Cringely predicts the second coming of Java by Zak on Wednesday October 12, 2011 @08:44PM (#3105424)
I just looked at the Alioth benchmarks and found that Lua (not JIT) is around three times faster than Python 3. I remember the differences being larger with Python 2.x, but I'm not going to take the time to look for those benchmarks. On one benchmark, Lua was much slower.

I barely know Python, though I've found it fairly easy to pick up and use when I've needed to. I know Ruby pretty well though, and I find Lua about as easy to use as Ruby.

Re:Cringely predicts the second coming of Java by tophercyll on Wednesday October 12, 2011 @09:53PM (#3105662)
LuaJIT adds another massive speed-up on top of the already healthy Lua performance.

http://luajit.org/performance_x86.html

http://luajit.org/performance.html

That said, I do agree that Lua can be more cumbersome than Python or Ruby.

[deleted]
Re:Cringely predicts the second coming of Java by tomjen3 on Wednesday October 12, 2011 @03:49PM (#3104261)
One of the things Lua was designed to do was to be easy to embed. You don't necessarily want to embed a JIT compiler too.
Re:Cringely predicts the second coming of Java by Zak on Wednesday October 12, 2011 @03:45PM (#3104235)
We could say that, but since LuaJIT isn't the default implementation, it's important to specify or people doing fact-checking might reasonably point out the claim as an error.

Edit: the deleted post said, essentially "Why not just say that Lua is as fast as Java?".

Re:Cringely predicts the second coming of Java by mattmanser on Wednesday October 12, 2011 @05:25PM (#3104673)
Let's be honest though, there's 0% chance of functional languages becoming mainstream in web development.
Re:Cringely predicts the second coming of Java by Zak on Wednesday October 12, 2011 @08:53PM (#3105465)
Of the languages I mentioned, only Haskell is functional, though I'll concede that Common Lisp isn't very likely to become mainstream either.

Lua, on the other hand is a relatively procedural scripting language. It can support functional programming if you want (it has closures and tail-call elimination), but that isn't the default. It doesn't even have map/reduce/filter in the standard library (I think it should).

I also dispute your claim fundamentally. Research-oriented languages like Haskell probably won't go mainstream, but a mostly-functional paradigm is very natural for web development. A GET request is naturally a pure function (it takes an HTTP request and returns a page). A POST can often be purely functional except for the bit at the end where it creates, updates or deletes a value. Languages and frameworks that encourage that style of thinking make it much easier to avoid creating a complex monstrosity.

Re:Cringely predicts the second coming of Java by rbanffy on Wednesday October 12, 2011 @05:54PM (#3104798)
The canonical way to program for Node.js is very functional.
Re:Cringely predicts the second coming of Java by burgerbrain on Wednesday October 12, 2011 @07:33PM (#3105199)
I would counter by pointing out that while that is true, the sorts of programmers who might use Node.js are dwarfed by the armies of incompetent untrained PHP developers out there. The HN crowd doesn't really give you a good window into reality in this case.

I also don't think that languages should worry about becoming "mainstream" for exactly that reason...

Re:Cringely predicts the second coming of Java by rbanffy on Wednesday October 12, 2011 @10:42PM (#3105812)
Very true. Being mainstream also means the language is used for stuff it really shouldn't be used for.
Re:Cringely predicts the second coming of Java by Cloven on Wednesday October 12, 2011 @05:26PM (#3104680)
This is an unusual statement to make, because in practice in the last decade, Java-based solutions are nowhere near 100x as fast as Perl/Python/Ruby based solutions; in fact I've found them generally to be slower.

The difficulty lies in defining what 'fast' means. It's possible that the JVM is more highly optimized than, e.g., the perl bytecode engine, but the highly abstracted Java libraries (FactoryFactories etc.) tend to be far less efficient and have larger memory footprints and significantly more stack-passing than the equivalent ruby/python/perl equivalents.

Re:Cringely predicts the second coming of Java by Zak on Wednesday October 12, 2011 @08:39PM (#3105406)
The JVM is fast, and the Java language is usually the fastest language on the JVM when code is written with speed in mind. The fact that people often do slow things with Java because it's hard to write extensible Java any other way (or because they just like overengineering) doesn't mean the language isn't fast.

Personally, I think using Clojure is a great way to get speed in practice. Inner loops can be as fast as they are in Java (with ugly optimizations), and extensible idiomatic code is a light lighter weight.

Re:Cringely predicts the second coming of Java by bad_user on Thursday October 13, 2011 @02:13AM (#3106330)
Unfortunately while the language matters, the ecosystem matters even more.

It isn't enough that Java is fast -- if all the libraries you're using are slow. And if the libraries you're using are slow, maybe you're measuring the wrong thing ;)

My biggest gripe with Java is that it is basically useless for anything other than big-scale web applications. And for those kinds of apps, many companies still go for C++.

I mean really, for scripting the startup time makes you want to puke. For desktop apps, I've never seen a Java application that I liked because the GUI toolkits available are brain-dead, and because Java apps have this nasty habit of freezing the interface in response to user events. Also, all Java apps are freakishly huge in regards to memory usage. I've seen Python apps that are tolerable, but nerver Java. Eclipse, the golden example, makes me want to hurt myself.

For small web apps you can get decent performance out of Python/Ruby/PHP on a 512MB VPS -- 200 reqs/sec at least is really not a problem. If you need more than that, it means you're successful, so why not throw money at it?

What else? Android is using its own VM that's not-Java. This means you cannot use libraries that do bytecode manipulation, and is essentially what http://www.ikvm.net/ is doing on top of .NET or Mono.

So in what cases does Java really bring value?

Don't get me wrong; I would love to see Mono being popular for web apps for instance -- it's a kick-ass open-source VM, with performance mostly on par with Java, but using less resources and being a better citizen on Unix (kind of ironic if you think about the roots of Java).