The design looks fantastic. One thought, though -
When I saw the "Try it" bit, my first intuition was to try to enter the "primes" example from the top right corner. Since it's been a while since I've played with ghci, and I'd forgotten its... peculiarities, it was a bit off-putting to find:
let
That's gotta be positively frustrating for a beginner. I feel like a free editing space with a "Run" button, like the one on coffeescript.org is a lot more user-friendly - to the extent that I actually regularly use that one to quickly test things out.
Just gonna hijack this comment...
Hi everyone, I'm the creator of Pharen. Feel free to ask me questions or remind me why this is a terrible idea. :) Also, I once got really bored and made an r/Pharen subreddit.
Yes there are a lot of issues with cross-language compilers. That said, Coffeescript, which compiles its own language to Javascript has had a lot of success and is being used in production. So it's at least possible to use languages like this. The two problems thing might not be as bad as you'd think.
The extra layer of abstraction is a big hurdle. When debugging you have to find the source of the problem in the PHP, though ideally after that you can just find the matching Pharen code and go from there. One of the things on my todo list is to have at least a rough line-to-line tracker built, so that it could at least tell you the general location a problem happened, if not the exact line.
Translating docs and example code for existing libraries into Pharen is a bigger issue, I think. Mainly because Pharen emphasizes a functional style of coding while most PHP code assumes you are doing things imperatively. This is something Clojure has to deal with in terms of Java interop so again it shouldn't be too hard to get around.
In terms of efficiency there is tail recursion optimization (converts a recursive function to having a while loop at the end) and a persistent sequence library in the works that would make functional looping through a list about as fast as imperative iteration. More aggressive optimizations might come in the future.
If you're interested, feel free to contribute. If you use IRC you can come hang out (or berate me personally) on #pharen on Freenode. Any suggestions or ideas are welcome.
>Shaun George • 4 hours ago | >How do you ssh into a coffee machine? can you share the coffee script please?
>Dmitry Suzdalev Shaun George • 3 hours ago | >http://coffeescript.org/
Hahahahahah
Normally, I wouldn't run a java applet because of the myriad of security vulnerabilities, and so by running someone's game, I am exposing my computer. Having said that, I have seen some absolutely amazing games built as Java Applets... will you need it? I don't know. I think that JVM uses up more resources than it should. There are far better languages suitable to your needs (Object Oriented languages that compile into performant javascript such as Coffeescript which would assuage my disinclination towards potential harm.
> Seriously, is the author, what, 20 years old? Are you fucking kidding me? I don't care how brilliant and eager he is. Programming language design isn't for almost-teenagers. Unless it is a strictly defined domain-specific language of limited power (and even then, doubt they'll nail it...), some kid can't design a useful new language.
> There is no mystical magical perfect language out there that can be made by a single kid who still has diaper marks except out of infinitesimally small chance of pure luck.
What's wrong with being 20 years old? Are you annoyed to still not have accomplished much in your 30's/40's? Many of the hits in any arena of technology, indeed anything really, are done by young people who have a "fresh" look on things. For a recent example, see Coffeescript, which is used by many, and was created after the designer read the book, Create Your Own Programming Language.
Making a programming language isn't rocket science, and it's a tremendously valuable learning experience. Stop being such a twat about it.
" CoffeeScript is a programming language that transcompiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehension and pattern matching." Here's the official CoffeeScript website: http://coffeescript.org And here's a wiki page on it: https://en.m.wikipedia.org/wiki/CoffeeScript
I've read the claim that the following is dynamically scoped?
x=1 g = -> console.log(x) x = 2
If we put that in a file, we get the following JavaScript:
// Generated by CoffeeScript 1.3.1 (function() { var g, x;
x = 1;
g = function() { console.log(x); return x = 2; };
}).call(this);
You or I may not like it, but that's lexical scoping. I propose the following "acid test" for dynamic scoping:
x = 'lexical'
acid = -> alert "#{x}ly scoped"
do (x = 'dynamic') -> acid(x)
If CoffeeScript is dynamically scoped, it will output "dynamically scoped" as the function acid
will look x
up in the current environment at runtime rather than at transpilation time.
CoffeeScript is a somewhat popular language in the webdev community that does this this these days. I think the basic idea was that there are a lot of ways to shoot yourself in the foot with JavaScript (ref: JavaScript, the Good Parts) and CoffeeScript provides simpler structures that generates normalized JavaScript that's less foot-shooty.
IMO there's a lot of downsides to this approach, not the least of which is that it makes debugging awkward because now you're writing code that's one-step-removed from the code that's actually throwing bugs.
Some people may not agree with me suggesting this to someone without more experience, but if you don't like JavaScript syntax and do like Ruby, you should try out CoffeeScript. Meteor even has a standard package for it:
meteor add coffeescript
Yeah, instanceof
would work to check, but these errors mostly come up unexpectedly when you fuck up. :)
CoffeeScript is just syntax candy that compiles into JS, but after a few weeks of working with it, I'd say it's a bit more than that... to quote their website:
> CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
It's hard to describe, but it's just fun working with it. I was always kinda bare-bones syntax guy, but a line like return false unless url.indexOf(@basePath) is 0
is just really cute. Plus what they turned loops and switch statements, etc., into... it makes the code much cleaner.
As for the hack, the Function object has a name
property in ECMAScript 6, but that's still in development and not widely supported.
> Well, CoffeeScript is dead
The coffeescript changelog seems to indicate that it is alive and well.
I think v1 is dead and legacy, and there was a lot of resistance to v2, but it happened, and coffeescript is still a thing.
Anyway, if there is a company hiring a JS developer, but don't know what a JS developer actually is in 2018, then that doesn't bode well for the company hiring.
Here, try this to see what I mean: link. Notice that it grabs the 14 first even though it is on a lower level than the 8.
> How to create an anonymous function and execute it?
do (arg1, arg2) -> console.log arg1 + arg2
compiles to
(function(arg1, arg2) { return console.log(arg1 + arg2); })(arg1, arg2);
If you want to chain them together, you have to wrap arguments with ()
Try Coffeescript here. The js2coffee compiler seems flawed, to me, compared to the official site.
But this is about CoffeeScript, not JavaScript. CoffeeScript compiles every file into its own function. Nothing gets dumped into the global scope unless you do so intentionally.
> absolutely maddening to work with unassisted, but fortunately they don't ever work with it unassisted
Curious case about the languages available to us:
Lots of work is done in C transparently, i.e. one almost never has to go to the level it compiles into (machine codes, represented as assembly code). Then there're interpreted languages / VMs, and one almost never has to go to the C/CPP-representation under them. And recently some made translated languages on top of both (1) (2), but didn't entirely manage to organize toolsets for the transparency, i.e. if something goes slightly wrong, there is still a need to go into the underlying representation.
The lesson is here is not clear, but it slightly suggests that making a translated language is cheap, but making a toolset to avoid dealing with stuff it is translated into is hard and expensive.
And then there's the point of actually spreading the learning of a language, and of how best to use it; a notable example in scripted languages is perl as compared to python: in a way, perl could be used about as conveniently as python is (with a little less sugar), but it did not nudge toward those practices, and lots of perl code thus became write-only code.
that being said:
Can read about coffeescript here. It's essentially js.
Long and short I don't think you'd be able to run this. I don't know if JavaScriptCore is capable of running this. Even if you compile all of the .coffee files to js you'd also need to write the obj-c wrapper and meh that shit's way over my head.
It's called "self hosting". The CoffeeScript compiler is the same way. The answer to "how?" is pretty mundane: you build it with an existing compiler (often a previous version of itself). Once you compile it to a binary, the language it was written in is pretty irrelevant.
try looking at http://www.sinatrarb.com/ then for a lightweight ruby framework. ruby is easy to write and understand, i can recommend it for small web apps.
nodejs or python would be my #2 choice, or maybe golang too if you like a C-style language.
nodejs isn't bad, i don't get why a lot of people seem to hate it. add some http://coffeescript.org/ and it's superb.
Looking at this again, I'm still wondering what that syntax will actually be used for. Just early returns? Why not just a macro?
cancel!(with Err("nope"), if x matches None);
I wrote a trivial version in a few minutes: https://play.rust-lang.org/?gist=916c60c7cb639f9cd2ae&version=stable
This reads nicely IMHO, and even gives you the fluffy feeling of using trailing if clauses. (Or whatever they are called in Ruby or CoffeeScript.)
Most indentation-structured languages actually do have formal written rules. Python, at least has a very trivial ruleset, because there's only one construct -- the "suite" that allows an INDENT/DEDENT pair, and suites are always begun with a :
on the previous line. Python's tokenizer also doesn't issue INDENT/DEDENT pairs for lines inside of an open pair of brackets, parentheses, or braces.
CoffeeScript's grammar, on the other hand, is a bit more complex, as there are more places where something can be between an INDENT and an OUTDENT, and they can occur inside of open parentheses, brackets, or braces.
Anyway, the grammar is where all the written formal definition takes place, specifically the "Grammatical Rules" section. Search for each place an INDENT or OUTDENT appears, to see all the places where you can indent something. A lot of things take a Block
, which is the main indented structure, but there are a bunch of other places where INDENT and OUTDENT are allowed.
Generally, I go like this:
/project_ID /bower_components /Build OR /dist /css /fonts /images /js /src /coffee site.coffee *.coffee /fonts /jade /block /layout /module /page index.jade /js /vendor /styl OR /sass OR /less /vendor /block /element /module /page global.styl *.styl /images *.jpg *.png *.gif *.svg /node_modules /non-web
project_ID
is the corresponding project code from our team's JIRA setup. Everything in /src
is build / compiled into /Build
.
non-web
is for extra project files like requirements documents, PSD mockups, unedited stock images, brand assets, etc.
I tend to build most projects with Jade, Stylus, and Coffeescript.
Yeah that's what I thought at first, but it keeps giving me an
Uncaught TypeError: Illegal invocation
I'm running these tests through Meteor using its CoffeeScript package. Could it somehow not function the same as the official npm CoffeeScript?
Well, the three lowest hanging fruit would be
All by Jeremy Ashkenas, as is Underscore.
Meta-bonus: Docco is the tool that turns source code with markdown comments into those nice annotated code pages.
Jade is an HTML preprocessing and templating engine based written in javascript.
Its primary purpose is for use in node.js projects as a templating engine, as it has the ability to compile bits of HTML into javascript functions for use in apps.
When working with projects that also utilize Stylus (or SASS with its indented syntax), and CoffeeScript, it also has the benefit of making the syntax for writing your markup, stylesheets and code all very similar, and often easier to read as well.
Glad it helped! You will be pleasantly surprised to know that a lot of the work in programming and computer science is basically "how do I make this easy to represent and work with?"
It's so common that there's a standard term for handling this problem, called the adapter pattern which is basically, "Given that I have to talk to a system that uses an ugly representation for code and data, I will write a converter between it and my pleasant language so I can keep working in a readable format."
It's also why, for example, they invented Coffeescript, which performs the same function for JavaScript that C does for assembly: remove all the repetitive cruft and make it readable, while still having a close correspondence with the ugly version. Take a look at their examples. At first, it's like "meh, I get to leave out the semicolons, so what?" but then you see the complicated stuff that CoffeeScript abstracts away.
> I am trying to grapple with javascript now. Thats a real beast to grapple with. :(
You liked Python and are trying to grapple javascript? Sounds like Coffeescript might interest you...
I am not a CoffeeScript reader either... That being said, I found this site: http://js2coffee.org/
X? is the JS equivalent of checking to see if the variable X has a value assigned
typeof x !== "undefined" && x !== null;
The other comparison being made is exactly what you expect. Is X greater than Y?
X > Y
Now, looking at the CoffeeScript site's instructions on loops, it seems that the for loops are similar to PHP. Basically this is saying...
For each item in the Array "foos" return a result that we will call "foo" but only when X is valid or greater than Y
So in JavaScript this would look something like...
var x = 5; var y = 3; var foos = [1, 2, 3, 4, 5, 6];
for (var i = 0; i < foos.length; i++) { if ( foos[i] === x || foos[i] > y ) { console.log(foos[i]); } }
Hope this helps!
EDIT: After re-reading the docs for CoffeeScript, I think had my function backwards and I changed it to the correct version.
Simpler class initialisation akin to that of Coffescript. This code is really redundant:
def init(self, name, age, height): self.name = name self.age = age self.height = height # Code
Something like this would be better (if a bit longer in terms of line length):
def init(self, self.name, self.age, self.height): # Code
Sounds like a job for RECURSION! edit: To see it in action, [click here](http://coffeescript.org/#try:%0Aoptions%20%3D%20%5B'b'%2C'c'%2C'a'%2C'e'%2C'd'%2C'f'%2C'g'%2C'h'%2C'a'%2C'e'%5D%0Alength%20%3D%20options.length%0A%0Acurrent%20%3D%20%5B%5D%0Abest%20%3D%20%5B%5D%0AbestScore%20%3D%20-Infinity%0AcurrentIndex%20%3D%20...) and then click "run" in the upper right.
Sorry if coffeescript isn't really your thing. If you want, I could write it in a different language or pseudocode for you.
edit: So I just realized that since my example evaluation function gives a higher score depending on how correlated the character code is to the index, I have created perhaps the most inefficient sorting algorithm I've ever seen. O(n!).
edit 2: If you really wanted to work with as many elements as possible, implementing a minimax on the recursion tree would probably give you a few extra elements.
this is what did it for me, using this and attatching the instances to angular.js' $scope is so powerful.
http://coffeescript.org/#classes
plus it's super clean, compiles to nice & safe javascript, and has a lot of little things that takes the pain out of js programming. i feel like I'm writing ruby in javascript. feels good man.
(task) => @tasks.push(() => task(() => @run()))
whose JavaScript counterpart is as follows.
var _this = this;
function(task) { return _this.tasks.push(function() { return task(function() { return _this.run(); }); }); }
You are also free to translate every CoffeeScript snippet into JavaScript counterpart using the Try CoffeeScript window at http://coffeescript.org/
Correct.
Also I noticed no one mentioned CoffeeScript which is a nice, clean little language that takes some ideas from ruby and python and compiles straight into javascript.
I'm totally in for making this happen Bootstrap world that shimei linked to looks like the closest so far, but it's limited in scope (seems to be intended to be taught quickly to highschoolers) and lacking in interactivity (more lesson plan than self-sufficient resource).
I'd be more into making some kind of interactive resource (I like literate programming) than just a video, but videos would accompany such a thing well. We could even do something novel like literate programming + videos in the comments for extended explanation. I'm imagining something a bit like this but with videos on the lhs as well as available separately through youtube/similar
Hm, if the syntax is bothersome maybe you could try Coffeescript?
I find my js UIs are structured slightly differently (though not necessarily better) than what you've posted. If I had a set of buttons like this, I might give them all a class and then attach a click handler to that class. Then, when that generic handler fires, it is passed some information about the specific button that was clicked. Maybe that information is tucked into the button as a data attribute or as an ID. Not necessarily simpler or shorter than what you've got, but just another potential route, I think.
Javascript is very powerful language. I don't know what you don't like about it, but if it's only the syntax, you can write in coffesecript, a language that compiles to javascript.
Javascript, by itself, has many more advantages than just being able to run on every web browser. Proof of that is that it's also used a lot on the server side (with node.js for example).
Javascript is a fantastic language for the web! It's robust and highly dynamic allowing you to build awesome applications that do not block the execution flow of the program (for every database request, for example), very quickly.
There are also great frameworks available for javascript, both client and server side. Backbone.js, node.js/express are good examples.
If you don't like HTML and CSS either, I kinda agree with you. But there's HAML and SASS to make your life easier.
Because real javascript is not like that, that is coffeescript, which is not natively supported by any browser. Execution of coffeescript requires compiling it to javascript code, either statically or dinamically (see coffeescript.js, or tools like codekit).
On the other hand, yes, the coffeescript console does help much in how to implement many complex construct in javascript.
I know this article is a troll, but still gotta point out how awesome coffeescript is.
if (typeof my_var !== "undefined" && my_var !== null) { // you idiots put Rasmus Lerdorf to shame }
vs
unless my_var? # Idiots, etc.
.
For completeness, for more languages you can try in the browser, there is also:
>Although suppressed within this documentation for clarity, all CoffeeScript output (except in files with import
or export
statements) is wrapped in an anonymous function: (function(){ … })();
. This safety wrapper, combined with the automatic generation of the var
keyword, make it exceedingly difficult to pollute the global namespace by accident. (The safety wrapper can be disabled with the bare
option, and is unnecessary and automatically disabled when using modules.)
Oh boy! CoffeeScript is like Ruby for JavaScript. If you like the Ruby syntax, you'll feel right at home. It's not like TypeScript, it doesn't add any real functionality, it only adds a different syntax. Love it!
I guess? I'm fairly sure that it was more so inspired by CoffeeScript's fat arrow function, and CoffeeScript was partly inspired by Python, so I guess so. You're talking about the arrow function, right?
Since you're already deep into backend work, it makes sense to me to transition to frontend, like JS, CSS, HTML. I don't know the reasons you don't like JS, but there's http://coffeescript.org/ that transpiles to JS with all the same effects.
I'm not sure if you've heard of https://jquery.com/, but I know I couldn't use JS without it. Makes playing with the DOM so much easier.
Great read.
It is worth noting that CoffeeScript 2.0 is in beta3 with ES6 support. http://coffeescript.org/v2/
We have converted a large CS codebase at work to 2.0 without any big issues.
You now have ES6 classes, spread/rest, async/await, JSX, fat arrows, import/export, tagged template literals, splats...
We just compile the CS2 code to ES6 code and then continue with Babel/webpack etc.
How do you even jade / stylus / coffeescript ? Ai un susvot de la Decebal incoace se știe ca Brian Herbert iși respecta tatal prea mult pentru ce vrei tu.
Spheres is written in coffeescript.
The front end is written using Angular and is also in coffeescript. I use Bootstrap for layout. My css is done using Stylus. My html using Jade.
My backend is node.js (in coffeescript). It uses knex.js to talk to an sqlite3 db (for now). It uses express as a webserver, but most of the action happens in websockets using socket.js
I maintain all of the above with grunt and I do all my work in WebStorm.
I couldn't be happier with my setup. Everything works and works well. Since grunt watches all my files, any changes are instantly available. If I change a style, it compiles the stylus, repackages the css, and tells the browser to refresh my page. the same goes for client-size coffeescript and pages. If I change the backend node code it bounces the webserver.
I have never used elm , but people who have really like it.
The other options for you are:
http://www.typescriptlang.org/
If you like Python, you will like coffeescript :-)
You're welcome. Technically there is no such thing as a jquery function. It's javascript and all I did was remove b & d (along with other classes) only to add it back in again. Ternary operators (the "a?b:c" part) can be used anywhere a value (like a+b) can be used. One warning is I actually fucked up recently by using cond?val:va2
in coffeescript recently. Coffescript does it differently because '?' is used for something else. The "The Existential Operator" http://coffeescript.org. To do what I wanted I had to do .addClass( if bar>0 then 'b' else 'd' )
. I'm pretty sure i'll mess that up again.
I'm not familiar with Typescript, but to make the translation easier there is an online coffeescript -> js compiler at http://coffeescript.org/ (Try Coffeescript on the top) or you can check the compiled source code all.js
If you find the syntax slightly verbose, it's quite a bit shorter in CoffeeScript.
Thanks for the pointers.
I took a look at Python's language reference. Its Lexical Analysis section has subsections called "Explicit Line Joining" and "Implicit Line Joining", which describe the situations in which indentation is ignored and an INDENT/DEDENT pair is not emitted.
For Coffeescript, this information seems to be provided here, I suppose? It seems to say that the newline+indentation will be ignored when either:
I must admit I can't read the LINE_CONTINUER regex; specifically:
(?![.\d])
My solution using litterate coffeescript:
https://github.com/gaultier/nodeWork/blob/master/218.litcoffee
Just playing with this mix of markdown and code, it's fun and actually quite good to write documentation ;)
A lot of people don't want to work in Javascript, but they still want to make stuff for the client side, and so Javascript has tons of languages that transpile (translate) to it. Languages like Typescript and CoffeeScript and Clojurescript have different features from normal JS (but still have to translate to working JS).
You can use the normal JS frameworks with any of them, and the best way to start is by looking at documentation like ClojureScript's or CoffeeScript's.
To be fair, many of the core packages have no documentation. Poor documentation aside, it doesn't excuse one from actually reading code (what a scary thought). That's actually how I'd like to see documentation done, I mean, annotated source is a beautiful thing.
OT: I'd like to see core-packages as their own git repos. I mean, I feel like meteor/meteor-tool is more of a build/dependancy management solution and meteor-core is the implementation of ideas under that framework. That's just my two cents though.
I've come up with this solution so far, using the coffee-script browser compiler.
<!DOCTYPE html> <html> <head> <title> Tests </title> <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" /> </head> <body> <div id="mocha"></div> <script src="coffeescript.js"></script> <script src="../../node_modules/mocha/mocha.js"></script> <script src="../../node_modules/should/should.js"></script> <script>mocha.ui('bdd');</script> <script> CoffeeScript.load("./myTests.coffee", function(){ if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } }, { bare: true }); </script> </body> </html>
Still interested to see if you guys know anything better/easier.
Anyone who's not a big fan of JavaScript should give CoffeeScript a try. It compiles to JS, looks a lot cleaner, and eliminates some of the quirks that JS has (cough ===).
When insulting javascript, I find it useful to point at CoffeeScript or its like, which can either be pre- or jit-"compiled" into javascript. There's a Node.js tool to compile it, or you can add a <code>&lt;script&gt;</code> tag targetting <code>coffee-script.js</code>, and write your website using <code>&lt;script type="text/coffeescript"&gt;</code>. It's even supported in Visual Studio.
Coffeescript is a language itself, that compiles into JS (http://coffeescript.org/)
The author of the plugin provided .coffee files for devs who prefer coding in coffee (it's similar to the Ruby syntax) so essentially it's quicker to develop with.
You can see the compiled output of coffeescript on it's website (click Try Coffeescript): http://coffeescript.org
Your particular code sample is a bit weird, because neither x nor y have anything to do with your loop.
var foo, i, _i, _len;
for (i = _i = 0, _len = foos.length; _i < _len; i = ++_i) { foo = foos[i]; if ((typeof x === "undefined" || x === null) || x > y) {
} }
I'm not sure what the issue is but I am guessing you are running into an issue where you are creating/simulating classes with JavaScript and call a method on an object and then it doesn't work right. You debug it and find out that inside of the method call, "this" does not refer to an instance of the class, but is something else, like Window.
If that is the issue then you probably want to catch it before you get into the body of your method. In other words, you need to use call or whatever technique to ensure initially that you are acting inside the scope of the object. There are another of ways to get around this.
You could just use call or apply one step sooner. In jQuery, you can use .proxy(). Prototype library has bind(). There is the function given here http://www.bennadel.com/blog/1517-Binding-Javascript-Method-References-To-Their-Parent-Classes.htm
What I prefer to do is just use CoffeeScript with => http://coffeescript.org/#fat_arrow. For example:
class EasiestReallyThis constructor: (@whatisthis) ->
thisAlwaysTheClassObj: => console.log "This thing is definitely a #{@whatisthis}"
test = new EasiestReallyThis('easyWay')
$('.mybutton').click -> test.thisAlwaysTheClassObj()
Look at the options you can provide to the <code>coffee</code> command. There is a --join
option that will concatenate files together and then output them. Is this not what you're looking for?
Taking advantage of a hack involving JavaScript's Array.join and CoffeeScript's "Everything is an Expression":
mean = (data) -> eval(data.join('+')) / data.length
variance = (data) -> mean( for number in data Math.pow(number - mean(data), 2) )
standardDeviation = (data) -> Math.sqrt variance(data)
dataSet = [0.4081, 0.5514, 0.0901, 0.4637, 0.5288, 0.0831, 0.0054, 0.0292, 0.0548, 0.4460, 0.0009, 0.9525, 0.2079, 0.3698, 0.4966, 0.0786, 0.4684, 0.1731, 0.1008, 0.3169, 0.0220, 0.1763, 0.5901, 0.4661, 0.6520, 0.1485, 0.0049, 0.7865, 0.8373, 0.6934, 0.3973, 0.3616, 0.4538, 0.2674, 0.3204, 0.5798, 0.2661, 0.0799, 0.0132, 0.0000, 0.1827, 0.2162, 0.9927, 0.1966, 0.1793, 0.7147, 0.3386, 0.2734, 0.5966, 0.9083, 0.3049, 0.0711, 0.0142, 0.1799, 0.3180, 0.6281, 0.0073, 0.2650, 0.0008, 0.4552] console.log "Mean: #{mean(dataSet)}" console.log "Variance: #{variance(dataSet)}" console.log "Standard deviation: #{standardDeviation(dataSet)}"
Output:
Mean: 0.32977166666666674 Variance: 0.07010303403055558 Standard deviation: 0.2647697755231053
I love CoffeeScript.
I agree, that is probably one of the weakest aspects of dealing with the language. It is farrrrrrr to simple to create a global, or mute out an existing variable, coupled with a difficulty in "hiding" code. That said, coffeescript goes a long ways towards "fixing" Javascript. Google also has a project called Dart which is trying to create a Javascript replacement, that can compile back to pure Javascript, but when I checked it out last it was so far away from being ready for prime time.