# Is it better for Discourse to use JavaScript or CoffeeScript?

**URL:** https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153
**Category:** Development
**Created:** [2013年二月15日 13:34 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153 "2013-02-15T13:34:20Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2013年二月16日 01:07 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/22 "2013-02-16T01:07:07Z")

</div>

> [@eviltrout](#):
>
> hybrid of Ruby/C because gems we use have FFI

I guess, but less of a hybrid, if every single time I debugged Ruby I had to run GDB and constantly found myself reading C source I think it would be closer. If every time I wrote I line of Ruby I had to construct a mental model of the way MRI is going to translate the thing to C (for example because I need to know its going to wrap up my switch statements in a closure or what have you), we would be a more of a hybrid system.

> [@danneu](#):
>
> that it ostensibly outweighs the benefits that non-hypothetical, real-life Discourse contributors experience while maintaining a Coffeescript codebase

Well, we have seen almost no contributions from the community wrt refactoring our js and we are a HUGE js app. In contrast we have seen massive amounts of refactoring around the Ruby side of things. Impossible for me to pin this on CS as I have no crystal ball, but it is a fact.

On a personal level I would be happy to never use CS again, I feel my hands are tied in weird ways and it encourages me to write stuff that I probably would never have written in the first place (like 4 levels of nested functions)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2013年二月16日 01:27 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/23 "2013-02-16T01:27:37Z")

</div>

It seems like the people have spoken.

I’m convinced! I am on board to convert the coffee to regular JS, assuming of course we set up jshint as part of our testing system.

---

<div class="post-metadata">

### Author: ![wagenet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wagenet/32/103878_2.png) [@wagenet](https://meta.discourse.org/u/wagenet)
#### Post date: [2013年二月16日 05:30 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/24 "2013-02-16T05:30:56Z")

</div>

This seems like a sound decision. If you want any help with setting up automated jshinting, let me know.

---

<div class="post-metadata">

### Author: ![ryanflorence](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryanflorence/32/103879_2.png) [@ryanflorence](https://meta.discourse.org/u/ryanflorence)
#### Post date: [2013年二月16日 06:20 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/25 "2013-02-16T06:20:44Z")

</div>

Wise choice @eviltrout.

I prefer CoffeeScript, personally, its the only language I write in that I don’t think about the language.

However, Discourse is going to (hopefully) be around for a very long time. There are so many things that are going to be difficult for CoffeeScript in the future. For example, default arguments. `null` in CoffeeScript will defer to the default while in ES6 it will not because `null !== undefined`. I can’t see how it will target ES6 successfully and keep backwards compat.

Worth noting, CoffeeScript fell off the top 10 list on github. CoffeeScripters _usually_ still like and write JavaScript, including the language’s creator. Discourse will get more contributors with JavaScript without question.

Better create a style guide first.

---

<div class="post-metadata">

### Author: ![nXqd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nxqd/32/114262_2.png) [@nXqd](https://meta.discourse.org/u/nXqd)
#### Post date: [2013年二月16日 16:01 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/26 "2013-02-16T16:01:27Z")

</div>

I prefer jS since it’s better to write in JS since the it will take a bit of time for another contributor to convert the current “Getting Started Guide” or “Tutorial” from Ember and another lib written in JS to coffeescript.

---

<div class="post-metadata">

### Author: ![danneu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danneu/32/102640_2.png) [@danneu](https://meta.discourse.org/u/danneu)
#### Post date: [2013年二月16日 16:36 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/27 "2013-02-16T16:36:30Z")

</div>

I feel you.

Javascript skills in general are already hard to find.

And since Ember devs are a fractional subset of that, It’s hard enough to find Ember devs that can contribute, JS or CS.

We had this similar discussion at work, but it’s obviously a lot different when you’re hiring people than leaning on open contributions.

---

<div class="post-metadata">

### Author: ![mikl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikl/32/103909_2.png) [@mikl](https://meta.discourse.org/u/mikl)
#### Post date: [2013年二月17日 13:27 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/28 "2013-02-17T13:27:34Z")

</div>

Thank you, @eviltrout, that makes me a lot more confident in Discourse’s future. Lowering the bar for contributors is a good thing ☀

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2013年二月17日 23:50 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/29 "2013-02-17T23:50:38Z")

</div>

Help, a PR or anything in this area would be much appreciated !

---

<div class="post-metadata">

### Author: ![wagenet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wagenet/32/103878_2.png) [@wagenet](https://meta.discourse.org/u/wagenet)
#### Post date: [2013年二月17日 23:56 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/30 "2013-02-17T23:56:57Z")

</div>

Not sure how quickly I could get a PR out, but if you want to ping me directly I can at least try to point you in the right direction.

---

<div class="post-metadata">

### Author: ![benaiah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benaiah/32/102387_2.png) [@benaiah](https://meta.discourse.org/u/benaiah)
#### Post date: [2013年二月19日 21:51 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/31 "2013-02-19T21:51:32Z")

</div>

> [@Superuser](#):
>
> CoffeeScript has significant whitespace.
> 
> So instant no. It makes it a pain in the butt to parse.

First, _whitespace itself_ is not significant in CoffeeScript, any more than it is in Javascript (where it separates tokens, as in virtually every other language). Whitespace is not significant in Python either - indentation level is. See [Python: Myths about Indentation](http://www.secnetix.de/olli/Python/block_indentation.hawk). Coffeescript works the same way.

Second, significant indentation is not actually hard to parse. On the contrary, it’s very simple - I refer you [back to the above article](http://www.secnetix.de/olli/Python/block_indentation.hawk). Essentially, the parser simply parses the difference in indentation as and tokens, modifying the level accordingly. While this might be slightly more difficult to parse than bracket-based blocks, it is hardly a “pain in the butt” to parse.

There are several things significant indentation _does_ make harder:

- Parsing with regexes. Which you should never do in the first place.
- Mixing tabs and spaces. Which you should never do in the first place.

> [@Superuser](#):
>
> Most people (except for Python developers) don’t like it.

This is completely subjective (and I suspect it’s probably not true).

> [@Superuser](#):
>
> Not to mention the problems of re-indenting everything when you have really long and ugly blocks you want to clean up (happens).

… which is much easier than balancing brackets, because it’s obvious at a glance. You already have to reindent when you write code in a bracket language. Now you just don’t have to balance the brackets.

> [@Superuser](#):
>
> Stick with JS. More people are experienced with JavaScript afterall [sic] and critical mass in attracting developers is important for Discourse.

This is the real reason Discourse should use Javascript. Don’t get me wrong - I do prefer Coffeescript, I just think Javascript is more appropriate for the official Discourse client.

---

<div class="post-metadata">

### Author: ![Jeremy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremy/32/130166_2.png) [@Jeremy](https://meta.discourse.org/u/Jeremy)
#### Post date: [2013年二月19日 22:03 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/32 "2013-02-19T22:03:15Z")

</div>

> [@benaiah](#):
>
> First, whitespace itself is not significant in CoffeeScript, any more than it is in Javascript (where it separates tokens, as in virtually every other language). Whitespace is not significant in Python either - indentation level is. See Python: Myths about Indentation. Coffeescript works the same way.

I disagree that indentation-sensitivity is not a type of whitespace-sensitivity, but even if that applies to Python it does not apply to CoffeeScript. CoffeeScript is more whitespace-sensitive than Python. Compare:

```
jQuery ($) -> bar

```

```
jQuery(function($) {
  return bar;
});

```

with:

```
jQuery($) -> bar

```

```
jQuery($)(function() {
  return bar;
});

```

It also doesn’t enforce consistent indentation in the same way as Python, allowing for silly cases like this:

```
[
  1
  ->
  2
  ->
  3
 ->
  4
  ->
  5
  ->
  6
]

```

Instead of causing a compile error, the mis-aligned `->` alters how the indentation of subsequent lines is interpreted.

```
[
  1, function() {}, 2, function() {}, 3, function() {
    4;
    (function() {});
    5;

    (function() {});
    return 6;
  }
];

```

I followed the CoffeeScript project on GitHub for a while, and my impression is that there are tons of edge cases in the compiler whose behaviour is poorly defined, varies&nbsp;between versions and may be difficult to replicate without a direct port. Part of the goal of the CoffeeScript 2.0 project was to define the grammar more rigorously, but I don’t know the status of that project.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2013年二月19日 22:26 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/33 "2013-02-19T22:26:39Z")

</div>

Some of my pet annoyances

```coffeescript
foo = bar ->
  ""

```

```javascript
var foo;

foo = bar(function() {
  return "";
});

```

* * *

```coffeescript
foo = bar->
  ""

```

no compily

* * *

```coffeescript
foo=(bar)->
  ""

```

```javascript
var foo;

foo = function(bar) {
  return "";
};

```

---

<div class="post-metadata">

### Author: ![jcolebrand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jcolebrand/32/102616_2.png) [@jcolebrand](https://meta.discourse.org/u/jcolebrand)
#### Post date: [2013年二月19日 22:30 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/34 "2013-02-19T22:30:11Z")

</div>

I concur with this if for no other reason than I use OTBS and the indentation is far more important to me than the closing brace. The closing brace is at best a handy visual aid to ensure I’m at the end of the intended logic branch, but only because braces are required.

On the flip side, braces allow me to use inline stubs for things like encapsulating API methods or throwing exceptions where code has not yet been implemented.

---

<div class="post-metadata">

### Author: ![alexspeller](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexspeller/32/104113_2.png) [@alexspeller](https://meta.discourse.org/u/alexspeller)
#### Post date: [2013年二月23日 02:30 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/35 "2013-02-23T02:30:05Z")

</div>

Perhaps I’m unique, it certainly seems so from reading the posts above, however I’d like to add that I’m much less likely to contribute to a project written in javascript than in coffeescript, and I also happen to be someone with the exact skillset necessary to contribute (rails/ember/coffee).

Does it come down to taste? I guess that ultimately it does, however I find that after working with coffeescript for so long writing, pure js just feels incredibly annoying, slow and unwieldy.

It certainly seems like I’m in the minority, however I don’t find that to be unusual when talking about coffeescript!

---

<div class="post-metadata">

### Author: ![rictic](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rictic/32/104121_2.png) [@rictic](https://meta.discourse.org/u/rictic)
#### Post date: [2013年二月23日 02:58 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/36 "2013-02-23T02:58:06Z")

</div>

Typescript is totally not windows only. It’s vanilla node.js code and runs anywhere.

---

<div class="post-metadata">

### Author: ![SkinnyGeek1010](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skinnygeek1010/32/104119_2.png) [@SkinnyGeek1010](https://meta.discourse.org/u/SkinnyGeek1010)
#### Post date: [2013年二月23日 03:01 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/37 "2013-02-23T03:01:08Z")

</div>

What if you would convert each module/script to vanilla as it’s modified? This would gradually convert everything over to JS as time permits. A solid style guide would be a must though!

> [@alexspeller](#):
>
> … Does it come down to taste? I guess that ultimately it does, however I find that after working with coffeescript for so long writing, pure js just feels incredibly annoying, slow and unwieldy.

I find that you can tab-trigger your way out of the ‘vanilla’ JS is more typing problem. You can have presets setup for almost everything… methods, functions, anon callbacks, AMD modules, etc…

One advantage that CS has is that it’s more readable _if_ you work with CS a lot. However, I found it hard to parse blocks when I first started writing it ( I mainly use it for tests currently).

---

<div class="post-metadata">

### Author: ![chadical](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chadical/32/104130_2.png) [@chadical](https://meta.discourse.org/u/chadical)
#### Post date: [2013年二月23日 04:21 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/38 "2013-02-23T04:21:50Z")

</div>

From a personal perspective, the only reason I would contribute to discourse is because the client base is coffee script. JavaScript… All the amazing innovations in tech… JavaScript? Kids don’t like it, and I’d put 50 bucks that JavaScript is the mainframe tech stack of the next generation(to be replaced). 5 years from now your coffee script can be compiled into JavaScript’s replacement. Discourse is awesome BECAUSE coffescript was used and enables creativity to trump syntax. Switching to JS might just send you “off course”.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2013年二月23日 05:04 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/39 "2013-02-23T05:04:49Z")

</div>

> [@chadical](#):
>
> the only reason I would contribute to discourse is because the client base is coffee script.

I would hope you would like to contribute to the project because you believe in the mission, like the software and want to evolve and improve online Discourse, not purely because we chose js or cs.

---

<div class="post-metadata">

### Author: ![nathanl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathanl/32/104157_2.png) [@nathanl](https://meta.discourse.org/u/nathanl)
#### Post date: [2013年二月23日 10:13 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/41 "2013-02-23T10:13:14Z")

</div>

> 5 years from now your coffee script can be compiled into JavaScript’s  
> replacement.

Javascript has been running in browsers for 18 years. It’s been adopted by every browser on every platform.

It’s possible that in 5 years, an alternative language will be supported by some browsers (and that would be nice). But it’s near-certain that Javascript will still be supported by all browsers. It has too much inertia to disappear that fast.

---

<div class="post-metadata">

### Author: ![chadical](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chadical/32/104130_2.png) [@chadical](https://meta.discourse.org/u/chadical)
#### Post date: [2013年二月23日 19:13 UTC](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153/42 "2013-02-23T19:13:27Z")

</div>

I agree with you on your point. To clarify: It’s not that I would only contribute to CS projects, it is that I’m not a JavaScript guru (I’m more of a devops/data warehouse/automation creature). I see CS as a tool that enables others to create clean & functional JS, is easier to read (opinion), and would provide an easier entry for me as a contributor.

Though come to think of it, it seems there are other barriers to contributing to open source other than the language itself. Contribution processes, Git pull requests, anxiety around being publicly chastised for janky pull requests, etc. 😄

How about streamlining the contribution process? Seems like there could be an opportunity here for some interesting open source development as well… a “GitHub” like service that manages contributions, integrates with github(others), and makes the contribution process more welcoming for developers who may be coming from varied backgrounds.

[上一頁](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153.md?page=1)

[下一頁](https://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153.md?page=3)
