Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20754 > unrolled thread

I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples

Started byMark Watson <mark.watson@gmail.com>
First post2013-07-20 09:25 -0700
Last post2013-07-20 16:02 -0700
Articles 6 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples Mark Watson <mark.watson@gmail.com> - 2013-07-20 09:25 -0700
    Re: I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples Stefan Weiss <krewecherl@gmail.com> - 2013-07-20 19:48 +0200
    Re: I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples Scott Sauyet <scott@sauyet.com> - 2013-07-20 18:21 +0000
    Re: I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-07-20 14:56 -0700
      Re: I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples Stefan Weiss <krewecherl@gmail.com> - 2013-07-21 00:50 +0200
        Re: I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-07-20 16:02 -0700

#20754 — I am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples

FromMark Watson <mark.watson@gmail.com>
Date2013-07-20 09:25 -0700
SubjectI am writing a new book on Artificial Intelligence: trying to decide between Coffeescript and Javascript for examples
Message-ID<38b6a684-466b-42b7-a1b9-369cbe41daa9@googlegroups.com>
In the last 20 years I have written a wide variety of books on AI, using Common Lisp, Scheme, and Java for the examples. Mostly because I have been enjoying client side development with both Meteor and Ember.js lately, I am thinking seriously of using Javascript for the examples for my new book project.

I have much less experience with Coffeescript, but it really does seem like a nice little language. (I have worked a lot with Clojurescript which also compiles to Javascript.)

My question: would having the examples in Coffeescript put off Javascript programmers from wanting to read my new book project? And, vice-versa: would Coffeescript developers not like the book if I use Javascript for the examples?

I am also thinking of using Coffeescript, and for each example taking the generated Javascript and manually editing it and cleaning it up, so the examples would be available in both languages - that seems like a hassle, but worthwhile if that is what people want.

Any advice will be appreciated!

[toc] | [next] | [standalone]


#20762

FromStefan Weiss <krewecherl@gmail.com>
Date2013-07-20 19:48 +0200
Message-ID<kseii0$frv$1@news.albasani.net>
In reply to#20754
On 2013-07-20 18:25, Mark Watson wrote:
> [Meteor, Ember.js, CoffeeScript, ClojureScript]

Dozens of platforms, frameworks, meta-languages and other productivity
enhancements for JavaScript-based applications are released every week.
Some of the ones you mentioned are (IMHO) too new/immature to be useful
in book examples. Time will tell if they're here to stay or just passing
fads.

That said, CoffeScript has been well established and stable for many
years, and many serious JS developers will have had some contact with it
by now.

> I have much less experience with Coffeescript, but it really does
> seem like a nice little language.
> 
> My question: would having the examples in Coffeescript put off
> Javascript programmers from wanting to read my new book project? And,
> vice-versa: would Coffeescript developers not like the book if I use
> Javascript for the examples?

I know some JavaScript developers who won't look at a book or project if
it uses a meta language like CoffeeScript. On the other hand, I would
imagine that most CoffeeScript users are also more or less familiar with
JavaScript.
CoffeeScript enthusiasts would be excited to see the examples in their
preferred language, but everybody else would have to learn new syntactic
rules and install the associated tools.

What it comes down to: do you want to make your book accessible to as
many people as possible, or do you want your examples to look pretty (by
using a less common "nice little language" like CoffeScript)?

If the main focus of the book is the AI topic, then the language used in
the examples is secondary - CoffeeScript or even pseudo code would be
fine. But if you want your readers to be able to quickly understand and
experiment with the examples, then JavaScript would be my first choice.

> I am also thinking of using Coffeescript, and for each example
> taking the generated Javascript and manually editing it and cleaning it
> up, so the examples would be available in both languages - that seems like a
> hassle, but worthwhile if that is what people want.

That doesn't sound like a terribly good idea. Double the code to
maintain, for very little benefit. Maybe you should ask in a
CoffeeScript forum if anybody there would be interested in AI books even
if the examples are in plain old JS.


- stefan

[toc] | [prev] | [next] | [standalone]


#20766

FromScott Sauyet <scott@sauyet.com>
Date2013-07-20 18:21 +0000
Message-ID<XnsA2039310FDE44scottsauyetcom@78.46.70.116>
In reply to#20754
Mark Watson wrote: 

> In the last 20 years I have written a wide variety of books on AI,
> using Common Lisp, Scheme, and Java for the examples. Mostly because I
> have been enjoying client side development with both Meteor and
> Ember.js lately, I am thinking seriously of using Javascript for the
> examples for my new book project. 
> 
> I have much less experience with Coffeescript, but it really does seem
> like a nice little language. (I have worked a lot with Clojurescript
> which also compiles to Javascript.) 
> 
> My question: would having the examples in Coffeescript put off
> Javascript programmers from wanting to read my new book project? 

This is quite possible.  Many Javascript programmers do not know 
Coffeescript, and among those who do, some would be turned off by it.


> And, vice-versa: would Coffeescript developers not like the book if 
> I use Javascript for the examples? 

This seems less likely.  They might sneer a bit, shake their heads over 
your pedestrian ways, but they will understand it and recognize that 
you're aiming at the wider audience.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#20768

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2013-07-20 14:56 -0700
Message-ID<509e1c2d-9449-4fd4-a69b-ac8aab40d5c1@googlegroups.com>
In reply to#20754
On Saturday, July 20, 2013 11:25:21 AM UTC-5, Mark Watson wrote:
> In the last 20 years I have written a wide variety of books on AI, using Common Lisp, Scheme, and Java for the examples. Mostly because I have been enjoying client side development with both Meteor and Ember.js lately, I am thinking seriously of using Javascript for the examples for my new book project.

s/Javascript/JavaScript/g

 
> I have much less experience with Coffeescript, but it really does seem like a nice little language. (I have worked a lot with Clojurescript which also compiles to Javascript.)

Except that the grammar is ambiguous/confused.

CoffeeScript
doSomething = () -> true
doSomething () ->  false
doSomething() ->  false

compiles to:

doSomething = function() {
  return true;
};

doSomething(function() {
  return false;
});

doSomething()(function() {
  return false;
});

where in the first place you could have used arrow functions in JavaScript:
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/arrow_functions>



> My question: would having the examples in Coffeescript put off Javascript programmers from wanting to read my new book project? And, vice-versa: would Coffeescript developers not like the book if I use Javascript for the examples?

If you are aiming for beginners or intermediate developers I think it's irrelevant. If you want your book to have relevant examples for a longer period of time and to appeal to a wider audience I'd focus on a JavaScript flavor. The syntax isn't as verbose as you'd think if you use a modern version of it (Mozilla's JavaScript for example 1.8+). 


> I am also thinking of using Coffeescript, and for each example taking the generated Javascript and manually editing it and cleaning it up, so the examples would be available in both languages - that seems like a hassle, but worthwhile if that is what people want.

One language only is my suggestion

[toc] | [prev] | [next] | [standalone]


#20769

FromStefan Weiss <krewecherl@gmail.com>
Date2013-07-21 00:50 +0200
Message-ID<ksf46s$iiu$1@news.albasani.net>
In reply to#20768
On 2013-07-20 23:56, Michael Haufe (TNO) wrote:
> Except that the grammar is ambiguous/confused.
> 
> CoffeeScript
> doSomething = () -> true
> doSomething () ->  false
> doSomething() ->  false
> 
> compiles to:
> 
> doSomething = function() {
>   return true;
> };
> 
> doSomething(function() {
>   return false;
> });
> 
> doSomething()(function() {
>   return false;
> });

Yes, white space is significant in CoffeScript: "fun()" and "fun ()" are
not the same thing. Similar errors have bitten me a couple of times when
I was experimenting with it. Debugging CoffeeScript turned out to be a
major pain, which is why I ultimately decided to stick to standard JS.
It's not *that* ugly :)

> where in the first place you could have used arrow functions in JavaScript:
> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/arrow_functions>

My memory may be playing tricks on me, but I think that idea came from
CoffeeScript and was adopted in Harmony, not the other way round.


- stefan


PS: Having mentioned "standard JS", I'd better go and put on a helmet
and some flame retardant protective gear. Just in case.

[toc] | [prev] | [next] | [standalone]


#20771

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2013-07-20 16:02 -0700
Message-ID<27aa94b0-5d9a-4b3a-84a7-532628e56a28@googlegroups.com>
In reply to#20769
On Saturday, July 20, 2013 5:50:03 PM UTC-5, Stefan Weiss wrote:
> On 2013-07-20 23:56, Michael Haufe (TNO) wrote:
> [...]
> > where in the first place you could have used arrow functions in JavaScript:
> > <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/arrow_functions>

> My memory may be playing tricks on me, but I think that idea came from
> CoffeeScript and was adopted in Harmony, not the other way round.

A lambda style expression was wanted for a long time. I was initially pushing for a let-expression style syntax (2008?), some others were pushing for (ruby|smalltalk)-block style, others for a unicode lambda or florin symbol, and others for the C# arrow syntax... CoffeeScript was a late comer had no impact on the desire, just a minor influence on the final syntax. I think falling into the current C# style syntax was by coincidence. 


> PS: Having mentioned "standard JS", I'd better go and put on a helmet
> and some flame retardant protective gear. Just in case.

One could argue it is standard by some combination of de-facto and de-jure I guess

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web