DevC++ and their lack of discernment

If you know me, you know that I program mainly C and Perl, that my preferred editor is Emacs, and that I use mostly Mac OS X for that task.

But, I teach programming, and sometimes I teach programming to students that never heard of Linux or, worse, that never used the command line of Windows. Given this, I tend to search for simple solutions to help them do not deal with the command line so I can use more time for the task of learning how to program.

With that in mind, I decided to suggest a C IDE for windows. The main IDE (I think) is Visual Studio. Although it is paid, there are protocols between Microsoft and the universities to use their software for free for academic purposes. But the Visual Studio installation disc is some hundreds of megabytes. That is not very portable. Also, the application is quite heavy when running. I decided to search for an alternative, and found DevC++. It is just 10 megabytes of download, uses GCC (or MinGW), and works quite well.

It just have one big and stupid problem. Although DevC++ is being developed for more than a decade, their developers did not implement, yet, a pause mechanism for when you are running a console program. In their faq they suggest to add a ‘system(“PAUSE”)’ in the end of the code. That is just stupid! Why to have to add such a line in your code, just during development, and then remove it when you want to ship the application? It would be quite more interesting to have an option in the IDE to force that window not to close. Some other similar applications, like the Lazarus IDE for Pascal, include that option already.

Now I need to decide if I should go back to Visual Studio, if I should explain why DevC++ doesn’t work properly, and explain how to add a pause at the end of the application, of if I should go back and teach students how to test their applications right from the command line.

Pascal: parameters by reference

I posted some time ago about Pascal, and the nice (and worst) things that Pascal has in its language. I discovered yet another cool thing. Unlike C, where you can pass parameters to functions by value, or using a pointer (and therefore, as reference), in Pascal you can use a value, you can use a pointer, or declare a parameter as a variable. This is similar to passing by pointer, but with a cleaner syntax.

Note the difference between

procedure foo(bar: integer);
bar := 10;


procedure foo(var bar: integer);
bar := 10;

The first procedure does not change anything in the outside world, while the second changes the value of the variable passed as argument.

As expected, the compiler raises an error if you call this second procedure with a constant integer.

Pascal: The Good, the Bad and the Ugly

As I posted before, I am teaching Pascal. I could discuss the relevance on teaching this language in this decade, but that is not my concern. I would like just to point The Good, the Bad and the Ugly I find in Pascal.

The Good: Pascal evolved and is a high level language. You have auto-growing strings (ok, with a size limit), you have arrays indexed by characters, integers or enumerated data types. That is good!

The Bad: Pascal syntax continues to be a mess. Begin and End keywords make the code big, the attribution with ‘:=’ makes it easy to type errors, and the low precedence of logic operators make me angry.

The Ugly: I can’t find a clean way to try opening a file without crashing the application. The only method I found (check the bottom of needs you to turn on and off compiler flags. That is annoying, stupid and decidedly too low level…

Pascal is not dead

Probably you know that I was a teacher at the Computer Science Department at Universidade do Minho. There I was a C and Perl teacher, as well as other classes that are not relevant for this post. Now, I am working at Instituto Politécnico do Porto, in the Escola Superior de Estudos Industriais e de Gestão. I am not responsible for the class, so I teach what the responsible teacher says. I was quite surprised they still used Pascal.

But this was a stupid question. Now, after getting back to the Pascal world, I noticed Pascal is not dead, and it getting better, and quite far from C when regarding the abstraction layer. I will not discuss efficiency. It I would do that, I would not program Perl anymore.

Pascal is, like C, a compiled language. But it supports growing strings. Strings can be edited as if they were Perl strings. You can add substrings to the string, remove substrings by nothing or other smaller or bigger strings. But you can also use it as an array of characters and access to each character individually. I really miss this feature in Perl.

Pascal is now supporting units as classes. This means it can be programmed as if it were an Object Oriented language. I did not get to that point yet. But it is nice to know Pascal evolved.

Oh, there is a free compiler (free pascal compiler) and there is an IDE (lazarus) that enables GUI application development just like the old Delphi.