Skip to content
This repository

Use CoffeeScript! #2472

Closed
wants to merge 1 commit into from
 +6,501 15,896
Michael Jackson

Come on guys. Time to upgrade.

Michael Jackson Use CoffeeScript!
Come on guys. Time to upgrade.
8662e09
Jann Horn

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

Maciej Małecki

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

Matthew McEachen

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

Alex MacCaw

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

Katsuya Noguchi
kn commented January 05, 2012

Nice!

Alexandru Vlăduţu

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

Ryan Tenney

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

Paul Miller

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

Jann Horn

You should use is instead of == where possible.

Christopher Jeffrey

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

TJ Holowaychuk

nom nom

Jann Horn

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

Paul Querna pquerna closed this January 05, 2012
Paul Querna
Collaborator

Stop wasting our time.

Paul Miller

node core devs cannot into jokes?

Matthew McEachen

"Wasting it with AWESOMENESS" - maccaw

Michael Jackson

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

Jann Horn

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

Rob Sayre

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.

Joshua Holbrook

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

Andrew Herbig

Wow, this didn't last long at all.

Christopher Jeffrey

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

Jann Horn

@jesusabdullah Char count would probably say more.

Isaac Z. Schlueter
Collaborator

@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.

Joshua Holbrook

@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.

Jann Horn

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.

Maciej Małecki

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

Jann Horn

/me thinks js2coffee needs to become better

Also, we need js2coco.

Pau Ramon Revilla

My eyes are bleeding! hi hi :)

Jann Horn

Actually, maybe I can do js2coco...

Tyler Washburn

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

Joshua Holbrook

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

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

Rob Sayre

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

Edward Hotchkiss

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

Brett Koonce

chilj: 42 minutes :3

Rob Sayre

eh, who cares

Michael Ficarra

@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

Tyler Larson

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.

Liam R. Black

@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

Arnout Kazemier

Omg, coffeescript

fapfapfap

Anyways

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

Joshua Holbrook

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.

Joshua Holbrook

@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.

Sam Breed

MICHAEL JACKSON, A MILLION DOLLARS

ya hear, me. holla

Justin Thomas

Hilarity

Benjamin Arthur Lupton

@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.

Blagovest Dachev

-(∞*100)

Joshua Kehn

@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.

Tyler Washburn

@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.

Joshua Kehn

@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.

Tyler Washburn

@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 Holowaychuk

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

Christopher Jeffrey

This is what my language will look like:

if (gossip is not true, seriously, it's not, i promise)
Alejandro Morales

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

Peter Lejeck

@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 Rogers

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

Arnout Kazemier

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

trololol

Dimitry Solovyov

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

Haskell was close.

Brave Dick

BRAINFUCK! BRAINFUCK PLS PLS PLS!

Tiago Rodrigues

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.

Mario Uher

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

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

Peter Lejeck

@trodrigues How about Lua— oh wait...

Diogo Gomes

+√-1

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

Dave

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

Blagovest Dachev

@antrover nailed it

Felipe Lima

Port entire node.js std lib to coffeescript?

Ken

+1

Roland Moriz

node is dead anyway. Dart ftw.

Joshua Kehn

@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?

Dave Jeffery

@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 Holowaychuk

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

Dave Jeffery

@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 Holowaychuk

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

Gray Zhang

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.

Dave Jeffery

@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.

Gianni Chiappetta
gf3 commented January 06, 2012

@NuckChorris You just reinvented AppleScript.

Zachary Johnson

Learn JavaScript.

Tyler Washburn

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

It was an example.

Jacob Swartwood

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

Sirwan Qutbi

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

Sandy

-1

Eric Schoffstall

9/10 A- would troll again!

crux

-1 no need for code hipsters fad

William Ge

-1

xiao

awesome post

Roland Moriz

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

Helmy Giacoman

DRY!

-1

Jason Lewis

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

Yuri Albuquerque

@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 Holowaychuk

@Denommus it's a troll

Christopher Jeffrey
chjj commented July 27, 2012

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

Billy Moon

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 05, 2012
Michael Jackson Use CoffeeScript!
Come on guys. Time to upgrade.
8662e09
Something went wrong with that request. Please try again.