A Bug's Life!

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?


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!


Training newbies : How a whole corporation may forget to go through simple things

Hello,

As you may know, I’ve been a trainer in a well-known IT school in France. I’m now back in it as a student, and although I’ve been mainly teaching Linux Technologies, I’m still really interested in everything that’s related to training.

That’s when a student who’s a freshman told me something : in their C class they were asked to display a rotating cube in SDL. Ok, that may seem a classic to most of us, experienced developers, but that’s where the problem is.

The fact is, they had no course on SDL, and although there are several resources about it online, they are only in their first year, most of them had little to no-knowledge about programming before, and they are French people (meaning that English is not their native language with all the problem that can cause, especially to people not already really familiar with our vocabulary).

By the way, on top of the difficulties related to the SDL, there are the difficulties related to the mathematics.

We have forgotten that all these layers, that are of little difficulty on their own (each one), when added, represent a big difficulty for newbies.

So, I suggest that we should add a step, a step that’s pretty natural because let’s remember something : years before the apparition of 3D Games, we had 2D Games, and 2D is far easier to manage because most people interested in computers are used to working on a screen which is 2D, also, they are generally just out from High-School where you do work in 2D most of the time.

Also, it’s way easier for the mind to think in 2D (just because that’s one variable less and also because it allows to forget about the project problem).

So, what’s a good exercise, providing all the difficulties (such as managing rotations with some trigonometry) while avoiding 3D?

It’s simple and that’s an application we’re all used to see : a clock!

With a clock, you have to draw and you also have to manage rotations. So, that’s a good idea.

That was just a thought that I wanted to share.

See you soon!

Note : Here, I use the word “newbie” just in the sense of “new-comers”, nothing negative as it is sometimes implied on the Web.


The Internet Explorer Nightmare

Hello!

Today at work, I had to create one of these things I don’t like because I think they’re not really useable but the client wants… Today the “I don’t like that” thing is… a vertical news scroller!

So, it’s a pretty simple thing indeed… a block (typically a rectangle) and inside it some content going from bottom to top until everything has been seen then you put everything at the bottom and go up again….

So, apart from the script that makes things go up (and it’s a simple one once you remember about scrollHeight and offsetHeight), you have to set the overflow property of the container to “hidden” in the CSS.

Straight-forward and simple ? Well… not exactly! That’s working on Firefox, Chrome, Safari and IE8 but not on IE7 nor IE6…

In fact, IE7 and IE6 behave like if overflow wasn’t set to hidden… it seems it has something to do with hasLayout but hasLayout was “true”…

In fact, for the overflow property to work correctly, you should set the “position” property to “relative” (and you can leave top and left to 0, so that doesn’t mess with the position). And… TADA! It works!

Pretty easy… once you know it!

Too bad we still have to deal with those stupidities!

See you soon!

(by the way, sorry, still no podcast, but I promised it will come, and it will… I’m still waiting for some graphics :))


The Podcast is coming

Hi,

Just a quick note to tell everyone that I’m sorry for being late to publish the first Podcast. You know, it’s always the same thing : quite a lot of work, a bit ill (nothing bad, don’t worry), and the need to sleep… Not to say that the Olympic Games haven’t been of any help. ;)

I hope to be posting it tomorrow evening!

See you soon!



Announcing the new haXe podcast serie.



Why you shouldn’t put a contact form on your website.

Hello,

Today at work I’ve been prospecting for a (web|communication)-agency. I came across several ones and I had to contact them.

That’s a pretty obvious and straight-forward thing. Well, at least it should be, because most of the time when calling you have difficulties to get to speak to someone who can help you (certainly because they are at a meeting).

But my point today is about contact forms included on websites. I came across several, and although that may seem pretty good for you because you can ask for some informations and have them for sure and also have them in a formatted way.

But the real problem is that mails sent by this way are not stored in your customer’s mailbox, making it difficult for him to track the conversation and have a trace of the contact.

So, one may argue that contact forms are also pretty good because they are a straightforward way to contact you without opening a mail application (yes some people do not have things correctly configured for mailto: links). That’s true, but that should never be the only possibility, nor should it “hide” your mail address.

I suggest to give both options and to present them with an equivalent sizing (i.e. : they should occupy the same space). Also, if the user choose to use the form, add a checkbox so that you can send him a copy of the mail for its archive.

That may seem a bit stupid, but trust me, even if I had a spreadsheet to follow my contacts, I sometime forgot to update it (I had some other things in mind) and the pain that comes with that can be avoided quite easily. And never forget : if you help me with my work, you’re already half way to get selected! ;-)

Any thoughts?

See you later!


Bought a netbook : Acer Aspire One

Hello,

Some weeks ago I bought a netbook. The reason was pretty simple : I have a macbook that I use both for my personal use and for school. So I have MacOSX on it, but being a web-developer and an IT student, I sometimes need to be able to do some testing on Windows. Add to that the fact that I’m the proud ashamed owner of Windows Mobile based phone and that I want to be able to develop for it and you’ve got the picture!

So I decided to buy a Acer Aspire One D250. It comes loaded with Windows 7 Starter Edition and Android.

First, let’s have a word about Windows 7 Starter Edition : it’s just a joke. Excuse me, but preventing the user from changing the wallpaper isn’t anything feature-based. Not being able to create a bridge between two network interfaces is much more one… so I upgraded to Windows 7 Professional as provided by MSDNAA account.

But enough talking about Windows.

So, what happened when I unboxed my netbook?

I turned it on and at my surprise, Windows was booting without me being presented with any LILO/GRUB screen to allow me to boot Androïd. I found out that there’s a Windows utility to “install” (or allow booting of) Androïd. That’s a bit strange but anyhow…

So, next thing, when you buy a computer loaded with an OS, you’re wanting your “restore CD”. Well, years before, they used to give it. Now you have to burn them…

But since a 10.1” wide-screen netbook, there’s no DVD-Drive. That’s normal… But the utility to create the discs won’t let me create an ISO image… no, it just keeps saying that it can’t create the restore discs since there’s no burner… You know they could at least let you create an image for you to put on an usb-drive or burn from another system, but no. Period.

Later I found a workaround by using the demo version of a software to create a virtual burner…

I also have to say that there’s a restore partition on the hard drive but come on, how well does it work if you screw up your partitions table or accidentally write on it? You’re just fucked.

That’s what makes you feel quite bad about a system that should be 100% embedded… it’s not well integrated and that made me feel like “We have a generic software to create restore discs, we just ship it on all computers”, period.

Tomorrow, I’m gonna talk about the Androïd system that comes with it.

See you online!



I suggest you watch this video in HD to be able to read the code.

haXe Podcast 1 : Getting started with haXe/Neko.

There’s sound ; turn up the volume if needed.

Also, sorry for not editing it more, I will certainly work on it again and replace it with a new and better version.



Some news about haXe/Java

Hello,

Sometimes ago I’ve been talking about haXe/Java and show-casing it with a very simple Android Application sample.

Obviously, the generated buzz has been quite huge (compared to our community’s size) but I’ve been surprised that no one contacted me to participate in the project.

Some days after, some events happened that prevented me to continue most of my personal work (you know, those kind of things that makes you wonder if you were right at the first place).

Well, that was before.

About a month ago, I’ve been contacted by several persons, some representing companies, some individuals. Some are offering sponsorship and some are offering help.

This is a great thing and I’m now quite excited about continuing the work on haXe/Java since I see people are really interested in it.

So, I’m going to write about some “problems” I have to face while writing this Java target.

haXe Void against Java Void

As you certainly know, haXe has a type Void. When you’re using it, it means that your function may return nothing (using a simple “return;” for example) or return null.

Java can also declare methods as void, but in such a case they can only “return;”. Although this may seem to be a very small difference it’s a quite important one.

The first idea would be to create a type “haXe.Void” to be used when we generate the Java code : that would actually allow us to return null.

But it has a drawback : Java makes an extensive use of method overriding (you can see that in the Android API for example), and a method declared as void in Java wouldn’t be overridable from haXe.

The second possibility would be to type as “void” and transform “return null;” to a simple “return;”. This is a possibility but I’m actually not feeling very comfortable with it because I feel like it may change the behavior of something at some time… (maybe throwing some problems when doing a == null).

Third possibility : let the developer choose the behavior to use by compiling Void to haXe.Void and having a java.Void that compiles to java’s native void.

What do you think about it ?


12
To Tumblr, Love Metalab