So I was facing a dilema regarding containers I'd use in my app.
HaXe standard library provides a basic set of containers suitable for any basic use : you have Array, List and Hash. As you know haXe is a cross-targetting language and compiler, meaning that what you code can be compiled to a wide variety of plateforms, sometimes by generating code for another compiler (like g++ for C++ or Xcode for ObjC) to compile. But you should also know that what works well on C++ doesn't work as well on Flash or Php, each plateform has it's particularities.
So what does that mean for containers.
Well the most explicit example is the Flash Array. Native Flash Arrays are in fact dynamic objects in wich each index is a property. That means accessing an index of Array in Flash is slower than calculating the position of the octets in memory that represents your data like you'll do in C.
When you create an Array in haXe and target Flash, it create a Native Flash Array, so try to avoid that in critical routines.
Take the haXe List container now. It's a basic chained list, so each element you put in the list is put in an listElem, a small object that has a pointer to you element and another one to the next listElem on the list. But in List, listElems are Arrays, wich is great for almost every haXe target except Flash.
A solution to List is FastList, haXe FastList is a chained-list implementation using typed objects for listElems, therefor it's optimised for Flash, but not at all optimised for other plateforms where array is the best implementation for listElems.
A wild library appears !
ListTools is an haXe library that provides a new List implementation : SugarList.
SugarList is a compile-time resolved type that binds either to an Array based List or a kind of FastList depending of your target, that's the beauty of haXe !
Unfortunatly this library was not maintained to the latest haXe compiler version.
I could make the few changes requested for this update but right now I'm focused in getting something working, so I'll drop the flash target until I do make those changes.
Sunday, September 25, 2011
Saturday, September 24, 2011
Facebook OpenGraph trial
I put my project asside last night to test the new Facebook functionalities.
If you didn't followed Facebook actuality or don't care, this thursday in Palo Alto Mark Zuckerberg presented Timeline during the f8 conference.
Timeline is the new profile that will be enabled for Facebook users in the next 3 weeks.
One of the most interesting stuff that will appear with Timeline is the ability for applications to track actions of the user and put them on their profile. It's the evolution of the controversed 'like' button. Now you cannot only 'like' something you can interact with something, for example you can tag the fact that you read a book, listen a song or watch a film.
I'll not discuss the ethic of this new feature, I'm not a big Facebook fan, but technically it's interesting as you can create meaningfull publications for the users by connecting nodes of the Facebook social graph, and more important, create new nodes.
One other very interesting stuff Facebook added recently is, thanks to a partnership with cloud deployment plateform Heroku, the ability for a developer to quickly go live at no cost by signing in to a Heroku account and getting a free server either running PHP, Ruby, Python or Node.js with a 5Mo database. Heroku uses git to retreive and post your application so you get both version control and automated publishing.
Thanks to this you're up and running in 5 minutes and you can focus on your code, really neat.
If you're interested in how to create such application, I'll tell here how I get into my first OpenGraph app called codeTracker, that will allow users to tell on their profile how much time they spent coding and what they are coding.
If you didn't followed Facebook actuality or don't care, this thursday in Palo Alto Mark Zuckerberg presented Timeline during the f8 conference.
Timeline is the new profile that will be enabled for Facebook users in the next 3 weeks.
One of the most interesting stuff that will appear with Timeline is the ability for applications to track actions of the user and put them on their profile. It's the evolution of the controversed 'like' button. Now you cannot only 'like' something you can interact with something, for example you can tag the fact that you read a book, listen a song or watch a film.
I'll not discuss the ethic of this new feature, I'm not a big Facebook fan, but technically it's interesting as you can create meaningfull publications for the users by connecting nodes of the Facebook social graph, and more important, create new nodes.
One other very interesting stuff Facebook added recently is, thanks to a partnership with cloud deployment plateform Heroku, the ability for a developer to quickly go live at no cost by signing in to a Heroku account and getting a free server either running PHP, Ruby, Python or Node.js with a 5Mo database. Heroku uses git to retreive and post your application so you get both version control and automated publishing.
Thanks to this you're up and running in 5 minutes and you can focus on your code, really neat.
If you're interested in how to create such application, I'll tell here how I get into my first OpenGraph app called codeTracker, that will allow users to tell on their profile how much time they spent coding and what they are coding.
Sunday, September 18, 2011
A Mermaid called Better
From the basic concept to the technical implementation, I'm always tempted by this Mermaid called Better.
You can see three examples on the previous bills, at concept phase I wander if I could extend my first and fairly good idea to a better, widder project.
While reviewing the technologies in my possesion I spend a lot of time trying to get to some technical specificity that won't even be relevant.
And as I think on my model I spend ages trying to fit a square in a cricle, juste because a clean inheritence tree is theoritically better.
In my work at the games company, we have this little phrase on the wall over the project followup board that says "Done is better than perfect". It means that, following the rule of 80/20, you'll take 20 minutes to get a 80% satisfying solution to your problem wich is surely enought, but 80 minutes to reach the other 20% at the expense of many other problems needing a solution.
You'd probably put this maxime somewhere at your workplace, or maybe a ceiling cat ;P
You can see three examples on the previous bills, at concept phase I wander if I could extend my first and fairly good idea to a better, widder project.
While reviewing the technologies in my possesion I spend a lot of time trying to get to some technical specificity that won't even be relevant.
And as I think on my model I spend ages trying to fit a square in a cricle, juste because a clean inheritence tree is theoritically better.
In my work at the games company, we have this little phrase on the wall over the project followup board that says "Done is better than perfect". It means that, following the rule of 80/20, you'll take 20 minutes to get a 80% satisfying solution to your problem wich is surely enought, but 80 minutes to reach the other 20% at the expense of many other problems needing a solution.
You'd probably put this maxime somewhere at your workplace, or maybe a ceiling cat ;P
Know your subject - pushing the model further
As I go deeper into my model, it seems that I don't know a lot of things about solfege, for instance, I never wandered if the G key represented an octave in particular ; when you read a score you focus on understanding if this little dot is a A or a B, the actual height of the note comes naturally when you play.
In fact it does, a quick browse to wikipedia, tells me that the G key represents the G note just below the A 440 Hz wich is the common reference frequency in western countries.
At the time I write this bill I already had the chance to talk about it with my singing teacher who has a great experience in music, it appears that at some point in the history of solfege, keys were used to determine wich instrument the score is intended to. From the G placed on the bottom line telling the score is for french violin to the F on the top line reserved to very low tones of basson.
The important thing here is that you cannot see the whole implications of your design with only a partial knowledge of your subject, even if it seems you know everything you need, you could significantly improve the scope of your reflexion throught some researches.
In fact it does, a quick browse to wikipedia, tells me that the G key represents the G note just below the A 440 Hz wich is the common reference frequency in western countries.
At the time I write this bill I already had the chance to talk about it with my singing teacher who has a great experience in music, it appears that at some point in the history of solfege, keys were used to determine wich instrument the score is intended to. From the G placed on the bottom line telling the score is for french violin to the F on the top line reserved to very low tones of basson.
The important thing here is that you cannot see the whole implications of your design with only a partial knowledge of your subject, even if it seems you know everything you need, you could significantly improve the scope of your reflexion throught some researches.
Setting up the model
Now that I know the basics of NME, let's get to work !
For my application I will need a score modelisation, I recall my first draft two years ago in as3, it wasn't as powerfull as I wanted, I'll try to do better this time.
I take a moment to imagine the internal representation of my score, I see a key, notes appearing randomly, from here it seems simple, maybe too simple, the score as I see it is too close to the first need of my applicaiton : putting random notes as it goes. If I were to show an whole score this won't stand.
I get away from my computer and begin to think how a score would be modeled in any other music software.
On a score we have two axis, one is time, sa time goes we increment a pointer to read the next symbols.
Notes are not the only symbols we encountre on a score so maybe it would be usefull to keep the possibility to represent other stuff like wait times.
On the other axis we have the height of the note, but keep in mind that notes may not be the only thing to represent.
Now I have plenty of ideas and thoughts are hard to hold, I begin to lose faith in my capacity to concentrate. It's time to move on and start implementing.
At this point the classical sheme for me is :
- create 3-4 classes and define their inheritence
- start defining attributes for the "entry point" class
- think these attributes could be part of the more generic class, create a class, redefine inheritence
- start implementing constructor of "entry point" class, need a super constructor, define every constructor in the parenthood
- think this one top level class is silly and serve no purpose, delete it, redefine inheritence subclass and constructor
- initialise attributes, if they are custom types create the constructor of those classes, go to point 4 then 2 then 3 then 4 again then 5
- at this point the model is pretty complex, no function implemenation except for some getter/setters, and I hit some design weirdness like a CRT
note : If you come across something like a CRT and you didn't intended to from the begining, you're probably overthinking your model
- think the model is too complex, see a brighter one, delete 3/4 of your classes, restart at point 1
Future me, if you've evolved from this and are able to think straight in those early moments of a project, I'm glad you did and I just want you to remember how long it took you to figure out this simple design.
For my application I will need a score modelisation, I recall my first draft two years ago in as3, it wasn't as powerfull as I wanted, I'll try to do better this time.
I take a moment to imagine the internal representation of my score, I see a key, notes appearing randomly, from here it seems simple, maybe too simple, the score as I see it is too close to the first need of my applicaiton : putting random notes as it goes. If I were to show an whole score this won't stand.
I get away from my computer and begin to think how a score would be modeled in any other music software.
On a score we have two axis, one is time, sa time goes we increment a pointer to read the next symbols.
Notes are not the only symbols we encountre on a score so maybe it would be usefull to keep the possibility to represent other stuff like wait times.
On the other axis we have the height of the note, but keep in mind that notes may not be the only thing to represent.
Now I have plenty of ideas and thoughts are hard to hold, I begin to lose faith in my capacity to concentrate. It's time to move on and start implementing.
At this point the classical sheme for me is :
- create 3-4 classes and define their inheritence
- start defining attributes for the "entry point" class
- think these attributes could be part of the more generic class, create a class, redefine inheritence
- start implementing constructor of "entry point" class, need a super constructor, define every constructor in the parenthood
- think this one top level class is silly and serve no purpose, delete it, redefine inheritence subclass and constructor
- initialise attributes, if they are custom types create the constructor of those classes, go to point 4 then 2 then 3 then 4 again then 5
- at this point the model is pretty complex, no function implemenation except for some getter/setters, and I hit some design weirdness like a CRT
note : If you come across something like a CRT and you didn't intended to from the begining, you're probably overthinking your model
- think the model is too complex, see a brighter one, delete 3/4 of your classes, restart at point 1
Future me, if you've evolved from this and are able to think straight in those early moments of a project, I'm glad you did and I just want you to remember how long it took you to figure out this simple design.
Saturday, September 17, 2011
first NME tests
With my environment ready I'll have to test to see if everything is operating by the book.
Runing the first samples I figured out that basic features are quite usable, you can put texts, draw shapes and lines and import png files, all with a perfectly mimiced flash API and good results on flash and win/CPP targets.
This is most engaging, at least the core concept is possible to make with these tools.
But I'm a little worried about my assets, I've make three simple assets with Inkscape and now I have svg files, including vector graphics in my project would be great as I probably wont need the same resolution for web, native and phone targets. I haven't found any samples using svg so it's maybe not implemented, the lack of results on Google confirms my suspicions. From a reading on the haXe mailing list I learn that a NME based Library called gm2d has svg import, let's install and see.
A quick test is non conclusive on the ability of gm2d to support svg, I think it's my doing, I probably don't get all the subtilities ; but something else catch my attention, gm2d is able to import swf files and use them in CPP projects ! This is great, I could use this for a lot of other projects, just not this one, but it requires some testing from work, there I will be able to produce different swf and see how gm2d supports them.
For now I just feel uncomfortable with gm2d, a quick look in the sources shows me a lot of nme's bindings to the flash API are rewritten so that could mean maybe less functionalities than NME, different bug database, and from the samples I see it's a very intrusive library.
I decide that it's to much to take and svg isn't worth it. I'll just keep with NME and maybe try gm2d another time.
Runing the first samples I figured out that basic features are quite usable, you can put texts, draw shapes and lines and import png files, all with a perfectly mimiced flash API and good results on flash and win/CPP targets.
This is most engaging, at least the core concept is possible to make with these tools.
But I'm a little worried about my assets, I've make three simple assets with Inkscape and now I have svg files, including vector graphics in my project would be great as I probably wont need the same resolution for web, native and phone targets. I haven't found any samples using svg so it's maybe not implemented, the lack of results on Google confirms my suspicions. From a reading on the haXe mailing list I learn that a NME based Library called gm2d has svg import, let's install and see.
A quick test is non conclusive on the ability of gm2d to support svg, I think it's my doing, I probably don't get all the subtilities ; but something else catch my attention, gm2d is able to import swf files and use them in CPP projects ! This is great, I could use this for a lot of other projects, just not this one, but it requires some testing from work, there I will be able to produce different swf and see how gm2d supports them.
For now I just feel uncomfortable with gm2d, a quick look in the sources shows me a lot of nme's bindings to the flash API are rewritten so that could mean maybe less functionalities than NME, different bug database, and from the samples I see it's a very intrusive library.
I decide that it's to much to take and svg isn't worth it. I'll just keep with NME and maybe try gm2d another time.
Installing haXe/NME
To get started I will need every components as listed on the haxenme.org get startted page.
When you think of the many hours you're going to pass coding your project it appears that choosing a good IDE is a primordial need. If you ever coded haXe with flashDevelop it's possible you'll never drop it as for now it's the best evironment for haXe, providing both good code completion and every basic feature you expect from a code editor ; well there are still the Vi and Emacs guys who will prefere the warm and comforting black background of the console.
FlashDevelop only runs on windows, and as i'm a linux amateur every computer at home runs a linux distro, currently I have no native windows. Hopefully I keep a windows XP virtual machine with enought ressources, so that will be my environment.
For now on just follow the get startted page on haxenme.org.
Now let's install haXe, I already have it but just to be sure I'll make a fresh install from the haXe site. This was quick ! Now for the libs, we need hxcpp and nme (> haxelib install hxcpp, >haxelib install nme), this takes only a few seconds. If I'm to compile for windows native I'm to install the Visual Studio environment, let's download it... and wait... and wait..., well at last it's here, but I can't install it yet as it requires SP3 to work on windows XP, mine is a no SP so back to a long download, run the SP3 installation and restart the VM. Installing VS takes a while, and requires 3 reboots.
While installing let's make some assets, I know I will need things like a Sol key and note graphics.
Using Flash Authoring would be great, I'm not an computer artist but Flash is simple enought for me to produce fair quality assets. But I did not invest in a liscence yet, not sure if I will someday, so I'll use inkscape and see how it goes.
Time goes and I produced the three most important assets : a Sol key, a quarter note and it's equivalent in red, obviously it took me more time that what VS required.
Finaly my environment is all set and I already have some assets.
When you think of the many hours you're going to pass coding your project it appears that choosing a good IDE is a primordial need. If you ever coded haXe with flashDevelop it's possible you'll never drop it as for now it's the best evironment for haXe, providing both good code completion and every basic feature you expect from a code editor ; well there are still the Vi and Emacs guys who will prefere the warm and comforting black background of the console.
FlashDevelop only runs on windows, and as i'm a linux amateur every computer at home runs a linux distro, currently I have no native windows. Hopefully I keep a windows XP virtual machine with enought ressources, so that will be my environment.
For now on just follow the get startted page on haxenme.org.
Now let's install haXe, I already have it but just to be sure I'll make a fresh install from the haXe site. This was quick ! Now for the libs, we need hxcpp and nme (> haxelib install hxcpp, >haxelib install nme), this takes only a few seconds. If I'm to compile for windows native I'm to install the Visual Studio environment, let's download it... and wait... and wait..., well at last it's here, but I can't install it yet as it requires SP3 to work on windows XP, mine is a no SP so back to a long download, run the SP3 installation and restart the VM. Installing VS takes a while, and requires 3 reboots.
While installing let's make some assets, I know I will need things like a Sol key and note graphics.
Using Flash Authoring would be great, I'm not an computer artist but Flash is simple enought for me to produce fair quality assets. But I did not invest in a liscence yet, not sure if I will someday, so I'll use inkscape and see how it goes.
Time goes and I produced the three most important assets : a Sol key, a quarter note and it's equivalent in red, obviously it took me more time that what VS required.
Finaly my environment is all set and I already have some assets.
A project follow up - concepts
The concept of the project is in fact long thought. Two years ago I started in a gaming agency as an intern, in order to catch the attention of my future employer I managed to start a small game project using as3 ; by the same time my father was starting to take piano lessons, he never touched a music instrument before. From my recall from my first music lessons the most difficult thing when you start is read a score, so I toke the oportunity to help him while setting up my gaming project and created a learn game to improve score reading ability. The concept is reading as much randomly generated notes on a score in one minute, for each note you have to tell its name by clicking on one of seven buttons (C,D,E,F,G,A,B).
Few weeks ago my father told me of this game and how it helped him gaining a comfortable reading skill and assured me studdents and teacher would like such tool.
And so the project was back on !
Starting a project is always a good time to sum up your abilities as a developer. You're facing a new promising and challenging idea that will take a lot of your time in the future weeks or months, it's the right time think out of the box and make it an opportunity to learn new technologies, experiment on concept you'd dream to implement on your day to day work and clarify the ones you're familiar with.
I wanted to give NME a try on a real project and see the whereabouts of developement on this framework, as you can put high expectation on such promising library without knowing what will be the underlying limitations.
Now that we have a concept and a framework let's put everything ready to code.
Few weeks ago my father told me of this game and how it helped him gaining a comfortable reading skill and assured me studdents and teacher would like such tool.
And so the project was back on !
Starting a project is always a good time to sum up your abilities as a developer. You're facing a new promising and challenging idea that will take a lot of your time in the future weeks or months, it's the right time think out of the box and make it an opportunity to learn new technologies, experiment on concept you'd dream to implement on your day to day work and clarify the ones you're familiar with.
I wanted to give NME a try on a real project and see the whereabouts of developement on this framework, as you can put high expectation on such promising library without knowing what will be the underlying limitations.
Now that we have a concept and a framework let's put everything ready to code.
A project follow up - intro
I wanted to bring the follow up of a project I'm working on at home as I felt it's representative of the way I code things, how I think a project, may it be little home project or a big company project, and what comes to my mind while coding.
For this project I choosed to give a try to haXe/NME. I'm familiar to haXe, I use for targetting flash in my games company and it's always been a pleasure to play with it. Lattely I heard of the great new features coming up on NME (Neko Media Engine) wich is an haXe library that provides flash-style UI programing for multiple haXe targets. So, in a nutshell, you can code flash-style once and compile to flash, IOs, Android, Windows native, linux native, Mac Os, and WebOs plateform. You can try out samples by installing haXe, NME and some other components (you'll need a C compiler for PC and Mac OSs and XCode with appropriate settings for IOs, as well as the android Sdk for android), just follow the get startted indications here, samples would be found in %HAXE_PATH%/lib/nme/samples.
Next, a bill on how the project starts, the first drafts and concepts and first outputs.
For this project I choosed to give a try to haXe/NME. I'm familiar to haXe, I use for targetting flash in my games company and it's always been a pleasure to play with it. Lattely I heard of the great new features coming up on NME (Neko Media Engine) wich is an haXe library that provides flash-style UI programing for multiple haXe targets. So, in a nutshell, you can code flash-style once and compile to flash, IOs, Android, Windows native, linux native, Mac Os, and WebOs plateform. You can try out samples by installing haXe, NME and some other components (you'll need a C compiler for PC and Mac OSs and XCode with appropriate settings for IOs, as well as the android Sdk for android), just follow the get startted indications here, samples would be found in %HAXE_PATH%/lib/nme/samples.
Next, a bill on how the project starts, the first drafts and concepts and first outputs.
Subscribe to:
Posts (Atom)