CoffeeScript: Little language that compiles to javascript
Javascript gets a lot of hate from a lot of people. Most of that comes from the name (java script) and the syntactic similarity to that language. Because of that, people say to themselves "Because I know java, I don't need to actually learn anything, I can just start coding" and either proceed to write extremely poor javascript, or just start hitting brick walls.
Personally, I have been doing rich interfaces since before "Ajax" was a thing, and have a great deal of experience working with the language. Compared to the way it used to be, we are entering a golden age for the language, where the platform innovation just seems to be growing exponentially every year.
That being said, there are still language warts, not the least of which is how java-esque everything is. Some things can be solved by libraries which fundamentally change the way you write the language in the first place (like the john resig school of unobtrusive javascript via jquery) Others are too baked in to the syntax to really be able to address.
Enter CoffeeScript.
# Assignment:
number: 42
opposite_day: true
# Conditions:
number: -42 if opposite_day
# Functions:
square: x => x * x.
# Arrays:
list: [1, 2, 3, 4, 5]
# Objects:
math: {
root: Math.sqrt
square: square
cube: x => x * square(x).
}
# Array comprehensions:
cubed_list: math.cube(num) for num in list.
becomes
var __a, __b, __c, __d, cubed_list, list, math, num, number, opposite_day, square;
// Assignment:
number = 42;
opposite_day = true;
// Conditions:
if (opposite_day) {
number = -42;
}
// Functions:
square = function(x) {
return x * x;
};
// Arrays:
list = [1, 2, 3, 4, 5];
// Objects:
math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};
// Array comprehensions:
__a = list;
__d = [];
for (__b=0, __c=__a.length; __b<__c; __b++) {
num = __a[__b];
__d[__b] = math.cube(num);
}
cubed_list = __d;
First thing I thought was "Oh look, Python.".
Looking closer, and it isn't just painting everything python. It is targeting either verbose or inconsistent syntax features, and replacing them with something better (often, but not always, lifted from python). It shows a good understanding of javascript (and where the real pain points are).
If I were to use a language like this, this would probably be the one. If I were to make a bet on a language like this that will gain traction, this would not be where I put my money (if anything, it would probably be obj-j).