adrienhaxaire.org | recent http://www.adrienhaxaire.org/feeds/recent/ Latest entries on adrienhaxaire.org Sun, 23 Oct 2011 20:00:00 GMT en-us Moving to ArchLinux http://www.adrienhaxaire.org/billets/moving-to-archlinux http://www.adrienhaxaire.org/billets/moving-to-archlinux Sun, 23 Oct 2011 20:00:00 GMT <em>Everything should be made as simple as possible, but not simpler.</em> - A. Einstein Last week I decided to move to <a href="http://www.archlinux.org">ArchLinux</a>. I wasn't excited at all with the release of Oneiric, as it was all about unity, and nothing more. The ubuntu button moved inside the dock, not in the top level bar, etc. I upgraded from Natty and everything went flawless as usual. But when I saw I had to use unity, I just got bored of having things decided for me. Of course I could have tried to use gnome-shell instead, or put KDE. I have a latop with a video chip, so Ubuntu was running slowly, and last time I tried KDE 4 I thought my laptop was about to melt. So instead of reinstalling a fresh Ubuntu 11.10, I just opted for a new distro, simple and lightweight, to have my laptop at full speed again. There are plenty of lightweight distros. Debian and Ubuntu based as well. I've heard lots of good points for ArchLinux in the Haskell mailing lists. But most of all, it just looked so <em>fun</em>. ArchLinux is a rolling distro, meaning that you can update your packages when a new version of the package is out, which is way more frequent than every six month. I think this is very nice; I like to have the latest version of the softwares I use. If I find a bug, then I just fill it instead of complaining about it. So let it be ArchLinux. Here we go: <ul> <li>read the installation guide,</li> <li>grab the install image,</li> <li>put it on a usb stick,</li> <li>read the installation guide again,</li> <li>backup all my data,</li> <li>format and partition my hard drive with a live gparted cd for the new install,</li> <li>open another laptop to check the installation guide if needed,</li> <li>plug the usb and reboot</li> </ul> The installation went flawlessly. It reminded me of my first install of a fedora core 5. There are some config file to edit manually, the ones with the scary name, such as /etc/rc.conf. Actually it was much simpler than I thought. I did not have network at the beginning because I put wrong information in the config file. Set up to be automatically determined for me worked better. I installed it with a cbale and the battery plugged by the way. This simplified lots of things. The funny thing is that you do not have Gnome or KDE, you do not have X at all. You have no user other than root, no sudo. And that's excellent. You install exactly what you want. I just wanted to have it working for starters, so I installed emacs, sudo, added a user, installed X and Gnome 3 with Gnome Shell. I'll go to simpler and lighter when I am more used to ArchLinux. Reboot, some problems once or twice with my ~/.xinit and after that, everything was alright. Total time, 2 hours I think. Next time will be 30 min I think, as now I know how to do it. First remark, may it be Gnome 3 and Gnome-Shell, that's pretty fast, even on my laptop! More than Unity for sure. That's exactly one thing I was looking for when coming to ArchLinux. I did not install the whole desktop environment; didn't want evolution, tomboy, etc. Keep it simple, manageable. My laptop is for home use, so I do not need that many things in it. That's a really nice desktop environment. Still don't know why Ubuntu dropped it. I was used to my four virtual desktops making a 2x2 square, so I'm still not completely used to the vertical line. Anyway, Alt-Tab is always faster. I installed some simple and basic things like evince, file roller, etc. The package manager, pacman, is quite nice and often adds advices for installing other packages, or configuring a new package. By the way, this does not take that long. Mostly a couple of minutes when you stumble upon a file you cannot open, or half an hour if you want to add some programs you know you'll need, like an email client, Gimp, git, svn, the haskell-platform, etc. There are thousands of unofficial packages in the AUR, the ArchLinux User Repositories, that can be installed simply. I installed Dropbox in few minutes and enabled it manually by adding it to my ~/.xinitrc file. The promise of ArchLinux is kept and true. It is simple because it does not decide everything for you. Once you edited some important config files more than once, you get used to it, and best of all, you understand them. I have learned more on GNU/Linux in one week than in the last year. Which is why I also wanted to move to ArchLinux. By the way, Archlinux is fine for newcommers too if they want to learn GNU/Linux and are not afraid of playing around with the terminal. In the end, it is true that editing directly the config file is simpler than accessing it through a menu for administrators with an application we may not want to spend 15 minutes to find, not knowing what it will do. All this ease of use and simplicity in ArchLinux comes also from the documentation on the ArchLinux wiki. Everything is written thoroughly. In conclusion, I am more than happy to have made the switch to ArchLinux. It is an insteresting distro, simple to use, and fun. Of course Ubuntu remains a good distro as well; but if you want to understand linux better, to give a new youth to your computer, and know a bit more what's inside a linux OS, then you should definitely give it a try. Fortran projects http://www.adrienhaxaire.org/billets/fortran-projects http://www.adrienhaxaire.org/billets/fortran-projects Sun, 19 Jun 2011 20:00:00 GMT It is time to make a pause in my developping frenzy to write a bit about the projects I am currently working on. I have started a new project, written in Fortran. It is called <em>fortun</em> and as you may have guessed, it is a unit test framework for Fortran. Why another unit test framework? Well, simply because I am not satisfied with the current ones. The one that looked interesting is called <em>fruit</em> and uses Ruby for the generation of the tests. I tried to install it but I didn't succeed. I could have looked for help, but how to trust something that doesn't even install when it should be plain simple? For other libaries, it can be ok, but for tests you want to be sure you can trust the library. I started this project because I am concerned about the quality of the code I write, but also because of the workflow it provides. Being able to check precisely the result of a procedure is one of the key points to writing beter and more bug free code. I am more confident in what I write and I can refactor way more often. The project is hosted on <a href="https://github.com/adrienhaxaire/fortun">github</a>. Writing a module with assertions is easy; it took me less than an hour I think. Things get way more complicated when you want to automate all these tests. It is going to be a real pain if we have to define ourselves all the compiling, execution, verification of the tests and the display of the report. Of course, tests should be created manually, and put in a module. But after that, everything should be automated. This implies: 1. finding all the files containing the tests 2. finding all the source files that need to be compiled in order to be linked for the tests 3. compiling all these files, in the proper manner 4. running the tests 5. checking them 6. displaying the results So far, I have written the first point. When starting to work on the second one, I realized it was going to be way more complicated than I thought. I will have to parse the files, find the subroutines to call, etc. These are advanced text file manipulation, the week spot of Fortran. To my rescue, regular expressions! How come there is no official Fortran library? Well, that's not surprising, as if you want to process text files, you choose a better suited language, like Perl or Python. In the Fortran wiki, there is a library, <a href="http://fortranwiki.org/fortran/show/regex_module">regex_module</a>, which wraps a C regexp library. I can use it, sure, but I want to keep it in pure Fortran. This naturally leads us to the new project inside the new project: regular expressions in Fortran! This, my friends, is another step. I can start simple to have it working, but I aim an optimized one, parallelized maybe. I would be silly not to take advantage of the good points of Fortran (and OpenMP). These algorithms have been the topic of researches for decades, I am quite happy to become more familiar with them. I have ordered the famous O'Reilly's <a href="http://www.amazon.co.uk/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/">Mastering Regular Expressions</a> by Friedl. I ordered it some days ago, as I want to master them, for every day use and for the curiosity. It looks like this book will be way more useful for me than I first thought. I see regular expressions like emacs. And unit tests like regular expressions. It takes you some time to be familiar with, but when you feel more comfortable with it, you wonder why it took you so long to try it, and how was life before. To sum up, some home projects for which I have plenty of good time with my friend Fortran, to which I will give some tools for a lifting, and make it an even friendlier language to use and learn. Only two links http://www.adrienhaxaire.org/billets/only-two-links http://www.adrienhaxaire.org/billets/only-two-links Sat, 04 Jun 2011 20:00:00 GMT On wednesday, I have been flooded by more than one hundred spams, on the main page. I was willing to add a filter to the comments, but it faded away as I don't have enough traffic to be worried. Until yesterday, though. The solution I chose is simple: no more than two occurences of 'http' per comment. This is still enough to give some useful links if needed. This is extremely simple and fast. In my Comment class, I have defined a check method which finds all the occurences of 'http' in the text of the comment. I use the regular expressions re module, and then it takes 4 lines: <code> import re [snip] def check(self): regex = re.compile("http") https = regex.findall(self.text) return (len(https)<=2) </code> as simple as that. I haven't measured the efficiency of it, but as it is in a GET request, it is less important. And, to be honest,I don't have lots of comments neither. I'll update it if needed, but for now, those 4 lines take away some worries. Starting Haskell http://www.adrienhaxaire.org/billets/starting-haskell http://www.adrienhaxaire.org/billets/starting-haskell Sun, 15 May 2011 20:00:00 GMT For some time I was looking at a functional language to learn, as it is another approach on solving the problems we encounter every day. I started to look at Erlang, as it is used for CouchDB. Still, it is more network oriented, and I wanted something more general. I also thought of Lisp and Scheme. Then I stumbled upon an article from Simon Peyton-Jones, <a href="http://portal.acm.org/citation.cfm?id=242823">"On the importance of being the right size: the challenge of conducting realistic experiments"</a>. I then took the firm decision of learning a functional language, and that this language shall be Haskell. My motivations are partly summarized in <a href="http://www.haskell.org/haskellwiki/Why_Haskell_Matters">Why Haskell matters</a>. First, functional programming opens a different approach on programming. This will give me an other look on the way to program with imperative languages. Second, all the advertisement on side-effect free programs is interesting, as I mentioned <a href="fortran-pure-procedures">in a previous post</a>. Now every function I write in Fortran will be at least pure. The laziness of Haskell didn't strike me at the first time, it was not a strong point to convince me. I see now why they emphasize on it. The same with the strong typing, by the way. One thing which seduced me is the elegance of functional programs, and the one in Haskell more particularly. I like the quicksort algorithm they describe because it focuses more on the algorithm than in its implementation itself. I have read that several times: "write what you want to do, and not how you want to do it". This is really enjoyable. But one of the most important point is the community. I felt at home there, with people contributing, helping, and putting efforts on writing elegant and efficient programs. I will find many places, links and people to learn more on computer science, functional programming in general, with a hogh level for a newbie as I am in this field. As I was looking for a book to learn it, I found <a href="http://book.realworldhaskell.org/">Real World Haskell</a>, which is free online. I then decided to buy a paper copy of the book, as I prefer to read on paper, and to contribute to the work of the authors. 700 pages which will keep me busy for a while. And this is a good thing: I did not want a sparse book that you can read only once (cf. PragProg and co.). So, here I am, starting from nearly scratch, as I have to forget about many habits I have developped with imperative languages. And this is good. Dear, I should have done that long time ago! Using gfortran under windows, part 1 http://www.adrienhaxaire.org/billets/gfortran-under-windows-1 http://www.adrienhaxaire.org/billets/gfortran-under-windows-1 Wed, 16 Mar 2011 20:00:00 GMT I have decided to try to compile the codebase at work with gfortran. Even if we use other compilers, I think it is important to be able to compile our code with several compilers, for some obvious reasons: 1. It assures me to produce good code, which is close to the standard. We still use compiler-specific optimization for the releases, but this is why pre-processors options are made for. 2. I come from GNU/Linux, I like it, and I want to use its tools every day. 3. I can spot more mistakes/improvements using gfortran as it is very precise with the variable declarations, their kind, etc. The -Wall spots many things I would not have thought of. 4. I trust it. 5. It will help me to be a better programmer. So far, I have installed it from the MinGW website and managed to compile the whole codebase. The generated executable still crashes, but these are not so bad news. I see I miss some basic windows knowledge for developping on it, and using gfortran will help me understanding the common errors encountered on windows (kernel32.dll I am looking at you). Therefore I am starting a series of posts on using gfortran under windows, for me as a reminder, and if this can help some other people, then I will be happy with it. The next chapter will be "What is a SIGILL" or "The dark side of kernel32.dll". Stay tuned ! Nouveau velo http://www.adrienhaxaire.org/billets/nouveau-velo http://www.adrienhaxaire.org/billets/nouveau-velo Tue, 08 Mar 2011 20:00:00 GMT Mon ben ça y est je deviens encore plus Hollandais, j'ai acheté un vélo ! Je l'ai pris dans le style d'ici, i.e. sans barre transversale, avec des grosses roues, des protections autour de la chaîne, mais surtout, un gros guidon et les freins à la pedale. Il n'y a qu'une seule vitesse, et c'est pas plus mal ainsi. En ville il n'est pas necessaire d'aller vite, et même lorsque l'on sort un peu de l'agglomeration, on peut aller suffisamment vite avec cette seule vitesse, sans trop pédaler dans la semoule. Le cadenas est une barre d'acier qui bloque la roue arriere. J'y ai ajouté une chaîne pour l'attacher a une barre par exemple. La roue avant n'est pas souvent attachée ici. En général c'est le vélo complet qui est volé (je touche du bois quand meme). Je vais pas tarder a mettre des sacoches aussi sur les côtés, pour quand j'irai faire les courses par exemple. Le problème c'est qu'il pleut tout le temps ici et qu'il y a plein de vent. Mais bon, je m'y ferai. L'avantage c'est que je vais gagner beaucoup de temps pour aller et revenir du travail. Je dois mettre dix minutes je pense. D'habitude c'est 20 minutes quand un bus arrive vite. Reste plus qu'à apprendre le jargon vélocipede en néérlandais, ca risque d'être marrant aussi. Pure procedures in Fortran http://www.adrienhaxaire.org/billets/fortran-pure-procedures http://www.adrienhaxaire.org/billets/fortran-pure-procedures Tue, 25 Jan 2011 20:00:00 GMT In Fortran, a keyword I haven't used enough so far is PURE. We want functions but also many subroutines to avoid side-effects. To ensure this, Fortran let us add the keyword PURE in front of a procedure declaration in order to tell the compiler that it does not contain any side-effect. As I keep forgetting the list of things to avoid in a PURE procedure, I write them down here in order to find them quickly too. Acccording to Wikipedia, the procedure should: - alter no global variable, - perform no I/O, - contain no saved variables (i.e. no SAVE attribute), - not alter any of its arguments if the procedure is a function. The first point is easy to tackle, in the idea that global variables should be used for constants (to avoid magic numbers for example), or in some rare occasions. The second one avoids debugging with print statements. However, we can either remove the PURE keyword when debugging, or use unit tests. The third one is not that difficult too, as the SAVE attribute can either be avoided with another design for the procedure or put in a wrapper subroutine for example. The last one can be summarized by declaring all the variables as INTENT(IN). To me, this appears more as common sense than restrictive conditions. At least, with the statement, the compiler can help us writing better code. I still need to find the exhaustive list of the conditions for a pure procedure. Any good link in the comments will be appreciated :) De Delftse Methode http://www.adrienhaxaire.org/billets/de-delftse-methode http://www.adrienhaxaire.org/billets/de-delftse-methode Sun, 21 Nov 2010 20:00:00 GMT Cela fait maintenant trois semaines que j'apprends le Néerlandais. Mon entreprise me l'a proposé, et j'ai accepté avec plaisir. La méthode que je suis est la célèbre méthode de Delft, <em>De Delftse Methode</em>. Je la suis avec deux collègues. D'autres collègues l'ont commencée avant et sont dans un cours plus avancé. La méthode repose sur un travail personnel assez intensif: de six à dix heures par semaine pour travailler les textes. Il y a le livre de cours avec deux cd pour les lessons et un cd-rom pour s'entraîner. le cd-rom est pourri et ne sert a rien. J'ai encodé les cd en mp3 et j'écoute les lessons le matin en allant travailler. Le principe est simple : c'est la méthode globale, donc tu apprends le texte par coeur comme un âne et ton cerveau fera le reste. Ca parrait assez critique de ma part mais c'est établi et affirmé par la méthode. Je trouve ça assez rageant de devoir apprendre tout ca par coeur. J'apprends a demontrer, pas a vomir. Mais je dois avouer que ca marche assez bien. Nous avons deux cours d'une heure par semaine. Avant chaque cours on va dans la salle informatique pour passer les tests de comprehension orale. On écoute des passages du texte que l'on a etudié puis on les écrit sur l'ordinateur. Le test est validé si on a 80% de mots justes. Dit autrement, ca ne sert à rien d'y aller si on n'a pas appris le texte avant. Puis vient le cours. Nous sommes 16 dans mon groupe. On n'y apprend rien de formel, tout ça est déjà dans le livre. On y va pour parler et pour écouter. Comprehension et expression orale. On peut toujours poser des questions si on en a, mais generalement, si on a bien travaillé en amont, ce ne sont que des petites questions concernant un détail precis. Les enseignants sont sympas et dynamiques. Meme les plus timides des élèves prennent la parole. Apres une grosse journee de travail j'aime bien y aller. En tout cas, j'ai pris le parti de jouer le jeu, en apprenant tous ces textes et en travaillant sérieusement. Je vois que je progresse assez vite, ce qui est normal quand on commence une langue et qu'on y passe dix heures par semaine. Dans la vie courante, chaque fois que je peux, je commence à parler en Néerlandais, puis je bascule sur l'anglais si c'est trop compliqué. Il me faudra encore pas mal de temps avant de pouvoir le parler couramment au travail, mais je saisis quelques morceaux de phrases et c'est assez agréable. Reste plus qu'à m'acheter un velo et je passerai inconnu. Edito du 14 novembre 2010 http://www.adrienhaxaire.org/billets/edito-20101114 http://www.adrienhaxaire.org/billets/edito-20101114 Sun, 14 Nov 2010 20:00:00 GMT Après une longue période d'absence, ce blog reprend de l'activité. Pour repartir sur de bonnes bases, je l'ai modifié en surface et en profondeur. J'utilise toujours Django, mais je suis passé de Postgresql à CouchDB. Au revoir les schémas rigides, et bienvenue à la flexibilité du NoSQL. Je commence à me servir de CouchDB localement pour gérer mes documents sur mon ordinateur. Cette epérience m'à permis de mieux en comprendre le fonctionnement dans la pratique; étant déjà emballé par la philosophie de CouchDB. En surface, le design est simplifié, j'ai viré le superflu. J'ai tout un tas d'idées pour augmenter ce site: je vous tiendrai au courant sur les nouvelles fonctionnalités ainsi que sur leur implémentation. Surtout, j'ai envie d'écrire plus et plus souvent. Cette nouvelle interface me simplifie beaucoup la tâche, donc ça va être bien plus sympa. Les billets techniques seront écrits en anglais, les notes d'humeur en français. En attendant, vous pouvez toujours vous balader sur le site, il ne contient pas grand chose pour le moment :) Fortran on freenode http://www.adrienhaxaire.org/billets/fortran-on-freenode http://www.adrienhaxaire.org/billets/fortran-on-freenode Thu, 19 Aug 2010 20:00:00 GMT Recently I've started using IRC to get some answers to my questions, but also to listen, read, and help if I can. I started by going on #django-fr, as I was very curious about it. Even if I couldn't help people yet, what people were talking about, and the advices they gave were a lot of paths to a better comprehension of Django. And, more than that, to how Django is used. And now I'm often online, reading what people say, and lurking for a person more newbie than me to help. As this was a very interesting experience (which is still of course), I looked for a fortran channel, in any case there was one. And I found it, simply #fortran. I didn't know what it would look like, or be; i was quite curious about it. After all, fortran is not as brand new and fashion as python is, for example. So I joined the channel, and read the welcome message: "Fortran is not dead, it just smells funny...". Wich made me laugh for the whole day. Didn't you ever have this question when you are telling people you code in fortran ? We often have to deal with old libraries or programs coded with the 77 norm. These codes are often strong for they have been tested, validated, etc for a while. So when a person discovering fortran has to implement new features in these codes, he or she can feel forced to write them using the 77 norm, i.e. the one that was defined 40 years ago. And this may not be very exciting a first sight for a young programmer who discovers fortran. Worse, it can give the impression that fortran is outdated. And this chan shows the opposite. We aren't many people connected frequently, but I would say this is a nice point also, as we may know each other sooner. Some people take this chan only for support, as often on IRC. But remaining people are happy to see that some people take time -when they can- to help and share about fortran. I think this is very important because a lot of people use fortran, it is a very powerful language, easy to learn and deep enough to fulfill a lot of a programmer's desires and needs. The lessons you can find are often old, because changes in fortran do not happen frequently, so they don't need to be updated. When I think about this chan, I have in mind this xkcd comic about python, when she says: 'come on, coding is fun again !'. This nearly what my boss told me this week about fortran, as we were writing some code with four hands. And this is true that we are having great time with fortran. Fortran is not dead, don't hesitate to come on #fortran to verify it :)