News for hackers. Stuff that matters.
Re:Have Tracing JIT Compilers Won? by stcredzero on Wednesday March 10, 2010 @08:33AM (#1180840)
With modern IDEs, tracing JIT, and type inference, I'm surprised that someone hasn't made the same lateral thinking sidestep that Hennessey & Patterson made for RISC. They offloaded much of the decoding work from the chip to the compiler, yielding faster chips in a smaller die size.

Perhaps the Go language is the start of such a sidestep. We should be able to offload a lot of the work of type annotation to the IDE and compiler, yielding a compiled language with the dynamic feel of an interpreted one. In fact, for langs with clean runtime models like Lisp, we should be able to allow intermediate states of partial annotation, and allow some interpreted execution for fast prototyping. (But demand full annotation before deployment.)

(EDIT: Yes, I was aware of Haskell when I posted this. Haskell. There I said it!)

Is there a tool that uses a Bayesian technique for suggesting type annotation that cannot be inferred? This would be tremendously useful. (And very dangerous in the hands of the incompetent.)

Re:Have Tracing JIT Compilers Won? by jrockway on Wednesday March 10, 2010 @09:29AM (#1180938)
You have just described Haskell. Annotate types if you want, let the compiler infer otherwise. Very dynamic feeling, but much safer. And you're right, it can make for some very fast code.
Re:Have Tracing JIT Compilers Won? by cynicalkane on Wednesday March 10, 2010 @11:11AM (#1181197)
I've always got the impression that Haskell's lazy properties makes it hard to reason about code performance. You can force high-performance code, but that requires circumventing the beauty of the language. Has this problem been solved?
Re:Have Tracing JIT Compilers Won? by jrockway on Wednesday March 10, 2010 @12:27PM (#1181425)
The "reasoning about performance" is more of a trap for the unwary than a fundamental problem.

Example; you have two threads in a producer/consumer setup. The first thread puts "g x" into the queue. The second thread removes this, and applies "f", and puts the result into a result queue. Then a result-processing thread prints those to the file.

You run this, and notice that it doesn't really take advantage of all cores. It seems to run slower on 2 or 3 cores than it does on 1 core, even though "f" and "g" are of roughly equal complexity and the application of each happens in a different thread! WTF?!?

The problem is, of course, that lazy evaluation "helped you". You never needed "g x" in the first thread, so it wasn't evaluated; the thunk was put in the queue. When you applied "f (g x)" in the second thread, you still didn't need the value of either computation, so it was never evaluated. You just put a thunk in the result queue. Finally, in the result-printing thread, you did need the result -- so all the work to evaluate the result was done there; in a single thread.

You realize this, switch to strict queues, and now your app is 2x faster.

(BTW, I simplified the producer/consumer model a bit. Normally you have one thread feeding work into a queue, n threads reading from that queue, doing work, and putting results into a result queue, and then a final result-aggregator thread. The end result would be the same; all the work would be done in that last thread. Slow!)

Re:Have Tracing JIT Compilers Won? by silentbicycle on Wednesday March 10, 2010 @11:23AM (#1181228)
OCaml has type inference too, though it doesn't have Haskell's typeclasses, which are very nice. (You can get much of the same functionality with functors (parametric modules), but it's not as straightforward.)

OCaml isn't lazy-by-default, so reasoning about time/space performance is generally easier. It's worth considering as an alternative to Haskell.

Re:Have Tracing JIT Compilers Won? by stcredzero on Wednesday March 10, 2010 @05:53PM (#1182250)
Not Haskell. Something more permissive.
Re:Have Tracing JIT Compilers Won? by stcredzero on Wednesday March 10, 2010 @09:33AM (#1180951)
I'd like this for a Smalltalk style OO environment. Strongtalk got partway there.