• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Coffeescript - what's good
 

Coffeescript - what's good

on

  • 1,591 views

JS

JS

Statistics

Views

Total Views
1,591
Views on SlideShare
826
Embed Views
765

Actions

Likes
2
Downloads
8
Comments
0

3 Embeds 765

http://blog.outsider.ne.kr 674
http://www.hanrss.com 54
http://feeds2.feedburner.com 37

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

    Coffeescript - what's good Coffeescript - what's good Presentation Transcript

    • CoffeeScript What’s good? 2010.10.10 OutsideratFRENDS
    • “ CoffeeScriptisBeautiful &INeverWanttoWritePlain ” JavaScriptAgain SamStephenson (prototype.jscreator)
    • 좋은것과익숙하지않은것을구별하기가쉽지않다.
    • ComparingJavaScript&CoffeeScript
    • FunctionSyntax
    • $("a").click(function(event){$(this).addClass("busy");})
    • $("a").click(function(event){$(this).addClass"busy"})
    • $("a").click(function(event){$(@).addClass"busy"})
    • $("a").click(event)->$(@).addClass"busy"
    • LoopSyntax
    • vardata=[];for(vari=0;i<84;i++){data.push(i*10/84);}
    • data=[]foriin[0..83]data.push(i*10/84)
    • data=[]data=i*10/84foriin[0..83]
    • data=i*10/84foriin[0..83]
    • ListComprehensions
    • init_board:function(){this.board=newArray(WIDTH);for(varx=0;x<this.board.length;x++){this.board[x]=newArray(HEIGHT)for(vary=0;y<this.board[x].length;y++){this.board[x][y]=false;}}}
    • init_board:->this.board=newArray(WIDTH)forxinthis.boardthis.board[x]=newArray(HEIGHT)foryinthis.board[x]this.board[x][y]=false
    • init_board:->@board=forxin[0...WIDTH]this.board[x]=newArray(HEIGHT)foryinthis.board[x]this.board[x][y]=false
    • init_board:->@board=forxin[0...WIDTH]foryin[0...HEIGHT]false
    • init_board:->@board=(falseforyin[0...HEIGHT]forxin[0...WIDTH])
    • SettingFields
    • constructor:function(keys,tokens){this.keys=keys;this.tokens=tokens;}
    • constructor:(keys,tokens)->this.keys=keysthis.tokens=tokens
    • constructor:(keys,tokens)->@keys=keys@tokens=tokens
    • constructor:(@keys,@tokens)->
    • DefensiveProgramming
    • varcountry=null;if(typeofmodel!==undefined&&model&&typeofmodel.profile===function){varprofile=model.profile();if(profile&&profile.location&&profile.location.country){country=profile.location.country.toString();}}
    • country=nulliftypeofmodelisntundefined&&model&&typeofmodel.profileisfunctionprofile=model.profile()ifprofile&&profile.location&&profile.location.countrycountry=profile.location.country.toString()
    • country=nulliftypeofmodelisntundefined&&model&&typeofmodel.profileisfunctionprofile=model.profile()ifprofile&&profile.locationcountry=profile.location.country?.toString()
    • country=nulliftypeofmodelisntundefined&&model&&typeofmodel.profileisfunctionprofile=model.profile()ifprofilecountry=profile.location?.country?.toString()
    • country=nulliftypeofmodelisntundefined&&model&&typeofmodel.profileisfunctionprofile=model.profile()country=profile?.location?.country?.toString()
    • country=nulliftypeofmodelisntundefined&&model&&profile=model.profile?()?country=profile?.location?.country?.toString()
    • country=nullprofile=model?.profile?()?country=profile?.location?.country?.toString()
    • profile=model?.profile?()?country=profile?.location?.country?.toString()
    • profile=model?.profile?()?country=profile?.location?.country?.toString()
    • country=model?.profile?()?.location?.country?.toString()
    • BareObjects
    • $.ajax({url:path,timeout:5,data:{from:"workspace"},dataType:"html",success:function(data){return$("#result").html(data);}});
    • $.ajax({url:path,timeout:5,data:{from:"workspace"},dataType:"html",success:(data)->return$("#result").html(data)})
    • $.ajax{url:pathtimeout:5data:{from:"workspace"}dataType:"html"success:(data)->$("#result").htmldata}
    • $.ajaxurl:pathtimeout:5data:from:"workspace"dataType:"html"success:(data)->$("#result").htmldata
    • FunctionBinding
    • functionrequest(){$.get(this.person.url,(function(data){$(this.el).html(data);}).bind(this))}
    • request=()->$.get(this.person.url,((data)->$(this.el).html(data);).bind(this))
    • request=()->$.get(this.person.url,((data)->$(@el).htmldata).bind(@))
    • request=()->$.get(this.person.url,(data)=>$(@el).htmldata)
    • request=()->$.getthis.person.url,(data)=>$(@el).htmldata
    • BadThings
    • Compile isinconvenience
    • Debugging ishard
    • ButIt’sComing
    • ShortSourceMap Demohttp://www.youtube.com/watch?v=UAGAB-yT0lQ
    • ToolsforCoffeeScript
    • js2coffeeconvertJavaScripttoCoffeeScripthttp://js2coffee.org/
    • CoffeeTableBookmarkletforCoffeeScriptConsolehttp://code.alecperkins.net/coffeetable/
    • cakeSimpleBuildSystemlikeMakehttps://github.com/jashkenas/coffee-script/wiki/[HowTo]-Compiling-and-Setting-Up-Build-Tools
    • CoffeeKupMarkupasCoffeeScripthttp://coffeekup.org/
    • Thankyou. @Outsideris outsideris@gmail.com http://blog.outsider.ne.kr
    • Resourceshttp://www.flickr.com/photos/41754875@N00/5942994577http://www.flickr.com/photos/61172365@N00/481680379