web oriented universal language

Strands™ Summer 2008 haXe Project Announcement

Posted on 2008-04-29 by Franco Ponticelli in General

We are pleased to announce that Strands.com, a provider of social recommendation technologies, is hosting a student open source coding summer project, focused solely on haXe.

You can find more information on the project and how to participate on this announcement page: http://labs.strands.com/Summer2008HaxeProject/

This project has very similar funding and terms to the 'other' open source summer coding project that you may be aware of. However, it is designed solely for current students in the haXe community.

Strands.com will provide funding for not more than 3 students, for not more than 2 projects. To see a list of suggested projects, please see the announcement page. We will prioritize the listed projects as well as those that get the most student interest.

Currently, the project involves myself (a PhD candidate at the Indiana University School of Informatics), and Franco Ponticelli, notable haXe community member and co-author of the recent book on haXe. We look forward to making this summer the "Summer of haXe"!

If you have any questions about the project, please use this mailing list.

Best,

- Justin and Franco

Physaxe : haXe Physics Engine

Posted on 2008-04-06 by Nicolas Cannasse in General

I'm please to announce the 1.0 Release of Physaxe : a haXe 2D Rigid Body Physics Engine heavily optimized for Flash Player 9.

A demo is always better than words, so you can play the following SWF, use 1-8 keys to change the demo and click to fire a block :

(if you want to check the real CPU spent by physaxe, you can press the 'D' key to disable drawing, which takes most of the CPU)

See the Physaxe project page for more informations.

Enjoy !

Nicolas

Towards haXe 2.0

Posted on 2008-03-24 by Nicolas Cannasse in General

After 1.19 Release, I'm planning to roll up several changes in the language and its libraries, with some of them which might require some code changes. This is done in order to "cleanup" features and libraries that were added incrementally during the past 2 years of development and prepare the language for future additional platforms.

All these changes can be discussed on the mailing list and you're welcome to submit your own there as well.

The list of changes are available on the haXe Wiki.

Flash 9 Optimizations

Posted on 2008-03-08 by Nicolas Cannasse in General

The new virtual machine than can run AS3 and haXe languages in the Flash Player 9 brings a lot of additional speed for many common operations. This is very good news for developers since you can now write more complex algorithms in Flash such as 3D or Physics engine with correct performances.

However, there are still several pitfalls since some operations are pretty slow when compared to others :

  • creating a new object is slow : if you have a lot of short living objects that are allocated frequently, it's better to create a "Allocator" class that will store a list of reusable instances.
  • calling a lot of methods is not so fast : when you have some small methods that are very often called, it's often faster to rewrite the code directly in the calling method. For example, given a Point class :
    var p = new Point(4,5);
    // the expression :
    p.add(p2.x,p2.y);
    // would be faster if written directly :
    p.x += p2.x;
    p.y += p2.y;
    
    This process of replacing a method call with the actual code is called inlining, and haXe compiler has support for an inline keyword so that you can define which methods will be automatically inlined by the compiler when called (see haXe Documentation)
  • accessing static vars and functions is slow : you can either create an instance and use instance variables and methods instead of static ones or use the haXe inline keyword.
  • reading and writing into arrays is slow : this is very bad news. The only native data structure of Flash9 is painfully slow. It's a lot faster to access a typed instance field than to access an array. One way to optimize that is to create your own linked list :
    // a cell containing instances of MyClass
    class MyCell {
        public var elt : MyClass;
        public var next : MyCell;
        public function new( elt, next ) {
            this.elt = elt;
            this.next = next;
        }
    }
    // a list managing a chained list of MyCell
    class MyList {
        public var head : MyCell;
        public function new() {
            head = null;
        }
        // add an element at the beginning of the list 
        public function add( elt : MyClass ) {
            head = new Cell(elt,head);
        }
    }
    // You can then iterate on your list this way :
    var l : MyCell = mylist.head;
    while( l != null ) {
        var e : MyClass = l.elt;
        // ... do something with e ...
        l = l.next;
    }
    

First, the good news : using a typed linked list is 2 to 3 times faster than using an Array ! (if you want to test that in AS3, make sure to type all your variables, the code here is entirely typed thanks to haXe type-inference)

Now the bad news : you will have a define a MyList and MyCell class for each different class you want to store. So you have to copy/paste the same code again and again. Using Dynamic (or * in AS3) is out of question here since that would require a cast for each reading of an element that would be slow again.

Current haXe users know that the language have typed arrays in order to ensure type-safety. You can also define your own parametrized classes, so it's pretty easy to write-once the following :

// a cell containing any instance
class Cell<T> {
    public var elt : T;
    public var next : Cell<T>;
    public function new( elt, next ) {
        this.elt = elt;
        this.next = next;
    }
}
// a list managing a chained list of cells
class List<T> {
    public var head : Cell<T>;
    public function new() {
        head = null;
    }
    // add an element at the beginning of the list 
    public function add( elt : T ) {
        head = new Cell(elt,head);
    }
}

The problem is that typed-parameters are only used for compile-time type checking. Since the Flash9 VM does not support them, they disappear in the compiled code and are then replaced by the AS3 * type, so all your accesses to the List will need an additional cast... we're back the problem.

Thinking about the problem, I was thinking then : why not let the compiler generate a specific version of the List class for each parameter it will be used ? This way it would generate a List_User and a Cell_User class that can contains User instances, and so on.... automatically at compile time !

That approach was proved quite easy to implement, so it works now in haXe. In order to let the user choose between speed and codesize, the default haXe List class has not been modified, but instead a new haxe.FastList class has been added (accessible when compiling for Flash9).

In order to create your own "generic" classes that will be specialized when used with a type parameter, you can simply have your class implements the haxe.rtti.Generic interface.

Both haxe.FastList and haxe.rtti.Generic are now on haXe CVS (you can download and compile it to give it a try) and will be part of the 1.19 Release.

Conclusion : there's a lot of painful things to do when you want to optimize your code to run fast on Flash9. But thanks to haXe inline and generics, it's a lot more easy to do while keeping your code clean and maintainable.

Professional haXe and Neko Book

Posted on 2008-01-31 by Lee McColl Sylvester in General

The Wrox Professional haXe and Neko book by Lee McColl Sylvester and Franco Ponticelli, is now available for purchase from Amazon.

This book, having taken a year to write, is the combined efforts of Lee and Franco, with much help from Nicolas Cannasse, Daniel Fischer, Ritchie Turner (aka. Blackdog) and the team at Wiley & Sons. The book is a comprehensive overview of the haXe language and Neko virtual machine, sporting 648 pages of infomation. The chapters include:

PART I

  • Chapter 1: Introducing haXe
  • Chapter 2: Installing and Using haXe and Neko
  • Chapter 3: Learning the Basics
  • Chapter 4: Controlling the Flow of Information
  • Chapter 5: Delving into Object-Oriented Programming
  • Chapter 6: Organizing Your Code
  • Chapter 7: When Things Go Wrong

PART II - Server Side, JavaScript, and Flash, Oh My!

  • Chapter 8: Cross Platform Tools
  • Chapter 9: Building Websites in haXe
  • Chapter 10: Seperating Design Using Templates
  • Chapter 11: Performing Server-Side Trickery
  • Chapter 12: Building Interactive Content With Flash
  • Chapter 13: Replacing the Need for an IDE
  • Chapter 14: More Interactive Content with JavaScript
  • Chapter 15: Putting It All Together with haXe Remoting

PART III - Extending The Possibilities

  • Chapter 16: haXe Advanced Topics
  • Chapter 17: Desktop Applications with Neko
  • Chapter 18: Desktop Flash with SWHX
  • Chapter 19: Multimedia with Neko
  • Chapter 20: Extending haXe with C/C++
  • Appendix A: Semantic HTML

Please, if you do buy it, Franco and I would be grateful if you could use our associates links. We don't get much for the sales of the book, and to be honest, that's not why we wrote it, but if we can buy ourselves books from the sale of this one, then we get some reward for our hard work:

You'll have to wait about 10 days longer from the .co.uk link, as it is released ten days later, but that should make the delivery date about the same if you live in the UK.

Again, thanks in advance to those that buy it, and we hope you enjoy the book. As always, stay tuned to the list for haXe and Neko updates.

Calendar

May 2008
Mo Tu We Th Fr Sa Su
<< >>
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Misc

 
Haxe Powered Rss flux Valid XHTML 1.0 Valid CSS