Semua Diskusi > Forum Steam > Off Topic > Rincian Topik
C++ is supposed to be OOP, right? >_>
It's entirely possible I'm missing something, but if I have a class A with a subclass B, why can I not cast an A to a B? >_______> That's a kinda important feature of OOP...
< >
Menampilkan 1-15 dari 50 komentar
Acetyl 10 Okt 2023 @ 3:20pm 
You could take a pointer or reference to the subclass. Only issue being whether the elements have a standard layout in memory or the compiler added padding for alignment. Otherwise if you're using inheritance or polymorphism, there's dynamic_cast. This actually seems more like an std::variant or union thing.
Terakhir diedit oleh Acetyl; 10 Okt 2023 @ 3:21pm
EASY PETE 10 Okt 2023 @ 3:38pm 
It's overrated anyway
Devsman 10 Okt 2023 @ 4:01pm 
Diposting pertama kali oleh Acetyl:
You could take a pointer or reference to the subclass. Only issue being whether the elements have a standard layout in memory or the compiler added padding for alignment. Otherwise if you're using inheritance or polymorphism, there's dynamic_cast. This actually seems more like an std::variant or union thing.
Will try. Thank you.

Diposting pertama kali oleh EASY PETE:
It's overrated anyway
It's one of those languages that are barbaric enough to have the assignment operator return something. I've never been a fan. I use its big brother for low level stuff once in a blue moon but I've mostly ignored C++ for about 15 years, lol. Until I got an assignment with it at work.
Devsman 17 Okt 2023 @ 7:16pm 
Diposting pertama kali oleh Acetyl:
You could take a pointer or reference to the subclass. Only issue being whether the elements have a standard layout in memory or the compiler added padding for alignment. Otherwise if you're using inheritance or polymorphism, there's dynamic_cast. This actually seems more like an std::variant or union thing.
Yep, turns out you can only cast a pointer for some reason. So THANKS! This solved my problem.

SMH, what the hell even is this language? Arrays are always indexed starting from zero. The bad assignment and equality operators. Weak typing. Shoddy contract support.

It's like I went back in time to 1985 and had a nightmare that the new successor to C that I'd been looking forward to was an incremental upgrade that should have released six years prior. Ada '83 blows this crap out of the water.
Terakhir diedit oleh Devsman; 17 Okt 2023 @ 7:17pm
Fajita Jim 17 Okt 2023 @ 7:20pm 
Diposting pertama kali oleh Devsman:
It's one of those languages that are barbaric enough to have the assignment operator return something.

♥♥♥♥. Pansy. Try COBOL.

Environment Division
Data Division
Procedure Division

♥♥♥♥
Devsman 17 Okt 2023 @ 7:23pm 
Diposting pertama kali oleh Fajita Jim:
Diposting pertama kali oleh Devsman:
It's one of those languages that are barbaric enough to have the assignment operator return something.

♥♥♥♥. Pansy. Try COBOL.

Environment Division
Data Division
Procedure Division

♥♥♥♥
I've heard tales from the days before C.

Dark times indeed. I'd just write assembly at that point, NGL.
Fajita Jim 17 Okt 2023 @ 7:25pm 
Diposting pertama kali oleh Devsman:
Dark times indeed. I'd just write assembly at that point, NGL.

The financial world runs on COBOL. Their ♥♥♥♥ can't be down for one second or they lose TRILLIONS! TRILLIONS I tell you! (So they say).

If I needed money I wouldn't have to work long. Any of you young whippersnappers looking for an early retirement here's your sign: COBOL.
Birds 17 Okt 2023 @ 8:29pm 
Declared class divisions are a step backwards and ultimately what C was created to avoid.

They've come back in fashion because your average modern programmer is taught one syntax that's as flexible as possible and then fills in the divisions set out by the project lead.

As such most modern languages do things like make the 0 enumerator inaccessible, typically adding an entire function to the project that's just 0-seeking because the language isn't supposed to be full-featured in the first place.
sleeps 17 Okt 2023 @ 10:57pm 
idk about c++ but i'm sure that even though it's oop, it's not necessary to write a code with it. even then, idc it's hard
Birds 17 Okt 2023 @ 10:57pm 
Diposting pertama kali oleh Wumbo:
command line interface master race

hang on let me just run the syntax shortcut that shows me the kernel folders without having to navigate.

oops i mistyped one character and accidentally activated my doomsday routine.

that's okay, the worm wasn't giving me issues on this os I flashed two weeks ago...

oh no, the worm came from my backup usb stick!!!
Birds 17 Okt 2023 @ 11:23pm 
Diposting pertama kali oleh Kiddiec͕̤̱͋̿͑͠at 🃏:
Sounds about right but each language has quirks and some quirks are better than others.

C++ was supposed to be my first major language, but instead, I only learned about it for 1 semester then moved on to other things. For most things, it's pretty easy and friendly to use but it's not quite accessible enough for beginner me. It also had an issue with the Microsoft library that our compilers in class had where Math.round would round to even numbers so 50% of the time it rounded up, and 50% of the time it rounded down but not based on the size of the decimal.

It's a bug leftover from the Visual Basic scripts the C+ includes were built off of, and the (singular) author refused to allow them to be changed for C++. The currents rightsholders are all moon cultists as well, and refuse to allow changes for the same reasons.

Microsoft's libraries are all built off of the same includes, so they are all subject to the same bug in various circumstances. As such remembering the algorithm's quirks can be important, such as basically falling apart when you toss it any multiple of 3. As a result just about any function which winds up calling that broken library has to include an exception which searches for and excludes 3s, and which also converts the data into a cipher which doesn't include 3's while it is being processed

imo, Actionscript 3 is the most accessible language that I've ever used. It's basically just rebranded / purloined javascript with some extras, though, such as an actual debugger console that throws actually useful error messages. The nice thing about that, though, was I'd often need to look for help on something in either JS or AS3 and someone said it was impossible, but by simply swapping JS to AS3 or AS3 to JS in the search parameter, I could find a topic for the "other language" that did the thing I was looking for that someone previously said was impossible. Since it's the same language I could just copy.

Once you get past the compiler and syntax bloat, Java is probably the second most accessible language, imo, probably about on par with C++. Even so, I still usually prefer scripting languages because you can test them a lot faster.

Java is built on the same broken library set, since it was sold to the same hostile entities that package the broken libs, and was designed as a way to develop for the web without having to learn Basic or Visual Basic.

It hasn't been updated in forever either as the intent behind buying it was to suffocate it, and it's kind of a stroke of luck that it took off. That and having been designed for a clear purpose that was eminently useful.

I'm not really sure if AS3 is still subject to the same security vulnerabilities introduced by the broken libs or not.
ナルゴ 17 Okt 2023 @ 11:29pm 
The guy that coined the term OOP, Alan Kay, envisioned Object Oriented programming as follows:
OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
-From an email exchange in 2003
http://www.purl.org/stefan_ram/pub/doc_kay_oop_en


His direct quote about C++:
I made up the term 'object-oriented', and I can tell you I didn't have C++ in mind
-- Alan Kay, OOPSLA '97

In other words. No. C++ does not fit the original definition of Object Oriented Programming.

It instead follows an entirely different paradigm that Bjarne Stroustrup(inventor of C++) defined, which hijacked the term OOP:
Given these general criteria for a definition of ’’object-oriented’’ you can find several plausible candidates, and several communities have their own definitions. However, I suggest we stick to the traditional definition of object-oriented used within broad communities of programmers. A language or technique is object-oriented if and only if it directly supports:
[1] Abstraction – providing some form of classes and objects.
[2] Inheritance – providing the ability to build new abstractions out of existing ones.
[3] Run-time polymorphism – providing some form of run-time binding.
This definition includes all major languages commonly referred to as object-oriented: Ada95, Beta, C++, CLOS, Eiffel, Simula, Smalltalk, and many other languages fit this definition.
https://www.stroustrup.com/oopsla.pdf

C++, along with Python, Java, C#, etc follow this instead.
Terakhir diedit oleh ナルゴ; 17 Okt 2023 @ 11:32pm
Birds 17 Okt 2023 @ 11:35pm 
Diposting pertama kali oleh Kiddiec͕̤̱͋̿͑͠at 🃏:
Diposting pertama kali oleh Birds:

It's a bug leftover from the Visual Basic scripts the C+ includes were built off of, and the (singular) author refused to allow them to be changed for C++. The currents rightsholders are all moon cultists as well, and refuse to allow changes for the same reasons.

Microsoft's libraries are all built off of the same includes, so they are all subject to the same bug in various circumstances. As such remembering the algorithm's quirks can be important, such as basically falling apart when you toss it any multiple of 3. As a result just about any function which winds up calling that broken library has to include an exception which searches for and excludes 3s, and which also converts the data into a cipher which doesn't include 3's while it is being processed
...
Or you could just do what my teacher suggested : figure out how to write your own version of the function that does what you want. In the case of the math rounding function, this is a relatively easy task, though, still quite a challenge for a beginner, like I was at the time. Now it's somewhat trivial but back then it was difficult.

Okay but on any enterprise application you're going to be working with the packaged libs. Not your bespoke 'good code' that you made yourself. And introducing a separate subfunction just to make your good code work with the libs is going to confuse everyone except you.

What do you think you are, some kind of skilled laborer? :p

Anyway the point behind the development of the libs in the first place was to design certain commonly-used functions that anyone could call, particularly in an enterprise environment where the codebase needed to be homogenized. The fact that they came out broken is, on the one hand, a heinous crime on the part of conspiratorial individuals, and on the other hand it's the natural end of most programming endeavors anyway.

AS3 is a branch of javascript and it's owned by Adobe instead of Microsoft so I'd guess probably not. Javascript only has so many functions in the first place. AS3 adds a lot of functions that JS actually did not have. Only 1 of them was broken in my experience - it was a pain to work around that but I figured it out. Too bad I don't remember the details since I had to abandon that project and move on to something else.

Yeah, but since it's a branch it has all the same libs and includes. And since Microsoft uses all of those in its codebase, I am doubly doubtful that they were removed.

Almost everyone moved away from AS3 when the foundational vulnerabilities in Java8 were discovered, as they depended on vulnerabilities included with libs from java 1 and were thus universal to the codebase.

The same vulnerabilities are why nothing past windows 98 is particularly secure, and the first step of hardening Win98 is simply removing those libraries entirely. Which, to reiterate, are 'legally inviolable' code from the late 80's which has wormed its way into absolutely everything.
Terakhir diedit oleh Birds; 17 Okt 2023 @ 11:38pm
Birds 17 Okt 2023 @ 11:39pm 
Diposting pertama kali oleh Nargo:
The guy that coined the term OOP, Alan Kay, envisioned Object Oriented programming as follows:
OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
-From an email exchange in 2003
http://www.purl.org/stefan_ram/pub/doc_kay_oop_en


His direct quote about C++:
I made up the term 'object-oriented', and I can tell you I didn't have C++ in mind
-- Alan Kay, OOPSLA '97

In other words. No. C++ does not fit the original definition of Object Oriented Programming.

It instead follows an entirely different paradigm that Bjarne Stroustrup(inventor of C++) defined, which hijacked the term OOP:
Given these general criteria for a definition of ’’object-oriented’’ you can find several plausible candidates, and several communities have their own definitions. However, I suggest we stick to the traditional definition of object-oriented used within broad communities of programmers. A language or technique is object-oriented if and only if it directly supports:
[1] Abstraction – providing some form of classes and objects.
[2] Inheritance – providing the ability to build new abstractions out of existing ones.
[3] Run-time polymorphism – providing some form of run-time binding.
This definition includes all major languages commonly referred to as object-oriented: Ada95, Beta, C++, CLOS, Eiffel, Simula, Smalltalk, and many other languages fit this definition.
https://www.stroustrup.com/oopsla.pdf

C++, along with Python, Java, C#, etc follow this instead.

The assignment of variables and working with variable classes is OOP, even if the 'OOP Guru' doesn't agree.

Otherwise the controversy is meaningless as both sides admit the term is made up and doesn't really describe anything at all.
Terakhir diedit oleh Birds; 17 Okt 2023 @ 11:40pm
Birds 17 Okt 2023 @ 11:53pm 
Diposting pertama kali oleh Kiddiec͕̤̱͋̿͑͠at 🃏:
Diposting pertama kali oleh Birds:
... Anyway the point behind the development of the libs in the first place was to design certain commonly-used functions that anyone could call, ...
Well, there's some pretty strong irony for ya then, given how many of them contain code that literally no one should call. :laughing_yeti:

Yes, well, we had to make hooks for the bots to get into our codebase somehow.

They were threatening to up their percentages on universal copyright if we didn't.

Also most modern libs load all their includes as one, such that there's no way to actually exclude problematic calls.

Minimalistic languages, such as Python, were designed with this problem in mind...but at the end of the day you can't get anything done without these libraries. And python's extremely permissive rules are basically just a gateway for bots calling these libraries with innocuous-looking code.

All other languages are similar, save for binary and maybe Basic if you can work around the libs in your i/o devices.

Meaning pretty much the entire past 40-50 years of software development needs to be thrown in the trash can.
Terakhir diedit oleh Birds; 17 Okt 2023 @ 11:57pm
< >
Menampilkan 1-15 dari 50 komentar
Per halaman: 1530 50

Semua Diskusi > Forum Steam > Off Topic > Rincian Topik
Tanggal Diposting: 10 Okt 2023 @ 3:16pm
Postingan: 50