Posted November 20, 2022 by Cosmo Myzrail Gorynych
#work in progress #ctjs #wip
Have you heard of CoffeeScript? If your answer is “yes”, there are high chances that you’re as old as a dinosaur or, say, me, and that you’re looking at this post with disgust right now. It was that edgy language that was proooobably invented by Python users as they could not bear the brackets in JS code. And I think that CoffeeScript’s best use case was overlooked and simply forgotten: its value in education!
CoffeeScript is unbelievably easy to learn, and it compiles to JavaScript one-to-one, meaning that anything that can be done in ct.js’ JavaScript works the same if written in CoffeeScript! It also supports all the newest JavaScript goodies 💖
In the next ct.js versions, each time you create a new project, you will be asked whether you want to create a CoffeeScript or JavaScript project:
The easy syntax of CoffeeScript is not just a plus for those who has only started learning programming, but also a boost to coding speed for experienced developers. Compare these two identical events in two programming languages:
CoffeeScript
The syntax is actually flexible: you can see yes
and no
instead of true
or false
, but you can write either way. There are also additional ways to write boolean operations and comparisons, like if not invincible and hp <= 0
, which is much better for beginners than if !invincible && hp <= 0
.
Adding CoffeeScript is not just adding a CoffeeScript to JavaScript converter. I already modified the built-in tokenizer (the thing that marks your code for syntax highlighting) and added a custom suggestions provider, so you get docs and code completions similar to what you are used to in JavaScript projects. There is still work to be done to support methods from catmods.
Docs are updated, too. The new theme of the future documentation site supports code tabs that let you choose between JavaScript or CoffeeScript in tutorials and other pages.
I’ve also updated the cheatsheets — they will come together with ct.js v3.2. They will have a 4th page! Mostly because you can’t quite make the number of three different pages on two-sided prints even, lol.
I plan to release CoffeeScript support with ct.js v3.2, and it will be the major feature of this release. Though I’ve already added small improvements to it, too! Stay tuned! 📺
If you want to use CoffeeScript, you can wait for a stable ct.js release, or you can use a Nightly version for this and other features right now: