SlideShare a Scribd company logo
1 of 19
Download to read offline
Haxe: What Makes It Cool
 Dev Ideas, episode 1


Brought to you by Chicken Wing Software
Hello, my name is...
 Eddie Sullivan
Founder, Chicken Wing Software
www.chickenwingsw.com
www.devideas.com
See also: UX Ideas
Haxe
     ≈
    JavaScript
               +   static types
                               +   Java-style classes
                                                        +
    type inference
                    +  algebraic types
www.haxe.org
Compiles to JavaScript, Flash, NekoVM, PHP, C++
Standard library
                + platform libs
                                +  RPC
Haxe is like JavaScript
(really ActionScript)
 Similar syntax and keywords (like function)
 Entire DOM-tree available
 Flash API available (no timeline)
 Can compile to .js file
 Can compile to .swf file
 Closures
 Regular expressions
DOM example
                             Example:
// Change an HTML element to a random color.
static function changeToRandomColor(id)
{
    var el = Lib.document.getElementById(id);
    var color = '#' + StringTools.hex(Std.random(0x1000000), 6);
    el.style.backgroundColor = color;
}
Haxe is like... Java
                             Example:
import js.Lib;
import StringTools;

class HaxeExample {
    // Required "main" function - called at startup.
    static function main() { }

    // Change an HTML element to a random color.
    static function changeToRandomColor(id)
    {
        var el = Lib.document.getElementById(id);
        var color = '#' + StringTools.hex(Std.random(0x1000000), 6);
        el.style.backgroundColor = color;
    }
}
Similarities to Java
 Java-style classes & inheritance
 Statically & strongly typed
 Single inheritance & interfaces
 Can compile to NekoVM, PHP, or C++
Some familiar keywords
      if/else          do/while
      true/false       new
      var              this
      try/catch        finally
      return           switch*
      enum*            for*

* Different behavior
Haxe is like... ML

 Type inference
     Types with less typing
 var x = "hello"; // x is a String
 var y:String;    // y is also a String
 x = 3;          // ERROR!

 Algebraic types (With enum and switch)
Haxe's enums
Defining the enum:
enum Command {
  sit;
  speak(word:String);
  move(x:Int, y:Int);
}
// ... inside a function
var cmd = Command.speak("Arf!");
Haxe's switch
Using the enum:
// ... inside a function:
switch (cmd) {
  case sit:
    this.sitting = true;
    case speak(text):
      trace(text);
    case move(x, y):
      this.location = new Point(x, y);
}
Haxe's for
More like "foreach" in C#
// ... inside a function:

var names = ['Ed', 'Fred', 'Ned', 'Ted'];
// Could have written:
// var names:Array<String> = ...

for(name in names) {
  trace("Hello " + name);
}
Other features
 Local functions/closures
 Type parameters (generics)
 Exceptions
 Dynamic & untyped values
 "Batteries Included"
      Remoting
     XML parsing/validation
     Sandboxing
     ...and much more!
Flash example (part 1)
import flash.display.Sprite;
import caurina.transitions.Tweener;
class Happy extends Sprite
{
    public function new(size:Float = 50)
    {
        super();
        graphics.lineStyle(1.0, 0x000000);
        graphics.beginFill(0xffff00);
        graphics.drawCircle(0, 0, size);
        graphics.endFill();
        graphics.moveTo(size * 0.3, size * 0.3);
        graphics.curveTo(0, size * 0.75, -size * 0.3, size * 0.3);
        graphics.drawCircle(-size * 0.225, -size * 0.3, size * 0.1);
        graphics.drawCircle(size * 0.225, -size * 0.3, size * 0.1);
    }
    // class continues on next slide...
Flash example (part 2)
   // ... continued from last slide
   public function start()
   {
       var that = this;
       Tweener.addTween(this, { rotation:360, time:2,
                                transition:"linear",
                                onComplete: start } );
       Tweener.addTween(this, { scaleX:.75, scaleY:.75, time:1 });
       Tweener.addTween(this, { scaleX:1, scaleY:1, time:1,
                                delay:1 } );
   }

    public function stop()
    {
        Tweener.removeTweens(this);
    }
} // End of class Happy
Flash example (part 3)
import flash.external.ExternalInterface;
import flash.Lib;

class Main
{
  static var happy = new Happy(25.0);
    static function main()
    {
      happy.x = 50;
      happy.y = 50;
      Lib.current.addChild(happy);
      ExternalInterface.addCallback("startHappy", happy.start);
      ExternalInterface.addCallback("stopHappy", happy.stop);
      happy.start();
    }
}
Flash example (part 4)
What it looks like:


Stop   -   Start
The Haxe Community
 Mailing list
 Forum
 Wiki
 Libraries / haxelib (lib.haxe.org)
 FlashDevelop
 More...
Thank you!
Chicken Wing Software - chickenwingsw.com
Dev Ideas - devideas.com
Follow me on Twitter: @eddieSullivan
Sign up for the newsletter to hear what's coming next
UX Ideas - uxideas.com

More Related Content

What's hot

Scala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language ScalaScala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language Scala
Jan Willem Tulp
 
10. session 10 loops and arrays
10. session 10   loops and arrays10. session 10   loops and arrays
10. session 10 loops and arrays
Phúc Đỗ
 

What's hot (20)

Go Java, Go!
Go Java, Go!Go Java, Go!
Go Java, Go!
 
... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)
 
Go Java, Go!
Go Java, Go!Go Java, Go!
Go Java, Go!
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
Scala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language ScalaScala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language Scala
 
Love Twig
Love TwigLove Twig
Love Twig
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev Assistant
 
PHP for hacks
PHP for hacksPHP for hacks
PHP for hacks
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Roles
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
Using PHP
Using PHPUsing PHP
Using PHP
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
 
Presentation on php string function part-1
Presentation on php string function part-1Presentation on php string function part-1
Presentation on php string function part-1
 
Sa
SaSa
Sa
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
 
From Java To Clojure (English version)
From Java To Clojure (English version)From Java To Clojure (English version)
From Java To Clojure (English version)
 
10. session 10 loops and arrays
10. session 10   loops and arrays10. session 10   loops and arrays
10. session 10 loops and arrays
 

Viewers also liked

Chicken Wing Dissection
Chicken Wing DissectionChicken Wing Dissection
Chicken Wing Dissection
chuckiecalsado
 
Ch10 muscle tissue
Ch10 muscle tissueCh10 muscle tissue
Ch10 muscle tissue
KemUnited
 
Chickenwingdissection
ChickenwingdissectionChickenwingdissection
Chickenwingdissection
msali_aphs
 
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGESUNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
Patricia Castro
 
Chicken wing dissection
Chicken wing dissectionChicken wing dissection
Chicken wing dissection
Jenny Dixon
 
Lesson 2 tendons, ligaments, cartilage and joints
Lesson 2   tendons, ligaments, cartilage and jointsLesson 2   tendons, ligaments, cartilage and joints
Lesson 2 tendons, ligaments, cartilage and joints
nmcquade
 

Viewers also liked (13)

Chicken wing prac hands 0n
Chicken wing prac hands 0nChicken wing prac hands 0n
Chicken wing prac hands 0n
 
Chicken Wing Dissection
Chicken Wing DissectionChicken Wing Dissection
Chicken Wing Dissection
 
Grade11 life sciences practical task
Grade11 life sciences practical taskGrade11 life sciences practical task
Grade11 life sciences practical task
 
Chicken Leg Dissection PowerPoint, Muscular System, Skeletal System,
Chicken Leg Dissection PowerPoint, Muscular System, Skeletal System,Chicken Leg Dissection PowerPoint, Muscular System, Skeletal System,
Chicken Leg Dissection PowerPoint, Muscular System, Skeletal System,
 
Ch10 muscle tissue
Ch10 muscle tissueCh10 muscle tissue
Ch10 muscle tissue
 
Life science grade 10
Life science grade 10Life science grade 10
Life science grade 10
 
Chickenwingdissection
ChickenwingdissectionChickenwingdissection
Chickenwingdissection
 
Exemplars tests, practicals & projects
Exemplars tests, practicals & projectsExemplars tests, practicals & projects
Exemplars tests, practicals & projects
 
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGESUNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
 
Revision
RevisionRevision
Revision
 
Chicken wing dissection
Chicken wing dissectionChicken wing dissection
Chicken wing dissection
 
Lesson 2 tendons, ligaments, cartilage and joints
Lesson 2   tendons, ligaments, cartilage and jointsLesson 2   tendons, ligaments, cartilage and joints
Lesson 2 tendons, ligaments, cartilage and joints
 
Chicken Anatomy & Physiology
Chicken Anatomy & Physiology Chicken Anatomy & Physiology
Chicken Anatomy & Physiology
 

Similar to Haxe: What Makes It Cool

Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
elliando dias
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 

Similar to Haxe: What Makes It Cool (20)

Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorov
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
JavaScript Lessons 2023
JavaScript Lessons 2023JavaScript Lessons 2023
JavaScript Lessons 2023
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilder
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Clean Code
Clean CodeClean Code
Clean Code
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Haxe: What Makes It Cool

  • 1. Haxe: What Makes It Cool Dev Ideas, episode 1 Brought to you by Chicken Wing Software
  • 2. Hello, my name is... Eddie Sullivan Founder, Chicken Wing Software www.chickenwingsw.com www.devideas.com See also: UX Ideas
  • 3. Haxe ≈ JavaScript + static types + Java-style classes + type inference + algebraic types www.haxe.org Compiles to JavaScript, Flash, NekoVM, PHP, C++ Standard library + platform libs + RPC
  • 4. Haxe is like JavaScript (really ActionScript) Similar syntax and keywords (like function) Entire DOM-tree available Flash API available (no timeline) Can compile to .js file Can compile to .swf file Closures Regular expressions
  • 5. DOM example Example: // Change an HTML element to a random color. static function changeToRandomColor(id) { var el = Lib.document.getElementById(id); var color = '#' + StringTools.hex(Std.random(0x1000000), 6); el.style.backgroundColor = color; }
  • 6. Haxe is like... Java Example: import js.Lib; import StringTools; class HaxeExample { // Required "main" function - called at startup. static function main() { } // Change an HTML element to a random color. static function changeToRandomColor(id) { var el = Lib.document.getElementById(id); var color = '#' + StringTools.hex(Std.random(0x1000000), 6); el.style.backgroundColor = color; } }
  • 7. Similarities to Java Java-style classes & inheritance Statically & strongly typed Single inheritance & interfaces Can compile to NekoVM, PHP, or C++
  • 8. Some familiar keywords if/else do/while true/false new var this try/catch finally return switch* enum* for* * Different behavior
  • 9. Haxe is like... ML Type inference Types with less typing var x = "hello"; // x is a String var y:String; // y is also a String x = 3; // ERROR! Algebraic types (With enum and switch)
  • 10. Haxe's enums Defining the enum: enum Command { sit; speak(word:String); move(x:Int, y:Int); } // ... inside a function var cmd = Command.speak("Arf!");
  • 11. Haxe's switch Using the enum: // ... inside a function: switch (cmd) { case sit: this.sitting = true; case speak(text): trace(text); case move(x, y): this.location = new Point(x, y); }
  • 12. Haxe's for More like "foreach" in C# // ... inside a function: var names = ['Ed', 'Fred', 'Ned', 'Ted']; // Could have written: // var names:Array<String> = ... for(name in names) { trace("Hello " + name); }
  • 13. Other features Local functions/closures Type parameters (generics) Exceptions Dynamic & untyped values "Batteries Included" Remoting XML parsing/validation Sandboxing ...and much more!
  • 14. Flash example (part 1) import flash.display.Sprite; import caurina.transitions.Tweener; class Happy extends Sprite { public function new(size:Float = 50) { super(); graphics.lineStyle(1.0, 0x000000); graphics.beginFill(0xffff00); graphics.drawCircle(0, 0, size); graphics.endFill(); graphics.moveTo(size * 0.3, size * 0.3); graphics.curveTo(0, size * 0.75, -size * 0.3, size * 0.3); graphics.drawCircle(-size * 0.225, -size * 0.3, size * 0.1); graphics.drawCircle(size * 0.225, -size * 0.3, size * 0.1); } // class continues on next slide...
  • 15. Flash example (part 2) // ... continued from last slide public function start() { var that = this; Tweener.addTween(this, { rotation:360, time:2, transition:"linear", onComplete: start } ); Tweener.addTween(this, { scaleX:.75, scaleY:.75, time:1 }); Tweener.addTween(this, { scaleX:1, scaleY:1, time:1, delay:1 } ); } public function stop() { Tweener.removeTweens(this); } } // End of class Happy
  • 16. Flash example (part 3) import flash.external.ExternalInterface; import flash.Lib; class Main { static var happy = new Happy(25.0); static function main() { happy.x = 50; happy.y = 50; Lib.current.addChild(happy); ExternalInterface.addCallback("startHappy", happy.start); ExternalInterface.addCallback("stopHappy", happy.stop); happy.start(); } }
  • 17. Flash example (part 4) What it looks like: Stop - Start
  • 18. The Haxe Community Mailing list Forum Wiki Libraries / haxelib (lib.haxe.org) FlashDevelop More...
  • 19. Thank you! Chicken Wing Software - chickenwingsw.com Dev Ideas - devideas.com Follow me on Twitter: @eddieSullivan Sign up for the newsletter to hear what's coming next UX Ideas - uxideas.com