#CoffeeScript Vs #javaScript,the good and the bad

First My Colorful Tv Error peice of code .

 

a look at how this is made

<canvas id="game" width="1600" height="700"></canvas>

CoffeeScript <3

ctx = document
  .getElementById("game")
  .getContext("2d")

ctx.fillStyle = "white"
ctx.fillRect 0, 0, ctx.canvas.width, ctx.canvas.height
noise = ->
  for x in [0..20]
    for y in [0..10]
      color = Math.floor(Math.random() * 360)
      ctx.fillStyle = "hsl(#{color}, 60%, 50%)"
      ctx.fillRect x * 65, y * 65, 57, 57

setInterval noise, 100

what about If you make this with javascript?
the Code will look like ”

(function() {
  var ctx, noise;

  ctx = document.getElementById("game").getContext("2d");

  ctx.fillStyle = "white";

  ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);

  noise = function() {
    var color, i, results, x, y;
    results = [];
    for (x = i = 0; i <= 20; x = ++i) {
      results.push((function() {
        var j, results1;
        results1 = [];
        for (y = j = 0; j <= 10; y = ++j) {
          color = Math.floor(Math.random() * 360);
          ctx.fillStyle = "hsl(" + color + ", 60%, 50%)";
          results1.push(ctx.fillRect(x * 65, y * 65, 57, 57));
        }
        return results1;
      })());
    }
    return results;
  };

  setInterval(noise, 100);

}).call(this);

isn’t CoffeeScript Golden?

CoffeeScript is an open source project that provides a new syntax for JavaScript.
First I’m kinda in-love with it , the Golden Rule of coffeescript is “it’s just javascript”
well Never Think of writing a big project with CoffeeScript ,
CoffeeScript is more for fun! Making Crazy Things.
Coffeescript was designed in the vein of Python and Ruby,
so if you hate those languages then you will probably hate coffee script

i Read this on los techies

I’ve worked on large projects in both javascript and coffeescript, and guess what? You can build an application in either one, and your decision of javascript or coffeescript is not going to make or break you.

If you are working on a project by yourself, then I would pick whichever language you prefer working in. It’s totally subjective, but you are going to be more productive coding in a language that you like coding in vs. one that you hate coding in.

Now, for the tricky part. What if you’re working on a team?

 

you always can change your javascript to CoffeeScript www.js2.coffee that domain tho!  -Bye

198341 Total Views 27 Views Today

Leave a Reply

Your email address will not be published. Required fields are marked *