soledad penadés
repeat 4[fd 100 rt 90]

Archive for the ‘code’ Category

20061029 Load avg: 0.95

It's been a very busy week and it doesn't seem to go down, but surprisingly for most people, I quite like the feeling of being busy, since it doesn't allow you to spend the time procrastinating and thinking about the divine wonders of the Things That I Would Do If…

Among other things, past week mr.doob and me went to the London Flash Platform Users Group Meeting, or shortly lfpug meeting. It was very interesting and I went back home willing to get there soon to be able to download and install adobe flex builder 2 in my mac, as it had just been released that very day and was fresh and risky, as any beta version in this world :)

But I finally installed it yesterday and got almost aslept when trying to compile my simple "hello world" test. Or maybe I was already getting aslept and I thought it was because of flex builder, I don't know. I'll have a look at it later when I sort out more urgent things, I suppose…

We also got escena.org v2 in a usable status (or that I think), when I finally fixed the issues with the Spotlight section (thanks to a trace's suggestion, must recognise). I haven't talked here about the site yet because it doesn't have all the features we've planned for it, but will do when it's in a more advanced status. In any case it seems promising :-)

And in a different topic, just registered on Thursday for my first cakeforge project: cakephpbb, which aims to provide a way of integrating a cakephp application with a phpbb forum. It's something terribly simple, and in fact it has not entirely been developed by me, since it's a result of the collaboration of several people (more of a mash up than anything else). But I've been testing it and already fixed a couple of bugs, and I'm going to provide the documentation for it.

The project was approved yesterday but I won't add any file until monday or tuesday, when I finish the docs (otherwise nobody will be able to use it and it will be a useless project) and get to understand how the cakeforge backend works.

There's more interesting stuff coming in but can't be disclosed yet so you'll have to remain intrigued for a bit more… hope you can stand it :-P

20061001 Programming languages which are human readable languages too

I came across this quote from an article by Bruce Eckel quite recently:
Bruce Eckel on python vs c/c++ indentation:

Let's throw away those curly braces — indentation already has meaning to the human mind, so we'll use that to indicate scope, instead.

After all the fuss with pascal, c++ and then python and its completely absence of braces, it's quite cool to find such a simple yet convincing reason. I think he's absolutely right, when I read the sentence I suddenly got aware of how often we use instinctively indentation to indicate hierarchies. A quick example could be todo.txt's, where in absence of real bullets you can write things like this:

Very important tasks
————————
- Task 1
- Task 2

And when hand writing these lists (i.e. with a real ballpen) we automatically indent the list items. At least I do!

This brings me to something that I had been thinking about too, the expressivity of a language, and more specifically, the expressivity of ruby. When you're learning ruby (such as me), and are faced with the fact that you can write things such as

do
[...]
until a=1

or also

do until a=1
[...]
end

Or

if something
[...]
end

in contrast to

unless not something
[...]
end

then you can have two reactions. There's the first one which will say "this is a horrible and confusing practice and that doesn't help anybody which is learning". And then there's the second reaction which is "well, the brain is not always thinking like a computer". Sometimes you're thinking aloud and may say: we'll do this and this and this until something happens (case A). And sometimes you say until something happens we will do this and this (case B). Normally you have to force your brain to work in just one manner, which somehow restricts your possibilities.
I believe it is this flexibility which you can't find in traditional programming languages (or new languages which inherited traditions) one of the key reasons for the success of python or ruby, because they are quite immediate.

(The irony is when one combines ruby's flexibility with rails' convention over configuration - like two opposite worlds handshaking!)

So what do you think? do you feel comfortable with C++'s-curly-braces-mania? do you think lax syntaxes are bad for learning to code because it makes lazy programmers - kind of too far away and unaware of the computer's internals?

20060918 Bugfixing, refactoring and improving xplsv.tv

We did a quick visit to NetAudio London on Friday; it was also the first time I went to Angel, and it's way posher than I thought (I was kind of expecting a devastated party area with lots of alternative artists and Bansky-was-here or Mind-you-this-is-not-a-Bansky everywhere, like Old Street).

And after that and some well-deserved eight hours of sleep, came an intensive week-end with xplsv.tv - but we are still not finished with it. I thought we were going to advance more but I was wrong.
So far, most of the work I've done is focused on the motion management. Apart from refactoring lots of code, I have fixed a couple of little bugs, some serious ones, and also added some little enhacements which I believe every artist in xplsv.tv will love when we move these changes to the live server, as they increase the usability of the motion management area.

It's been really delicious to replace all the "rude error messages with an exclamation mark at the end" with something a bit more human and nicer. By the way, I still don't understand why did I enter all the messages like that, and I don't understand either why most of the non-english native speakers tend to write errors messages in that very manner. To my disgust, I have noticed it repeatedly these last months; maybe it has to do with the fact that (luckily) my english level has improved (or that I think).
Some examples:

  • You must enter the title of the motion! becomes Please enter a title for the motion
  • You must be the creator of the work! becomes Please confirm you're allowed to publish the motion here

Obviously if you're an artist in xplsv.tv and have any suggestion, you're more than welcome. (I could put funnier messages, like Hey dude, do not forget the title! but I am trying to be serious :D ).

I also experienced one of the joys of refactoring: things work better with less lines of code. I love that.
Meanwhile, mr.doob was working in the motiongraphics TV, and he made live a new version of the tv. Now you can resize it to suit your tastes - and this has made him feel the desperate urge to encode again the videos so that they have a better resolution. And if you like the new TV, do not forget to vote for it at digg! (yeah, let's do a bit of self-promotion, just for once ;) )

20060911 Going forward with thisisnotanengine

After some months dedicated to little and unimportant businesses, such as getting a fantastic tan which left as soon as it arrived, and finding a new job, I finally half-made my mind about the future of thisisnotanengine. For whoever which do not know what is it, it was our answer to the supercomplicated demosystems around there which are more focused in 3d stuff than in sequencing. It started simple, with a flash sequencer, but with the addition of blackpawn to the team it has grown big and powerful into a binary mega sequencer - but still simple and easy!

The main idea is very erm… simple… we have something similar to MIDI files but for sequencing a demo. The sequencer (the demo studio) helps you build the sequence, but you can also build it yourself, since it is an XML file. In fact, I did it like that for tube demo, but it's not something you would recommend to everybody. That XML contains a list of resources and a list of when the resources are used, along with usual things as modifiers, parameters, etc. And it can be read by any "engine", which does not neccessarily have to implement everything defined by the XML - it simply ignores what it does not understand. This allows you to sequence with a platform and produce a result for another platform. For example, Holy guadalupe! is a flash demo but it was sequenced with the demo editor which runs in windows.

While I was making "tube", trace and blackpawn were working on the demosystem, and they had to make certain changes to the definition of the XML file. I just decided to left the implementation of these changes in my version of the code "for later", since I knew they would take me quite a lot of time to implement.

Although the current version of my player is more decent than the first one (used for vslpx), it is still far from being clean. I just didn't feel like modifying the parser/loader in C++ again, so I decided it was a good moment to start experimenting with (tadaaaaa) python! (I don't know much python yet, though, but seems that its learning curve behaves quite well, one day you're writing 1+1 programs and next day you are writing the next big Web 3.0 project).

The main idea is to build a library in C++ which will implement the graphics and sound code, and leave the remaining to python, connecting everything with some kind of bindings like the ones provided by Boost.Python or SWIG. But keeping things simple. Even if I started using STL, some things still get horribly complicated in C++ but would be much easier with Python, and the inverse. And I tend to get paralysed when I see code which is excessively complicated (specially if it could be simpler), so that's not good.

Another goal of this is to stop depending on any IDE for compiling. That is, even if I'll use XCode for writing the code and all of that, I am trying to avoid using it for managing the project settings. My aim is to use Make for these tasks, since configuring a project with XCode's interface does not provide as much visibility as a makefile does. It could also help me with other goal, which is to get rid of Visual Studio in Windows. I want to investigate which free and modern compiler can be used, specially if it does not annoy me with false STL warnings. Also I presume that using the same or similar compiler (barring platform differences) would help me with the crossplatform development.

By the way, now that we have a fully working computer with decent graphic cards and ubuntu installed, I will probably try to get a linux version as well. From my experience it is relatively easy to get my code working in different systems, now that I have learnt not to use proprietary functions, so it shouldn't take too much time.

I am still in the research phase. I first started with Edwin Jakobs homepage (who is a very famous dutch scener), where he related his experiencies with C++ and Python in order to build pom pom, their scriptable engine. From there I began testing SWIG in order to get a simple test library which could be able to open a window with a certain background color (specified from python) and play a sound file (also specified from python). But I haven't managed to get to that yet… I'm running into lots of problems mainly because of my horrible ignorance of building anything else apart from a simple console application and the funky differences between usual GCC conventions and Apple's implementation of GCC - but I'll find out the solutions somehow!

More to follow… but meanwhile if you have any experience in building dynamic libraries for mac or in doing exactly what I am trying to achieve, I'll love to know about it!

20060812 Open source: from unstable to unstoppable

Some years ago I somehow ridiculised the radical efforts of the linux fanatics everywhere we discussed any topic, specially when they tried to introduce their love for their operating system on every single occassion - even if it was not a suitable one. It really got on my nerves, and was a kind of "Ok, just don't get near linux, you'll be scared of those freaking nerds". And it was actually true… each time you tried to get any information on linux you got a cascade of non-argued reasons, which didn't help at all; in fact they just served the opposite purpose, to make me avoid open source as much as possible, and just rely on commercial products, while increasing my general confusion about all things linux.

But there was a new actor which was appeared in the scenario, and it was called Firebird - later renamed to Firefox. First time I heard of it, it was the usual dabbadabba from ultralinux fanatics: oh yeah there's a new browser which is open source and it's free and it's supercool because it has tabs and well, it actually is open source and based on netscape's source code…! I felt a chill in my spine. Based in netscape… URGH. I already had had to develop a couple of relatively big websites and I it was kind of a nightmare to have a decent styling on the then omnipresent Netscape 3/4. CSS? WTF? who needs css when you can have inline font declarations?

So I just kept avoiding firefox for a while, until they started their reasonable and human campaign: Take back the web. And they did it well! Why advertise things which are so surreal and ethereal such as open source, ability to access the intimacies of the browser and so on, when what people wanted was to browse any page without playing a hit-or-miss game against the pop ups?

Then it gained value for me. A browser which removed the annoyances and dangers, and could be customised at your will, and even more - which was reliable: you put some standard css and it worked. End of the story: it works. Somehow one can think it is the same idea that was used for advertising macs: they simply work.

Moral implications come later, just by the sole fact of being remotely involved with the community. Any open source software community will do, even a very small one. Using the software, getting in touch with developers, submitting bug reports, suggestions, even contributing with more code or documentation… makes you feel like you're kind of giving back something of what you have received for free (Note: I know there are also stupid coders which won't care about how many bugs you submit and won't accept any suggestion or fix anyway. Yes there are idiots everywhere - I suppose it's inherent to human nature).

It also makes you aware of the implications of closed software. What if that program which you absolutely need gets discontinued and there's a hidden bug which appears next year, and there's no one which can fix it, and you don't have a way of migrating your data to a new program? Cry.

With open source, it is different. Not in the sense that even your six year old niece could fix the funky, although buggy, Tux-goes-to-snowland game, but it means that maybe someone which is interested enough can do it. Or maybe you can pay him/her for doing it. But at least there's one way out; you're not trapped.

And that is my point: if you/we want people to move to opensource products, we have to use real reasons. Do not talk about religious like premises, they won't work. People want value, not airy sentences without any immediate effect on their pockets or timetables. Show them Firefox, Thunderbird, Ubuntu, Open Office, Gaim, Blender, Python, PHP, Apache, Ruby, Rails, MySQL, gcc, wordpress… and then they will get convinced.
Now about giving back to the community… I have been thinking about it thoroughly: there are thousands of companies making money of open source software without donating a single dollar back for it. But I came to one conclusion: if they don't give a buck for free software, they won't give it either for commercial, non-free software. They will copy it illegally as well… amoral people are not stopped by laws however.

It's quite funny how they try to protect themselves from the GPL implications. I have seen quite a lot of project managers and company directors feverishly studying the GPL to find out how can they avoid to distribute the source code of their applications based on GPL software, while not having to adhere to a commercial license (and hence having to pay).

For example, they are particularly obsessed with MySQL licensing. MySQL comes in two license flavours, one is the GPL which makes you distribute the sources of the application you build using MySQL, and the commercial one, which allows you to not to distribute anything, if you pay. So there are those avaricious and greedy executives which are going to save the value of an Oracle or MSSQL server license (which is not little amount) and don't even want to donate a ridiculous amount for allowing the coders to have some beers. They will justify that they do not distribute the application - but install it in their private servers, hence it is not distributing anything. Miserable wankers! Sometimes I really would like the judges to take more seriously the GPL and give all these people a good lesson.

Even though, I'm very optimistic about all of this open source scene. Now that we have learnt the lesson, more useful products are being developed with higher quality standards than commercial software. A simple comparison ridiculises commercial software: compare bloated internet explorer 7, after more than 5 years of what they call "development" and still can't support main CSS features which other open source browsers such as Firefox or Safari do support since more than one year ago. Want more? Compare Ubuntu with Windows, for instance.

Also, it's not only about individuals, companies seem to have changed their approach too. See macromedia/adobe with their new Flash 9 open source compilers and IDEs, for example. All of this looks very promising. Maybe it's just that open source is getting really mature and it's ready for invading every single electronic device on Earth. Maybe it's just us becoming adults and aware of what we do with computers.

But there's still quite a lot of work to do: lots of these programs need a good rework on interfacing and documentation, otherwise they are unusable and obscure. Lots more are ego-pumping projects for their developers, which didn't work as they expected and so are abandoned. Same occurs for the projects which just duplicate the functionalities of another one, but do not add anything new - for example, CMS software. Do not misunderstand me: I'm all for people writing whatever code they want, but it's stupid to start yet-another-CMS-for-LAMP when there are lots of them which are not even finished. What those projects need is a bit of collaboration between individuals so as to conquer more than one small sandhill, and reach the peak of a big mountain instead.

And we all can contribute to it! Long life open source!