Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active March 24, 2025 06:15
Show Gist options
  • Save diegopacheco/c33ef1d8e41ba376e240358ce78ebd3d to your computer and use it in GitHub Desktop.
Save diegopacheco/c33ef1d8e41ba376e240358ce78ebd3d to your computer and use it in GitHub Desktop.

Revisions

  1. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -164,6 +164,9 @@ abstract MyAbstract(String) {

    #### 7 - Building to Target Langs

    Haxe allow you to build to several target langs such as JS, C++, C#, Java, JVM, Python, Lua, PHP, Flash.
    Here are some examples

    Java
    ```bash
    haxe --main Main --jvm Main.jar
  2. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -162,6 +162,22 @@ abstract MyAbstract(String) {
    }
    ```

    #### 7 - Building to Target Langs

    Java
    ```bash
    haxe --main Main --jvm Main.jar
    ```

    JS
    ```bash
    haxe --main Main --js Main.js
    ```

    Python
    ```bash
    haxe --main Main --python main.py
    ```

    ## Other Tiny Essays

  3. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 22 additions and 2 deletions.
    24 changes: 22 additions & 2 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -136,10 +136,30 @@ class Main {
    }
    ```

    #### 6 - ???
    #### 6 - Operator Overloading

    TODO
    Haxe support Operator overloading like Scala.
    ```haxe
    abstract MyAbstract(String) {
    public inline function new(s:String) {
    this = s;
    }
    @:op(A * B)
    public function repeat(rhs:Int):MyAbstract {
    var s:StringBuf = new StringBuf();
    for (i in 0...rhs)
    s.add(this);
    return new MyAbstract(s.toString());
    }
    }
    class Main {
    static public function main() {
    var a = new MyAbstract("foo");
    trace(a * 3); // foofoofoo
    }
    }
    ```


  4. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 25 additions and 2 deletions.
    27 changes: 25 additions & 2 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -107,10 +107,33 @@ class Main {
    }
    ```

    #### 5 - ???
    #### 5 - STD Lib support for Unit Tests

    TODO
    I love languages that have good STD libs so it minimize how many external libs you need to use.
    Haxe has Unit Tests support, built-in, IMHO a bit verbose but still cool.
    ```haxe
    import utest.Runner;
    import utest.ui.Report;
    import utest.Test;
    import utest.Assert;
    class MyTestCase extends Test {
    public function testBasic() {
    Assert.equals("A", "A");
    }
    }
    class Main {
    public static function main() {
    //the long way
    var runner = new Runner();
    runner.addCase(new MyTestCase());
    Report.create(runner);
    runner.run();
    //the short way in case you don't need to handle any specifics
    utest.UTest.run([new MyTestCase()]);
    }
    }
    ```

    #### 6 - ???
  5. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -91,10 +91,20 @@ class Main {
    }
    ```

    #### 4 - ???
    #### 4 - Maps

    TODO
    Like any decent language, there are collections, here is how we use Maps.
    ```haxe
    class Main {
    static public function main() {
    var capitals = ["Brazil" => "Brasilia", "USA" => "Washington", "Argentina" => "Buenos Aires"];
    trace(capitals);
    trace(capitals["Brazil"]);
    for (country in capitals.keys()) {
    trace(country + " => " + capitals[country]);
    }
    }
    }
    ```

    #### 5 - ???
  6. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -72,10 +72,23 @@ class Main {
    }
    ```

    #### 3 - ???
    #### 3 - Pattern Matcher

    TODO
    Like Haskell, Scala or Rust - Haxe has Pattern matcher.
    ```haxe
    class Main {
    static public function main() {
    var myArray = [7, 6];
    var s = switch (myArray) {
    case [a, b] if (b > a):
    b + ">" + a;
    case [a, b]:
    b + "<=" + a;
    case _: "found something else";
    }
    trace(s); // 6<=7
    }
    }
    ```

    #### 4 - ???
  7. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -51,8 +51,6 @@ class Main {
    #### 2 - Generics

    Like Java, Scala or Kotlin, Haxe has support for generics.

    TODO
    ```haxe
    @:generic
    class MyValue<T> {
  8. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -50,8 +50,28 @@ class Main {

    #### 2 - Generics

    Like Java, Scala or Kotlin, Haxe has support for generics.

    TODO
    ```haxe
    @:generic
    class MyValue<T> {
    public var value:T;
    public function new(value:T) {
    this.value = value;
    }
    }
    class Main {
    static public function main() {
    var a = new MyValue<String>("Hello");
    trace(a);
    var b = new MyValue<Int>(42);
    trace(b);
    }
    }
    ```

    #### 3 - ???
  9. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,37 @@ class Main {
    }
    ```

    #### 2 - Generics

    TODO
    ```haxe
    ```

    #### 3 - ???

    TODO
    ```haxe
    ```

    #### 4 - ???

    TODO
    ```haxe
    ```

    #### 5 - ???

    TODO
    ```haxe
    ```

    #### 6 - ???

    TODO
    ```haxe
    ```


    ## Other Tiny Essays

    * Rust: https://gist.github.com/diegopacheco/4b7dfeb781ad3455ae2a6b090d9deaa7
  10. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 22 additions and 3 deletions.
    25 changes: 22 additions & 3 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -22,11 +22,30 @@ I love to learn new programing languages, it help to open the mind to new possib

    My POCs with Haxe: https://github.com/diegopacheco/haxe-playground <br/>

    #### 1 - ???

    ???
    #### 1 - OOP Support

    Haxe has classes, constructors and several OOP features like Java.
    ```haxe
    class Point {
    var x:Int;
    var y:Int;
    public function new(x, y) {
    this.x = x;
    this.y = y;
    }
    public function toString() {
    return "Point(" + x + "," + y + ")";
    }
    }
    class Main {
    static public function main() {
    var p = new Point(10, 20);
    trace(p.toString());
    }
    }
    ```

    ## Other Tiny Essays
  11. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,8 @@ I love to learn new programing languages, it help to open the mind to new possib

    * Cool
    * Fun
    * Syntax feels like JavaScript
    * You will see slighly different outputs depending on the target language

    ### Show me the code

  12. diegopacheco revised this gist Mar 24, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,10 @@ I love to learn new programing languages, it help to open the mind to new possib

    * Multi-plataform
    * Good for Games
    * High-level strictly-typed
    * Can build cross-platform applications targeting JS, C++, C#, Java, JVM, Python, Lua, PHP, Flash

    ### My Feelings (20-Jan-2025 haxe )
    ### My Feelings (12-Jan-2025 haxe 4.3.6)

    * Cool
    * Fun
  13. diegopacheco created this gist Mar 24, 2025.
    44 changes: 44 additions & 0 deletions haxe-tiny-essay.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    ## Haxe Lang Tiny Essay

    created: 23.MAR.2025

    I love to learn new programing languages, it help to open the mind to new possibilities and compare different approaches. For instance, I learned Ruby and Scala in 2010, Clojure and Haskell in 2011, Go in 2015, Kotlin 2016, Rust in 2018 and Idris, TypeScript in 2019, 2020 Pandemic strike did a bunch of pocs but not with new langs(crazy year), Zig in 2021, 2022(coding in lots of langs but nothing new) - in 2023 I'm learning Nim and V. Learn at least one lang per year. This post is not complain, it's just to share some toughts, notes and impressions.

    ### Why Haxe

    * Multi-plataform
    * Good for Games

    ### My Feelings (20-Jan-2025 haxe )

    * Cool
    * Fun

    ### Show me the code

    My POCs with Haxe: https://github.com/diegopacheco/haxe-playground <br/>

    #### 1 - ???

    ???

    ```haxe
    ```

    ## Other Tiny Essays

    * Rust: https://gist.github.com/diegopacheco/4b7dfeb781ad3455ae2a6b090d9deaa7
    * Scala: https://gist.github.com/diegopacheco/1b5df4287dd1ce4276631fd630267311
    * Zig: https://gist.github.com/diegopacheco/7d7c8110db68352d58a18b0e3e3c2bb0
    * Kotlin: https://gist.github.com/diegopacheco/f6beabf1451cfe1ec2dc89a19a78fdc5
    * Clojure: https://gist.github.com/diegopacheco/9453877378f007e8903a359f298a0afa
    * Haskell: https://gist.github.com/diegopacheco/057087dc7ae236bdd0700014a31c88ef
    * Nim Lang: https://gist.github.com/diegopacheco/0fb84d881e2423147d9cb6f8619bf473
    * V Lang: https://gist.github.com/diegopacheco/3d0b176eb83e569da582a0770209e22f
    * Gleam: https://gist.github.com/diegopacheco/2fdb5be0446ccb8f07d02105a46aab75
    * Misc https://gist.github.com/diegopacheco/49329d726d0e2bd1c709ba1187a92c97

    #### About me

    * https://diegopacheco.github.io/
    * http://diego-pacheco.blogspot.com/