Where and for what is haXe used?

Well, it seems like you are interested in haXe, and we will soon write our first haXe program together. However, before doing that, you may be wondering who uses haXe, and for what kind of tasks or applications it is used.

Where is haXe used?

haXe is actually used in several places. There are some companies that are using it for their professional work. That does not necessarily mean that they use haXe for their whole work; many companies that uses haXe are indeed going through a move towards haXe, or are simply using haXe for some parts of their work and do not necessarily plan to use it more. Even though haXe is not difficult to learn, it is really difficult to change the technologies a company is using.

There are also several open source projects that use haXe. For example, haXe libraries are written in haXe, and many of these are open source.

There are also hobbyists, or students, who are learning and using haXe. Learning haXe and participating in the community helps in learning many programming concepts (the community sometime talks about some people that are not in haXe at the moment but may be added later, for example.) It is also advantageous to learn something other than what is usually taught in schools.

What is haXe used for?

haXe is used for a lot of different things. At first, it is mainly used for making website-related things. This can be web-based tools (such as a mind-mapping program), or games in Flash or JavaScript.

It can also be used for writing desktop applications. Some people have been using a great combination of Flash and Neko to achieve this. However, this is not the only way to do things! You can write command-line applications that will not need Flash, or you can use or write another graphic library.

One can write servers with haXe too. The framework provides some helpers to do that. One impressive example of a server written in haXe is haXeVideo available at http://code.google.com/p/haxevideo/. This is a video server that allows live streaming of videos to Flash clients. Although it is not ready for production at the moment, it is a great start and can put you on the right track.

haXe can be used to directly target mobile devices such as iOS and Android, but it's also possible to use it to write web-based applications targeting mobile devices. Nowadays, many phones have a browser that is able to run JavaScript code. There are also some runtimes that allow one to create applications based on web technologies running on mobile devices.

One language to rule them all

If you have already been developing web applications, then you certainly know how painful it is to switch from, say, PHP, to JavaScript and Flash. In fact, even the most basic things can become painful in such a scheme. For example, switching from one language to another can make adding objects to an array or a list difficult and error-prone while developing web applications.

haXe is there to unify the development of the three main parts of web applications; with it, you will be able to write your server-code, your client-code, and your rich-client code with only one language: haXe. However, it is also possible to use it with other languages.

Object-oriented programming

haXe also brings the oriented-object programming concept with the well-known principle of classes to platforms that do not natively support it. This way, you will be able to create a program using the well-known concepts of classes, types (also with generics), enums, and others even if this program runs in the browser.

haXe versions

haXe's version 1 was made available in 2006, but since 2008, we have been using haXe 2. haXe 2 brought several changes both to the language and to the library. Therefore, this is the version we're going to learn together. When you get familiar with haXe, you will understand that haXe is a very fast evolving language and sometimes, even minor versions may bring some important new features. This allows haXe to bring you more and more power as time goes by, but keep in mind that it may sometime (although this is very rare) break your code.

Note that in this book, we are using haXe Version 2.0.6.

At the beginning of haXe, only the Flash and Neko targets were available. This means that haXe code could only be compiled to be run on Flash (AVM indeed, as that is the name of the virtual machine) or on the Neko virtual machine. Some weeks after, the already-announced Javascript target made its appearance, but with limited support (particularly in regards to closures). Nowadays, the Javascript target is really mature and can be used without any major problems. Later on, new versions of Flash were supported. All of these targets and the base of the compiler were due to Nicolas Cannasse from Motion-Twin. He is the genius mind behind haXe.

The first target that had been created by someone else was the PHP target. Franco Ponticelli released it hoping that people would experience with it, as it is much easier to get a PHP host than a Neko host. Since then, the PHP target has evolved and has become very mature and may be used in a production environment.

In 2009, the C++ generator was developed by Hugh Sanderson. This target creates C++ code from your haXe code. You can then compile it with a C++ compiler, such as GCC. Beware that it is still under heavy work. Hugh Sanderson is famous in the haXe community for making possible the development of games for iPhone and Android with haXe.

Some people are working on implementing other targets. At the time of writing this book, we know about a Java target in development by yours truly.

Also, note that even though it is not really a target on its own, it is now possible to use the Javascript target to write applications that are to be run on NodeJS.

haXe and the new models of web applications

Nowadays, we see many new and exciting web applications that are using a model that is quite new where the following three parts are communicating together:

  1. The server.
  2. The client-side with Flash.
  3. The client-side with Javascript.

It is usually quite difficult to make those three parts communicate because each language has its own structure. With haXe, as you are using the same language everywhere, you do not have to switch between structures.

In addition, haXe has support for its own remoting; this is a way to allow you to communicate between several haXe applications as seamlessly as possible through the network or between a JavaScript and a Flash application running in the same page.

Some people have also implemented haXeRemoting in other languages making it possible to communicate with applications written in those languages.

haXe as an universal language

Nowadays, haXe can be used in order to do much more than just assisting with web applications. It can now be used in order to create, for example, applications for the iPhone or Android devices or for desktops.

In order to do so, a part of the Flash API has been implemented and made available when targeting C++. This way, it is possible to use this well-known API to create games on Windows, Linux, MacOSX, iPhone, and Android.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.68