8 ms·
CoffeeScript is still very relevant for me. I have two medium-sized Ember projects written in CoffeeScript (and Emblem and Sass--the original, indented variety,
by ralmidani 9y ago
CoffeeScript is still very relevant for me. I have two medium-sized Ember projects written in CoffeeScript (and Emblem and Sass--the original, indented variety, thank you very much).
I have been looking at React (will probably skip due to the patent license) and Vue, but cannot imagine going back to semicolons and (excessive) curly braces and parens.
If you married CoffeeScript just out of convenience (being able to avoid prototypes, bind, etc.), then it no longer serves much of a purpose. But if, like me, you fell in love with CoffeeScript's beauty, then no amount of ES6+ features will make it obsolete (as long as you can also keep using those features directly in CoffeeScript).
- twykke 9y agoi also don't use CoffeeScript because of any 'feature' it has over standard JS but instead because of its concise but expressive syntax. it's less about what it does have/do, and more about what it doesn't have/do. some small aspects of CS i forgo because they (in my opinion) are a little too concise such that they sacrifice readability, but all in all it has my favorite syntax of any language.
- ralmidani 9y agoExactly. I personally think calling .map() on an array is more readable than an array comprehension. But since CS is "just JavaScript" you are free to use the native JS array methods (and even more elegantly, at that).
- twykke 9y agolist comprehensions was exactly what i was talking about :) however i replace them with lodash and ramda, which benefit enormously from CS's lambda syntax
- atom-morgan 9y agoI wish this line of thinking was more common. So many people feel forced to use parts of a language when you don't have to.
- sgustard 9y agoCS breaks the ternary ?: operator which is a big headache for me.
- igl 9y agoEverything is an expression. Including if statements. There is no need of such syntax abominations.
- jashkenas 9y agoBingo. Remember when you first first learned the ternary operator syntax? I recall thinking something along the lines of, "Wow, that's cryptic!" result = if condition then success else failure
- sgustard 9y agoSure, but other coffee operations like x||=5 are also abominations. Brevity and purity are often at odds and the choices made by a language can be arbitrary.
- methyl 9y ago> cannot imagine going back to semicolons Actually, Javascript does not require semicolons to be present. If you skip them, the only edge-case is when you try to start your line with `[` or `(`. In that case, you can prefix the line with `;`.
- ralmidani 9y agoI like consistency. And I am paranoid. When I write JS, I always include semicolons. When I write CS, it is a non-issue.
- akvadrako 9y agoI consistently don't use semicolons in JS. It's just noise.
- jdmichal 9y agoOmitting semicolons breaks the "delete a line in isolation" rule, unless you begin the line with a semicolon instead. Which is even noiser than just having them at the end of the line, where they are unconsciously glossed over by anyone who's ever worked in a language with C-derived syntax.
- RussianCow 9y agoI hear this a lot, but in ~4 years writing JavaScript without semicolons, I've had to do this maybe two or three times. I just don't feel like starting a line with [ or ( is very common, to the point that it's a complete non-issue to me.
- tga 9y agoIn the majority of cases you can't "delete a line in isolation", because it's part of a program. You have to look around and understand what the impact of deleting that line will be -- and modify nearby lines as necessary.
- pramodliv1 9y ago
- ripexz 9y agoWith Vue.js you can use Coffeescript (alongside others) as well as SCSS, Pug, etc in single file components using lang="coffee" attribute in the script (or style or template for the others) tag. Need to add a couple more dependencies to your package.json but it works like a charm. https://vuejs.org/v2/guide/single-file-components.html https://vuejs.org/v2/guide/single-file-components.html
- rmetzler 9y agoI loved CoffeeScript, but I felt it was a double edged sword. I would still use it though, if there were JSX style xml/html tags. But React changed everything for me and as a full stack dev, I can use only few frameworks on one level. Edit: Ok, JSX is now supported. http://coffeescript.org/v2/#jsx http://coffeescript.org/v2/#jsx And I'm glad they broke the different behaviour of =>. It might need a fix in a lot of code bases, but this price is cheaper than having the mental burden of it.
- rapind 9y agoI personally can't stand jsx, and coffeescript makes it so much nicer to avoid when using React. It's almost like haml / slim / jade / pug if you know what I mean. I wrote a comparison about it a couple years ago: http://rapin.com/blog/2015/02/03/reactjs-with-coffeescript/ http://rapin.com/blog/2015/02/03/reactjs-with-coffeescript/ I'm not doing much react these days (cough elm), but I think it's still mostly relevant.
- desireco42 9y agoYeah, Elm is the bomb! Had to grin when I saw your comment. I am really happy with this refactor of Coffeescript but Elm is what I do.
- cies 9y agoElm... And not to forget PureScript... and to a lesser extend ReasonML (by which you can still use React and JSX)... and Haskell/GHCJS. There are quite a lot of ways to seek refuge from both type scarcity and the "semicolon" line noise that was mentioned. Here some benchmarks for several of the FWs that are popular in these languages (Elm has the FW built-in, ReasonML-React is missing but should be close to React.js). https://medium.com/@saurabhnanda/benchmarks-fp-languages-libraries-for-front-end-development-a11af0542f7e https://medium.com/@saurabhnanda/benchmarks-fp-languages-lib...
- ddlsmurf 9y agoI'm not a big fan of the new =>, it means the arguments variable will have parent scope in => but not in ->, it kind of erodes into coffeescript's elegance/consistency imho, unless I'm missing something ?
- dugmartin 9y agoI felt the same way when I switched from CoffeeScript to TypeScript but the type checking was worth all the braces, returns and lack of existential operator. If CoffeeScript added an (optional) type system I'd switch back in an instant.
- kbp 9y ago> If CoffeeScript added an (optional) type system I'd switch back in an instant. The home page talks a little about achieving this by using Flow annotations in Coffeescript source and then having the build system pass the Javascript output to Flow: http://coffeescript.org/#type-annotations http://coffeescript.org/#type-annotations
- GeoffreyBooth 9y agoIt’s not elegant, but there is a way to do type checking in CoffeeScript: http://coffeescript.org/#type-annotations http://coffeescript.org/#type-annotations
- ralmidani 9y agoThanks for the link. :) But wow, "not elegant" is an understatement.
- Yaggo 9y agoThis is cool! That being said, it would be very nice to have (optional) syntactically more beautiful type annotation. I assume Flow must be compatible with regular javascript, but CoffeeScript could take more flexible approach. I have no idea what the actual syntax could be, though.
- ralmidani 9y agoThat would be really nice, but CoffeeScript will probably not be adding types unless they start adding them to JavaScript. It is a dilemma, but so far I have gotten by without type-checking.
- vanderZwan 9y ago
- andrei_says_ 9y agoI feel very much the same. My first language is Ruby and CS just clicked. I continue using it in my Vue projects and it's a pleasure. I appreciate the work the team has put into bringing elegance and brevity to my daily life.
- snarkyturtle 9y agoIt's easier when you use something like Prettier which formats the code for you, same workflow as coffeescript except less work and possibly more readability.
- alwillis 9y agoI just started a new project and decided to go back to the indented Sass syntax as well. Makes a nice compliment with CoffeeScript, Halm, Slim, etc.
- TheAceOfHearts 9y agoMight I suggest trying out JavaScript Standard Style [0]? It has editor plugins and a CLI tool for linting. You can write JavaScript just fine without semicolons. I used to be in the same camp, but Feross eventually convinced me to try dropping em. Despite being cautious and a bit skeptical, I tried it out in a few projects by removing all semicolons with a search and replace. In every single case, I encountered zero issues. [0] https://standardjs.com https://standardjs.com
- drumttocs8 9y agoMaybe it's just me, but I can't imagine dealing with scope without those little curly braces. They give a definitive beginning and end I can see, rather than trust my indents are correct. But maybe I just didn't give Coffeescript enough time to get used to it.