3 ms·
> I never understood why anyone ever used Coffeescript whereas I do think I have a solid understanding of why people use YAML. When Coffeescript was invented,
by jeroenhd 3y ago
> I never understood why anyone ever used Coffeescript whereas I do think I have a solid understanding of why people use YAML.
When Coffeescript was invented, it was an advancement on top of the awful Javascript standards at the time. It never went anywhere because Javascript caught up, but Coffeescript had a good reason for existing.
Today, Coffeescript is a remnant of old frontends that nobody has bothered transpiling into Javascript yet, but back in the day it was a promising new development.
- lucideer 3y ago> it was an advancement That was certainly the selling point. I never saw any advancements in it - the features were aesthetic syntactic sugar.
- jeroenhd 3y agoCoffeescript came with spreads and destructuring, and added string interpolation, just to name a few things. It also added classes and inheritance, the ?. operator, . I suppose you could argue those are just synctatic sugar because they compiled down to ES5, in the same way you can argue that any programming language is synctatic sugar over raw machine code. I may disagree (_heavily_) with the Pythonesque syntax Coffeescript chose, but it took a while for ES6 to be widely available, and Coffeescript made ES6 features work on most browsers without any additional effort. It's easy to take today's Javascript for granted, but the web was very different back in 2009.
- d_k_f 3y agoIn addition to this: ruby-like classes and "sane"/expected handling of this using fat arrow functions. I've worked with a few developers at the time that considered themselves pure backend/rails developers and didn't (bother to) grok the details around the way this worked in JS. I distinctly remember lots of var that = this; in JS code back then, which wasn't required anymore when using CoffeScript.
- mikepurvis 3y agoClass sanity was the major reason I chose it for a project in the early 2010s. I was interacting with the classes in OpenLayers and being able to do so without all those footguns was very welcome.
- PH95VuimJjqBqy 3y agojavascript was never designed to be used like a classic OOP language, that's why jquery won, it was functional which meant it didn't fight you the way the other libraries did. javascript is first and foremost functional no matter how hard MS and others have tried to hammer it into a more typical OOP language.
- Dylan16807 3y agoI'm not sure what you mean. You can put functions into objects, you have "this" when you call the functions, you even have prototypes. It seems to me like the language is designed to let you do OOP just fine, and the only thing that was awkward was organizing the code where you define all those functions and the constructor. So they added a sugar keyword for it.
- PH95VuimJjqBqy 3y agoright, it's awkward, so don't do that, be functional instead. jquery vs mootools/scriptaculous/etc. jquery won for a reason, it's just flat out a better experience in terms of code specifically because it uses a functional approach in its api rather than an OOP approach.
- Dylan16807 3y ago> right, it's awkward, so don't do that, be functional instead. I feel like you're just saying that because you like functional code. I'm sure that when they've added syntax to make certain functional things easier to type, you didn't respond "it's awkward, so don't do that, write it in an entirely different way instead". Regardless of what is "better", which tends to differ based on situation, there was no need for the awkwardness. Classes weren't bad to use, it was just that declaring them had some pointless busywork.
- dartos 3y agoFat arrow functions were adopted from coffee script. IIRC it also had some different scoping rules so you didn’t need to sprinkle `bind` all over.