Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use CoffeeScript! #2472

Closed
wants to merge 1 commit into from
+6,501 −15,896
@mjackson

Come on guys. Time to upgrade.

@mjackson mjackson Use CoffeeScript!
Come on guys. Time to upgrade.
8662e09
@thejh

Do the tests still run? Also, coco is better.

@mmalecki

+1, there's no way core can be written in JS. You need these advanced features and only CoffeeScript can provide them.

@mceachen

YEAH! THIS ISN'T A TROLL! AT ALL! much.

@maccman

+1. Now I can actually read Node's source.

@kn
kn commented

Nice!

@alessioalex

Dart is so much better, but we should ditch V8 in favor of SpiderMonkey too #lol

@ryantenney

-1. Now I can't read Node's source.

@paulmillr

+1. Now I am willing to read Node's source.

@chjj

You were supposed to wait until april 1st to do this!

@thejh

You should use is instead of == where possible.

@tj
tj commented

nom nom

@thejh

Also, you should omit call parens where possible, looks much better.

@pquerna pquerna closed this
@pquerna
Owner

Stop wasting our time.

@paulmillr

node core devs cannot into jokes?

@mceachen

"Wasting it with AWESOMENESS" - maccaw

@mjackson

Wha?! Do you realize how much time it took me to port the entire stdlib of node to CoffeeScript? It was so awesome!

@thejh

@mjijackson Sure you didn't use js2coffee? ;)

@sayrer

15 896 / 6 501 = 2.44516228

I think you need to close this pull request 1.44516228 more times in order to maintain your current level of efficiency.

@jfhbrook

Worthiness of troll attempt aside, I do find the differences in line counts interesting.

@andrew12

Wow, this didn't last long at all.

@chjj

How long until this is posted on hacker news I wonder.

@thejh

@jesusabdullah Char count would probably say more.

@isaacs
Owner

@mjijackson Sorry, I have to agree with @pquerna. Not a very well executed troll.

You're too well known of a noder (and not well-known as a crazy idiot), so it's obvious this is a joke. Too obvious to be funny, I'm afraid. It would have been better to start a new github account to do this from, get denied with no explanation, then have Hacker News blow up in flames over how much paul hates open source contributions, and node isn't community-friendly.

@jfhbrook

@thejh probably.

If nothing else, this is definitely an interesting node/coffee case study, at least assuming he coffeescript is relatively idiomatic and not bizarro-generated.

@thejh

Hmm, 193440 chars coffee vs 433111 chars JS. And if he had used more cool syntax, it'd probably be even less chars.

Well, code length isn't everything, but I think this does say something.

@mmalecki

@isaacs has a point here.
/me goes to create a new account

@thejh

/me thinks js2coffee needs to become better

Also, we need js2coco.

@masylum

My eyes are bleeding! hi hi :)

@thejh

Actually, maybe I can do js2coco...

@partheseas

Regardless of how well known he is, I still thought it was funny~

@jfhbrook

Regardless of how well known he is, I still thought it was funny~

The real problem is that FTFY coffeescript ports have become passe.

@sayrer

Someone will actually do this now, by hand. I wonder how much shorter the code will be.

@edwardhotchkiss

Reopen (You don't have permission to reopen this issue)

@asparagui

chilj: 42 minutes :3

@sayrer

eh, who cares

@michaelficarra

@limeblack: you can make ridiculous looking examples like that in any language. In fact, Jeremy just made one in JS a few minutes ago (no idea why). And they get much, much worse. A convincing argument would be showing something that looks innocent and straightforward, and showing how the compilation differs from what you'd expect. That is a sign of a flawed language. Not saying that CoffeeScript has no flaws, but that your example was not a good one. The CS flaws can be seen in the ~200 issues we have open right now.

edited a little

@talltyler

Last time I checked js2coffee strips out comments. When you take this into account and that you wont have ending curly braces the line count isn't really impressive.

@limeblack

@michaelficarra

CofeeScript in a simple way

Which of the three Javascript examples does the following generate?

foo -> bar 'foo', -> 'bar'

The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter.

CoffeeScript doesn't have an ending delimiter which increases ambiguity.

Although CoffeeScript functions certainly could be wrapped in paranthesis for clarity, the intended function creation could have been a lot simpler with an ending delimiter.

I'm not against white space significant languages with missing ending delimiters for functionn. In fact Python is great. Python just doesn't have multiline anonymous functions.

Considering having single line anonymous functions isn't an option, having an ending delimiter would be ideal.

Editted added last sentence

@3rd-Eden

Omg, coffeescript

fapfapfap

Anyways

@jesusabdullah that because they have removed all the comments + line breaks. It's not that impressive.

@jfhbrook

Not that I condone js vs. cs flame wars, but:

I'm not against white space significant languages with missing ending delimiters for function. In fact Python is great. Python just doesn't have multiline anonymous functions.

I've actually researched the reason for this, and the answer as far as I can tell really does boil down to this exactly. Basically, Guido foresaw these ambiguities and decided it was too gross-looking to implement. This later came to be described with the answer, "Multi-line lambdas aren't pythonic."

That said, I'm not sure that this decision really was the lesser of two evils. This is one thing that makes studying CS interesting.

@jfhbrook

@jesusabdullah that because they have removed all the comments + line breaks. It's not that impressive.

The count is lines total then, not sloc? I guess that makes sense given the context of version control (versus making these sorts of comparisons).

If the coffeescript was more or less the same length as the original javascript I'm not sure I'd find it less interesting. In fact, this sounds like an easy way to measure large-scale differences in coffeescript. If the overall sloc for both ends up being comparable then it could be a strong indicator that coffeescript and javascript themselves are more similar than people may think. Likewise for a very different line count. Of course, this is just one of many dimensions but it's an easy one to deal with.

An idea to make this a more fair comparison: Convert the new coffeescript back to js and see what happens, . I wonder if they reach an equilibrium in the same way human language translations do.

I digress.

@wookiehangover

MICHAEL JACKSON, A MILLION DOLLARS

ya hear, me. holla

@base698

Hilarity

@balupton

@limeblack what a terrible example... You can have ambiguity in any language, and in any language the coder should avoid ambiguity. Just because you can write terrible ambiguous code in coffee-script (just like any other language), doesn't mean you should or it should be condoned. The great thing in coffeescript vd javascript is that sometimes not using parenthesis is cleaner, and sometimes it isn't - but coffeescript allows the coder to make a decision on that, where JavaScript doesn't.

In short, your example was like complaining knives can kill people, so knives are shit, and that everyone should always use spoons for everything.

@dachev

-(∞*100)

@joshkehn

@balupton You're forgetting that knives have a purpose as a utensile. CoffeeScript is to JavaScript as a dull knife wrapped in bubble wrap is to a knife.

@limeblack That example was awesome.

@partheseas

@joshkehn How so?

CoffeeScript has a purpose as a language. To be written faster, read better, and look prettier with fewer symbols getting in the way of real words that people understand.

@joshkehn

@tylermwashburn I disagree that a language should be designed to “look pretty”. I also disagree that people can only understand “real words” and that “symbols get in the way.” !true reads better (and is written faster) then not true.

It's all a matter of preference I guess. Looking at the number of packages written in CS vs JavaScript I'm not worried about being overrun by CS code at any point in the near future.

@partheseas

@joshkehn I think designing a "pretty" language is a great idea. I'm ocd, so the clean appearance is pleasing to me. Some (read "a lot of") people probably (read "do") prefer the extra symbols though.

I'm not saying that only real words are understandable, but personally I can comprehend the meaning of not true faster than !true. It's just how my brain is wired. And even though it's longer, for some it can still be typed faster than the JS alternative. It's another one of those things that depends on the person though.

You can also pull off a lot of valid English in CoffeeScript, which I like. Such as..

gossip is not true

..or in JS..

gossip === !true
@tj
tj commented

why would you write gossip === !true haha.. !gossip?

@chjj

This is what my language will look like:

if (gossip is not true, seriously, it's not, i promise)
@alejandro

Big Fail! gossip === !true really?
Edit: Oh @visionmedia is faster than me...

@NuckChorris

@chjj I will require proper capitalization in my language, as well as proper punctuation.

If the variable entitled "gossip" is not true, then...

In addition, any mistakes and it rm -rf's your hard drive.

@mikeal

you guys do all realize that when you comment on this thread, the terrorists win :)

@3rd-Eden

@mikeal We are only replying so we can send annoying e-mails to everybody who replied in this pull request.

trololol

@disolovyov

In addition, any mistakes and it rm -rf's your hard drive.

Haskell was close.

@bravedick

BRAINFUCK! BRAINFUCK PLS PLS PLS!

@trodrigues

I don't see any reason as to why Node.js shouldn't be rewritten in Malbolge. It's the only language that makes sense.

@haihappen

@joshkehn: I disagree that a language should be designed to “look pretty”.

Yeah, Lisp is so much better to read than Ruby!

@NuckChorris

@trodrigues How about Lua— oh wait...

@graphnode

+√-1

About lua... something like Love2d in node.js would be awesome.

@Mulemister

These coffeescript flamewars/jokes are ludicrous and are becoming a real turn off in the land of javascript.

@dachev

@antrover nailed it

@felipecsl

Port entire node.js std lib to coffeescript?

@hlee

+1

@rmoriz

node is dead anyway. Dart ftw.

@joshkehn

@tylermwashburn I don't see how gossip === !true is cleaner then !gossip.

Here is a great one. gossip is weakly true translates to gossip === weakly(true). How do you like this no-symbol syntax?

@davej

@visionmedia @alejandromg Technically gossip === !true is not the same as !gossip, the first uses the identity operator and the second implicitly uses the equality operator (thus no type conversion is performed). They will produce different truthiness values when gossip is an empty string for example.

@tj
tj commented

@davej in context... that's like people using typeof === 'foo' when it's always a string, you just have to actually use your mind

@davej

@visionmedia Sure, I was just pointing out that they are not the same thing and there are instances where !gossip wouldn't be what you want. Personally, I think it's easier just to get into the habit of using === or !== all the time because it's more explicit and less likely to introduce bugs.

@tj
tj commented

I think I wouldn't want to use someone's software if they didn't know how to decide between == and ===

@otakustay

I love coffee, but one question, why is buffer.coffee EMPTY?

@derdesign

js → coffee → back to js, heh

@sandro-pasquali

@davej @visionmedia It's a debate similar to the CS/JS one. Is it better to subsidize the original developer by spending the code maintenance time of future developers, or is it better to spread the cost evenly?

CS wants to gain followers, so promotion of the former benefits make more sense.
JS has a much larger presence in large scale application development (where the costs of maintenance are much more important -- debugging tools/ease, staffing availability, standardized coding conventions, consistent interfaces, actual financial cost...many more), so ignoring those costs rings hollow.

@davej

@visionmedia It's not about knowing how to decide between == and ===, it's about saving yourself (and people reading your code) the hassle when === will do what you want. Sure, you can do a few little tricks when you know that null == undefined and 0 == '' but why bother, you're just making your code less understandable for the sake of a few characters.

@gf3
gf3 commented

@NuckChorris You just reinvented AppleScript.

@zachstronaut

Learn JavaScript.

@partheseas

Guys, holy fuck. I know how to program. I know !gossip is shorter/cleaner/whatever.

It was an example.

@jswartwood

In JS !gossip === shorter/cleaner/whatever

@sirwan

Coffee script is why programmers are disliked amongst our inter-disciplinary colleagues.

@sandywu

-1

@contra

9/10 A- would troll again!

@crux

-1 no need for code hipsters fad

@iwege

-1

@xxoo

awesome post

@rmoriz

does anyone remember PHP? they argued about backslashes as namespace separators. Bloody amateurs.

@eos87

DRY!

-1

@canweriotnow

This is almost as funny as that time @dhh switched Rails over to CoffeeScript by default.... only he wasn't trolling.

@Denommus

@mjijackson I think that if you're not trolling and are being serious about that, you have all the liberty of forking node and make your own project in CoffeScript based on it.

@tj
tj commented

@Denommus it's a troll

@chjj

I still think we should have waited til april fools for this. I was disappointed when I saw it in january.

@billymoon

js2Coffee (and back)

square = (x) -> x * x
var square;

square = function(x) {
  return x * x;
};
square = undefined
square = (x) ->
  x * x
var square;

square = void 0;

square = function(x) {
  return x * x;
};

etc...

@renfredxh renfredxh referenced this pull request in mehulkar/github-hall-of-fame
Merged

Add Node's "Use CoffeeScript" PR #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2012
  1. Michael Jackson

    Use CoffeeScript!

    mjackson authored
    Come on guys. Time to upgrade.
Something went wrong with that request. Please try again.