Trying coffeescript
Recently decided to give coffeescript a go, it’s nice and syntactically similar to other languages such as Python.
From the coffeescript developers:
CoffeeScript is a little language that compiles into JavaScript. Underneath all of those embarrassing braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
Here’s my first test with it, first of all a golfjs solution I wrote, using obfuscated (read: in as few bytes as possible) JavaScript:
i=input,v=i.match(/[aeiou]/gi),y=i.match(/y/gi),
output=(v?v.length:0)+(y?y.length/2:0)
And here’s the same code in coffeescript:
v = /[AEIOU]{1}/gi
y = /Y{1}/gi
a = if input.match(vow) then input.match(vow).length else 0
b = if input.match(y) then input.match(y).length*0.5 else 0
output = a+b
And the JavaScript coffeescript compiles to:
var a, b, output, v, y;
v = /[AEIOU]{1}/gi;
y = /Y{1}/gi;
a = input.match(vow) ? input.match(vow).length : 0;
b = input.match(y) ? input.match(y).length * 0.5 : 0;
output = a + b;
Related posts
- Android Auto on my HR-V's Android 4.0.4 head unit
I recently bought a 2018 Honda HR-V as our family car. It has a 7” touchscreen running Android 4.0.4, a version so old it predates Android Auto by about three years. It runs Android Auto now anyway, thanks to a small app I built over the course of a week.
- Rebuilding and analysing 4 years of Wordle stats from WhatsApp chat logs
Yes, I’m still playing Wordle in 2026. According to Wordle, I’ve played 1,559 games, I win 99% of the time, my current streak is 107 days and my longest is 278. Four numbers, and they’re mostly correct. What I don’t get is anything behind them. No per-game history. No way to compare a Tuesday to a Sunday. No sense of whether I’ve actually got better at this over four years. Each day I’ve played, I’ve also shared the result to WhatsApp. Just a habit, not a data strategy, but it turns out that habit quietly built a far more detailed record than Wordle itself ever keeps. One I can finally ask my own questions of. So I looked into rebuilding my own copy of the data.
- What's the most popular number in Hacker News titles?
Two consecutive titles on the HN front page yesterday had a 6 in them. This means nothing. But it’s the sort of nothing that lodges in your brain until you do something about it, so what is the most popular number in Hacker News titles?
Discussion
No interactions yet
Comments are closed
You can still reply from your own site with a Webmention.
