Page 1 of 2

CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 02:21
by Duha
Hi,
CoffeeScript documentation wrote: CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript runtime, and tends to run as fast or faster than the equivalent handwritten JavaScript.
http://jashkenas.github.com/coffee-script/


And some words from me:
+
it has good syntax. (to do same thing you need less code)
code is more readable.
code is more valid (you will never forget about var. You cant shoot you legs by using global variable in cycles)

-
You need to learn it. (I have experience in languages which influenced it syntax, I just read docks and start writing.)
Debugging is not good.

Here just two files in js and coffeescript for example:
coffescript
javascript

At current time there is no good way to load coffeescript directy in the game. But it is easy to add. To convert coffescript to javascript you just need js file.

Code: Select all

include('multiplay/skirmish/coffee-script.js')
CoffeeScript.eval('console "It works!"')

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 03:28
by aubergine
Been there, done that, ran away screaming. After trying it for about 2 months, my reaction was that it didn't make code any easier to read or write, and it certainly didn't speed stuff up because lots of the more modern JS compiler optimisations don't get applied.

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 10:34
by Duha
aubergine wrote:Been there, done that, ran away screaming. After trying it for about 2 months, my reaction was that it didn't make code any easier to read or write
20 lines instead 10 is harder read and write?
You like brace-counting?
and it certainly didn't speed stuff up because lots of the more modern JS compiler optimisations don't get applied.
Propably you are only one here who knows about "modern JS compilers".
Coffee script converts to pure javascript. Why optimization does not work?

PS. I am coding python and ruby and CoffeeScript is just javascript with python-ruby syntax.

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 17:42
by milo christiansen
Duha wrote:PS. I am coding python and ruby and CoffeeScript is just javascript with python-ruby syntax.
Which are two examples of horible syntax. Python is my all time least favorite language, largly because of its indentation sensitve nature, but also because of all sorts of other little things.

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 18:02
by Duha
milo christiansen wrote:
Duha wrote:PS. I am coding python and ruby and CoffeeScript is just javascript with python-ruby syntax.
Which are two examples of horible syntax.
Give me example of pretty syntax. (C-style, lisp, perl, brainfuck, whitespace?)
Python is my all time least favorite language, largly because of its indentation sensitve nature, but also because of all sorts of other little things.
tastes differ.

I like python for indentation, and other little things (OOP, functional, ducktyping, batteries, runtime debugging, etc.)
IMHO it is language for fast and easy development.

What is you first favorite?

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 18:05
by aubergine
Javascript might have some rough edges, in fact it has lots of them. And it might not be the nicest thing to look at.

But, IMHO, it's the code equivalent of this tea bowl:

Image

http://en.wikipedia.org/wiki/Wabi-sabi

Coffee Script, on the other hand, is more like this:

Image

It was a good idea in theory, but in practice it's not somewhere I'd want to go.

http://en.wikipedia.org/wiki/Jay_Maynard

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 19:20
by Andrie
lol lol :lol2: :lol2: :wink: :lol2: :lol2: :wink:

Re: CoffeeScript for warzone scripting.

Posted: 31 Oct 2012, 22:35
by Duha
aubergine wrote:Coffee Script, on the other hand, is more like this:
IMHO Jay is more cooler then old ugly cup.

And almost same proportion in ages (17 for javascript and 3 for coffescript.)

Re: CoffeeScript for warzone scripting.

Posted: 01 Nov 2012, 14:08
by raycast
JavaScript fan shirt:
Image

Javascript... WAT?!?

Re: CoffeeScript for warzone scripting.

Posted: 01 Nov 2012, 20:04
by aubergine
I'd rather wear that masochism t-shirt than Jay's groin-exposing Tron leotard.

EDIT: Jay is actually a really cool bloke. But that tron leotard... eye rape!

Re: CoffeeScript for warzone scripting.

Posted: 02 Nov 2012, 01:01
by Duha
aubergine wrote:I'd rather wear that masochism t-shirt than Jay's groin-exposing Tron leotard.

EDIT: Jay is actually a really cool bloke. But that tron leotard... eye rape!
I dont` like masochism (once I have deal with AutoIt).

If someone decide to use coffescript I will add here tutorial how to have fast development.

Re: CoffeeScript for warzone scripting.

Posted: 02 Nov 2012, 01:53
by aubergine
Duha,

I think it's worth adding tutorial anyway - at the end of the day, if people want to use coffeescript and that results in more AIs or warzone mods, it's good for the community despite the ugly syntax :P

Re: CoffeeScript for warzone scripting.

Posted: 02 Nov 2012, 14:48
by raycast
On a side note: a benefit of CoffeScript may be that it will already catch a number of errors when compiling into JavaScript. While when you write JavaScript directly, most errors will only pop up once the script (or even: part of the script!) is actually used.

But I havn't used CoffeeScript, I don't know how good the CS-to-JS compiler is at catching errors. I have, however, used the Google Closure Compiler. It does a reasonable job at this, definitely better than debugging with the web browser...

Re: CoffeeScript for warzone scripting.

Posted: 02 Nov 2012, 20:27
by iap
If you want to find a better language that compiles to JS, try haxe.
http://haxe.org/

Re: CoffeeScript for warzone scripting.

Posted: 03 Nov 2012, 01:42
by Duha
iap wrote:If you want to find a better language that compiles to JS, try haxe.
http://haxe.org/
It is language (Has more docs to read). Coffeescript is syntax for js.

It has some benefits for debuging but not in wz case.

It less readable. IMHO

CoffeeScript is the #11 most popular language on GitHub
HaXe is the #48 most popular language on GitHub