0

haXe is cool

I heard of the computer programming language haXe a long time ago when I discovered Neko.  At the time I wasn't at all interested in haXe, it was the lower-level Neko language that intrigued me.  I even set out to create a new web framework in Neko.  I made good progress before my busy life got the better of me.  This semester, as you know I'm taking Advanced Programming Languages and had to learn OCaml as part of the course.  I really like the power and expressivity of the language, but some reason it hasn't caught on mainstream.  My guess is the somewhat difficult syntax and the fact that it's a mostly functional language.  

Well, fast forward to now.  I had to learn haXe this week for work. (Not the first place I expected to learn a new language since we're still using PHP 4).  Adobe had released Flash 10 a little while ago and our file uploader that depended on a flash backend stopped working.  It has something to do with a new security policy and fact that we were using a javascript event to trigger the file dialog.  To make a long story short, I soon found that I would have to repimplement the entire button in flash to get around the new security rules.  I have never done much in flash except for some dabbling in SwishMax some years ago.  I first found Nicholas Canassee's mtasc compiler.  It seemed like a perfect fit.  Here was a small, fast open-source actionscript compiler that could allow me to write flash in my no-ide-and-no-propietary-stuff manner.  After a couple days of overtime trying to get to it work I finally realized that he hadn't finished the compiler and it didn't support event listeners.  These are needed to give the user any kind of feedback when uploading files so I had to scrap that project.

Then I noticed that haXe was the solution I needed.  The reason he had not finished mtasc was because he was working on haXe and it was better.  One day of overtime later I had converted my ActionScript 2.0 upload button to a small haXe program that targeted Flash 9.  It worked like a charm.  Now I decided to give the language a little more serious thought.  I went online and found there was one book on the language and it could be had cheap on Amazon, so I ordered the book.  While ordering the book my wife asked me how long haXe had been around, I didnt know, so I looked it up on Wikipedia.  While there I noticed that it has many of the features from Ocaml that I love.  The cool type system, and pattern matching are two of the important features.  Also being based on ECMA script it felt at home since I spend a lot of time programming in Javscript and love the language, but hate most implementations.

My wife even went on to correct part of the article for haXe in Wikipedia.  Keep in mind she's not a programmer or even a techie and here she is caring enough about some obscure programming language to bother correcting minor parts of the entry.  That's a cool wife!

I look forward to learning more about this seemingly perfect language after my book come in in a week and I finish 4 more school projects.

3

Roundabout the Game

One day, a few weeks ago, I had decided that it was about time I started making web games again.  Computers are faster, the choice of technology is greater and my skills are better.  Also as an added bonus, this years game conference awarded top scores to simple, non graphic intensive games.This shows a shift in gaming taste to focus on gameplay and not intense graphics.  That's good news for me since I only make simple games that focus on unique gameplay.

So I decided that I'l play with technology at the same time as making the game.  I had originally planned on making the game in SVG/Javascript, but hit a performance issue once I started doing full screen scrolling.  I develop the game on my eeePC since it has a small screen and a slow processor.   That way I'm forced to keep the performance in mind.  After hitting a wall with SVG and not being able to speed up the engine without drasticly cutting features out of my game, I rewrote the engine to use canvas tag.  This was a little faster in Firefox, worked in more browsers, but for some strange reason, crawled to a halt in Safari.  Part of it might be because my Safari was in a WindowsXP guest inside of a VirtualBox hosted by Ubuntu Linux.  My friend on a real windows box didn't have the same problem.
The current released version of the game is at http://roundabout.creationix.com/.  It is under massive development untill I'm able to release my level editor.  For the moment you can play the first three test levels to see some features of the game.  I doubt it runs at all in Internet Explorer since that browser doesn't support the canvas tag.  I even included the js hack that tries to convert it to vml, but still no good with my tests.
Test it out, tell me what you think.  And if anyone is interested in developing levels, let me know and I'll send you a link with an admin account when that part is done.

2

Hello world!

Well, I've finally done it and installed a blog.  In this blog I have a place to publish my thoughts and accomplishments for anyone who may be interested.  Also I plan to start some discussions about Software Engineering topics and projects as I post about them.

First let's hear from my favorite scripting languages:

#/usr/bin/python
print "Hello World\n"
#/usr/bin/ruby
puts "Hello World\n"
#/usr/bin/php
echo "Hello World\n";

Then a blast from the past. I programmed in QBasic for roughly 6 years. I've since forgotten it all. I even had to look up the syntax for comments.

' This is Q-Basic
CLS
phrase$ = "Hello World!"
LOCATE 13,40
PRINT phrase$
END

And now two of my favorite compiled languages:

(* This is OCaml *)
print_endline "Hello world!";;
// This is C#
using System;
class MyClass
{
  static void Main()
  {
    Console.WriteLine("Hello World!");
  }
}
2

The LaQs are on the way.

I finally ordered the LaQ construction toys I've been wanting.  I can't wait till they get here.  They're made by a Japanese company so they're hard to find.  My favorite online store www.constructiontoys.com is going out of business and their remaining stock is all half off.  Here are some picture of the kits I ordered.

Penguin

1

OCaml Oh My…

I'm starting my graduate classes finally.  My school has this cool program called Fast Track where you're allowed to take graduate level classes as an undergrad student and get dual credit.  I finally qualified for the program and signed up for as many classes as I could fit in.

One of those classes is one called Advanced Programming Languages.  It's so advanced that I had to get permission from the Associate Dean.  He said no so I went to the teacher and he said he's out of town but it's ok with him as long as I learn OCaml before the class.  So I went back to the Associate Dean and he finally signed for my class.  Now I'm going through OCaml tutorials.  Having a strong background in procedural programming, it's very different for me.  I've done some work in the past with XSLT (a functional language written in xml, yuck) and used the functional parts of PHP, Ruby, and Python.  I've even tried to read the Neko compiler which is self hosting written in NekoML. NekoML is a variant of OCaml, but a little easier.  Well I couldn't read much of it.

Here is my first OCaml program.  It uses nested functions and takes advantage of the rec keyword to control function namespacing:

let range a b =
  let rec range a b accum =
    if b < a then accum
    else range a (b - 1) (b :: accum)
  in
  range a b [];;
 
range 1 10;;

Pretty cool huh.  I ran it in the interactive interpreter like I do in my scripting languages. The range function defined in the outer can't be used till after it's definition since I didn't include the rec keyword. The inner one uses rec and an extra accumulator so that it will be compiled with tail recursion.  Otherwise my range function would be very limited in what it could do without causing stack overflow.  Once the inner range function is defined, the outer one, which is just a wrapper, can call it directly.