Learn the C with Shodan

09/11/2017 00:33 warfley#16
Quote:
Originally Posted by algernong View Post
I'm writing from the following stance: OOP (or programming paradigms in general) isn't about syntax or language features, but how we organize and design code.

This stance seems to be right:

[Only registered and activated users can see links. Click Here To Register...]


[Only registered and activated users can see links. Click Here To Register...]

With this in mind, object oriented code is independent from the language it is written in. OOP languages like Java offer syntactical sugar to explicitly support the OO paradigm. This, however, doesn't mean that every Java code is object oriented.

Oder explizit nochmal:

Das ist doch quasi die Definition von Syntax Zucker und hat nichts mit irgendwelchen Paradigmen zu tun. Zuerst kommt das Paradigma, dann die Sprache, mit der man das komfortabler anwenden kann.
Well I like to stick to standards, like the ISO/IEC-2382-15-Standard:
Quote:
Pertaining to a technique or a programming language that supports objects, classes, and inheritance.
Or like Alan Kay, (about the inventor of OOP) categorized it:
Quote:
1. Everything is an object
2. Objects communicate by sending and receiving messages (in terms of objects),
3. Objects have their own memory (in terms of objects)
4. Every object is an instance of a class (which must be an object)
5. The class holds the shared behavior for its instances (in the form of objects in a program list)
6. To eval a program list, control is passed to the first object and the remainder is treated as its message
These two definitions differ a little bit, as the first one is a technical one to define what a language must have to be called OOP, while the second defines the style of writing code like you wrote.
And neither of these definitions can fit to C.
09/11/2017 01:24 algernong#17
The ISO definitions seems to be irrelevant since it only defines what a language needs to be called "OOP language"; I didn't claim C to be an OOP language by definition but that you can write object oriented code with it (i.e. code that is in line with the paradigm) and that it is practical to do so.

The second quote seems to be a definition of the paradigm, right? So it's about code itself, not the language and doesn't contract my stance as far as I see it. Your code example seems to be in line with this definition.
09/11/2017 01:40 warfley#18
Quote:
Originally Posted by algernong View Post
The ISO definitions seems to be irrelevant since it only defines what a language needs to be called "OOP language"; I didn't claim C to be an OOP language by definition but that you can write object oriented code with it (i.e. code that is in line with the paradigm) and that it is practical to do so.

The second quote seems to be a definition of the paradigm, right? So it's about code itself, not the language and doesn't contract my stance as far as I see it. Your code example seems to be in line with this definition.
Well the points 4 and 5:
Quote:
4. Every object is an instance of a class (which must be an object)
5. The class holds the shared behavior for its instances (in the form of objects in a program list)
First of all, there is nothing in C that can nearly count as a class, which is a object itself to interact, and secondly there is no code bound to the class (as there is no class). The functions for structs are just simple functions, can be called from wherever, with whatever parameters.

So this is basically completely missing, and this is the most important part of OOP.

My main problem with calling this OOP is, that this would make the term procedural programming redundant, as with this, strict procedural programming (which also requires the encapsulation of state based code into procedures, while the state is a dataset) would cover exactly the same within C. Therefore im finding it pretty hard to say, lets say we also have classes in C (except for there is no real definition what this might look like) and call it OOP.

Or to put it in another light, if you are using C++, and mix this style with real OOP, how do you discriminate, because compared to C++ classes calling both OOP is not really helpful