SlideShare a Scribd company logo
1 of 32
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
Install:Install:
REPL in your Terminal:REPL in your Terminal:
REPL in the Browser:REPL in the Browser:
coffeescript.orgcoffeescript.org
Or
[ 'TRY COFFEESCRIPT' tab ]
WELCOME . . .WELCOME . . .
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Introduction
●
Setup & Installation, Terminal & Browser REPL, Coffeescript Compilation
●
Coffeescript / Javascript Similarities & Differences
● Syntax Details
●
Javascript vs Coffeescript Debate & Controversy
●
ECMAscript5 / ECMAscript6 Changes & Coffeescript
●
Code Examples
●
Resources
OutlineOutline
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
An alternate syntax for Javascript
●
Compiles to Javascript
●
Inspired by Ruby and Python syntax
●
Strives to be simpler and cleaner than JS
●
Mostly a strict one-to-one correspondence with JS
●
A few extra features
●
Classes – "pseudo-classical object orientation"
●
Author: Jeremy Ashkenas
●
Current version: 1.9.1
IntroductionIntroduction
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
Requires up-to-date, stable versions of NodeJS and NPM (Node Package
Manager).
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
Install:Install:
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
After installing Coffeescript, an REPL
(an environment for entering and
evaluating Coffeescript statements) is
available in your terminal by entering
either of these commands:
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
REPLREPL
Or
An REPL is also available in your
browser at coffeescript.org . Select
the TRY COFFEESCRIPT tab.
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
To manually compile a Coffeescript file, enter coffee -c (or coffee --compile)
in the terminal, followed by the filename (and path if in a subdirectory or
other directory).
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
Compiling CoffeescriptCompiling Coffeescript
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
The most common option for the compile command is -b or --bare. This
option will disable the function wrapper which is placed around the
Javascript program by default.
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
Compiling CoffeescriptCompiling Coffeescript
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
Many frameworks and development environments will compile Coffeescript
files automatically.
Examples:
●
Ruby on Rails, Sinatra: compile Coffeescript files automatically when
serving an HTTP request for the corresponding Javascript file.
●
Many text editors, such as Sublime, and many IDEs, can automatically
compile Coffeescript files every time they are saved.
●
Workflow managers such as Grunt can be configured to automatically
compile Coffeescript files as they are saved.
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
Compiling CoffeescriptCompiling Coffeescript
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
The Coffeescript compiler also has a -w or --watch option to automatically
compile Coffeescript files as they are saved.
Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL,
Coffeescript CompilationCoffeescript Compilation
Compiling CoffeescriptCompiling Coffeescript
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
With Coffeescript, you're still operating in the Javascript environment
●
Slogan: "It's just Javascript"
●
Use the same data types, standard classes and libraries
Coffeescript / Javascript Similarities & DifferencesCoffeescript / Javascript Similarities & Differences
DifferencesDifferences
SimilaritiesSimilarities
●
Different syntax
●
Blocks and statements marked by whitespace instead of { } and ;
●
No var, function or prototype keywords
●
Coffeescript insulates you from certain Javascript snags
●
Coffeescript must be compiled to JS but may be done automatically
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
** Syntax Details **** Syntax Details **
●
Statements and blocks
●
Variables
●
Operators and aliases
●
String Interpolation
●
Arrays
●
Array ranges
●
Comprehensions
●
Objects
●
Functions
●
Fat arrows
●
If – else
●
Prefix and postfix conditionals
●
Switch
●
Classes
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
You don't use semicolons ; .
●
Indentation is significant, and used to delimit blocks of multiple lines of
code.
●
Indentation delimits blocks of code instead of curly braces { } .
●
You don't need an end keyword at the end of a block, as in Ruby.
** Syntax Details **** Syntax Details **
Statements and blocksStatements and blocks
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
No var keyword.
●
Variables are not global unless you use them somewhere in the global
scope.
●
Coffeescript generates var statements and places them at the top of the
scope where they are used.
●
This scheme precludes "shadowing". You cannot use the same variable name
within nested scopes and expect them to represent different variables.
** Syntax Details **** Syntax Details **
VariablesVariables
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Either the keyword is or a double equal sign == will be compiled to a
Javascript triple equal sign === . Coffeescript will not compile anything
into the Javascript double equal sign == .
●
The keywords and, or and not can be substituted for && , || and ! ,
respectively.
** Syntax Details **** Syntax Details **
Operators and aliasesOperators and aliases
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
If you place an expression inside of curly brackets preceeded by a sharp
sign #{ } , and this construct is inside a string literal within a pair of
quote marks, then when the string is accessed, it will evaluate the
expression in the brackets and insert its equivalent string into the
containing string.
** Syntax Details **** Syntax Details **
String interpolationString interpolation
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Similar syntax to Javascript.
●
Multi-line array literals are allowed.
●
Commas at end of lines are optional with multi-line syntax.
** Syntax Details **** Syntax Details **
ArraysArrays
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
A 'begin' and 'end' number inside the square brackets for an array can be
used to designate a slice of the array.
** Syntax Details **** Syntax Details **
Array rangesArray ranges
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Both inline and multi-line syntax.
●
Commas not needed for multi-line form.
●
Quotes around key names are optional in object literals.
** Syntax Details **** Syntax Details **
ObjectsObjects
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Use for iterations instead of loops.
●
Syntax for array iterations is for item in array .
●
Syntax for iterations over the keys of an object is for key, value of object .
●
Just use one parameter to iterate over the keys only.
** Syntax Details **** Syntax Details **
ComprehensionsComprehensions
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
No function keyword.
●
Use arrow -> instead.
●
Function block is delimited with indentation.
●
Place parameters in parentheses like in Javascript.
●
When calling a function, parentheses are optional.
** Syntax Details **** Syntax Details **
FunctionsFunctions
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Defining a function with a "fat arrow" => instead of a "skinny arrow" -> will
bind the value of the this keyword to the 'this' for the function in which it's
defined. This will prevent the 'this' reference from being diverted to
another scope by, for example, a function callback.
●
In Coffeescript, the 'at' symbol @ is a convenient shortcut/alias for the this
keyword.
** Syntax Details **** Syntax Details **
Fat arrowsFat arrows
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
if - else statements are written without parentheses or curly brackets.
●
Blocks are delimited by indentation.
●
Use if and then for a single line if statement. Do not use the then keyword
when using the multi-line syntax.
** Syntax Details **** Syntax Details **
If - elseIf - else
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
A one-line if statement can be written by appending the if clause after the
executable statement.
** Syntax Details **** Syntax Details **
Prefix and postfix conditionalsPrefix and postfix conditionals
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Use when and else keywords instead of case and default.
●
Don't need to end each 'case' with a break keyword.
●
Blocks for individual cases are delimited by indentation.
** Syntax Details **** Syntax Details **
SwitchSwitch
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
"Pseudo-classical object orientation".
●
Use class keyword to begin a class definition.
●
Use indentation as a delimiter, indenting everything after the class
keyword.
** Syntax Details **** Syntax Details **
ClassesClasses
●
Classes can extend other classes. Use the extends keyword.
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Create a new instance of the class with the new keyword, followed by a
space and then the class name, appended with a list of constructor
parameters in parentheses, if required.
** Syntax Details **** Syntax Details **
ClassesClasses
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
** Syntax Details **** Syntax Details **
ClassesClasses
●
Define class instance methods with a colon : instead of an equal sign = .
●
Constructor methods must be named constructor().
●
Use the this alias @ to designate instance attributes.
●
Use the this alias @ when referencing an instance method from elsewhere
within the class.
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Syntax issues – semicolons
●
Syntax issues – curly brackets vs whitespace
●
Compilation
●
Learning curve and adoption
Javascript vs Coffeescript Debate & ControversyJavascript vs Coffeescript Debate & Controversy
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
Array iterator methods:
●
forEach()
●
map()
●
filter()
●
every()
●
some()
●
reduce()
●
reduceRight()
●
indexOf()
●
lastIndexOf()
ECMAscript5 / ECMAscript6 Changes & CoffeescriptECMAscript5 / ECMAscript6 Changes & Coffeescript
ECMAscript5ECMAscript5
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
●
Classes: class, constructor and extends keywords
●
Modules: import and export keywords
●
Arrows: Can use => instead of function for anonymous functions
●
String Interpolation: Enclose expression to coerce into a string with $(),
enclose entire string expression with backtick `` characters instead of
quotes
ECMAscript5 / ECMAscript6 Changes & CoffeescriptECMAscript5 / ECMAscript6 Changes & Coffeescript
ECMAscript6ECMAscript6
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
github.com/jrschmidt/grandpa-basic-1980github.com/jrschmidt/grandpa-basic-1980
Code ExamplesCode Examples
Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or
Useful Tool?Useful Tool?
John R SchmidtJohn R Schmidt
SoCal Code CampSoCal Code Camp
Fullerton 2015Fullerton 2015
OFFICIAL WEBSITE: coffeescript.org
SLIDES: Coffeescript: No really, it's just Javascript by Brian Mann
slideshare.net/backbonerails/coffeescript-no Feb 2014
BOOK: CoffeeScript: Accelerated JavaScript Development
Trevor Burnham – Pragmatic Programmers 2ndEd Feb 2015
VIDEO: Jeremy Ashkenas: A Cup of CoffeeScript
youtube.com/watch?v=A5Sg04IEkvk 2010/2013
VIDEO: CoffeeScript: The Good Parts by Azat Mardan
youtube.com/watch?v=WX5Y6Dq1OHE Aug 2014
ResourcesResources

More Related Content

Similar to Coffeescript: Fad or Useful Tool? Socal Code Camp Fullerton 2015

HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
Lucas Jellema
 
Containerize vs Virtualize? NGDC 2009
Containerize vs Virtualize? NGDC 2009Containerize vs Virtualize? NGDC 2009
Containerize vs Virtualize? NGDC 2009
Andy d
 
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
PROIDEA
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
Sasha Goldshtein
 

Similar to Coffeescript: Fad or Useful Tool? Socal Code Camp Fullerton 2015 (20)

Graal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformGraal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution Platform
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
 
Coffeescript intro
Coffeescript   introCoffeescript   intro
Coffeescript intro
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
JVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdfJVM Under The Hood WDI.pdf
JVM Under The Hood WDI.pdf
 
ETL in Clojure
ETL in ClojureETL in Clojure
ETL in Clojure
 
Apache Big Data Europe 2016
Apache Big Data Europe 2016Apache Big Data Europe 2016
Apache Big Data Europe 2016
 
Containerize vs Virtualize? NGDC 2009
Containerize vs Virtualize? NGDC 2009Containerize vs Virtualize? NGDC 2009
Containerize vs Virtualize? NGDC 2009
 
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetesSpryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
 
Python introduction
Python introductionPython introduction
Python introduction
 
REST in Peace. Long live gRPC! @ Codineers
REST in Peace. Long live gRPC! @ CodineersREST in Peace. Long live gRPC! @ Codineers
REST in Peace. Long live gRPC! @ Codineers
 
Rails is Easy*
Rails is Easy*Rails is Easy*
Rails is Easy*
 
Writing Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScript
 
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
CONFidence 2015: MIMOSAWRITERROUTER - Abusing EPC on Cisco Router to collect ...
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
 
The Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACCThe Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACC
 
ATS Programming Tutorial
ATS Programming TutorialATS Programming Tutorial
ATS Programming Tutorial
 
From GameMaker to Game Baker - Porting Hotline Miami
From GameMaker to Game Baker - Porting Hotline MiamiFrom GameMaker to Game Baker - Porting Hotline Miami
From GameMaker to Game Baker - Porting Hotline Miami
 
Safer IoT using functional language
Safer IoT using functional languageSafer IoT using functional language
Safer IoT using functional language
 
You got database in my cloud!
You got database  in my cloud!You got database  in my cloud!
You got database in my cloud!
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Coffeescript: Fad or Useful Tool? Socal Code Camp Fullerton 2015

  • 1. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 Install:Install: REPL in your Terminal:REPL in your Terminal: REPL in the Browser:REPL in the Browser: coffeescript.orgcoffeescript.org Or [ 'TRY COFFEESCRIPT' tab ] WELCOME . . .WELCOME . . .
  • 2. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Introduction ● Setup & Installation, Terminal & Browser REPL, Coffeescript Compilation ● Coffeescript / Javascript Similarities & Differences ● Syntax Details ● Javascript vs Coffeescript Debate & Controversy ● ECMAscript5 / ECMAscript6 Changes & Coffeescript ● Code Examples ● Resources OutlineOutline
  • 3. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● An alternate syntax for Javascript ● Compiles to Javascript ● Inspired by Ruby and Python syntax ● Strives to be simpler and cleaner than JS ● Mostly a strict one-to-one correspondence with JS ● A few extra features ● Classes – "pseudo-classical object orientation" ● Author: Jeremy Ashkenas ● Current version: 1.9.1 IntroductionIntroduction
  • 4. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 Requires up-to-date, stable versions of NodeJS and NPM (Node Package Manager). Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation Install:Install:
  • 5. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 After installing Coffeescript, an REPL (an environment for entering and evaluating Coffeescript statements) is available in your terminal by entering either of these commands: Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation REPLREPL Or An REPL is also available in your browser at coffeescript.org . Select the TRY COFFEESCRIPT tab.
  • 6. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 To manually compile a Coffeescript file, enter coffee -c (or coffee --compile) in the terminal, followed by the filename (and path if in a subdirectory or other directory). Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation Compiling CoffeescriptCompiling Coffeescript
  • 7. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 The most common option for the compile command is -b or --bare. This option will disable the function wrapper which is placed around the Javascript program by default. Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation Compiling CoffeescriptCompiling Coffeescript
  • 8. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 Many frameworks and development environments will compile Coffeescript files automatically. Examples: ● Ruby on Rails, Sinatra: compile Coffeescript files automatically when serving an HTTP request for the corresponding Javascript file. ● Many text editors, such as Sublime, and many IDEs, can automatically compile Coffeescript files every time they are saved. ● Workflow managers such as Grunt can be configured to automatically compile Coffeescript files as they are saved. Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation Compiling CoffeescriptCompiling Coffeescript
  • 9. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 The Coffeescript compiler also has a -w or --watch option to automatically compile Coffeescript files as they are saved. Setup & Installation, Terminal & Browser REPL,Setup & Installation, Terminal & Browser REPL, Coffeescript CompilationCoffeescript Compilation Compiling CoffeescriptCompiling Coffeescript
  • 10. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● With Coffeescript, you're still operating in the Javascript environment ● Slogan: "It's just Javascript" ● Use the same data types, standard classes and libraries Coffeescript / Javascript Similarities & DifferencesCoffeescript / Javascript Similarities & Differences DifferencesDifferences SimilaritiesSimilarities ● Different syntax ● Blocks and statements marked by whitespace instead of { } and ; ● No var, function or prototype keywords ● Coffeescript insulates you from certain Javascript snags ● Coffeescript must be compiled to JS but may be done automatically
  • 11. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ** Syntax Details **** Syntax Details ** ● Statements and blocks ● Variables ● Operators and aliases ● String Interpolation ● Arrays ● Array ranges ● Comprehensions ● Objects ● Functions ● Fat arrows ● If – else ● Prefix and postfix conditionals ● Switch ● Classes
  • 12. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● You don't use semicolons ; . ● Indentation is significant, and used to delimit blocks of multiple lines of code. ● Indentation delimits blocks of code instead of curly braces { } . ● You don't need an end keyword at the end of a block, as in Ruby. ** Syntax Details **** Syntax Details ** Statements and blocksStatements and blocks
  • 13. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● No var keyword. ● Variables are not global unless you use them somewhere in the global scope. ● Coffeescript generates var statements and places them at the top of the scope where they are used. ● This scheme precludes "shadowing". You cannot use the same variable name within nested scopes and expect them to represent different variables. ** Syntax Details **** Syntax Details ** VariablesVariables
  • 14. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Either the keyword is or a double equal sign == will be compiled to a Javascript triple equal sign === . Coffeescript will not compile anything into the Javascript double equal sign == . ● The keywords and, or and not can be substituted for && , || and ! , respectively. ** Syntax Details **** Syntax Details ** Operators and aliasesOperators and aliases
  • 15. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● If you place an expression inside of curly brackets preceeded by a sharp sign #{ } , and this construct is inside a string literal within a pair of quote marks, then when the string is accessed, it will evaluate the expression in the brackets and insert its equivalent string into the containing string. ** Syntax Details **** Syntax Details ** String interpolationString interpolation
  • 16. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Similar syntax to Javascript. ● Multi-line array literals are allowed. ● Commas at end of lines are optional with multi-line syntax. ** Syntax Details **** Syntax Details ** ArraysArrays
  • 17. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● A 'begin' and 'end' number inside the square brackets for an array can be used to designate a slice of the array. ** Syntax Details **** Syntax Details ** Array rangesArray ranges
  • 18. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Both inline and multi-line syntax. ● Commas not needed for multi-line form. ● Quotes around key names are optional in object literals. ** Syntax Details **** Syntax Details ** ObjectsObjects
  • 19. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Use for iterations instead of loops. ● Syntax for array iterations is for item in array . ● Syntax for iterations over the keys of an object is for key, value of object . ● Just use one parameter to iterate over the keys only. ** Syntax Details **** Syntax Details ** ComprehensionsComprehensions
  • 20. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● No function keyword. ● Use arrow -> instead. ● Function block is delimited with indentation. ● Place parameters in parentheses like in Javascript. ● When calling a function, parentheses are optional. ** Syntax Details **** Syntax Details ** FunctionsFunctions
  • 21. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Defining a function with a "fat arrow" => instead of a "skinny arrow" -> will bind the value of the this keyword to the 'this' for the function in which it's defined. This will prevent the 'this' reference from being diverted to another scope by, for example, a function callback. ● In Coffeescript, the 'at' symbol @ is a convenient shortcut/alias for the this keyword. ** Syntax Details **** Syntax Details ** Fat arrowsFat arrows
  • 22. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● if - else statements are written without parentheses or curly brackets. ● Blocks are delimited by indentation. ● Use if and then for a single line if statement. Do not use the then keyword when using the multi-line syntax. ** Syntax Details **** Syntax Details ** If - elseIf - else
  • 23. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 A one-line if statement can be written by appending the if clause after the executable statement. ** Syntax Details **** Syntax Details ** Prefix and postfix conditionalsPrefix and postfix conditionals
  • 24. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Use when and else keywords instead of case and default. ● Don't need to end each 'case' with a break keyword. ● Blocks for individual cases are delimited by indentation. ** Syntax Details **** Syntax Details ** SwitchSwitch
  • 25. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● "Pseudo-classical object orientation". ● Use class keyword to begin a class definition. ● Use indentation as a delimiter, indenting everything after the class keyword. ** Syntax Details **** Syntax Details ** ClassesClasses ● Classes can extend other classes. Use the extends keyword.
  • 26. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Create a new instance of the class with the new keyword, followed by a space and then the class name, appended with a list of constructor parameters in parentheses, if required. ** Syntax Details **** Syntax Details ** ClassesClasses
  • 27. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ** Syntax Details **** Syntax Details ** ClassesClasses ● Define class instance methods with a colon : instead of an equal sign = . ● Constructor methods must be named constructor(). ● Use the this alias @ to designate instance attributes. ● Use the this alias @ when referencing an instance method from elsewhere within the class.
  • 28. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Syntax issues – semicolons ● Syntax issues – curly brackets vs whitespace ● Compilation ● Learning curve and adoption Javascript vs Coffeescript Debate & ControversyJavascript vs Coffeescript Debate & Controversy
  • 29. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 Array iterator methods: ● forEach() ● map() ● filter() ● every() ● some() ● reduce() ● reduceRight() ● indexOf() ● lastIndexOf() ECMAscript5 / ECMAscript6 Changes & CoffeescriptECMAscript5 / ECMAscript6 Changes & Coffeescript ECMAscript5ECMAscript5
  • 30. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 ● Classes: class, constructor and extends keywords ● Modules: import and export keywords ● Arrows: Can use => instead of function for anonymous functions ● String Interpolation: Enclose expression to coerce into a string with $(), enclose entire string expression with backtick `` characters instead of quotes ECMAscript5 / ECMAscript6 Changes & CoffeescriptECMAscript5 / ECMAscript6 Changes & Coffeescript ECMAscript6ECMAscript6
  • 31. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 github.com/jrschmidt/grandpa-basic-1980github.com/jrschmidt/grandpa-basic-1980 Code ExamplesCode Examples
  • 32. Coffeescript:Coffeescript: Worthless Fad orWorthless Fad or Useful Tool?Useful Tool? John R SchmidtJohn R Schmidt SoCal Code CampSoCal Code Camp Fullerton 2015Fullerton 2015 OFFICIAL WEBSITE: coffeescript.org SLIDES: Coffeescript: No really, it's just Javascript by Brian Mann slideshare.net/backbonerails/coffeescript-no Feb 2014 BOOK: CoffeeScript: Accelerated JavaScript Development Trevor Burnham – Pragmatic Programmers 2ndEd Feb 2015 VIDEO: Jeremy Ashkenas: A Cup of CoffeeScript youtube.com/watch?v=A5Sg04IEkvk 2010/2013 VIDEO: CoffeeScript: The Good Parts by Azat Mardan youtube.com/watch?v=WX5Y6Dq1OHE Aug 2014 ResourcesResources