Date post: | 17-Dec-2015 |
Category: |
Documents |
Upload: | constance-barker |
View: | 222 times |
Download: | 0 times |
CoffeeScript vs. TypeScript
CoffeeScript vs. TypeScript
What should you use in your What should you use in your application?application?
About MEAbout MEPaul OliverPaul Oliver
Lead Developer @Farm Credit Lead Developer @Farm Credit Services of AmericaServices of America
Twitter: Twitter: @ItsPaultastic@ItsPaultastic
(Slides and links will be tweeted (Slides and links will be tweeted after conference)after conference)
AGENDAAGENDAAbout Each About Each LanguageLanguage
SetupSetup
DemoDemo
ComparisonsComparisons
ConclusionConclusion
About About CoffeeScriptCoffeeScriptFirst Release October First Release October
20092009
Open Source (Github)Open Source (Github)
11th Most Popular 11th Most Popular language on Github.language on Github.
''The original idea was for The original idea was for CoffeeScript to be "unfancy CoffeeScript to be "unfancy JavaScript"--JavaScript boiled JavaScript"--JavaScript boiled down to its regular essence down to its regular essence without the language quirks you without the language quirks you usually have to watch out for. Java usually have to watch out for. Java is a fancy word for coffee, so is a fancy word for coffee, so unfancy JavaScript is unfancy JavaScript is CoffeeScript.CoffeeScript.' '
Jeremy AshkenasJeremy AshkenasCoffeeScript creatorCoffeeScript creator
About TypeScriptAbout TypeScriptFirst released in October First released in October 2012 by Microsoft. 2012 by Microsoft.
Anders HejlsbergAnders Hejlsberg designed much of designed much of TypeScript.TypeScript.
Open Source and hosted Open Source and hosted on CodePlexon CodePlex
Not in the Top 90 Not in the Top 90 languages on Github languages on Github (yet)(yet)
Transcompiles to Transcompiles to JavaScript (ES3 and ES6)JavaScript (ES3 and ES6)
SETUPSETUP
CompileCompiledd
JavaScriJavaScriptpt
Visual Studio 2012Visual Studio 2012 ASP.NET Web Tools ASP.NET Web Tools 2012.22012.2
Web Essentials Web Essentials
Wait? Compiled Wait? Compiled JavaScript?JavaScript?zookeeper = "Paul"
session = 106alert(zookeeper)alert(session)
var zookeeper : string = "Paul";var session : number = 106;alert(zookeeper);alert(session);
var session, zookeeper;zookeeper = "Paul";session = 106;alert(zookeeper);alert(session);
CompileCompilerr
CompilerCompiler
TYPESCRIPT IS TYPESCRIPT IS IN ALPHA!IN ALPHA!
DON’T install the DON’T install the latest version (0.9 latest version (0.9 alpha)...it has major alpha)...it has major memory problems.memory problems.
Look for an older Look for an older version 0.8.3.1 version 0.8.3.1 http://bit.ly/1eLhX9X
Requires Restart. Requires Restart. Why?Why?
COFFEESCRIPTCOFFEESCRIPT FEATURES FEATURES
NOT IN NOT IN TYPESCRIPTTYPESCRIPTFixes comparison operators Fixes comparison operators
((====, , !==!==))
Correctly hoists variable declarationsCorrectly hoists variable declarations
Loop comprehensionsLoop comprehensionsfor food in foods where...for food in foods where...
Better default parameter handling (Better default parameter handling (nullnull and and undefinedundefined))
Great support for arrays Great support for arrays elements = arr[3..6]elements = arr[3..6]
Does not require all the “Does not require all the “ceremonyceremony” of static typing” of static typing
Wraps the compiled JavaScript in a safety wrapper to prevent global contaminationWraps the compiled JavaScript in a safety wrapper to prevent global contamination
String interpolation: String interpolation: “Hello #{“Hello #{namename}”}”
Many more...Many more...
TYPESCRIPTTYPESCRIPT FEATURES FEATURES
NOT IN NOT IN CoFFEESCRIPTCoFFEESCRIPTIntellisense! (in Visual Studio)Intellisense! (in Visual Studio)
Squiggly Lines! (in Visual Studio)Squiggly Lines! (in Visual Studio)
Static Type CheckingStatic Type Checking
JavaScript-like syntaxJavaScript-like syntax
You can use You can use ==== if you want. if you want. (Why?)(Why?)
Supports some of the Supports some of the EcmaScript standards still being EcmaScript standards still being solidified (like solidified (like modulemodule and and letlet))
CONVERTING CONVERTING Legacy CodeLegacy Code
It took about It took about 25 times 25 times longerlonger to to
convert legacy convert legacy code to code to
TypeScriptTypeScript
CONVERTING CONVERTING Legacy CodeLegacy Code
It took about It took about 25 times 25 times longerlonger to to
convert legacy convert legacy code to code to
TypeScriptTypeScript
amber.js
amber.coffee
js2coffee amber.js > amber.coffeejs2typescript amber.jsError: Command not foundError: Command not found
How to Choose?How to Choose?Prefer “stable and popular” Prefer “stable and popular” to “new and unproven”to “new and unproven”
Working with legacy code Working with legacy code (new code is fine too!)(new code is fine too!)
Prefer typing less codePrefer typing less code
Don’t need Intellisense or Don’t need Intellisense or refactoring built into your refactoring built into your toolingtooling
Willing to learn a new syntaxWilling to learn a new syntax
Understand how JavaScript Understand how JavaScript worksworks
Don’t mind working with Don’t mind working with bleeding edgebleeding edge
Not working with legacy Not working with legacy codecode
Don’t mind typing more to Don’t mind typing more to get more hints and get more hints and features from your IDEfeatures from your IDE
Really want Intellisense Really want Intellisense and static type checkingand static type checking
Prefer a language that Prefer a language that looks similar to JavaScriptlooks similar to JavaScript
Understand how JavaScript Understand how JavaScript worksworks
CONTACT MECONTACT [email protected]@enterprisemapper.com
Twitter: Twitter: @ItsPaultastic@ItsPaultastic
(Slides and links will be tweeted (Slides and links will be tweeted after conference)after conference)
Interested in Early Access to Interested in Early Access to Enterprise Mapper?Enterprise Mapper?
http://enterprisemapper.comhttp://enterprisemapper.com