• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Coffeescript en cinco (o diez) minutos

on

  • 5,278 views

 

Statistics

Views

Total Views
5,278
Views on SlideShare
5,276
Embed Views
2

Actions

Likes
1
Downloads
41
Comments
0

1 Embed 2

http://paper.li 2

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Coffeescript en cinco (o diez) minutos Coffeescript en cinco (o diez) minutos Presentation Transcript

  • CoffeeScript en cinco minutos Federico Builes federico@mheroin.com
  • match = (regexp, text) -> return match_here(regexp.slice(1), text) if regexp[0] is '^' while text return true if match_here(regexp, text) text = text.slice(1) false match_here = (regexp, text) -> [cur, next] = [regexp[0], regexp[1]] if regexp.length is 0 then return true if next is '*' then return match_star(cur, regexp.slice(2), text) if cur is '$' and not next then return text.length is 0 if text then return match_here(regexp.slice(1), text.slice(1)) false
  • JavaScript === BASIC
  • “...the teaching of BASIC should be rated as a criminal offense: it mutilates the mind beyond recovery.” Edsger W. Dijkstra
  • ∴ (eso significa conclusión)
  • Whitespace if (persona.estudia("economia")) { while (oferta > demanda) { if persona.estudia("economia") comprar(); comprar() while oferta > demanda } vender() while demanda > oferta while (demanda > oferta) { vender(); } }
  • Paréntesis Opcionales person.should_not be(null) person.should_not(be(null));
  • Azúcar Sintáctica I shave if guy.hairy? "ni pío" unless tipo.tiene_condon? quemar_musica if grupo is "Black Sabbath" prender_tina if tina is off ganador = true if numero in [0, 42]
  • Azúcar Sintáctica II comprar while oferta() > demanda() vender unless oferta() > demanda() print num for num in [10..1] arreglo = [1, 2, 3, 4] hash = { key1: "valor1", key2: "valor2" }
  • Operador Existencial (?) despachar = true if camion.listo? and !lloviendo? if ((camion.listo != null) && !(typeof lloviendo != "undefined" && lloviendo !== null)) { despachar = true; }
  • Clases class Animal constructor: (@nombre) -> mover: (metros) -> alert @nombre + " se movio " + metros + "m." class Caballo extends Animal mover: -> alert "Galopando..." super 45 un_caballo = new Caballo "Pegaso Jr." un_caballo.mover()
  • Animal = (function() { function Animal(_arg) { this.nombre = _arg; return this; } return Animal; })(); Animal.prototype.mover = function(metros) { return alert(this.nombre + " se movio " + metros + "m."); }; Caballo = (function() { function Caballo() { return Animal.apply(this, arguments); } return Caballo; })(); esto es lo que sugiere Crockford... y falta código.
  • Ejecución en HTML <script src="extras/coffee-script.js"></script> <script type="text/coffeescript"> # Eval the compiled js. $('button.run').click -> try eval window.compiled_js catch error then alert error current_nav = null </script>
  • 900 págs 176 págs
  • Referencias http://jashkenas.github.com/coffee-script/ https://github.com/jashkenas/coffee-script http://www.flickr.com/photos/elgregein/474141687 http://www.flickr.com/photos/nyuhuhuu/
  • ¿Preguntas? federico@mheroin.com @febuiles http://github.com/febuiles