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

... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)James Titcumb
 
Scala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language ScalaScala: Devnology - Learn A Language Scala
Scala: Devnology - Learn A Language ScalaJan Willem Tulp
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev AssistantDave Cross
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboardsDenis Ristic
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Rolessartak
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?FITC
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java DevelopersMichael Galpin
 
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-1Mysoftheaven (BD) Ltd.
 
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 3Mohd Harris Ahmad Jaal
 
From Java To Clojure (English version)
From Java To Clojure (English version)From Java To Clojure (English version)
From Java To Clojure (English version)Kent Ohashi
 
10. session 10 loops and arrays
10. session 10   loops and arrays10. session 10   loops and arrays
10. session 10 loops and arraysPhú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 Dissectionchuckiecalsado
 
Grade11 life sciences practical task
Grade11 life sciences practical taskGrade11 life sciences practical task
Grade11 life sciences practical taskMbongiseni Ndaba
 
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,www.sciencepowerpoint.com
 
Ch10 muscle tissue
Ch10 muscle tissueCh10 muscle tissue
Ch10 muscle tissueKemUnited
 
Chickenwingdissection
ChickenwingdissectionChickenwingdissection
Chickenwingdissectionmsali_aphs
 
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGESUNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGES
UNIT 3 JOINTS-LIGAMENTS-TENDONS & CARTILAGESPatricia Castro
 
Chicken wing dissection
Chicken wing dissectionChicken wing dissection
Chicken wing dissectionJenny 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 jointsnmcquade
 

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

Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorovSergei Egorov
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lispelliando dias
 
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...Domenic Denicola
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.pptJamers2
 
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 SwingBuilderAndres Almiray
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation JavascriptRamesh Nair
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerDavid Muñoz Díaz
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptAnjan Banda
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application FrameworkJady Yang
 

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

Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Recently uploaded (20)

Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

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