2 ms·
>but all the features you list already exist in Python Not all: - string interpolation is way more flexible in CS - splats are sort of partially covered by s
by mistercow 14y ago
>but all the features you list already exist in Python
Not all:
- string interpolation is way more flexible in CS
- splats are sort of partially covered by several python features, but not nearly so elegantly
- the existential operator is not found in Python at all; you have to test against None instead. Also, Python does not have anything like the "soak" feature that the existential operator does.
- No really, readable regex. Python still doesn't even have a literal notation for regexes, but CoffeeScript allows multiline literals with comments, ignored whitespace, and interpolation.
Also, I don't think that lowboy mentioned multiline lambdas, but yeah, multiline lambdas.
I once thought as you do that syntax is secondary and that what really matters is functionality. That was before I started using CoffeeScript. The thing is, syntax isn't important for the sake of making it a pleasure to write. It's important for making it a pleasure to read. And odd scoping scenarios notwithstanding, CoffeeScript is exceptional in that regard.
Here's an example. String interpolation in CoffeeScript is incredibly simple:
console.log "Hello #{name}, how are you doing?"
translates to
console.log "Hello"+name+", how are you doing?"
That's all. Typing it out, CoffeeScript saves you one keystroke. But there is a subtle boon to readability in the interpolation syntax. The first line says "We're placing the result of an expression here". The second line says "We're ending the string, concatenating the result of an expression, and then we're going to concatenate another string to that." The canonization of the idiom into syntax lets your brain relax and stop trying to translate.