June 24, 2022

On Friday, 24 June 2022 at 14:30:54 UTC, Zoadian wrote:

>

I'm not claiming objects are generally bad. But OOP in general is a bad design strategy if you want efficient programs.

The Simula class concept is to a large extent meant to support changing the model later. So it is sensible for simulation where you experiment (programming cost being higher than hardware costs). This is basically where inheritance comes in. You have a working model, then someobody tells you: we actually need to model not only Doctors, but also Nurses, AmbulanceDrivers etc. How quickly can you accomodate that wish? This is also a strength of relation-based databases, just add more tables.

>

All these problems can be solved, at least to some extend, but IMHO it's not a good strategy for implementation.

I don't think existing languages have good support for hardware. C++/C requires the compiler to use the same layout for fields in a record as the source. That is a bummer for inheritance in terms of cache-lines, but that is not an OO weakness, it is a language weakness.

If we talk high level OO, then there should be no hard relationship between the code and the layout (e.g. it could broken down to structs of arrays or arrays of structs or components etc by the compiler based on hints or analysis).

Main stream languages are very primitive still… Outside of Rust, many languages seems to be satisfied by adding a thin layer over LLVM…

>

it's fine to model a system as OOP at first, restructure it to something more performant.

Sure, you can implement an OO-model in C or assembly. Most games of the 80s probably had some ad hoc OO-model implemented in clever ways in assembly to pack it into 32/64K RAM :-)

June 24, 2022

On Friday, 24 June 2022 at 15:14:44 UTC, Ola Fosheim Grøstad wrote:

>

The Simula class concept is to a large extent meant to support changing the model later. So it is sensible for simulation where you experiment (programming cost being higher than hardware costs). This is basically where inheritance comes in. You have a working model, then someobody tells you: we actually need to model not only Doctors, but also Nurses, AmbulanceDrivers etc. How quickly can you accomodate that wish? This is also a strength of relation-based databases, just add more tables.

On a personal note: I also use have a default preference for OO when that makes it possible to avoid documentation because the implementation has a 1-1 correspondence with the model. Then you don't have to deal with out-of-date documentation and the boring task of writing documentation.

This is also desirable when you evolve software rather than plan it (experimental prototyping or simulation). If you expect a lot of successive changes then documentation becomes a real burden.

June 24, 2022

On Friday, 24 June 2022 at 15:14:44 UTC, Ola Fosheim Grøstad wrote:

>

I don't think existing languages have good support for hardware. C++/C requires the compiler to use the same layout for fields in a record as the source.

Please show me an alternative that allows to respect the substitution principle.

June 24, 2022

On Friday, 24 June 2022 at 18:08:15 UTC, user1234 wrote:

>

On Friday, 24 June 2022 at 15:14:44 UTC, Ola Fosheim Grøstad wrote:

>

I don't think existing languages have good support for hardware. C++/C requires the compiler to use the same layout for fields in a record as the source.

Please show me an alternative that allows to respect the substitution principle.

The simple approach is to reserve space for the fields you want to be on the same cache line. The root cause for the C++ model is separate compilation. If the compiler knows the full class hierarchy then it can choose a different layout. That is obvious.

June 25, 2022
On Friday, 24 June 2022 at 13:48:35 UTC, Zoadian wrote:
>
> No disrespect, but this is a programming language forum, i'd really appreciate if it stayed that way.
>

Actually, I was under the impression a moderator had locked this thread, as they decided it was off topic.

But before they do that again, let me say this:

(1) Philosophy is not a religion. It is a tool.

(2) Philospohy and Programming/Programming Languages, are deeply 'entangled' whether you have the capacity to see to that level of detail, or not ;-)

(3) the statement item (2) above is demonstrated throughout academic literature on computing. It's not something I just made up ;-)

I was watching this fascinating talk by Matt Godbolt last night.

'CppCon 2018: Matt Godbolt “The Bits Between the Bits: How We Get to main()'
https://www.youtube.com/watch?v=dOfucXtyEsU

It's like he's deep within the quantum world of computing ;-)

Of course, it gets even more quantum than that too... and seemingly, just keeps going... to what end .. I do not know.
June 25, 2022
On Friday, 24 June 2022 at 13:48:35 UTC, Zoadian wrote:
>
> ...
> And to add something to the topic. objects are a great why to think about things. they are, as it turned out, not they great in programming.
> OOP leads to slow, hard to reason about code. it encurages mutable state, spread across the whole programm. it's essentially global variables all over again, just hidden behind a layer of obfuscation.
> It also makes testing a lot harder to actually implement.
> That being said, there are cases where it's ok to use, but imho they are incredibly rare.
>
> - Someone who works on hard realtime systems

I think if we put these claims to the test, they would be found wanting.

I'd also love to see, what a non-OOP program would look like, if one were completing this assignment, with the use of objects.

Certainly possible, no doubt.

You could do it in C. Hell, you could do it in Assembly. But would you?

https://solidsoftware.com.au/Tool/Software/AI/Agents/TrafficAgents.html

That assignment, is minisule, compared to software projects being untaken everyday, all around the world.

June 25, 2022
On Saturday, 25 June 2022 at 09:29:09 UTC, forkit wrote:
>
> I'd also love to see, what a non-OOP program would look like, if one were completing this assignment, with the use of objects.
>

Correction: The previous post should say 'without the use of objects' ;-)
June 25, 2022
On Saturday, 25 June 2022 at 09:29:09 UTC, forkit wrote:
> I think if we put these claims to the test, they would be found wanting.
>
> I'd also love to see, what a non-OOP program would look like, if one were completing this assignment, with the use of objects.

Probably the most common "non-OOP" way of organizing data is to use tables.

You see tables most commonly in relational databases, but also in data science (where they go by the name "data frame" [1]) and in low-level code using so-called "data-oriented design" (where they go by the name "structure of arrays" [2]).

Whether tables or objects are a better way of organizing data is a decades-old debate that I have no intention of wading into here. Regardless of which you prefer, you must admit that both tables and objects have a long history of successful use in real-world software.

[1] https://www.oilshell.org/blog/2018/11/30.html
[2] https://en.wikipedia.org/wiki/AoS_and_SoA
June 25, 2022

On Saturday, 25 June 2022 at 18:05:31 UTC, Paul Backus wrote:

>

Whether tables or objects are a better way of organizing data is a decades-old debate that I have no intention of wading into here.

What debate? You can easily represent objects in a relational database. One table for the superclass, another one for the subclass extension. The main discussion has really been about whether you want relational or hierarchical structure. The latter is better for performance. It is fairly easy to distribute objects or hierarchical, but relational is harder, yet very flexible. Keep in mind that XML databases often are implemented as relational tables, and you can represent objects as XML with ease…

The real clash is really with lower level languages adding OOP, as OOP is very much a high level concept. Java and C# don't really improve a whole lot on the runtime organization over Simula. Which is sad. Still primitive in other words.

June 25, 2022

On Saturday, 25 June 2022 at 18:23:20 UTC, Ola Fosheim Grøstad wrote:

>

The real clash is really with lower level languages adding OOP, as OOP is very much a high level concept. Java and C# don't really improve a whole lot on the runtime organization over Simula. Which is sad. Still primitive in other words.

In other words, C++ messed up OOP by exposing the implementation and thereby depriving the compiler from optimization opportunities. OOP does not dictate a particular organization in memory.