Getting started with VALA

While browsing and looking for news in the open source world, I came to find about VALA.  A ‘new’ programming language created to design and implement applications for GNOME. VALA has built-in features GObject, GLib,… VALA is translated into C code and apparently it is very efficient C code (benchmarks) So I wanted to dive into VALA and find out more about it…Documentation and blog posts about VALA are rare, except for the official language description page, and even though the people seems to be very active on the project (Version 0.8.0 released in March 2010) the information on it is limited. The standard documentation is rather good online and on the site of VALA may information can be found, however as soon as something goes wrong no information is available. So I want to describe here my experience setting up the environment to compile and run my first VALA program.
I prepared my Ubuntu environment with the following packages
user@computer:$ sudo apt-get install flex lex bison yacc glib gobject-introspection libglib2.0-dev
You could install the version of VALA from the Ubuntu repositories, but the version for Karmic is 0.7.6 and apparently this version contains some bugs.
Rather download the latest version of VALA from here, the version I have been using is version 0.8.0. To install VALA you need to use the standard method, extract the files to a folder, open terminal in that folder and then use first,
user@computer:$ ./configure
, second,
user@computer:$ make
and last,
user@computer:$ make install.
So I tried the Hello World example (from here):
using GLib;

public class Sample : Object {
public Sample () {
}

public void run () {
stdout.printf ("Hello, world!\n");
std
}

static int main (string[] args) {
var sample = new Sample ();
sample.run ();
return 0;
}
}
However trying to compile it, I get the following error message
user@computer:$ valac -o hello hello.c
valac: error while loading shared libraries: libvala.so.0: cannot open shared object file: No such file or directory
Clearly the compiler could not find the libraries, however they were exactly where they were supposed to be, namely in the directory /usr/local/lib. To correct the error at compiling time, I had to run the command
user@computer:$ sudo ldconfig
to update the linkers to dynamic libraries.
I use gEdit together with Valencia plugin to write VALA code and I also want to try out the Vala Toys for gEdit. However with the latest version of VALA (0.8.0) the current version of Valencia 0.2.1 is not compatible with version 0.8.0. You need to check out the latest version from the development trunk of valencia via Subversion, where additional information on the plugin is available.
After that the hello world compiled just fine. I am curious to see where VALA is taking me. Many bindings exists for GTK+, Cairo, Clutter, GNOME,….

Valencia AutoComplete

Go To Definition of a Method or Class

Arte+7 Downer (Download and Streamer) for Python and Linux

Note:
The following application might not be legal, and ARTE did not respond to my messages to ask if it is legal to download their videos on Arte+7. The following application was created as an educational project, and will not receive further features or other development from my side (at least until the legal issue is clearly solved).

Download Python Script

The Arte+7 Downer got inspired from the arte+7 Recorder. However this excellent application is missing some desired features, like saving the description of the downloaded video and the corresponding screenshot. Further to preview a video it is necessary to start the download of the video.
The idea was born to create this small script because I wanted to create something other than a ‘Hello World’ in Python and I wanted to be able to stream Arte+7 videos in fullscreen mode in my favorite video player. Arte+7 have interesting shows which are available for streaming online for  7 days. However it is only possible to view the shows in the browser on their website. The code is a mess and it definitely is not very beautiful, but it works. I will try to clean up the code some day.
The usage is pretty simple, first download the script and you need to have the Python modules html2text, urllib2, StringIO and it uses the mimms package to record the video stream. To run the script simply type python arte7.py in your terminal. Or to make the file executable Right-Click the file and enable “Properties > Permissions > Allowing Executing File as Program”. After that simply double-click the file to start Arte+7 Downer. The application does only work if there is an available internet connection (or if the arte+7 page is available).
The main window contains just a list of the online shows with the date they came online and the date they will be removed. To select an item double-click on it.

Main Window

A window with details on the selected item opens and you can either select to view the video or to save it (default folder $home/Videos/Arte+7/). The ‘Save Info’ Button saves the description into a text file and the image as a jpeg file into the same folder as the video file under the same name (with different extensions).

Detailled View with Control Buttons

That’s it, the code is a mess, as it is quite difficult to extract the mms URL from the Arte+7 site. Have fun looking through the code and watching Arte+7 in a real video player.

On Software vs Architecture

Software contains bugs! And we are used to it, but we shouldn’t accept it as a truth!
I am currently working on my PhD thesis (to finish it at last) which is on the subject of the underlying automata of model checking. Model checking is a formal verification technique used to proof that a system is correct, meaning that the system is satisfying given properties. This technique is already used much for software verification in some fields like flight engineering. The software of the Airbus A380 was verified using formal verification methods.
The understanding of formal verification methods is pretty advanced in Science, however the practicability of formal methods to the average programmer is close to zero. A verification of a random program would require like 10-20 times the time it took to write the original code. It took more than a year to a team of specialists to verify part of the A380 software. It will take years before formal methods are build into compilers that will help the programmer with its job to provide a correct program.
Bugs are mistakes, coding errors or design errors, made at some point during the development of the code. We have grown from a point were complaining about bugs in the OS was a daily routine(Windows 95) to a point where we actually are online long enough to notice bugs in software or hardware. Small devices are growing to complete computers (iPhones, GPS,…), and the number of processor is increasing per machine. Asynchronous processes and other requirements of clients make the situation worse, before we can make it any better.
In architecture, an architect designs the plan of a building, the architect has a diploma and he was trained to design plans. After the architect has finished his job, the plan goes to an engineer who is responsible for verifying the plan. He does some calculations about stability, controls the materials used and either gives a go or gives it back to the architect to redesign the plan. But only after the engineer gives his OK, the plan gets reworked to get a plan for the workers, with millimetre precise plans. After those plans are done, the real construction starts, getting on the place where the final building should be standing. During the whole process the architect controls the execution of the work, discusses issues with the workers on fields, try to discover problems before they are in stone…Finally the architect has all the responsibility of the final result.
Sometimes before the final construction, the architect creates some prototypes of the whole house or of some parts, and even the engineer for some special constructions creates prototypes of some parts to verify their properties.
I don’t want to analyse the process of software design, but as a programmer ask yourself if you want to live in your code. Software should be created more like buildings, get a plan first, you are allowed to use prototypes during the plan making phase. However give the plan and not the prototype to an engineer would verifies it. Then start the programming, but as soon as issues arise, stop the process and choose a solution before it’s too late to go back (and the walls around are too high).
Of course for software the comparison with buildings is not true for most of the software, that’s why most software engineers or programmers don’t respect the process. If the program in contrast to a building contains bugs, in general no lives are at risk or only a limited amount of money.
Some famous ‘BUGS’ from Software and other Space:
  • Russian Venus Lander (VENERA from wikipedia): The Venera 9 and 10 landers had two cameras each. Only one functioned because the lens covers failed to separate from the second camera on each lander. The design was changed for Venera 11 and 12, but this made the problem worse and all cameras failed on those missions.
and even better:
  • Venera 13 and 14 were the only landers on which all cameras worked properly; although unfortunately, the lens cap on Venera 14 landed exactly in the way of the soil compression probe.
  • NASA Mars Lander: NASA lost a $125 million Mars orbiter because one engineering team used metric units while another used English units for a key spacecraft operation,  ~ cnn.com
  • Pentium Bug: The Pentium FDIV bug was a bug in Intel’s original Pentium floating point unit (FPU). Certain floating point division operations performed with these processors would produce incorrect results. According to Intel, there were a few missing entries in the lookup table used by the divide operation algorithm. ~wikipedia.org

Spreading the Word (Create a Ubuntu based Linux-Distro from Local Repositories)

In Chad since January 2009, I was desperately looking for a way to get people to consider Linux as an operating system. 99% of the people still use Windows XP SP2 as primary operating system, mainly because getting hacked versions of Vista is kind of difficult. People use an operating system which is basically 9 years old, with an update SP2 from ????. Every computer in the city and I guess in the country as well are infected by viruses or other malicious code. And some viruses recently are starting to make USB sticks unusable by setting them to write protected and erasing the partition table. I can recover the documents, but yet the stick remains unusable. A computer in Sarh generally gets reinstalled every 3 to 4 months and with the malicious code, most of the users documents get erased.

The main reason why people should use a Linux version is that they can focus on working instead of getting rid of the viruses. Many attempts from last year failed, because the only distribution I had on my was a simple Ubuntu installation CD. However the users want to listen to MP3, want to watch movie, want to convert video and music to put it on their phones… And Ubuntu by default has not much to offer for the users here. Of course everyone can add packages, however evaluating the costs for the Internet connection, this means like an investment of hundreds of euro to get the necessary packages. To note that copying music and videos from a device to another is actually a huge business here, so the necessity of those packages is not just for fun. After my 2 months stay in Europe for November and December 2009, my first idea was to bring down the repositories on a local HD , however when I was down in Sarh again, a much better idea came up. Instead of teaching everyone how to install new packages and that everyone has to buy 8 DVD (quite expensive here), I though, just add packages to the install disc and get rid of those packages which are not useful here, like translations. This means I decided to create my own distribution disc based upon Ubuntu 9.10.

After a quick study on Bing I noticed that the existing tools to help you create your distro, require a decent Internet connection to download the additional packages.(UCK, Reconstructor,…) So none of them was of any use to me. However I came across this excellent tutorial on the ubuntu wiki, showing step-by-step how to proceed to end up with a working Ubuntu based distro. And here it was possible to change the sources such that I could use my local repositories to install additional packages.

The installation DVD holds now 1.4 GB of packages, and after an installation you are ready to go, no additional work is necessary. Ubuntu brings back sound to computers, where audio drivers were missing, Ubuntu brings a nice working OS without troubles with viruses (with viruses running around here) and even people with few computer knowledge are able to install Ubuntu, where right now some people ask like 50 euros to install a hacked version of Windows XP. I started with 2 of my projects, two one-man businesses on the local market copying music to phones, memory cards or MP3 players, before their computers had massive virus problems and the viruses caused many problems as their clients hardware was infected too.

For 1 month both startups are using Ubuntu, which gives them more working hours per week then before with Windows XP, as often the computers had to be reinstalled. And then from there the word is spreading by itself, right now after one months the installation of Ubuntu in town has ‘exploded’ and right now there are more then 10 computers of which I know running fully on Ubuntu. People recognise no more virus problems and no more driver issues, and people can decide!!

open source needs community (on example of chad)

our computer school...the cfik

showing a linux installation to students

in 2 days, i will go back to chad for 6 months. (i have been there for ten months in 2009) i will be working in a small computer school in the south of chad in a small town called sarh. before that there are some thoughts i would like to write down before leaving.

actual situation of IT in sarh (2009)

in sarh, computers are rare and computer knowledge is gold. typing one single page brings 1 euro, installing anti-virus software (any free version and often outdated to 3 months or more) can cost up to 30 euros. 99% of computers run windows xp sp2, cracked version. the outdated virus software and the excessive use of usb sticks let viruses propagate rapidly on computers. except the computers in our school, every computer i laid hand on was infected with viruses. most used software is microsoft office 2003.

people love computers; you can watch movies, listen to music, share pictures, record songs…etc. and yes computers are used for business as well, in banks, insurance companies, administration…so people are willing to learn an how to use computers. but they want to learn it so they find jobs more easily, which means at our school we need to run on windows xp as well, we need to teach microsoft office 2003 as well. i insisted that we teach at least openoffice 3.1 as well, however students prefer word over writer, but calc wins against excel.

internet is slow and expensive. the connection is made with one of the two mobile network providers (tigo or zaïn), downloading 5mb costs about 2.5 euros and can take up to 10-12 minutes (if connection works) sometimes it is not possible to connect for several days. updating a anti-virus software (~40mb for avg) costs almost 20euros which is the monthly salary of an average person.

actual situation of open source in sarh (2009)

our school teaches openoffice 3.1, besides ms-office 2003. which means that around 160 people in sarh know about at least one open source project. i have investigated and those people working with computers use internet explorer, ms-office 2003 (or 2007), preferred anti-virus is avira. Some people use FireFox version 2.5(due to the fact that one guy in the town had this on a cd). in a photo studio they are working on some proprietary software as well, photoshop cs3. the reason why people are afraid of learning a new product, is that the people around could not help them. there is no existent community to provide any support and often people use this as an excuse why they stick with the known software. And people find it very hard to see that two pieces of software can lead to the same result.

linux is not used by anyone, because there is no support and no knowledge. the idea to search for answers within a community (offline or online) has not come to the city yet.

starting a community

i believe people and the whole region could benefit a lot from switching over to linux. people just want to do office, watch movies, listen to music and sometimes internet. so ubuntu does all that very fine. a simple example is simply that computers would be safe from viruses, and computers don’t need to be reinstalled every two months. however the lack of support is a major barrier for switching from windows to ubuntu. as long as i am there it’s fine, however people will be helpless when i am gone without support. luckily, computer problems are often solved as somebody else has already solved it (community). so getting a little community together would be a first step towards promoting linux (open source) in chad.

from my work experience in switzerland, i know that a small community works great. our company organized monthly meetings (free and open) where anyone could present and/or listen. everyone gained, listeners and presenters, company and other companies. so my plan is to set up the same thing in sarh. a little community with the people working with computers, have regular meetings, where i will lead for the first weeks and then give the community to local hands. i hope my school will allow to have the meetings within the school itself. in sarh, people who have the knowledge of computers are not very eager to share as their knowledge brings them a good revenu.

my goal is to create a little community, talk about linux and other open source projects. i will talk on how to find help within a community. and even if no one switches over to open source software, i hope the community will remain so at least one part of open source remains in the town.

i have made a complete mirror of all ubuntu repositories and medibuntu repository, which helps to get the people together…and i can make decent installations of ubuntu.

mankind made a huge step when knowledge could be shared not only from person to person but over generations through books. to help isolated towns (no paved roads, almost no internet, no newspaper) sharing knowledge could be a revolution, because right now as a good friend once told me :’ the problem of us chadian is that we take our knowledge with us to the grave’ (he himself died few weeks later)

chrome vs firefox on ubuntu

at first i wanted to install chrome only to prove how much i did not want to use google’s browser. however, since the day i installed chrome, i used it and google’s chrome is much better than i expected. but as i do love my old firefox i still didn’t have the guts to set chrome as my default browser…yet. i also got used to the blueish look of chrome inside the brownish ubuntu theme and the fact that it looks like an alien on my ubuntu desktop is not disturbing me anymore.

if you want to you can switch from chrome’s default theme to the gtk+ theme.(tools->options->use gtk+ theme) an advantage of chrome is having the tab on the very top of the window, is simply the best place to put them. and after using chrome only for a few hours, i got used to it so quickly that i keep on searching the tabs when i use firefox. i saw that opera is doing it the same way as chrome, tabs on top, which means that the address bar is within a tab. this means that there is not a universal address bar anymore, which is for me quite logical. after heavy usage i noticed that using chrome is a lot of fun and it feels like it is a lot faster than firefox on ubuntu karmic. so i tried to find out more if that’s true

as i am often working on battery, i try to close the apps as soon as i don’t need them, which also means i need to re-open applications a lot. startup time is therefore important, startup time comparison for chrome and firefox (from launching till ready for use):

1. chrome : 1.1 seconds; 2. firefox : 4.4 seconds

this could be related to add-ons, i am using firebug and delicious bookmarks in firefox and delicious bookmarks in chrome. but definitely chrome is faster on startup.

then i tried to find out about how much memory or processor time both applications require. however finding the memory usage of an application is not that simple, then how do you define memory usage? virtual memory, shared memory or resident memory? so i decided to simply use system monitor of ubuntu for a quick. what i quickly realized is that chrome uses for each tab a new process (and 3 other default processes). i opened the same pages(simple text sites and some with heavy flash) in chrome and firefox in 5 tabs and the results were

memory usage after 1 hour usage (30 min each):

1.firefox : 142mb; 2.chrome : 173mb (sum of all 8 processes)

process time when pages were open and me not using the browsers:

1. chrome : 0%; 2. firefox: 30%!!!

i guess the processor time is due to the flash inside some pages, but still i could not get an explanation for this huge difference for both browsers. this makes firefox no good choice for visiting flash sites while short on battery.

the third and maybe most important point for browsers is to render pages fast (and correctly). for the speed there is a nice site allowing to making some rendering speed tests for your browser (peacekeeper) i recommend that you go and check your browser yourself and either confirm or reject my results. my results from peacekeeper were

1. chrome : 1591 points; 2.firefox 3.5.6 : 632 points; 3. firefox 3.5.5 : 599 points

on the acid3 test chrome scores a full 100/100 points, where firefox again lacks behind with 93 points. both browsers passed the browser security test. on google v8 benchmarks, i can’t believe the results 2273 – 161 for chrome. i start to think that something is wrong?

what i was missing for chrome and a major barrier for making it my default browser was the lack (or me not knowing) of a delicious bookmark plugin. til today i found the delicious bookmark plugin for chrome.(chromium delicious plugin) further there is an adblock plugin for chrome as well (here), but i know that some of you have to stay with firefox as there is no ‘no-script’ plugin for chrome.(or none that i know of)

i have to admit that chrome is an excellent new browser for linux, and that i am impressed. what makes me wonder, how is this possible? firefox almost exists in version 6, and chrome is the first official release on linux?

conclusion i will use chrome for a while, still trying to find that something is wrong with it, however i also start believing that firefox is out on linux. it may still be a nice product, but come on…after so many attempts to get a nice browser for linux, google shows that one can succeed in first attempt. congratulations to the team of chrome. best browser award? no, since i don’t know much about opera, epiphany, and co. but chrome surely makes it to the top 3!

malicious code attacks linux users

windows users know them too well…linux- and mac-users have been spared and often bragged that they don’t need to worry about them. i am talking about malware or malicious code. malicious code is trying to take advantage of the user’s resources (financial, hardware, bandwidth, data…) without being detected by the user. this week a supposed screensaver on gnome-look.org actually contained no screensaver but code for a DoS attack on www.mmowned.com.(more information)

the malware can easily be removed (here), but what do we learn from this incident? a first look on the code reveals again how simple it is to write such small pieces of code, and surely the little boy who created it learned all the stuff by himself without getting a bachelor or master degree. but more importantly it shows that linux is spreading and gaining more and more standard users, which is making linux more vulnerable as well. up to now linux has been a safe operating system, not because the code was better but mainly because the users knew what they were doing, and the user is still the best protection against any malware.

in the same way as linux, osx is getting more and more exposed, not because code is getting worse, but because those two os have become an excellent alternative to windows and many non-tech (or non-geek) people are migrating from windows to one of them. often those users believe that linux and osx are safe and that no malware exists for those, so the users are erroneously mislead and they put themselves (and others, case of a DOS attack) at risk. for windows the users knew they had to add a virus- and malware-protection and they must know that the same risks exist for any operating systems (even iphones).

virus protection (here), firewalls (here), user rights, updates and upgrades…all these things exists not only in the windows world, they can be useful in linux as well and users have to understand why and when they can be useful and were the dangers are. anyway the user himself is the only one who (if possible) can protect himself, but don’t argue that any operating system is better because they don’t know malware.