News for hackers. Stuff that matters.
Re:A success story for Haxe by brianberns on Friday March 13, 2015 @11:37PM (#9201467)
The sample program on the Haxe main page demonstrates a complete misunderstanding of the value of dictionaries. Not exactly inspiring one to learn more.

    class Test {
      static function main() {
        var people = [
          "Elizabeth" => "Programming",
          "Joel" => "Design"
        ];
        for (name in people.keys()) {
          var job = people[name];
          trace('$name does $job for a living!');
        }
      }
    }
Re:A success story for Haxe by jdonaldson on Saturday March 14, 2015 @12:14AM (#9201527)
It's a simple example, but it's showing a lot of nice things.

The "people" instance is using anonymous syntax for a Map type. Haxe's Map types are actually abstract types: http://haxe.org/manual/types-abstract.html. I doubt many developers are familiar with this type of feature.

For instance, here's a "packed array" implementation that lets me store an array of integers in a fraction of the space usually needed for a standard array type: https://github.com/jdonaldson/packhx Abstract types let me use the same api that standard arrays use (including array accessors), even if the underlying runtime implementation is completely different.

The other nice things going on in the example is the simple for loop using an iterator, and the nice string interpolation. Granted, this is nothing super sophisticated, but it's great to have these same features across all the targets that Haxe supports.

Re:A success story for Haxe by joneil on Saturday March 14, 2015 @09:19AM (#9202526)
Haha, I was the one that wrote that example for the homepage. It was never meant to be a comment on the ideal data structures for different use cases. Rather it's just there to give developers a taste of the syntax: there's more semicolons and brackets than Python, less explicit typing than Java.

If you have an example of a better code sample for introducing language syntax, I'd love to see it so I can learn from it.

Re:A success story for Haxe by brianberns on Wednesday March 25, 2015 @12:18AM (#9261261)
My point is that if you're going to iterate through the entire dictionary, there should be a way to get full key-value pairs, so you don't have to look up the value for each key. There's no need to change the entire example. Something like this:

        for ((name, job) in people) {
          trace('$name does $job for a living!');
        }