notes / thoughts

11.11.2025: C++ constructors are not it
I hate C++, but can't stop writing it. One of the things that I really hate are constructors.

For initializing any object for which the initialization logic can result in an unrecoverable error I never use constructors directly. The reason is simple: Constructors don't return values, so they can't return error values. If I want to adequately communicate that the construction failed, I have to throw an exception.

Loads of people tend to use two-phase initialization as a valid alternative, but it really isn't. Even the C++ core guidelines say that you shouldn't do this, as it removes any guarantee that an instance of a two-phase-initialized object will be valid at any point in time.

The only real solution I've found is to make constructors private and only expose custom factory functions which can return an error if needed. This is far from a solution I'm completely happy with, but the best one I currently know.

(btw this video by Logan Smith is really great and hammers the point home).
01.10.2025: changes i would make to freepascal
Even though it is probably my favourite implementation of my favourite language, there are many things which annoy me. This list in particular is just an outline of some smaller things (be it language, rtl or compiler side) which I would change.
  • Case sensitivity by default.
  • Scoped access by default.
    • i.e accessing functions, procedures, types, etc. from other units would require proper identifier resolution
  • Sane(r) defaults.
    • AnsiString as the standard string type.
    • UTF-8 as the standard codepage.
    • The "Integer" type should correspond to NativeInt.
      • If this is a problem, you should be using fixed-width integers anyways.
  • Make it possible to combine one unit per compiler invocation.
    • A single fpc invocation building an entire program is cool, but sometimes I want to control what gets recompiled and whatnot.
  • Add flexible array members
    • This is something that I mainly wish for when creating bindings to C libraries or when working on a lower level where this actually matters.
  • Allow for trailing commas in array initializations and enum definitions.
    • Potentially also applies to other places which i can't think of right now.