02 8 / 2011
haXe 2: Beginner’s Guide book is published and on sale!
(Note that this is the mail I’ve sent to the haXe mailing-list. More to come about my feelings on the writing of the book in the next few days.)
Hello everyone!
This mail is a bit unusual and I hope everyone will be happy to read the news inside.
It is my great pleasure to announce that my new and first book “haXe 2: Beginner’s Guide” is now available!As the name implies, this is a guide to beginners.
Writing a book is not an easy task, but I enjoyed it and hope you will enjoy reading this book too.
As you may know, I’ve been coding with haXe since the very beginning and I have to say I have always enjoyed this language.Now, haXe is evolving pretty fast and more and more people and companies, with various ranges of skills, are using it to do lots of things such as website editors, games, or any other kind of applications.
haXe is gaining momentum and this book is a proof of it. By the way, I’d really like to thank Packt Publishing for their support. Now, let’s show them how much we appreciate it!
In the next weeks and months, haXe is certainly going to break the limits and extend to new horizons. With the new CPP target and NME, haXe will certainly be able to fill the gap that has been created by several OS’ and devices and I can’t express how excited I am because of this!
I’d like to thank each and everyone of you, newcomers and people who have been there from the beginning. You make it so exciting to be part of this community! Now, I’d like to thank Nicolas for sure, but also Franco. Thanks for always being OK to have a talk and share your ideas! Hugh for writing the CPP target although we had very few exchanges. Thanks to all the reviewers!
Also, thanks to Pimm Hogeling for writing the foreword of the book.
Thanks to everyone who has been participating in this community and let’s continue to make haXe and its eco-system better and better.
You can find the book here: http://www.packtpub.com/haxe-2-beginners-guide/book
Regards,
Benjamin Dasnois
05 4 / 2010
Going untyped or Dynamic : the difference and how important it will be.
Hello,
Most of my fellow haXe developers may think that untyped is just like a block of code where everything acts like Dynamic. Well, that’s false, and I’m gonna explain in this post what both of these things really are.
So first, untyped. Untyped is a keyword that acts on a block of code and basically, it just tells the compiler to get out of your way when it comes to typing. One could see that as temporarily deactivating the typing sub-system.
On the other hand, there’s the Dynamic type. Dynamic really *is* a type, it’s just that it has a special behavior. It’s behavior is that it has an infinite number of fields (accessible in reading) and all of these fields also are Dynamic. That’s the basic thing of Dynamics, after that there are all the other things such as implementing Dynamic but I’m not gonna describe everything here. The language reference is there to do that.
No, if I talk about it today, it’s because I’m pretty sure many haXe programmers have been using untyped blocks in their code instead of Dynamics (maybe because it’s easier to just write “untyped”), and that worked since most of the platforms we have in the official compiler today are dynamic.
So, this code will certainly work on JS/Flash/Neko and even PHP :
var s : String;
s = “Hello”;
untyped s.something = 12;
But here, what we do want to achieve is really a Dynamic behavior (although that’s quite stupid to declare the variable as String, but that’s just for the sake of the example). So it would be better to write :
var s : String;
s = “Hello”;
var d : Dynamic;
d = s;
d.something = 12;
Well, we could have done it with a bit less lines but I wanted to keep things crystal clear. Here, we will achieve the same behavior as in the first example, but instead of just switching the typing system to off, we ask it to take care of making the code work. In the platforms we have in the compiler at the moment, that’s not a problem because they are dynamic (not C indeed but it’s pretty young in the compiler).
Now, the Java target is coming, and although I can’t say if it will ever make it into the official distribution I do hope so. And since Java is really a static language, one will have to use the Dynamic type as that will ensure that the compiler will take care of doing all the magic things for you.
Want more explanations? Have any questions or comment?
Permalink 4 notes
29 3 / 2010
haXe/Java is still there and it’s closer than ever!
Hello,
Yes! That’s true! I’m still working on haXe/Java (to give you some news about the project I’m alone on it again because David had to leave due to free-time lacking, and some of my fellow haxers have offered to help so I know I can ask them if I have problems).
Not only am I still working on it, but I’m really back to it! You know, I was kind of disappointed because I had lots of difficulties with the Dynamic’s, but recently, someone brought a question to the mailing-list and Nicolas came to clarify things about what Dynamic’s are supposed to do or not. To put it shortly, Dynamic’s can be considered almost as “untyped” (still I suggest you read the thread).
Well, what that means is that I simplified my view on (and what I expected from) Dynamic’s and that’s going to make it way easier to implement them. Unfortunately, that also certainly means that java will be the platform with the poorer support for Dynamic’s.
Dynamic’s were needed in order to be able to implement anonymous objects (and typedefs up to some point).
So, now, haXe/Java is really closer to us than it has ever been!
See you soon!
18 10 / 2009
Typing functions in haXe
Hello everyone,
There’s been an interesting question on the haXe’s mailing-list regarding typing of functions. No matter what the question really was, it made me think I should write something about functions typing in haXe because it may not be really obvious when you’re not used to it.
So, Functions are typed.
Yes, functions are, like any other object, typed. Their type depends on two thing :
- The arguments taken by the function
- The return type of the function (the type of the object that’s going to be returned)
So a function written like this :
public function m1(arg1 : String, arg2 : String) : Int
would be typed as taking as first parameter a String, as second parameter a String, and returning an Int. We note this like that :
String->String->Int
More fun.
What’s even funnier, is that a function can take a function as a parameter, it can also return a function. So, how would we write that? It’s easy, just put parenthesis around things! Now, let’s imagine a function m1 that wants as first parameter a String, as second argument a function taking a String and returning an Int, and that returns an Int. We would write it like that :
function m1(arg1 : String, arg2 : String->Int) : Int;
And this would be typed as :
String->(String->Int)->Int.
Imagine m2, which takes the same parameters as m1 but returns a function taking an Int, an Int and returning a String. We could write it like this :
function m2(arg1 : String, arg2 : String->Int) : Int->Int->String;
This would be typed as :
String->(String->Int)->(Int->Int->String)
And you can embed things more and more… but pay attention to the parenthesis! ;)
08 8 / 2009
Why haXe has so much potential (not about syntax and expressiveness)
Hello,
Nicolas Cannasse has written about why Action Script 3 is a failure, so I’m going to write about why I think haXe has a great potential to become the language of the future.
haXe is about Web Development
Well seriously… Everyone is aware of that, first targets of haXe were Flash, Neko (was mostly used for server-side at the time) and JavaScript. That’s the basic definition of “web development” : develop a web-site and a web-site is composed of three parts :
- The server side.
- The Rich client side (Flash)
- The “less rich” client side (JavaScript)
So, it’s obvious that haXe is made for web-development, since it even has what was needed : Remoting. Flash and JS can communicate with the server very easily, and Flash and JS can communicate together as easily. So everything is there.
Everything is about Web Development
Let’s be honest, nowadays, everything is about the web : most of the applications on your desktop connect to the web or have something to do with the web (even composing a document means that you certainly want to email it or publish it…) and even better : desktop applications are now built using web technologies (think about AIR and Titanium) and this is possible up to a certain point.
What haXe provides
haXe is able to target JS and Flash ; that means it can be used to develop desktop applications easily (by targeting AIR for example). That allows the developer to use one language to develop web-sites and desktop applications with technologies that he knows, and more over, the developer can use the haXe framework to easily make the desktop application communicate with the web-application. And think about it : we are doing more and more mobile applications, and what are their purpose? Allowing us to stay “connected” everywhere. That means that what we have on our computers, on our mobile phones are indeed web-applications, or at least, extensions to web-applications.
And I guess that’s why haXe (apart from the syntax and all related things) has so much potential : it’s been thought for the web and it is still being thought for it.
29 7 / 2009
I finally implemented Generics!
Hello everyone,
I just wanted to write to let you know that the haXe/Java generator (the one used in the haXe on Android video) now supports generics.
It may seem obvious but that was not that easy to implement.
haXe supports constraints on generics, but those constraints won’t be written in the generated output.
I hope there aren’t too many bugs and by the way, I’m getting more confident with OCaml (even though my style may be ugly at the moment!)
Stay tuned!