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

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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