Welcome to Gaia! :: View User's Journal | Gaia Journals

 
 

View User's Journal

clammytavern4265 Journal
clammytavern4265 Personal Journal
Improving a Programmer's Efficiency by Developing with Haxe
In the past, the question "which language do you program in?" had a simple answer. Usually a choice of : C; C++; Visual Basic. However, today the answer is slightly more complicated. Today the answer would be "it depends on the project that I'm working on today" or even "what time is it?". Gone are the days when a programmer could specialize in a single programming language and for them to expect to only know that.

...

Take, for example, a simple web application. A simple web application will require the use of at least Javascript on the client machine. If any server functionality is required (for example setting up an AJAX application that uses a MySQL database) then a knowledge of PHP is required as well (so that's two programming languages).

Of course, no web application is worth its salt if it can't be turned into an iPhone app. So, even for a simple application, at least 3 programming languages are needed (or maybe 3 programmers). And, of course, someone will want some Flash adding into the mix.

The answer to all of this is not to hire half a dozen programmers - it is to learn a new programming language, Just one - Haxe.

Haxe (which is pronounced 'hex') is free, open source and (most importantly) multi-platform. This means that it is possible for a programmer to write using a single, standardized language that currently targets:

C++FlashJavascriptNeko Virtual MachinePHPAnd work is currently under way to support:The question is, therefore, can a single code file be written that may be compiled into any of the languages. The simple answer is - yes.

The starting point for any Haxe application is a simple text file. In this case the application with output the words "Hello World":

class Hello

static function main()

trace("Hello World !" wink ;

It is immediately obvious from this code that Haxe is an object-oriented language and that the file (which should be saved as "Hello.hx") contains the definition for a class. The class itself must contain at least one function - the obligatory "main".

That code can now be compiled into the target language by creating a file containing the compilation instructions. This file requires a .hxml suffix (for example php_compile.hxml) and contains the instructions detailing:

the compilation language and output destinationthe class to be compiledSo, to compile the PHP "Hello" class into a directory named www the file contents would read:

-php www

-main Hello

Compilation is then a matter of double clicking on the .hxml file. The end result would be a PHP file that would load and run an instance of the class.

The format for a C++ compilation is similar to PHP:

-cpp cpp

-main Hello

And the end result would be a C++ executable.

Finally a Javascript file can be created from the code:

-js test.js

-main Test

Once great advantage at this point is that the compilation process identifies any problems with the code without the Javascript and PHP files needing to be loaded into a web browser. The application developer can now concentrate on the design rather than the semantics. And they can now do it more quickly and more efficiently.





 
 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum