Significant Whitespace

by Justin Meyer

Significant Whitespace

Justin Meyer If you haven't read it already, please read Ryan Florence's "A Case Against Using CoffeeScript." It's well thought out and makes a lot of interesting points. But for me, the most important one was Significant White-space Means CoffeeScript Will Always Be Compiled.

posted in Development on December 14, 2011 by Justin Meyer

If you haven’t read it already, please read Ryan Florence’s A Case
Against Using
CoffeeScript
.
It’s well thought out and makes a lot of interesting points. But for me,
the most important one was: Significant White-space Means CoffeeScript
Will Always Be Compiled
.

He goes on to say:

It makes no sense for a web scripting language to have significant
white-space; you can’t compress it. Therefore it will never really be
supported natively, and will always be a compile-to-JS language, and
will therefore always have a terrible debugging experience.

I like CoffeeScript, probably because I like Ruby, and it’s supported by
JavaScriptMVC’s dependency management system – Steal. It’s also done a
great job of influencing JavaScript as a playground to explore ideas.
I’ve heard (either directly at conferences, or word of mouth) that both
Brendan Eich and Douglas Crockford think that CoffeeScript is good
stuff.

But with that being said …

I wonder if CoffeeScript would be more useful (it’s already extremely
useful) to the JS community had it not decided to make whitespace
significant. It could give us the syntactic sugar we crave such as:

destructuring
and
spread

[a,b] = [b,a]

block
or
arrow
functions

a.map {|e| e * e} 

default
values

function add( x= 0, y = 0) { }

rest
parameters

function( foo, ...args ){ }

simple
classes

class Monster { }

… but provide a path for browser support.

Could it work?

On the surface, it seems trivial to accomplish with a script loader like
RequireJS or Steal. Simply load the Harmony style code, process it, and
eval it. CoffeeScript could even be a starting point. Browsers that
support it can skip processing entirely. The tricky part might be
compiling to a specific version of JS to minimize the amount of
re-writing.

The benefit is that much of your code will have a solid debugging
experience. And, it might encourage people to build apps with parts of
Harmony well before they are done.

It seems like such a big bag of win that I’m almost surprised someone
for ECMA hasn’t whipped this up for RequireJS as a plugin. Anyone got a
Harmony -> JS compiler in the works?

blog comments powered by Disqus

CanJS 2.2 Release

Justin Meyerposted in Development, Open Source, Uncategorized on April 5, 2015 by Justin MeyerCanJS 2.2 is out. It's awesome. This article covers the top 10 enhancements added since 2.1. Some of the improvements include Browserify and StealJS support, can-EVENT arguments, observable promises, and in-page automatically rendered templates. The article includes a lot of good JSBins to learn from too.

Getting Started with Cordova

Brian Moschelposted in Development on March 26, 2015 by Brian MoschelAt Bitovi, we’re big fans of building applications with web technologies and using build tools to target other platforms like iOS, Android, and desktop. This article will provide a quick guide to getting up and running quickly with Cordova.

Contact Us
(312) 620-0386 | contact@bitovi.com
 or cancel