Just realized that I hadn’t put last week’s Message from the CTO up as a post. Maybe it was because I was so excited that we’d managed to record it as a video! (And, yes, there are now several videos in the pipeline…)
Compilers, compilers?
Back in the days of yore, pre-Internet, you knew where you stood with compilers. You'd write some code in some quasi-mathematical English, and then you'd let loose a compiler on it to produce a nice object file containing machine code that you then linked with other obj files into a program. Easy, huh?
That must have been some time ago -- I'm showing my age here -- because we've had interpreters for a while where the code gets compiled on the fly into macro instructions that a state machine can execute. We've even had compilers that produce some kind of intermediate language that gets executed by a run-time virtual machine, which is after all a glorified state machine.
But just recently I've been looking into another type of compiler altogether, one that compiles your code into another programming language. Because of my natural bent at the moment, I'm particularly interested in compilers that compile to JavaScript.
One example is Script# which compiles C# code written against a special run-time to the equivalent JavaScript code. The interesting thing about this one is the conversion of a strongly-typed language into a dynamic language.
That's possibly the most extreme case, however there's another that's just as powerful: CoffeeScript. What this one does is it abstracts out all the nasty things about JavaScript, adds a bunch of syntactic sugar, and compiles to very clean JavaScript. Companies like Google are now starting to add debugging information to the compiler output so that you can debug CoffeeScript directly.
I often hear that some people find it hard to write client-side code in JavaScript. I think we're getting to the point where it'll no longer be necessary. JavaScript is becoming the assembly language of the web: write in some high level language, compile to JavaScript, and deploy the files produced as part of your site.
You can watch the video here.
For fun, here’s the CoffeeScript code we showed in the video:
wrap = (originalHandler) ->
(event, pos, item) ->
if item
dataPoint = item.series.data[item.dataIndex]
originalHandler.call this, event, pos, item if dataPoint[2]
It’s the equivalent of the last bit of code from this recent blog post of mine.
Free DevExpress Products – Get Your Copy Today
The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the
DevExpress Support Center at your convenience. We’ll be happy to follow-up.