Pascal and LOC

code, pascal

Unrelated to Corona, my work contract expires at the end of this month. Good time for some reflection. In this job, Pascal was and is still the main language used for writing tools for use in the clinic or for data collection. My main problem with that also was and is that it’s hard to find Pascal code online. Github project? I can’t recall stumbling upon a single one. Code questions? Very, very few on Stack Overflow. The Lazarus forums have some discussion and inline code examples. Unfortunately, the job used Embarcaderos tools exclusively, and it was not hard (e.g. for string manipulation) to come across small differences confusing the newcomer.

When you compare that to the vastness of online resources for languages such as Python and C++, you’re paying a high price for using that language, in my opinion. In this job, tools were also always GUI first, which I (and many others) will grant is Pascals strong suit, although it also led to problems automating tools, which to me have always been the starting point of any program. (Roughly, after getting to a PoC, I try to stick to lib-script-gui as the order of priorities. A lib makes it easy to reason, a script makes it easy to repeat, a GUI makes it easy to… well, that depends on your GUI, in particular how much time you have completing it and how flexible you need it to be. In research, desired or relevant outputs change so often, it’s hard to imagine writing GUIs and being stuck to that fixed interaction are really ever worth it. I think it’s no wonder Mathematica/Jupyter Notebooks are so successful, they make scripting and viewing different kinds of outputs breezy. On top of that, in particular Python’s ecosystem is so rich and easily used, you barely need to be able to code. At least when you start out.

The existing Pascal code in this job had another feature that was hard for me to deal with, which was many very long source files. Think 10kLOC+. Many close to or more than 100kLOC. Incredible. Embarcadero nor Lazarus were helping with that; as IDEs they felt outdated. Eclipse, Visual Studio (Code), Qt Creator (and my favorite, KDevelop), they all had much better code highlighting, navigation and project management functions than their Pascal alternatives. I felt they did not offer me any help when dealing with those ginormous files, which I’ve never really seen in any Python/C++ projects. Sure, Geant4 has some files in the kLOC range, but those are (were?) exceptional, and longstanding dogma recommends avoiding that.

Hence my interest stumbling across the SciPasTips Twitter account: finally a sign of life! Any life! Well, no Github projects or code linked so far, but I found a Pascal course. With code! And what do I see when I open up a random example’s main class source code? An 11kLOC file… I guess it’s a cultural thing.

It’s a pity, I really feel like there’s a more modern and understandable (and thus usable) language hiding somewhere in Pascal. It’s just that tools and customs seem not to be helping, GUI design excepted. Excepted too perhaps is C library interop, that was (almost) easier than using the lib in C itself.