Blogs

This Blog

News

Favorite Posts

Archives

ctodx

Discussions, news and rants from the CTO of DevExpress, Julian M Bucknall

Compilers. Compilers? (Message from the CTO, newsletter 52)

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.

Published Aug 18 2011, 07:05 AM by
Filed under:
Bookmark and Share

Comments

Felipe R Machado

COBOL compilers and the original C++ compilers all did the same a long, long time ago... I think my age is also showing, and I'm only 35!!! (alright, I admit, my first computer had a Z-80 CPU with 32 KB available of memory... OLD!!!)

BTW, I simply can't love CoffeeScript more than I already do!

August 19, 2011 12:13 AM

Ron Grove

There are multiple Object Pascal projects working in this direction right now as well. Very interesting to track their progress. It's getting a little bewildering at how many ways there are to skin the proverbial cat nowadays...

August 19, 2011 12:30 AM

About Julian Bucknall (DevExpress)

Julian is the Chief Technology Officer at Developer Express. You can reach him directly at julianb@devexpress.com. You can also follow him on Twitter with the ID JMBucknall.
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2014 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners