More impressions on Windows Programming

I'm still learning how to program for Windows in C++ using the Win32 API, and I'm writing more of my impressions — remember that I've worked with Linux for the past 12 years, and this all is practically new for me.

  • Visual Studio is not a bad IDE, but it is not excellent either (at least for C++). That, or I have been spoilt by Eclipse and IntelliJ IDEA and their excellent support for refactoring (at least for Java). IDEA has such a powerful autocompletion, I have written complete modules without writing a method or variable name in full. In Visual Studio, OTOH, IntelliSense stops working all the time. Are you initializing a variable in the definition? It stops working. Have you got a syntax error 50 lines up? It stops working. Are you using C++ templates? It stops working. I don't know why it stops working so much, when it doesn't even try to figure out whether you want to input a type or a method or a variable name.
  • It is hard work embedding Internet Explorer in an application when you aren't using MFC or Visual Basic or C# or one of those frameworks that give you a "WebBrowser" class in which all the work is already done. Not knowing anything about OLE/COM/ActiveX didn't help, of course. I have to thank Jeff Glatt for his article, “Embed an HTML control in your own window using plain C” (and his “COM in plain C” series), and the authors of wxCode's IEHtmlWin component (once again, Free Software comes to the rescue!). Reading them helped me to understand how it works. Now when I go read the documentation on MSDN, it makes sense!.
  • Talking about MSDN, the quality of the documentation varies. At some points it is very comprehensive and includes tutorials and guides and everything, and can be read as an introductory book. However, at other points it already assumes you know how to do what you want to learn, and only includes a very broad overview and reference information. Not that the documentation in most Linux or free/open source projects is much better in general, mind you...
  • Update: I also want to correct my previous assertion that there was few documentation and my assumption that they kept it scarce on purpose for book publishers' sakes. It turns out there is plenty of documentation (see the point above), only that I didn't know how to find it, as it wasn't in the Express Edition help files. I think. Anyway, it's all online on MSDN.

Two weeks after

On August 15th I had posted a story saying that I was going to use Windows more frequently, and that I was even going to learn how to program for Windows. Let's see how it's going:

Of all the differences between Windows and Linux, the one I notice the most is the lack, in Windows, of the “primary selection”. That's the technical term for the X-Window feature that allows you to select some text with the mouse and then paste it anywhere pressing the mouse wheel. I use that all the time in Linux, so in Windows I always forget to press Control-C and Control-V to copy and paste.

As I said before, I'm also learning how to program for Windows. At first I had downloaded Visual Studio C++ Express Edition (as it is free of charge), but it has so many limitations that it did actually get in my way. Fortunately, in Microsoft's web site there's an evaluation version of Visual Studio Professional Edition, which has all the features but also a 90-day limit, so I downloaded it (3 GB) and I'm using it now.

The program I'm writing is a Twitter client. Writing this program will allow me to work in many different parts of Windows, such as the user interface, network communications, APIs for interpreting XML and working with graphics, etc. It will be quite hard because I have to learn everything as I go, but I already managed to write a program that displays a window and can download data from Twitter and show it in the window in the same XML format it was received from the server in:

A screen capture of the program's window.

Ah, and I also played (and finished) World of Goo. That's a game about joining balls of goo forming structures to achieve an objective. It was made by four people on a 10,000-dollar budget, and it was very successful. It is truly a beautiful game, and it's worth it. Ah, and it works on Windows, Mac and Linux (and there are demo versions for the three architectures).

Taxis in Dublin and in New York City

When I first arrived to Dublin, I was told that there were more taxis in Dublin than yellow cabs in New York city. Of course, I didn't believe that, so I asked for clarification: “per capita, or in absolute terms?” “In absolute terms” was the response. I didn't really believe that, but let the matter rest.

Until yesterday, that is. In conversation, the taxi subject came somehow and I finally decided to investigate the matter. I decided to count only licences for vehicles of the type commonly called “taxi” or “yellow cab”; this excludes hackneys, limos and so on.

So, for the conclusions: Co. Dublin has roughly 12,000 taxis for roughly 1,200,000 people. That's 100 persons to a taxi. New York City, however, has roughly 13,000 taxis for roughly 8,400,000 people. That's 646 persons to a taxi. Therefore, Dublin has fewer taxis than New York City in absolute terms, but way more per capita. Had my friend said “per capita”, he would have been right.

Coming to the dark side

I've been using Linux since the end of 1996. At first, like everybody else, I dual-booted between Windows 95/98 and Linux; however, when I bought a new computer back in 2004 I only installed Linux in it (even though I had set aside some room for a Windows partition, in the end I never got around to installing it), so I used Linux exclusively until I bought my new computer, one year ago.

This computer came with Windows Vista. I briefly thought about emptying the hard disk and installing Linux alone, but in the end decided to just reduce the size of the Windows partition and install Linux alongside it. This partition remained essentially unused until a couple of months ago.

A couple of months ago I noticed I had been bored when using my computer. After all, even with an Internet connection, there's a limit to the number of LOLcats one can look at in a day. So I remembered I had a Windows partition, and ordered the Orange Box. The Orange Box is a box, coloured orange (duh), containing several games (three episodes of Half-Life 2, Portal and Team Fortress 2, as far as I can remember). I completed Portal in four hours, tried Half-Life 2 (didn't like it very much, so I never got very far in it) and then started with Team Fortress 2, which I play and enjoy quite a lot.

Right before that, I had also bought a HD camcorder, to make all those little videos I post every once in a while. It turns out that all free video editing software for Linux sucks, but there was Microsoft Movie Maker in my Windows partition, which also sucks, but at least it works, so I could edit my videos, even if I could not do a lot of things.

Between those two things, I found myself using Windows quite a bit. Not quite a lot, mind you, but a fair bit nevertheless, so I wondered: “What would it be like using Windows more?”

One of the things I would like to try is Windows programming, so for an “authentic” experience I went and downloaded and installed Visual C++ Express, which is free (as in beer). In search of a tutorial to get me started, I opened the online help and clicked on a link promisingly titled “create your first Windows C++ application”, and sure enough, it was a page full of instructions on how to build a program that displays a window and shows “Hello, World!” However, the link for “Next step” wasn't titled “Add a button to the window” or “Make your application interactive” or something like that, which would be the obvious second step for a tutorial, but something like “Use the CLR from C++”.

I think I hit one of the differences in philosophy between the “Free Software” camp and the... well, the rest of the world. I'm assuming that there's a lot of companies publishing books with titles like “Learn Windows programming in 24 hours” or “How to study for your MSCE exam”, and they would get mightily upset if Microsoft included a comprehensive, free tutorial in Visual C++ Express.

So I caved in and bought two books: “Windows via C/C++” and “Windows Internals” (I'd prefer to do systems programming). I haven't opened them yet (there are still 350 pages left to finish “War and Peace”), but soon will.

I'll report back when I have more experience in this Windows thing.

Confesiones de un troll de Internet

Este vídeo-documental demuestra que el que juega con fuego (aunque sea virtual) a veces se quema.

Pasatiempos de verano

Sudoku blanco.

Lo hago todos los días, pero siempre me da una solución distinta de la del periódico.

15-second summary of “Gödel, Escher, Bach”

Note: It's been a while since I read it, so I may have forgotten or mixed up some details.

…… ………! … …… ……! ……? …!? ………? ………?? …??…? …?!??? ?…???! ??……??? …???…??!????? !?

And this was the point where I knew I had wasted $25.

Los protagonistas de las películas de terror

En este vídeo vemos lo que ocurre cuando el protagonista de una película de terror tiene tiempo de reflexionar.

Why do evil scientists build their secret lairs in volcano islands?

A volcano island offers many advantages to the enterprising evil scientist:

  • Land near the volcano is cheap, land on the volcano is even cheaper, and land inside the volcano is practically free!
  • If the island is far enough from other land, you can use it as a base to launch rockets or intercontinental missiles without endangering or causing inconvenience to any surrounding population.
  • Lots of geothermal energy provide heating in Winter and allow you to power a great amount of equipment without spending a single euro and without emitting any CO2 to the atmosphere. It is Green energy!
  • If you ever need to deliver a nuclear warhead or a Laser pulse to the Earth's core, easy access to a magma chamber provides a convenient pathway for a drill.
  • If you are artistically inclined, the volcano presents a big face of rock on which you can carve your face, a skull with glowing eyes, or anything you want.

Of course, it also has its disadvantages:

  • Its distance to land will mean that you'll need to ferry any materials by helicopter, plane or boat, which can become expensive very soon.
  • This also means that you'll need to provide transportation, lodging, food and entertainment to all your minions.
  • Finally, take into account that, even though you have the whole island to yourself, this island still belongs to a country, so you may not be exempt from its employment laws and labor agreements. Many forget this, and then get in lots of trouble and have to pay millions in compensation when a secret agent comes and wrecks the place and hundreds of minions die.
Jacobo Tarrío is not an evil scientist, but spends too much time thinking about how to get an island, declare independence, and then rule it with an iron fist.

El guante y el duelo

En estos tiempos en los que se han perdido las buenas costumbres del pasado, ya nadie sabe cómo desafiar a otra persona a un duelo. Como ejemplo de mi afirmación pondré a Homer Simpson, que en un episodio deambula con un guante en el bolsillo, listo para dar un guantazo a quien se cruce en su camino y decirle: “señor, lo desafío a un duelo”.

El problema es que Homer lo está haciendo mal.

En aquellos buenos tiempos pasados, había varias formas de solucionar las cuestiones de honor: las ofensas más leves se podían solucionar con una disculpa, pero las más graves causaban tal daño al honor de uno, que sólo era posible repararlo mediante la celebración de un duelo.

Y con esto llegamos a la función de los guantes en los duelos. Hoy en día, mucha gente piensa que, cuando uno era insultado y quería reparar su honor mediante un duelo, debía darle un guantazo a su ofensor. Sin embargo, en realidad se hacía al revés: el caballero ofendido se quitaría el guante y lo arrojaría delante de su ofensor; se suponía que éste debía, entonces, recoger el guante y abofetear a la persona originalmente insultada.

Esto se hacía así porque un guantazo era el insulto más grave que se podía infligir a un caballero, y sólo se podía reparar en un duelo. Por tanto, este gesto obligaba a reparar en duelo una ofensa que, en principio, se habría podido resolver por otros medios.

Uno podría pensar que el resultado final sería el mismo si el ofendido fuese quien le diera el guantazo al ofensor; sin embargo, esto haría que se inviertieran los papeles de “desafiante” y “desafiado”, con lo que eso supone a la hora de decidir quién elige el sitio y la hora, y quién elige las armas.

(Por supuesto, generalmente no era necesario dar realmente el guantazo; con recoger el guante ya se consideraba que el guantazo estaba dado y el desafío aceptado. Ahora bien, si uno todavía tenía ganas de seguir insultando, no había nada que le impidiese dar el guantazo).

Espero que, después de leer esto, sepáis qué hacer la próxima vez que necesitéis desafiar a alguien a un duelo.