HN Gopher Feed (2017-09-18) - page 1 of 10 ___________________________________________________________________
Announcing CoffeeScript 2
434 points by GeoffreyBooth
http://coffeescript.org/announcing-coffeescript-2/___________________________________________________________________
jondubois - 4 hours ago
I never understood the need for CoffeeScript. I especially don't
understand why someone would want it now.Compilation of JavaScript
is a terrible idea. I have worked with loads of different compile
to JS languages. The compile step is a huge pain. The language has
to be much much much better than JS for it to be worthwhile. I
think that even JSX or TypeScript don't cut it... Close but still
not worth the hassle! I used CoffeeScript for 6 months, it was a
very lucrative contract but I had to quit in part because I really
didn't like CoffeeScript.What I love in a language is simplicity
and unfortunately, you cannot make something simpler by adding a
layer of complexity on top of it. It might look simpler at first
glance, but it isn't once you start debugging, messing with source
maps and buggy source code watchers.If there was a native
CoffeeScript interpreter inside browsers, then I might consider
using it... Otherwise, no.
maxscam - 1 hours ago
I found using the coffeescript loader for webpack solves all
these problems. You cant execute cs in the browser but you still
can place breakpoints in the original code. The compilation to js
is not novel anyway, its the same thing as we see with ESnext
just on a bigger scale.
fiatjaf - 4 hours ago
Since you were changing everything, I thought it would include a
bunch of new revolutionary syntax and features, just like
Coffeescript 1 did many years ago and made the world jump into
ES6+.Since this is just keeping up with the already existing ES6,
why would anyone bother to move from ES6 to Coffee?
bayesian_horse - 4 hours ago
Because it's more concise and readable.
[deleted]
elbywan - 1 hours ago
I used CoffeeScript for personal projects and absolutely loved the
syntax.Wasn't able to promote it at work though, because of the
lack of support at that time (it felt kinda rusty, most 3rd party
libraries were deprecated, and no jsx).Glad to see things are
changing, the new release looks great !
[deleted]
kuon - 4 hours ago
I really liked CoffeeScript, it's a good way to generate sane
JavaScript. But I have switched to Elm for larger projects. The
maintainability it brings is a lifesaver.
city41 - 6 hours ago
I can't imagine CoffeeScript will see much adoption these days as
most people seem to think ES6+ is "good enough". I miss how concise
functions are in CoffeeScript and also miss being able to do object
literals without the braces. But there's no chance at all in
convincing my team to adopt it, as modern JS really is "good
enough".
camus2 - 6 hours ago
The only reason most people used CS was short hand function
declaration and classes, It really made writing javascript easier
as dealing explicitly with prototypes is a pain in the ass AND it
also eliminated differences between browsers when it came to JS
implementation (yes IE8 was still a thing back then).All these
things are irrelevant today.1/ Most of CS features are supported
by javascript2/ ECMASCRIPT spec is big and complex. Learning
another syntax on top of something every front end developer
should know is a wasted effort in my opinion.
DiThi - 6 hours ago
> The only reason most people used CS was short hand function
declaration and classesAnd for loops (which double as list
comprehensions). And the existential operator. And "this."
shorthand. Among other reasons. To my team it's also more
clean-looking than Python (which used to be my favourite
language), esp. when using a good syntax highlighter like
Atom's (or at least that differentiates function calls, like
Github's).Yes, there's not much difference now from ES6
regarding features, but for some of us it's still worth it.
jmcgough - 5 hours ago
I miss some elements of coffeescript (the existential operator
was really cool), but I think in some ways it served its purpose:
large parts of it were lifted for use in es6.These days we have
typescript as another option, and I feel like there's more gains
from that than the syntactic niceness of coffeescript.
fiatjaf - 4 hours ago
Oh, object literals without the braces, how much I miss you!
sandstrom - 5 hours ago
This is true (few adopting coffeescript), but CoffeeScript
influenced much of todays ES6+, so it still lives on :)
jashkenas - 6 hours ago
And that's totally fine! I don't get a chance to use it much
these days either.But for the folks who still do ? or have
existing codebases ? this update is for you.
anythrow123 - 5 hours ago
I still use CS every day on multiple projects. IMAO CS is one
of the best non-typed languages out there. It's really sad that
so many modern/babel JS proponents fail to see the beauty of
it.I hope that this release (and hopefully future releases)
will help to keep CS alive. Thanks to all contributors!
jonnytran - 6 hours ago
Thank you! I love CoffeeScript! It's been so sad to see it
slowly fade away in favor of, in my opinion, inferior and
uglier things. I -- and many others, I'm sure -- appreciate
this update a great deal. I hope I get to write beautiful
CoffeeScript code again soon.To parent post, why should we
settle for "good enough"?
madeofpalk - 6 hours ago
> To parent post, why should we settle for "good
enough"?Because it's an actual standard and benefits from
wider mindshare and support.
tmzt - 6 hours ago
Hey, I'm working on a template language that compiles into
Redux + IncrementalDOM. Part of it involves a pipeline syntax
similar to underscore or lodash. I'm wondering what you would
consider a modern equivalent of those two libraries using
native methods, iterators, etc. or if vanillajs is sufficient
now.If anyone wants to take a look it's at
tmzt.github.io/isymtope and github.com/tmzt/isymtopeThe
#cleanup-symbols branch is much further along and has a mostly
working TodoMvc.
jashkenas - 6 hours ago
Hmmm. If you're doing the compilation yourself, I'd imagine
you could rely on what browsers provide these days, and
compile to what you need. For the kinds of data
transformations that templates tend to need, I wouldn't
imagine that you'd really find a utility library to be
necessary. Check out the Svelte output, for example.
acemarke - 5 hours ago
Very intriguing! I'm a Redux maintainer - please feel free
to ping me if you've got any questions on the Redux side of
things.
munificent - 5 hours ago
I think it's worth remembering too that the reason JS is "good
enough" for most these days is because of all of the great
language features that you and friends put into CoffeeScript
and which then got adopted by JS.
ethagnawl - 1 hours ago
This is not said often enough. Thanks, jashkenas!
tootie - 2 hours ago
I honestly think both ES6, Coffee and the like are going in the
absolute wrong direction. Every release replaces more keywords
with punctuation marks. That's the reason the community abandoned
Perl. How much productivity do I gain by replacing "function()"
with "() =>"? Round and round we go.Before anyone tells me, yes I
know the semantics are slightly different, but muddling the
semantics with arcane syntax is not an optimal solution.
fineline - 31 minutes ago
>> Every release replaces more keywords with punctuation
marks.I can't think of any other examples. Closures get used
heavily in JS and arrow functions do make their use quicker and
more concise, as well as fixing `this`. Compared to other
languages like Scala, OCaml, Elm and Haskell, with symbols for
functional combination and pipelining, pattern matching, and
whatever you call the thing where you can miss out parameters
and use underscores in function bodies in Scala ... JS is
relatively light on symbols.
city41 - 1 hours ago
I think the comparison to perl isn't fair. It's pretty accepted
that () => is a function type construct. It mimics lambdas and
function calls in many other languages. Perl did really crazy
stuff like storing regex results in obscure global variables.As
for () =>, it can make a big difference in scenarios like
`myArray.map(a => a.foo)` versus `myArray.map(function(a) {
return a.foo })`
melling - 6 hours ago
I was browsing the CoffeeScript docs and everything looks much
more concise. It seems like your code would half the size. Have
people done real world comparisons on large code bases?
Rewrites?
williamdclt - 6 hours ago
We did. And had to "decaffeinate" everything a few months later
because it is hell to work with implicit returns, objects
without brackets, no spread operator, significant whitespace,
no variable declaration keyword...It really is a matter of
taste, but the large majority of us didn't like it. It is
pretty, but I felt like fighting against the language all the
time (implicitly returning an bracketless object is not
something that's easily readable)
fivesigma - 5 hours ago
This mirrors my experience as well. Try having a relatively
simple piece of code exhaust all available memory because CS
was kind enough to turn a simple loop into a clusterfuck of
epic proportions all because you forgot to return null on a
function that well, doesn't need to return anything. Then you
go and decaffeinate the entire thing, actually look at the JS
output and your jaw drops at the amount of useless crap that
your "syntactic sugar" added. Is it really worth it?This
could easily be fixed by adding a -!> operator that disables
implicit returns, but no, they are so opinionated that a
change like that will ruin their perfect little universe. I
know that there are forks that add this sort of functionality
among fixing some of my other gripes with CS but my point
still stands: I'm not going to invest my time into a cult.
DiThi - 5 hours ago
> implicit returnsIn my experience it has only been a problem
when porting existing code bases. We only had to be a bit
careful putting a return after a for loop at the end of a
function so it doesn't build a list unnecessarily (otherwise
implicit returns of unused random values don't hurt). For
clarity, one of the few rules we have is to use return
explicitly when a function is more than a single expression.>
objects without bracketsThe language allows it but it doesn't
mean you must use them. We have a loose style guide where we
forbid a few confusing uses (like bracket-less one liners or
returned objects). So loose it's shorter than this comment.>
no spread operatorIt always had a spread operator (except for
the first month of life). It's just called splat instead of
spread, like in Python. Now it also allows ES6 syntax which
is very similar (...foo vs. foo...).> significant
whitespaceThat's not a bug, it's a feature ;)> no variable
declaration keywordIn the last year or two, that only bite us
once. If it's more frequent than that your functions are way
too long.But as you say, it's a matter of taste.
twykke - 5 hours ago
some colleagues of mine have complained about the
significant whitespace being difficult to understand. i
can't argue with something subjective like that.however i
like to point that our entire codebase, CS, JS, TS, Python,
Java, Swift, 100% of it already has significant
whitespace....it's just that the JS/TS/Java also have curly
brackets.
jashkenas - 5 hours ago
From the perspective of how it was intended to be used,
you've got it exactly right. Just because you can
implicitly return a braceless object, doesn't mean you
should.
twykke - 5 hours ago
i tend to use an explicit return except in one-line
functions; there are plenty of CS features you can forgo
if you don't think they benefit you.
clairity - 5 hours ago
i really wanted to like coffeescript, but the idea of compiling,
transpiling or any other kind of piling of javascript just rubbed
me the wrong way. this is true of scss, less and other css
flavors too.i understand the problems these tools are trying to
solve, but i don't like that you have to learn two (or more)
grammars and syntaxes, and the quirky interactions between them,
to get those benefits (because you can't debug one without
debugging the other). it's a lot more cognitive overhead for what
amounts to a little syntactic sugar.standard es-whatever
javascript needs to be "good enough", and, despite my disdain for
using coffeescript, the improvements that coffeescript induced in
javascript are heartily welcomed.
8ytecoder - 4 hours ago
If you automate it and it's part of your deployment pipeline,
you'd hardly notice it's there. We use both SCSS and CS via
Rails and it's a breeze. The occasional times when I don't
understand why something is not working I go to the
coffeescript website and read the transpiled code and it's
usually obvious what's going on.
sidcool - 6 hours ago
CoffeeScript has lost a lot of adoption after Typescript and ES6
gaining its turf. But by all means it's a good wrapper to
JavaScript. Congrats on shipping.
kbenson - 6 hours ago
> So a CoffeeScript => is now output as =>Wait, using the arrow
function notation doesn't bind this, arguments, super, or
new.target[1] in javascript, as opposed to the normal function
syntax. Not being a user of coffeescript, did coffeescript not do
that already, or did they also throw in code to change that in the
generated code?It seem to me it would make sense to map items that
match conceptually, not just notationally (unless it's common to
have both coffeescript and JS side by side). Can someone comment
on how this is handled?1: https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Refe...Edit: Added "in javascript" after
reference to make it obvious I was talking about JS behavior for
the binding.
madeofpalk - 6 hours ago
Coffeescript's => binds this. Javascript's => also binds this
(more or less)Seems to map fairly well conceptually.
kbenson - 6 hours ago
> Javascript's => also binds this (more or less)Javascript's =>
doesn't bind this though, and function does, which was my point
(and is what the reference I included was saying). That's a
specific change in JS, and either coffeescript had code in
place to emulate the current behavior in prior versions where
they used function(), or they have code in place now to emulate
function() now that they're using =>.I'm going to update my
original comment to be a bit more clear on what I was saying.
madeofpalk - 5 hours ago
> Javascript's => doesn't bind this thoughI think we're
getting our wires crossed. Both Javascript and CoffeeScript
have (more or less, for the common use cases) the same `this`
behaviour for =>. It preserves the `this` value from the
context.
kbenson - 5 hours ago
Yes, that's what was explained in the sibling. There's a
lot of confusion on what "binds this" can mean, and while I
thought you might have been misinterpreting me, I may have
been misinterpreting you. I was using the terminology that
MDN uses in reference to the function arrow, but in the
context of this question, some additional elaboration might
have been useful to distinguish exactly what "this" is when
it's bound (the calling environment, or the current subject
being called on as is often the case).
likeclockwork - 5 hours ago
You have it backwards. => in JS binds this, and => in coffee
used to bind this also but now just emits JS' =>. => in JS
was pretty much taken from coffee, there was no prior version
of => in JS.Coffee also has -> which desugars to a regular
function() {}
irishsultan - 5 hours ago
Old Coffeescript behaviour for => was to use a function where
this was bound to that of the environment. This seems subtly
different from having this not being bound at all (in that
you can't rebind it under the new translation), but that's
unlikely to have been a common use case.The main other
difference seems to be that there is no arguments object for
the local function anymore, although once again that's
unlikely to be a problem in most functions defined with a fat
arrow.As someone else also said, there were two ways to
define functions, one using =>, one using -> the latter maps
to a normal JS function.
kbenson - 5 hours ago
> Old Coffeescript behaviour for => was to use a function
where this was bound to that of the environment.Okay, so it
sounds like coffeescript 1.0 => was effectively doing what
JS => does now, so it makes sense to move to the newer JS
syntax Thanks for elaborating! (It's interesting how
"binds this" can, and was interpreted in multiple ways,
Perhaps there's a better, more specific wording I could
have used to cut through those misunderstandings, whether
they be with those that replied or me reading their
replies).
Nullabillity - 6 hours ago
CoffeeScript did already bound `this` for `=>`. There is also
`->`, which is morally equivalent to JS' old-style `function`.
thechewanater - 6 hours ago
In coffeescript 1.x fat arrow functions already bound "this",
although binding "arguments" is an actual
change.http://coffeescript.org/#breaking-change-fat-arrow
feelandcoffee - 6 hours ago
I don't know what to think about coffeescript anymore. I love it
back then before babel and ES6, but right know I didn't even know
how to use coffee and a library used today. Still miss the python
/ruby-sque sintaxt witouth brackets.Edit: After reading more about
the changes about CS 2.0, I may give it one more chance, let's see
how it work now.
[deleted]
catacombs - 6 hours ago
Jeremy,First off thank you for Underscore, Backbone and
CoffeeScript. Your work really has helped me and my development
team.This question is a little off topic but one I've been wanting
to ask for a long time:Last year you took a year off from The New
York Times to ride your motorcycle across the Western Hemisphere.
Just recently you were hired back at the paper, doing what it
appears to be the same thing in the graphics department.From a
hiring perspective, did you have to reapply for your job, or did
the Times just give you the necessary time off?If this was
considered a "sabbatical," how did you justify traveling around the
Americas as something that could benefit the paper?I don't mean to
offend. I'm genuinely curious. A lot of people aren't fortunate
enough to take a year off for traveling and then be rehired at
their company, especially in the journalism industry with the
revenue declines, job cuts and managers wanting to hire cheaper
people.Thanks again for all you've contributed.
jashkenas - 6 hours ago
Happy to answer, although this is a bit of a funny forum for
it:From a work perspective, it's pretty simple. I quit, and then
was rehired to the same position a year later.But The Times'
Graphics Desk was super nice about it. We had a handshake
agreement that I'd come back when I got back, and they even lent
me a laptop to maybe file some travel-ish bits and bobs from
along the road. So in that sense, it was partially justified.In
the end I didn't end up writing anything for them for a few
reasons: I didn't want to turn the ride into work; I wasn't on my
best NYT-standards behavior (booze, bribes, women) ? well, one
spectacular woman, and we're married now; and finally, I
personally hew somewhat to the Janet Malcolm attitude:?Every
journalist who is not too stupid or full of himself to notice
what is going on knows that what he does is morally indefensible.
He is a kind of confidence man, preying on people's vanity,
ignorance, or loneliness, gaining their trust and betraying them
without remorse.?Especially with respect to travel writing. You
can do it right, but you really have to take the time and be
invested and involved. And I was riding to follow the seasons and
wasn't.Ultimately, even though the industry as a whole is in
decline, the NYT and other world-class news sources are still
strong, and in some ways, getting stronger. In particular, the
visual journalism The Times publishes every year keeps pushing
the state of the art.
chrisallenlane - 5 hours ago
> In the end I didn't end up writing anything for themI
understand that you didn't write anything professionally about
your trip, but did you ever write anything casually about it -
blog posts or the like? It sounds like it would make for
interesting reading :)
jashkenas - 5 hours ago
From roughly sketched map to marriage, it's all archived on
Instagram. But I'm afraid there's nothing more than that
written up ... yet.
chrisallenlane - 4 hours ago
I'll check it out and will keep my eyes open. Thanks :)
catacombs - 5 hours ago
I admit it is a funny forum to ask this, but, hey, here we
are.Thanks for the response. It seems your situation was
unique, and you're definitely fortunate to have a department
willing to make this agreement.The Average Joe more than likely
can't pull this off, especially if the company can hire a
replacement.
markdog12 - 5 hours ago
I'd say NYT was fortunate to have him, and realized it.
jgalt212 - 5 hours ago
agreed, he's a star. And companies, rightfully so, do
pretty much all they can to retain stars.
franze - 5 hours ago
actually I don't think it so uncommon. when you travel you
meet a lot of people who just quit and can prop. go back to
the job when / if they return.just do it.
jonny_eh - 6 hours ago
As important as your work on the above mentioned libraries
were, your continued work at the NYTimes is even more
important. So thanks!
md224 - 6 hours ago
> booze, bribes, womenKind of curious about the "bribes"
part...
catacombs - 5 hours ago
Probably bribes for police, soldiers or any other government
official he ran into during his travels.
jashkenas - 5 hours ago
Nothing too spectacular, I've got enough Spanish to talk
through all of the border crossing paperwork comprehensively,
which helps avoid problems with papers down the line.You have
to get a temporary import/export permit and country-specific
insurance every time you cross a border. I ended up crossing
33, so that's plenty of paperwork to potentially get fouled
up on. And in some countries checkpoint cops love busting
gringos for their paperwork, because if they're missing
something mandatory, that's easy money.I screwed up the
US/Mexico border first by not having done my research.
Crossing from Presidio to Ojinaga, I made sure to get Mexican
insurance, but didn't think to set Banamex bond for the
temporary import permit ? not required in the border zone, so
the customs officials don't mention it. I didn't have it, and
if any official in the length of Mexico had asked me for my
paperwork (despite passing multiple checkpoints), that would
have been full legal grounds to seize the bike. But I made it
to the Guatemalan border trouble-free, and the customs exit
officer nailed me for it there. "It's easier if you just pay
me the fine." Around $50, I think. I got change from his
wallet.The second not doing my research screwup was not
bringing my original title document to the motorcycle with
me, just some color photocopies. In most cases, copies are
fine ? after all, we don't drive around with our titles in
our glove boxes. But leaving El Salvador, at the Honduras
border, a cop in front of the immigration building decided to
make an issue of it. "I'm sorry, but without the original
title document, there's nothing that can be done." After
about half an hour, with some help from a roadside border-
crossing fixer (there are many on the El Salvador / Honduras
border, because these situations are notorious there) and a
little over $200, the bike and I were through.Of course, the
first thing I did after arriving in Choluteca, Honduras, was
to head over to the police station and file a false report,
saying that I had left the original title in the top bag of
the motorcycle and someone had stolen it, along with a few
other miscellaneous documents. When getting yourself out of
paperwork trouble, an officially stamped police report is as
good as gold. From that point on, at any border where the
photocopied title wasn't good enough (Peru, in particular,
gave me a really hard time about it), I could show them the
police report, show them that the VIN on the report matched
the VIN on the photocopied title matched the VIN on the bike,
and we were good to go.Like I said, not NYT-standards
behavior.
throwawayknecht - 5 hours ago
> not NYT-standards behavior.Are you kidding? Spin the bit
about the border-crossing fixer into a homily about
capitalism, italicize a list of the meats you ate, and
you've got a Friedman column.
santoriv - 6 hours ago
I can't answer for him. but it would seem to me that there is a
pretty universal shortage of quality developers, much less
superstar developers familiar with your existing codebase.
Rehiring him would be a no-brainer.
rattray - 6 hours ago
jashkenas is a graphics editor, not a developer. Your point
still stands though.
catacombs - 5 hours ago
Graphics editors are also developers if they are writing code
to make graphics, i.e. every newspaper's graphics team that
has made interactive projects.
markdog12 - 4 hours ago
Created CoffeeScript, Backbone, Underscore, but not a
developer?https://github.com/jashkenas
catacombs - 6 hours ago
That is a good point. The NYT is responsible for other awesome
tools: d3.js, ai2html, etc.I'm sure if the company has a person
who creates a tool that is used all over the world under its
watch, they would allow that person to take as much time off as
he or she needs.Still, I know people who are --- no pun
intended -- the backbone of codebases at their company, and
taking a year off and being rehired is out of the
question.What's to stop the company from finding a replacement
who can be up to speed with the code in a short amount of time?
kristiandupont - 6 hours ago
>What's to stop the company from finding a replacement who
can be up to speed with the code in a short amount of
time?The fact that it's very, very hard and the competition
is fierce?Also, this is not a romantic relationship we're
talking about. If you leave your place of work, no matter how
irreplaceable you are the company is going to carry on as
best they can. If a year later you are available again and
they still need a person for this position that they know you
would fit well, why would they not rehire you?
catacombs - 5 hours ago
The competition is fierce for whom? The company picking
from a pool of developers, or the developers competing for
the job?If the former, then the company is an advantageous
position to pick someone from the pool. It's not like ZERO
people will apply for the job.If you're talking about the
latter, then it's irrelevant. I'm mainly focusing on the
company.
sotojuan - 5 hours ago
> If the former, then the company is an advantageous
position to pick someone from the pool. It's not like
ZERO people will apply for the jobThe pool of people as
talented as jashkenas, that are looking for a job, and
want to work in the NY Times is tiny.
santoriv - 5 hours ago
I think that something else to take into consideration is
that hiring good people is a non-trivial problem. Folks
can do well in a interview and seem amicable and then
turn out to be incompetent and/or jerks later. So there
is substantial risk in hiring. It seems like knowing for
certain that someone is competent and works well with the
rest of the team is worth A LOT.
sctb - 5 hours ago
We detached this subthread from
https://news.ycombinator.com/item?id=15276996 and marked it off-
topic.
jashkenas - 4 hours ago
It most certainly is. Thanks, mods!
no_wizard - 4 hours ago
This is honestly the first time I have looked close at
CoffeeScript. At a passing glance, it looks really close to Python
with javascript elements added in. Is that a correct assessment? If
it is, this might be for me.My other question is: how nice does
coffee script play with other libraries? We (unfortunately) use
jQuery a lot. I have also been using underscore and lodash as well.
Are those two even needed when writing coffee script? I'm kind of
assuming not, since they're both largely just adding
methods/functions.
Justsignedup - 4 hours ago
CoffeeScript is javascript. It is just a nicer (in some people's
opinion) form of javascript. It added some much needed features a
few years back, but with recent JS advances the utility of
coffeescript are much less than they used to be.So invoking
jquery and everything is totally 100% supported. In fact that is
how I used coffeescript a few years ago.
rmrfrmrf - 1 hours ago
Having used CoffeeScript a while back, it's kind of like a weird
mix of Ruby, Python, and Perl. With all the good underpinnings of
JavaScript, of course.
ralmidani - 4 hours ago
If you like Python, you will love CoffeeScript. :)I have not used
Underscore/Lodash in production, but I use jQuery a lot with
CoffeeScript. CoffeeScript does not replace jQuery, although it
can make your jQuery a lot nicer.As far as other libraries, there
really are no restrictions; CoffeeScript compiles transparently
to JavaScript. The only thing holding it back would be poor
support in the specific ecosystem you are working with, such as a
lack of plugins that automate the build process. In that case,
you may need to compile manually or set up your own build script.
But other than that, you can use CoffeeScript in place of JS
pretty much anywhere.
no_wizard - 3 hours ago
I figured jQuery would be fine. Now that I think about it, I
can't imagine why most things wouldn't really, since all
javascript libraries are just extensions of those things.Does
CoffeeScript just convert the modules methods/functions
accordingly when needing to be called?Just curious how that
works.Since so much of JavaScript development, especially
nowadays, ties into a lot of frameworks/libraries (modules? I'm
not always sure what we want to call it), I just didn't see a
reference (maybe I missed it) on their page in regards to what
it actually looks like to invoke module/framework/library
specific things.
ralmidani - 3 hours ago
CoffeeScript does not do anything framework- or library-
specific. It simply compiles your code to JavaScript, which
is then parsed and executed as usual.
no_wizard - 2 hours ago
Good point. I guess I'm not making myself clear. If I'm
working with jQuery, for instance, do I need to do anything
different than I do now in terms of invoking say, the
simplest thing, $(function({_..code here.._}) (or for you
old schoolers $document.ready({_..code here.._}). Thats
what I guess I mean. Maybe I just need to toy with it. I
suspect I might be overthinking this in my head.
maxscam - 1 hours ago
Its actually a great example of Coffeesctipt conciseness,
the jQuery ready function is just $ ->
ralmidani - 1 hours ago
Yeah, play around with the online compiler on the
website.Your jQuery example would simply be written:$ ->
_..code here.._
[deleted]
aleph4 - 3 hours ago
It's "just" Javascript, so it plays quite well with everything.
Definitely jQuery. Main issue was that the missing JSX support.
It definitely a Pythonic JS, and I much preferred it to JS a few
years ago.
[deleted]
maxpert - 4 hours ago
As much as I love CoffeeScript (because I love Python), I think
over time the project is loosing it's value due to ES6 (Frankly I
believe even TypeScript is going to suffer the same plague soon).
One possible incentive for me might be the toolkit and the pre-
built stuff that I can get out of box from such transpilers (JSX is
a good addition for example, however I am surprised why something
like PUG, or HAML was not adopted instead of JSX from syntax
perspective). None the less I greatly appreciate the hard work team
is doing and look forward for stuff like pattern patching and some
functional inspirations.
breuleux - 1 hours ago
For what it's worth, Earl Grey has a more lightweight syntax to
build HTML, advanced pattern matching, and looks more like
Python: http://www.earl-grey.io/ (Disclaimer: I made this).
bayesian_horse - 4 hours ago
ES6 solves some of the problems CoffeeScript solved back in the
day. It's still verbose, still full of "line noise".JSX wasn't
adopted by CS2 at all. It's just that certain things are passed
unmolested into the compiled output, which happens to make it jsx
compatible. Other similar preprocessors would work, too.
TazeTSchnitzel - 4 hours ago
> loosing it's value due to ES6 (Frankly I believe even
TypeScript is going to suffer the same plague soon)Why would ES6
being more widely adopted hurt TypeScript? TypeScript is and
always has been ES6 compatible. Are you imagining people would
suddenly lose interest in static typing?
Rotareti - 4 hours ago
> I think over time the project is loosing it's value due to ES6
(Frankly I believe even TypeScript is going to suffer the same
plague soon)I could imagine TS going to suffer some plague like
this to another language that is statically typed like Elm,
Haskell, etc., but probably not to JS.
ralmidani - 4 hours ago
Check out CoffeeScript JSXY. It's basically CS2 but with a HAML-
inspired alternative to JSX syntax.https://github.com/helixbass
/coffeescript-jsxy
[deleted]
ludicast - 6 hours ago
Congrats!I loved the elegance coffeescript & it was the language
that convinced me JS was a reasonable target.Though I, like many,
moved to TS, I use CS every day via its spiritual child es6.
root_axis - 4 hours ago
I love CoffeeScript. Thanks for this.I know, I know, "what about
types". Perhaps it'll get there one day. There's always flow.Thanks
again.
FractalFlows - 3 hours ago
Great!
kodablah - 6 hours ago
While I understand the let vs var thing, I wish I could tell the
compiler that I promise not to non-obviously reference a local var
(e.g. in an eval). Then CoffeeScript could determine it is only
written at decl time and could use const. Technically, this could
be used for var scoping too in the let vs var issue.> Keep in mind
that const only protects you from reassigning a variableWhile I
haven't looked, I'd suspect there are performance implications too.
[deleted]
[deleted]
forty - 2 hours ago
At work we started node with node 0.6, CS was nice at the time, it
would bring cool stuffs such as arrow functions. Nowadays we are
using Typescript, and we love it. To be honest, I am quite happy we
are getting rid of CS, the lake of variable declaration specific
syntax (as opposed to assignment statements) is really a big bug of
the language IMO which can lead to really awful bugs in your code
if you are not careful. We have been using
https://github.com/decaffeinate/decaffeinate to help getting rid of
our CS files, it works quite well.
XCSme - 5 hours ago
TypeScript still seems the much better choice.
bayesian_horse - 4 hours ago
For certain situations or teams, yes. For others, no.
[deleted]
shallot_router - 2 hours ago
I wish someone could take the best parts of TypeScript and
CoffeeScript and put them together.
maxscam - 1 hours ago
I think its likely that at some point in the future cs will get
strong type support. Iirc the creator is opposed to it but
theres interest from others.
AriaMinaei - 1 hours ago
I'd happily go back to CoffeeScript if I could keep using
Flow/TS/ESLint and the rest of my toolset.That's entirely possible,
and the setup would look like this:CS would produce a babel-
compatible AST, instead of producing the final ES6 source code. It
would simply leave the job of generating the final code to babel
(via babel-generator).You'd then be able to re-use some (though not
all) of babel plugins on top of CoffeeScript. babel-macros for
example will work out of the box: https://github.com/kentcdodds
/babel-macrosESLint would mostly work out of the box. Syntactic
rules won't be relevant anymore, such as the one that enforces
semicolons, but other rules will be fully useful. You could still
enforce no undeclared vars for example. Importantly, you'd still
see ESLint errors in your editor exactly where they occur in the
.coffee source file, and not in the final transpiled file. This
would work, because ESLint can read a babel-compatible AST which is
what CS would produce. I've already tried in a small POC.I'm sure
it would be trivial to patch TypeScript to accept babel-compatible
AST instead of doing the parsing itself. You'd then use TypeScript
as a type-checker and not as a transpiler (This is already possible
iiuc with babylon 7). Type checking would then work in .coffee
files just like it would in .ts files. Some language-server
commands like find-references, goto-definition, and show-type would
also work. Refactoring commands of course wouldn't work, because
they are specific to the typescript syntax.Flow would work out the
same way too. Right now it has its own parser written in OCaml,
which produces an AST that is compatible with that of babylon 7.
All you have to do is to bypass that parser and get the AST from
CS. You'd then get type errors inside .coffee files, and all the
other goodies you expect from flow.---There is no reason why one
should have to choose between CS and the rest of the JS ecosystem.
The fact that you have to give up type-checking and linting in
exchange for CoffeeScript/SweetJS/your-favorite-stage-1-proposal,
is only because the tools don't play nicely together. They could.
And with all the recent standardisation work already done, that is
a low-hanging fruit.
jonnytran - 24 minutes ago
Will the next version of Rails include this by default?
...Unfortunately, it would be a breaking change, so maybe not until
Rails 6?
ralmidani - 6 hours 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).
methyl - 5 hours ago
> cannot imagine going back to semicolonsActually, 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 `;`.
Bahamut - 4 hours ago
There is a nasty edge case if you concatenate scripts and use
an IIFE in a script
ralmidani - 5 hours ago
I like consistency. And I am paranoid. When I write JS, I
always include semicolons. When I write CS, it is a non-issue.
vanderZwan - 3 hours ago
I have my VSC set up to automatically format and insert
semicolons when I save. Saves a lot of hassle.
akvadrako - 4 hours ago
I consistently don't use semicolons in JS. It's just noise.
jdmichal - 4 hours ago
Omitting 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 - 4 hours ago
I 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.
pramodliv1 - 3 hours ago
> And I am paranoidYou should write tests when building a
project in a dynamically typed language to alleviate some
paranoia anyway. As long as you have decent test coverage and
use a decent linter/formatter such as StandardJS[0] or
prettier[1], you'll be fine.[0]https://standardjs.com/
[1]https://github.com/prettier/prettier
boubiyeah - 2 hours ago
And with Typescript (or a linter, I guess) you would get a nice
red line on that 1 out of a million line where a ; is needed.;
are eyesores to an already fairly technical debt heavy/bloated
language.
dugmartin - 3 hours ago
I 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 - 3 hours 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
GeoffreyBooth - 2 hours ago
It?s not elegant, but there is a way to do type checking in
CoffeeScript: http://coffeescript.org/#type-annotations
ralmidani - 1 hours ago
Thanks for the link. :)But wow, "not elegant" is an
understatement.
ralmidani - 3 hours ago
That 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 - 3 hours ago
Well, guess it's time for someone to build yet another layer
of abstraction by writing a typed superset that compiles-to-
CoffeeScript then!(I'm joking, but actually.. why not?)
rmetzler - 4 hours ago
I 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/#jsxAnd 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.
ddlsmurf - 48 minutes ago
I'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 ?
rapind - 1 hours ago
I 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/I'm not doing much react these days
(cough elm), but I think it's still mostly relevant.
twykke - 5 hours ago
i 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 - 5 hours ago
Exactly.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 - 5 hours ago
list 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 - 4 hours ago
I 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.
ripexz - 2 hours ago
With 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
Akujin - 5 hours ago
Augh. Anytime I see a Coffescript project all I see is wasted money
trying to recruit engineers who actually want to use it. 90% of
people who write JavaScript roll their eyes and move on.
ralmidani - 4 hours ago
Another way to look at it: you will only draw developers who
share your appreciation for whitespace-significant languages.I
have worked on two startups with a fellow programmer who knew
Python but not CoffeeScript. He picked it up very quickly, along
with Emblem (indented Handlbars alternative, useful for Ember
projects) and indented Sass. Once we told the text editor to
insert 4 spaces in place of tabs, we had much less to worry about
in terms of stylistic disagreements.
kibwen - 6 hours ago
Never used CoffeeScript in anger, and I don't see it regaining the
level of hype it once had, but despite its lack of dominance I
think it emphatically suceeded in helping to push Javascript
towards its modern (and much improved, IMO) incarnation. A good
recent example of how a technology doesn't need to capture
marketshare in order to have a positive impact on the market.
dtech - 4 hours ago
I respect CoffeeScript for what it did and playing a part in making
Javascript and its ecosystem better.That said, for a new
development, is there any reason to use it over ES6? If you don't
like the current Javascript, Cofeescript isn't going to convince
you (Elm, Purescript, Scala.JS etc. might). The only direct value
is see in this version is as an upgrade target for existing
codebases.
camus2 - 6 hours ago
First congrats, this is hard-work. Second I implore people not to
use a language where the designers think breaking changes are OK,
while giving no real advantage over plain modern Javascript or the
use of a linter. Worse, since CS has slighly different semantics
than JS it will lead to so much confusion. Coffee Script served its
purpose, now let it rest.
creatonez - 6 hours ago
>Second I implore people not to use a language where the
designers think breaking changes are OKThis is a big deal when
you also have to use libraries written in the same language.
Python 3 being a fundamentally different language (the underlying
bytecode is not backwards compatible) from Python 2 made the
transition very difficult.However, this will never be a problem
for a javascript transpiler.And also, the list of breaking
changes really isn't too incredible. I imagine it'll be fine for
most coffeescript projects to take this update quite liberally,
as it shouldn't be too hard to write CoffeeScript 1.x/2.x
polyglot code to transition to the new version.
bpicolo - 7 hours ago
The breaking changes page is ironically quite broken (latest
chrome)http://coffeescript.org/#breaking-changesEdit: Seems that my
computer doesn't consider the cert authority valid for
bootstrapcdn.
SquareWheel - 6 hours ago
Seems to work here okay. Also latest Chrome.
83457 - 6 hours ago
I tried before and after the very latest update without a
problem.
[deleted]
jashkenas - 7 hours ago
In open source, it's lovely, and fairly rare, to see someone pick
up the ball on a quiet project, and run with it to completion
without getting frustrated or losing interest first.Geoffrey Booth
? with big assists from Simon Lydell and Chris Connelly ? has
really gone the distance here, spending a full year working on
drafts of CoffeeScript 2.0 to upgrade it from a language designed
around ES3, to make it as ES6+ friendly as
possible.https://github.com/jashkenas/coffeescript/commits/masterHe
also redid the website and the docs for good measure:
http://coffeescript.org/Bravo.
rattray - 6 hours ago
You can also see on the "Contributors" graph a major increase in
CoffeeScript contributions in the past year or so:
https://github.com/jashkenas/coffeescript/graphs/contributor...A
bunch of people helped out: https://github.com/jashkenas/coffeesc
ript/wiki/CoffeeScript-...And GeoffreyBooth coordinated the
effort, posting regular status updates & calls for help, handling
bugs / feature requests, etc. I didn't realize he was also
writing most of the code!CoffeeScript2 started with a manifesto
at https://github.com/coffeescript6/discuss which turned into a
cooperative effort with jashkenas to move CoffeeScript forward in
a responsible way. An interesting story in its own right.
[deleted]
bpicolo - 6 hours ago
It's very impressive to see what the team did here in picking it
up from you as maintainer. Props to the team!
virtualwhys - 3 hours ago
Huh, just finished migrating a small 5K front end from CS to
Scala.js.Miss the concision of CS, both in terms of syntax and
generated output, but otherwise really enjoying typed JS. Also,
it's kind of cool not immediately knowing whether a particular
source file is for the front end or back end -- like, oh, wait,
this is the front end ;-)
skilesare - 6 hours ago
Been following for a while. Great job getting it out!CoffeeScript
has saved me thousands of hours of parentheses closing alone.
srb- - 5 hours ago
As a CoffeeScript fan things were looking pretty bleak a year or
two ago. In particular there was zero momentum for new features.How
things have changed! Major kudos to Geoffrey Booth and all
involved. Coffee's beautiful syntax combined with async/await has
taken a lot of the 'ick' away from coding in JS, at least for me.
twykke - 5 hours ago
having used Coffeescript almost exclusively (in the Node.js
world) for something like 6 years, async/await was the only
feature i have been gnashing my teeth waiting for, but i wasn't
even that impatient because i have also been using Fibers for
just as long.
maxscam - 1 hours ago
Exactly. I'm glad to see people arent absolutely shitting on it
here like they have been over the past year or two, which is when
I started using it,
ricardobeat - 6 hours ago
So great to see a good release after all these years.
Congratulations to all!I'm curious though about what happened to
the Kickstarter project that took a few grand to write what was to
be "CoffeeScript 2" at the time - did any of that code end up in
this release?
rattray - 6 hours ago
link?
jashkenas - 6 hours ago
It didn't.Although Geoffrey and folks considered a rewrite of the
compiler along the lines of Michael Ficarra's CoffeeScriptRedux,
they decided it was more pragmatic just to work with the existing
compiler and get it to produce Modern JS instead of the Lowest-
Common-Denominator JS it previously output.A wise choice,
especially given 2017 interest and energy levels.Edit: To be
clear, to the extent anything can or can not be considered
official in open source, Michael's project was his project, and
never made it in to the main repo. We encouraged it just as we'd
encourage anyone to try and make an independent implementation ?
but CoffeeScript has never asked for financial support.