3 ms·
Delphi had a ton of features that you'd find in C# but were absent from Borland Pascal 7, like: 1. The 'class' defined objects which were always allocated on t
by badsectoracula 6y ago
Delphi had a ton of features that you'd find in C# but were absent from Borland Pascal 7, like:
1. The 'class' defined objects which were always allocated on the heap
2. Classes themselves being values with their own metaclass types
3. Classes having their own class procedures which could also be virtual (belonging to their metaclass)
4. Being able to instantiate an object instance dynamically using a class value (metaclass instance)
5. Classes having properties with getters and setters
6. A rich (for its time) RTTI with classes exposing properties to it and being able to alter at runtime (you can query a class for the exposed properties, their types, etc and there are utilities for setting them by their name as as string) - this was the basis for automatic form and component serialization ("streaming")
7. "Fat" pointers for method callbacks that could be used to associate event handlers
And a bunch of other stuff i certainly forget. Even at version 1 Delphi's Object Pascal was a much more powerful language than any Pascal dialect before it (the Object Pascal in BP7 was a very small improvement on the one introduced in TP5.5 which AFAIK was mostly the same as Apple's Object Pascal - though i think one difference is that in Apple's objects must be allocated on the heap like in Delphi whereas in TP5.5/6/7 they can be allocated either in the heap or live in the stack).
- pjmlp 6y ago> Even at version 1 Delphi's Object Pascal was a much more powerful language than anything before Only if we ignore that many of its new features were already present in Eiffel, including those 7. Here is another two Eiffel features that we still don't have in modern languages as widespread as it should, design by contract, and non nullable types. Language archeology is an interesting subject, unless you are comparing Delphi with TP. By the way, I really hated that with Delphi I had to deal with class and legacy object to express parallel concepts, and that OWL was thrown out of the Window and I had to rewrite everything back into VCL.
- badsectoracula 6y agoSorry i meant anything when it came to Pascal, not in general. Many of the features found in Delphi 1 can also be found in other languages like Smalltalk (in fact sometimes i wonder if the reason of the massive changes between BP7 and Delphi 1 is Anders learning Smalltalk in-between :-P). About objects, i agree that the two systems are weird and IMO it is made even worse with the introduction of 'advanced records' in Free Pascal and recent Delphis which also act as objects-except-not-really. IMO the 'object' types should have been extended with the new stuff and have 'class' just be syntax sugar for 'pointer to object' and 'record' be just a synonym for 'object' for backwards compatibility (so that everything is really an 'object' - it is "Object Pascal" after all :-P). I do not know how Delphi handles this nowadays but in Free Pascal 'class' has the most advanced features but must always be heap allocated (meaning you can't embed them in other compound types or allocate them on the stack), 'object' has a lot of the 'class' and/or 'record' functionality but arbitrarily missing some (e.g. support for management operators, so you can't have RAII-like objects) and 'record' (after explicitly enabling support for advanced records) does have more functionality available (e.g. management operators) but does not support inheritance. You can work around it (e.g. put all your data of an object inside an advanced record with management operators and then put that record inside the object so that you can write code that does any cleanup when the object is declared on the stack and goes out of scope) but it can be annoying - and maddening when you work on the compiler itself and notice that all these compound data structures are implemented internally the same way and the compiler explicitly disables support for some!