sabato 16 febbraio 2013

My story about using Linux

As for a lot of other Linux users and sysadmins I first met Linux at university. At that time I was attending a C-programming course which aim was teaching students about system calls, and in particular POSIX system calls (e.g., open, lseek, read, write and so on). One of the laboratories was running Debian Gnu/Linux (without X) and was used to let us connect to another laboratory where Solaris machines were in charge of students accounting. Of course, being lazy as a lot of other computer scientist, going to the laboratory just to test and run my small applications sounded to me like a huge waste of time, and therefore I decided to test applications at home, using my home desktop computer. 

It was years before the virtualization trend (and in fact a few years later a society called VMWARE was releasing its first version of virtualization stack) and therefore I had to install Linux on the bare hardware. I got a 3GB ATA hard disk that I placed on the slave controller of my desktop computer, and a friend of mine gave me a CDROM containing Red Hat Linux 5.2. And so I started spending time to install this operating system.
At that time it took around 2 hours to install the whole system (and gadgets) on my Celeron computer, but it was nice.

Of course, as others Windows-ized users did (I guess), I worked entirely as root because, you know, you are not so stupid to break the whole system with a miswritten command! And in fact, one evening while trying to make X running on my machine I corrupted something so that my system was no more able to execute X. And of course I did not have a backup of the modified files, and trying to solve the panic I generated I break out something else so that the only reasonable choice for me at that time was to reinstall everything from scratch.

Lesson learned: do backups and work as root as less as possible!

Last I was able to make X run on my computer, and at that time it was FVWM, that I suspect it is the most horrible windowing system I've ever seen. However I was so happy of my configuration that I called my parents to show them how beautiful it was my running system. And I suspect they did not understand my excitement for a few windows that
looked like the Microsoft Windows ones after your video card has  crashed.

By the way, I was in the Linux tunnel and started doing some  development stuff with it. However I was not able to use it for day-to-day work because, quite frankly, I had no day-to-day work. Moreover, configuring peripherals was a mess: I had to buy an external modem because my winmodem was useless with Linux. Making the printer, an HP on the parallel port to work was a little easier, but not at zero time. At that time the only way for me to get a new Linux distribution was buying some magazine with CDROMs included, since
downloading with a 56kb/s modem was a pain. And this is how I discovered a release based on Red Hat Linux, called Mandrake, that was shipped with KDE preconfigured. I was impressed! At glance the KDE was like a beautiful version of the CDE I was using sometimes on the University Solaris machines, and had a lot of things and gadgets that made me feel like at home.

In the meantime I started reading an Italian magazine entirely dedicated to Linux. At first, it was boring for me: who cares about how to install mod_perl on an Apache web server? I did not know what Perl was, and what Apache httpd was, and was interested only in getting all stuff connected to my computer to work! But as days passed, I was more and more interested in all kind of stuff that was related to Linux and the software you could run on it.

Some of the University projects I did were slightly related and tied to Linux, so I also started using it for a kind of day-by-day work, until it came my master thesis. I had to develop using Java, and therefore the choice among Linux and Windows was optional, but since I knew that would have been the last time I had to experiment without being fired, I choose to boot my laptop with Linux and force myself to use it. 
And I never looked back!

At that time I was running Red Hat 7.3, with KDE 3.0 and a lot of  peripherals were working out of the box, and others were either useless or I was not interested in getting them to work (e.g., the winmodem, since I was using the Ethernet cable to connect to the University network). That was the time I started writing my own small utilities (oh, and in the meantime I also learnt Perl) to backup my files, archive them, and so on. On one hand, I did not have the experience (and the will) to search for and study existing software, and on the other hand, I was recognizing the power of this system that allows you to write everything you want and, most notably, allows you to do. In fact, there was no need to download a complex IDE with a C compiler, I already had gcc. There was no need to download and install some extension for file scavenging and bulk renaming, I could write a three line script...

My first job was still tied to Linux, and I have to admit that I suspect I found such job because other friends of mine did not get the University chance for learning Linux. Unluckily, I had just to administer machines
running Linux, since I had also to use a compiler that was licensed only for Microsoft Windows, and therefore my computer was booted into Windows. But as soon as out of work, my laptop was running Linux!
Then, a special day: we got a compiler license for Linux. 
And my laptop did not boot Windows anymore!

Using it day by day also on my own machine allowed me to improve my skills on a lot of aspects, including scripting and programming. In those days I was addicted to KDE in a particular way, and therefore my poor laptop was forced to compile again and again every new version was released, and this was the cause for having it to run a "little" slower. But I was gaining time since I did not have to install SSH clients, X clients, and other fancy stuff since I had all there, in my black-foreground terminal window.

A few years later, for a reason I don't remember any more, I got a new job and I was not in charge of doing any particular development, but on the other hand, had to work with Microsoft Office. For that reason I started to boot my laptop into Windows again, and after a while I was booting it into Microsoft Windows only.
That was fine: after all I was simply writing articles, doing some Java development and teaching students, so after all I was not doing any serious work (and to some extent, nothing really productive). And then again I got a job where I was developing, administering and managing
on Linux machines. And again, I switched back to Linux for my own computer and the happiness reached myself.

A few years later, my wife got an EEE PC running Windows that was unusable. I installed Linux on it and used it for running even server applications when doing demos at conferences. And that was the time
I made my wife switching to Linux too.

Today I use Linux and other Unix systems (FreeBSD in particular), even at work, even if not suggested in doing so. 
Sorry pals, I got so much development power than I don't feel the need to apologize!

venerdì 15 febbraio 2013

Hiding your own source code: rm

Often, or better always, some of your friends, or colleagues, or co-workers in general will come up with a question about how to protect the code they write against people that want to steal it.
"I am so smart, I wrote this elegant, fast, reliable piece of code and I don't want anyone else to take it and embed it in their programs" or something like that.
When asked about how to hide your own source code I usually pick up a piece of the Perl FAQs that states:

How can I hide the source for my Perl program?
Delete it.[ ... ] Security through obscurity, the name for hiding your bugs
instead of fixing them, is little security indeed.

In my opinion, in these days of the GitHub, BitBucket, Sourceforge and the others free repositories talking about code obfuscation is simply stupid: the whole world is sharing with you tons of source code and you, little tiny programmer, believe that your code is so great that you have to protect it running a "macumba" on anybody who just sees it?
Well, I'm not so smart and my code is not so brilliant. And this is the reason why I strongly believe that my code should be public: on one hand I want to help people providing them ideas and programs, and on the other hand I'm thankful to anybody points me to errors or programming bad practices or whatever way I can improve my way of writing programs.

Of course there are techniques that are based on a crypto-loader that will decipher on the fly your (ciphered) code and run it, so that on the disk only a ciphered text will exist. But usually these techniques are not easy to use, and performance are not really good at all.

But sometimes you are forced to keep your code hidden due to some contract terms or policies. Well, in such case the only solution I see is to not give away any source code at all.
But be aware pal, reverse engineering is something hard but not impossible. After all Samba was a reverse engineering effort, and did you know that OpenBSD runs on Sun Ultrasparc III machine due to reverse engineering?

I guess the only true way to keep your code only for you is to edit-save-compile-run only into your brain. Oh, and not dream about it because some scientist with some dream-machine-from-the-future could get it out of your brain too!

Sysadmin Panics: changelog, commit, copy-and-paste

Per un motivo che non riesco a spiegare esistono ancora su questo pianeta dei sysadmin che usano gli strumenti di controllo delle versioni in modi barbari. Ora, e' vero, gia' e' una gran cosa che usino tali strumenti, ma almeno che spendano una manciata di secondi (si noti, secondi!) in piu' per usare tali strumenti al meglio.
Capita infatti che alcuni sysadmin in evidente stato confusionale usino gli strumenti di controllo delle versioni come un CHANGELOG: in sostanza associato ad ogni modifica (o peggio ancora in ogni singolo file) questi mantengono un changelog il cui contenuto e' esattamente identico a quello dei loro messaggi di commit.
Il caso piu' demenziale al quale ho assistito e' stato quello di un sysadmin che sistematicamente inseriva, in cima ad ogni file (!) un changelog delle modifiche appena fatte come ad esempio:

31/12/2010: ho fatto foo

per poi fare copia in colla del messaggio (!!) all'interno del messaggio di commit del sistema di revisione. In sostanza quindi leggere i log del sistema di revisione e/o ogni singolo file produce lo stesso risultato, che e' quello di avere un changelog. Tuttavia questo richiede sforzo doppio da parte del sysadmin...e francamente non ho mai trovato nessun programmatore fare una simile cosa, penso perche' dotato di maggiore comprensione degli strumenti.
Se quello che si vuole e' veramente avere un log anche all'interno dei file in questione si abbia almeno la decenza di usare le variabili auto-magiche che il proprio ambiente di revisione mette (sicuramente) a disposizione.

giovedì 14 febbraio 2013

GMail clean up

One year ago I merged two of my e-mail accounts into a single one, the GMail one to be honest.
The account I was "merging" was the one on which I run mailing lists, and that is of course full of e-mails at a very high frequency. It took me a lot of work to diligently set up filters and labels in order to categorize all my incoming e-mails, but today I'm proud to announce that my Inbox has changed from this

to this

Buon San (FSFE) Valentino

Oggi, giorno di San Valentino, festa fondamentalmente inutile secondo il mio punto di vista, voglio contribuire ad una iniziativa simpatica della Free Software Foundation e quindi voglio dichiarare il mio amore verso il Free Software. In particolare intendo ringraziare gli autori dei seguenti programmi, che uso abitualmente e che rendono la mia esperienza informatica qualcosa di unico:

- tutto il team di sviluppatori di Eclipse
- gli autori di Gnu Emacs e di Org Mode
- gli autori del KDE
- gli autori di PCBSD

I love Free Software!

Un ringraziamento particolare a tutti coloro che tentano di difendere e diffondere la mentalita' del Free Software e dell'Open Source, senza la quale molti di noi (informatici) non saremmo quello che siamo oggi.

venerdì 8 febbraio 2013

My story about using IBM Eclipse

For one reason or the other, my jobs always required the development of Java applications. I was used to work with Borland JBuilder, and the main reasons were it was simple but powerful and did not waste  megabytes or RAM making me wait more than 30 seconds to start and be fully functional. Nevertheless, it had some limitations, and so I was thinking to switch to a more complex and heavy environment, in particular NetBeans.
Then, at the 2002 PPPJ in Kilkenny, I attended the keynote speech of Mr. Vivek Sarkar that was at that time employed at IBM and therefore presented Eclipse 2. After the speech, while having a coffee, I asked what were the differences between Eclipse and NetBeans and why use one instead of the other. The main reason I got was the code refactoring, so once at home I installed Eclipse and tried it on my code base. At glance I did not like it: it was too heavy and complex, with too many functions and windows and tabs and other annoying stuff (I'm a terminal guy...). But the code refactoring was really impressive and I found it really useful.

So I started using Eclipse for my day-to-day development. 

Today it is still my Java default IDE, and I have noticed that a lot of people use it as a kind of fancy editor with autocompletion, without using some of the more interesting features like run configurations and Mylin.
In one of my previous job I had to create a client-server Java application that should have been really fast to run on Microsoft Windows and Apple machines. So I thought it was time for giving a try to SWT, the IBM Java toolkit Eclipse is based on. 

From SWT to Eclipse RCP the jump was fast and great, and therefore I started developing applications using Eclipse RCP v3.

sabato 2 febbraio 2013

My story about using GNU Emacs

GNU Emacs is surely the program I use for the most of the time I spend in front of a computer. It is the first program I install into a new machine and it is my favourite editor.
I started using GNU Emacs back to the days when I was an university student. In those days I was attending an Operating Systems course that was based on Unix, and being Unix a system where handling text files (both for configuration or programming) is so important, the course had a particular focus on the vi text editor. 
I have to admit: I hate vi with the passion. Is not that I don't see how powerful it is, but I find the editor too awkward for me to use in day-by-day activity. 
Am I in the editing mode? Command mode? Aline mode? What is that ~ at the beginning of each line? You get the idea of what I was thinking!

However, at that time I both did not have the choice to switch to another editor (because the exam had to be done in vi!) and I did not have enough skills to evaluate another editor.
The only choice was therefore to study vi and try to understand why my professors were so excited in using it. And my hate raised up again when I discovered that they were teaching us a really inefficient way of using the editor itself. As an instance, the official course documentation mentioned the :wq! way of exiting the editor without forgetting to save the current file. Well, good luck with make then! I found that ZZ was a more intelligent way of exiting having the editor to save only if really needed, and therefore without modifying the file metadata and without firing up a make each time. Well, begin an university course, the projects were really limited to a few files, so having to run make each time was not a big deal, but the fact is that each tool should be used in the much proper way. As another example, there were no explaination about splitting windows, regular expression search and so on. After all, they were teaching vi much more like an Unix Notepad application!
Actually, I see a lot of my colleagues that still proudly use vi in a very elemntary way, and others that have chosen to switch to Notepad++ because it is much more powerful.
Sorry guys, you are using the tools in the wrong way!

Last but not least, not only university was teaching vi in a bad way, but for the worst reason ever! In fact, one reason to study vi was that "it is an editor you can find on any Unix installation". I discovered years later that it was not true at all, and in fact many Unixes does not include vi in the base system. Another reason gave to us from the professors was
that "it can run even when X Window does not work", and while this is true, I have to mention that professors were using SSH to connect to servers from Microsoft Windows clients and that none of the servers at the university were running X Window. So who cares if the editor works or not with X?

Once the Operating System course was over, I decided to study another editor for my incoming Unix activity, and since I did not want to waste my time learning some naive program, I decided to give a try to the other World's Dominating Editor: GNU Emacs.
Well, I cannot explain why, but the GNU Emacs commands were simpler for me to remember than the vi modes one, even if I have to admit that both have a very cryptic set of keyboard mappings! The only drawback of Emacs at that time was the resource consumption: Emacs required a few megabytes, around 32/64, and for my poor Intel Celeron 700 MHz with 192 MB of RAM it was a big deal to load the editor. But once
it was loaded it was fast and responsive. And by the way, it was much lighter than Forte4Java or Eclipse!
At least Emacs had a status bar (the mode line) and the minibuffer and there was also a X port, even if I never used it because I wanted to learn the "real" terminal one application. For a lot of time I was using Emacs as a pure editor, and the set of commands I knew were the basic ones that allowed me to do the routinely work. And I was proud to be almost the only guy that was firing up Emacs instead of vi in the whole laboratory!

Then came the days of my master degree thesis. As usual (for me), I decided to use the thesis as an excuse to learn other tools, so I picked up Borland (now Inprise) JBuilder for the Java development, LaTeX and Emacs for writing the documentation, Umbrello UML Modeller and Dia for the diagrams and pictures. Everything was going fine, and my LaTeX file was growing quickly: at the end it was more than 84000 words and more than 9300 lines. Emacs was working diligently, without showing any problem with such a big file. Almost at the end of the thesis, when I was relaxing and enjoying the last days of work, I decided to give a try to other editors: Kate (the default editor for the KDE environment) and Kyle (an ad-hoc editor for LaTeX). The result was horrible in both cases: Kyle was crashing on each forward-search I was doing, and Kate was extremely slow even in jumping from the beginning to the end.
This little and simple experiment convinced me that there was no need to search for another good editor, and that Emacs was what I needed for almost every job.

The next year I was working as sysadmin and developer and I was using Emacs for pretty much everything I did including scripting, Perl  programming, text processing and so on. The only programming  language I was not using Emacs for was Java, since I was switching to Eclipse (a tool I still use for Java development). In particular I had also to
develop in a strange language, Dataflex, that is similar someway to Cobol. I was disappointed to see that Emacs did not had a specific major mode for such language, but at least it was something I could use for doing my programs!

I continued to use Emacs for several years, pretty much for any editing that does not involve a whole IDE. And often I fire up Emacs when I want to have a quick view at files or folders without having to start
a more complex and heavy tool. Sometime I try other IDEs, because I believe that one should always try everything, but sooner or later I always come back to Emacs. The "heavy" factor is no more important these days: Emacs has not grown in size as other tools (like Eclipse) did, and therefore is fast to load and always responsive.

Last year I decided to study Emacs Lisp, in order to improve both my developer and Emacs skills. I have to admit that elisp is not my ideal language, but it is fun enough for me to write some function to  instrument the editor to do what I want, when I want, where I want. And this is the power of Emacs.
Today a lot of people think at Emacs as a text editor, but Emacs is a text editor as much as Eclipse is a Java IDE: this is not true! 
Eclipse is a whole Java platform on top of which the IDE is the mainstream product and Equinox is the reference platform;
Emacs is a lisp interpreter on top of which you can work with files. 
This is what I see.

Today, thanks to Org mode, Magit, Autocomplete and other features, Emacs is really a great environment to spend the whole day into.