Friday, March 16, 2007

Delphi and general design decisions in a language

Here are some pros and cons with Delphi, over and above what I’ve written (e.g. the great value of the Delphi-environment).

One thing I value in a language is ease of use when it comes to standard stuff. Those ordinary things you always do, like using basic I/O, file operations, conversions, arithmetic and so on. Most languages have their annoyances (actually, all I know have that, with the possible exception of Python though I’ve just barely begun using that. I don’t mind the forced indentation in Python.) Java requires too much work to do I/O (all that stuff with streams to do such as simple operation. But Java has that nice feature that auto converts non-strings to strings when using the "+"-operator. Delphi doesn’t, so you have to using function calls for that, although is an inbuilt always accessible easy-to-use function.

I like arrays in Delphi. Index doesn’t have to start at zero, and the indices in multidimensional arrays can be written within the same brackets, for example like this: [i, j] (instead of [i][j]). Simple and nice. Also, as in languages such as PHP and Python it’s possible to use ordinary arrays as map/key structures. That is, as indices you can use whatever values you want, including myArray[myString] where myString is a string. (Languages such as Java and C++ only let you use integers as index values. In ordinary arrays that is, there are of course available map-structures as classes, but that requires a little more work to use.)

The way you can receive several variables of a certain type with one declaration (in functions and procedures) is nice. You can type some_function(row, line: Integer), not having to type the type (no pun intended) twice, as in many languages).

And btw, I love the inbuilt powerful data types in Python. Having that powerful tool at your disposal with that ease of use is really nice, and worth writing about in its own blog-post some day.

Delphi deviates from the usual by having return-statements (called "Result" in Delphi) that works as variables. They do not end the function upon being called, but just changes its content and whatever the content is when the function has reached its end is what’s getting returned. That’s kind of weird and actually an semantic difference (compared to most other structured and object oriented languages) rather than a syntactic one. Haven’t decided for certain what I think about it, but I think I like it.


No comments:

Locations of visitors to this page