Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

Object Oriented Programming

Name: Anonymous 2010-09-21 13:22

As a novice programmer and as someone who started learning programming with C, OOP just seems annoying to me. Seems as though it's easier to accomplish the same tasks without it. Is it actually necessary to learn it?

Name: Anonymous 2010-09-21 13:24

Yes

Name: Anonymous 2010-09-21 13:25

>>1
Only if you aren't interested in getting a job as a programmer.  Can you even find a job these days that has an explicit requirement of "non-OOP?"

Name: Anonymous 2010-09-21 13:28

>>3
I'm in engineering actually, so it's likely that I will be doing some programming though probably not as much as a 'real' programmer.

Name: Anonymous 2010-09-21 13:29

>>3
U MENA NO EXPLICIT REQUIREMENT FOR OOP?

Name: Anonymous 2010-09-21 13:30

>>3
Systems programming. There is NO requirement for OOP as it's all done in C.

Name: Anonymous 2010-09-21 13:35

>>5
I've seen jobs with explicit OOP with "[so many] years of experience."  What kind of requirement is that?  These days it's hard to come across a desire for languages that can't even simulate OOP.

Name: Anonymous 2010-09-21 13:44

>>7
Luckily, with enough boilerplate, even assembly can simulate objects.

Name: VIPPER 2010-09-21 14:20

What the fuck is an object? Is that some kind of struct with functions, that operate one the struct itself?

Name: Anonymous 2010-09-21 14:23

>>9
Seriously? No wonder all you say is 66JEWS]99.

Name: Anonymous 2010-09-21 14:43

>>10
Seriously?

Yes, YMCHNBT.

Name: Anonymous 2010-09-21 15:18

>>1
Forget about learning OOP.  Nearly all of learning will be memoizing buzzwords associated with simple ideas.  Just take a couple of PLs with support for both ``kinds'' of OOP (e. g. C++ and Smalltalk), if you find out how two of this work, as a systems programmer you'll learn pretty much everything there is to learn about implementation).

>>4
There isn't much use for objects in engineering.  No language/system for modeling, number crunching or FPGA that I can think of and that is actually used requires objects.

Name: Anonymous 2010-09-21 16:05

I can't tell if >>1 is a troll, but it's not a ridiculous question to ask whether OOP is valuable or not.

If you're competent in C, your code naturally becomes more "table based."  Big switch statements get replaced by function tables.  Your data structures tend to fall into arrays-of-structs or structs-of-arrays.  You separate related code into libraries and document well.  And once you become comfortable with a style like this, OOP doesn't really offer you much.

Name: Anonymous 2010-09-21 16:20

>>13
One could argue that you are doing "OOP", just on a module level.

As for >>1,
Is it actually necessary to learn it?
As with everything, that is up to you, but this sounds like a plea to justify your laziness. It is always better to try it out and get your own informed opinion, than to remain an ignorant parrot.

Name: Anonymous 2010-09-21 16:33

arrays-of-structs or structs-of-arrays
Learn about processor caches you incompetent person. It's either structs of arrays, or too fucking slow to be worth writing it in C. Arrays-of-structs almost guarantee that every next struct will be a cache miss.

Name: Anonymous 2010-09-21 16:34

>>14
One could argue that you are doing "OOP", just on a module level.
Yes, except that you own it.  You control how it's organized, instead of some standards organization.  Plus, you don't get all the unwanted baggage templates anyone? that someone thought would be useful but isn't.

Name: Anonymous 2010-09-21 17:03

>>12
ust take a couple of PLs with support for both ``kinds'' of OOP (e. g. C++ and Smalltalk)
What, the broken kind and the actual kind? If you want to learn OOP, you should know about Smalltalk style and CLOS style. Factor comes with some good examples of the latter. But don't get mixed up with C++ until you understand OO. The system there is pretty WTF and includes features (the whole public/private/protected system) that are really only relevant when you're working with morons or are a moron.

Don't inherit too much.

Name: Anonymous 2010-09-21 17:08

>>17
features (the whole public/private/protected system) that are really only relevant when you're working with morons
So, so true.  So many sepplers don't get this.  They seem to think that public/private is a substitute for documentation.

Name: Anonymous 2010-09-21 17:48

>>18
public/private is good for automated documentation systems.  Users of your classes don't want to browse a fuckton of internal circuitry, they want a clean API so they can get shit done instead of looking through stuff they don't need for ages.  Good, competent users who demand that complexity and side effects be documented.
I don't see a lot of objections to internal functions in modules like non-exported stuff in Haskell.  Even Perl has export lists.  Private methods are like that, only for classes.
It doesn't make a lot sense for classes like Point, Circle, HelloWorld though, that's why it keeps being brought up.  It does have a use in real world.

Name: Anonymous 2010-09-22 14:56

>>19
Automated documentation isn't good.

Name: Anonymous 2010-09-22 15:01

>>20
Documentation isn't good. Real men don't need it. Never.

Name: Anonymous 2010-09-22 15:04

>>20
...for class HelloWorld

Name: Anonymous 2010-09-22 15:12

>>21
True, but Real Men would still be making do with rocks and sticks for weaponry, and the abacus skills would be their computer science.

Name: Anonymous 2010-09-22 15:32

protip: object oriented programming doesn't necessarily have anything to do with classes

Name: Anonymous 2010-09-22 16:16

>>24
Tell us how prototype-based programming is the real true OOP.

Name: Anonymous 2010-09-22 16:28

>>25
why would i tell you that?

Name: Anonymous 2010-09-22 23:59

>>25
I prefer protos myself.

Name: Anonymous 2010-09-23 0:22

>>27
Enjoy not being able to proxy cannon anymore.

Name: Anonymous 2010-09-23 1:14

>>28
I will, along with my job.

Name: Anonymous 2010-09-23 4:08

>>1

It's convenient, esp. if you want to get paid. And yes, it's annoying if your language sucks (C++, Java). It's not quite so if you get a decent language with decent abstraction capabilities that don't involve enterprise mess and design patterns/copypasta.

>>6

Then again, C is about as big a pain in the ass as OOP.

>>9

Basically, yes. Some kind of struct, some of its members being functions, and these functions being bound to (or sometimes explicitly passed) an object which is itself. Basically, if obj is an object of class cls, obj.function(x) would be the equivalent of cls:function(obj, x).

>>14

Listen to this man

>>16

Ever heard of abstraction?

>>17

posts truth like the fist of an angry god hits the face of the Earth. Listen especially to this guy.

>>24

True.

>>25

Less kinds of animals; more generic and powerful objects.

>>28

Yes but I can barrel roll.

Name: Anonymous 2010-09-23 6:13

>>16
I do not understand why people like you say templates are unwanted baggage.

Do you seriously think generic parametric polymorphism is a bad thing? Have you completely ignored the past 30 years of language development? Or do you just not fucking want to understand how templates work?

Of all the ridiculous features in C++, templates are just about the only useful one.

Name: Anonymous 2010-09-23 10:58

>>31
Maybe they're annoyed at the fact templates bite in C++ because C++ sucks, but would enjoy decent OOP if given a decent language.

Name: Anonymous 2010-09-23 11:12

OOP is a design method for your software. If your specs result in a system that's easily divided into "objects", then you would ideally use an OOP design for the system. Programming in OOP should be as simple as programming in any other design method: your implementation should always follow the designated system models and specs.

I would bet that anybody here that complains about OOP (or C++ for that matter) are the sort of lone cowboy programmers that don't even do tangible system models (on a piece of e/paper that's ready to be file) let alone actually code according to a system model.

Name: Anonymous 2010-09-23 11:58

>>30
kinds of animals
FFFFUUU–

Why does everyone pick the worst examples on Earth to illustrate OOP, anyway? In TC++PL, Bjarne uses employees and their subclass "manager" to demonstrate inheritance. Yeah, let's just spend a chapter modeling something no one in their right mind would actually do. It's no wonder OO confuses people, when this is how it's taught.

Name: Anonymous 2010-09-23 12:46

>>34

I see where you are coming, but you are not coming from my post as I intended it. By "less kinds of animals" I meant less language axioms/concepts/core objects/element types. A class-based object system requires objects, and then it requires classes, or a special type of object which is a class and which you may make instance of while this doesn't hold true for other objects. On the other side, a prototype-based object system requires little speciality, and is thus cleaner, simpler and more flexible. That's what I meant; not some convoluted example of OOP.

Name: Anonymous 2010-09-23 12:58

>>34
The examples are contrived to avoid distracting complexity. Real-world object use is always partly to hide some greater complexity, so to give and explain a genuine example would involve presenting a volume of incidental junk that just gets in the way. Try coming up with your own example and you'll see what I mean. (Or: prove me wrong--that would be cool.)

Name: Anonymous 2010-09-23 13:14

>>36

class Fart:
    - smell (1 to 10)
    - noise (average, in dB)
    - function Rip(seconds)

class WetFart subclasses Fart:
    - shit (in grams)

Name: Anonymous 2010-09-23 14:05

>>35
I thought you were advocating for fewer animal examples.

>>36
If a little more complexity is what it takes to show a good use of OOP instead of a real world structure that you would never, under any circumstances, want to encode, I think that's fine. If we really want to use animals, for example, we could use an example somewhat like this:
(defclass aminal ()
  (number-of-legs
   brain
   has-claws
   ...))

(defclass brain ()
  (vision-center
   hearing-center
   ...))

(defclass human-brain (brain)
  (language-center
   ...))

It's not necessarily perfect, but (in addition to showing composition as a bonus) it does illustrate a somewhat viable use of inheritance, since brains differ in ways potentially relevant to the operation of the program, and share a certain number of slots (justifying the superclass).

Name: Anonymous 2010-09-23 14:21

>>38
It looks like Dwarf Fortress creature gen code.

Name: Anonymous 2010-09-23 14:38

>>38
And yet your code is never used. In that sense it's worse than the average example.

Usually you want to mess with an object or class because you got it from somewhere else. This is where the examples tend to break down, they take the view that you're writing the object, and taking the long way around to get functionality you could have added in the first place. Personally I'd start with subclassing and work backwards (and forwards) from there. In fundamentally OO-languages that's about all you can do and the concept doesn't take a lot of time to master.

Name: Anonymous 2010-09-23 15:06

>>40
And yet your code is never used. In that sense it's worse than the average example.
You mean because it's not part of a real program? I did do something very like this recently.... At least my code is in principle usable. The manager example I mentioned has no reason to even exist.

Subclassing probably shouldn't even be taught until students have a good grasp of OO. They tend to get the idea that it's something that should be used whenever possible, instead of avoided until you can't help it.

Name: Anonymous 2010-09-23 15:31

>>32
OOP and templates are distinct, unrelated concepts. Your post makes no sense.

I didn't say templates didn't suck. They have a number of design flaws, yes, but they are definitely not "unwanted baggage".

Name: Anonymous 2010-09-23 15:41

Subclassing probably shouldn't even be taught until students have a good grasp of OO.
I feel this way about class creation in the first place, since the over-architecture of classes problem manifests itself there just as much. Then again, if I were writing a tutorial on class definition/subclassing/etc. it would boil down to "save yourself the trouble and go find a proto language instead."

Name: Anonymous 2010-09-23 17:03

>>42
I didn't say templates didn't suck. They have a number of design flaws, yes, but they are definitely not "unwanted baggage".

I'll say it:  Templates suck.  They're a compile-time band-aid for the fact that C++ isn't truly polymorphic.

Name: Anonymous 2010-09-29 18:24

Just try and learn C++.
C++ > C for pretty much anything.

Name: Anonymous 2010-09-29 18:55

>>45
This board is for programmers. Kindly leave.

Name: Anonymous 2010-09-29 20:11

lol i hate interface oriented programming i am so trendy and cool hi my name is hotaru and i use .net

Name: Anonymous 2010-09-29 20:21

>>44
C++ without templates is truly polymorphic.  However, it is limited to first argument dispatch and only has first order polymorphism.  Templates in C++ are merely a way to add type polymorphism to C++, and they're one of the few systems in the world that actually have dependent types.  E.g., in C++ you can define a template for matrices like this:


template<int N>
struct matrix {
    double v[N][N];
};

template<int N>
matrix<N> operator*(matrix<N> const &x, matrix<N> const &y);


In Haskell, doing that is an utter pain in the ass.  You can do it, it just really sucks.  However, dependent types aren't something that people really miss that much when they're gone... not like multi parameter dispatch, rank two types, garbage collection, a proper module system (instead of header files, which suck), higher order functions, closures, lambda expressions, nested functions, etc...  (all of which are missing in C++ (although Cocks will fix it just a little tiny bit), and the hacks that allow you to write "lambda expressions" using templates are really terrible).

>>45
IHBT.

>>46
Okay, leaving.

Name: Anonymous 2010-09-29 21:17

>>46
I'm not a programmer, I'm an ENTERPRISE SOLUTIONS ARCHITECT

Name: Anonymous 2010-09-29 22:30

>>48
I have proof[1] that C++ templates are not true dependent types.


[1] http://en.wikipedia.org/wiki/Talk:Dependent_type

Name: Anonymous 2010-09-29 22:43

>>49
BUZZWORD COMPLIANCE: ACHIEVED

Name: Anonymous 2010-09-29 23:36

>>50
Fair, but parameterized types are not supported in very many languages.  They're also not useful that often.

Name: Anonymous 2010-09-30 2:22

To all in this thread: please stop using C++ instead of the proper name, Sepples.

Name: Anonymous 2010-09-30 2:24

The amazing thing is that >>9 is not wrong.

Name: Anonymous 2010-09-30 10:23

Learn Squeak Smalltalk and youll then understand how OO was really meant to be implemented and not OO contorted to fit into C style programming

Name: Anonymous 2010-09-30 10:35

>>55
Durp, if you think Sepples and Java are proper OO then you need to seriously sort your life out.

Name: Anonymous 2010-09-30 10:44

>>56
what part of "Learn Squeak Smalltalk" do you interpret as "if you think Sepples and Java are proper OO"?

Name: Anonymous 2010-09-30 10:51

>>57
OO contorted to fit into C style
I meant the hypothetical 'you', i.e. 'one' in Queen's English and 'man' auf Deutsch. It wasn't meant to be personal.

Name: Anonymous 2010-09-30 11:11

>>55
If anything, Smalltalk just follows a consistent paradigm.  Java and "C-style programming" for OO follows paradigms that skew in a few places from perfect consistency yet remain valid OO.  It sounds more like you favor it because it isn't (as) imperative.

Name: Anonymous 2010-09-30 16:40

Haskell is a medium-sized dog

Name: Anonymous 2010-09-30 18:04

Haskell is a medium sized homosexual.

Name: Anonymous 2010-10-01 2:28

>>61
NO HE'S A FUCKING MEDIUM SIZED DOG

FUCK YOU FAGGOT

YOUR DUM

Name: Anonymous 2010-10-01 4:31

I learned OOP from C++.

Name: Anonymous 2010-10-01 6:30

>>63
Then, sorry, but you don't know shit.

Name: Anonymous 2010-10-01 7:43

Well, you dont have to use OOP for everything. But is a good thing to know.

You can omit OOP for small proyects (for example, if you are a sysadmin you will just write perl scripts).

But for BIG proyects, you better learn OOP.

Some languages, like Java, abuses OOP. So don't use that to learn OOP. C++, or Object Pascal are good tools to learn OOP.

>>62 Accept the reality. He is a medium sized dog

Name: Anonymous 2010-10-01 9:13

what's so hard about oop that you even have to ask this question

maybe you're dumb/lazy?

Name: Anonymous 2010-10-01 10:05

>>65
Back to /g/ please

Name: Anonymous 2010-10-01 10:52

>>65
C++, or Object Pascal are good tools to learn OOP

Oh, please!

Name: Anonymous 2010-10-01 12:45

>>67,68

What's the problem? To learn OOP these are ok languages, in the same way QBasic is an appropiate language to learn very basic programming.

Name: Anonymous 2010-10-01 14:05

>>65
C++, or Object Pascal are good tools to learn OOP.
QBasic is an appropiate language to learn
Who is this idiot?

Name: Anonymous 2010-10-01 14:12

>>69
Java, for all its sins, is a significant improvement over sepples.,

Name: Anonymous 2010-10-01 15:10

>>71
That's true in a general sense, but it's just as bad when it comes to ``learning OOP''.

Name: Anonymous 2010-10-01 15:25

>>71
Wrong. In C++, you can still just ignore classes and OOP and use it as a dialect of C.

Name: Anonymous 2010-10-01 15:35

>>73
In which case, you may as well just use C.

Name: Anonymous 2010-10-01 15:42

or QBasic

Name: Anonymous 2010-10-01 18:10

>>74
Restricting yourself to a limited subset of Sepples — like classes, single inheritance, no templates, no references, no operator overloading — is fine. It's just like using structs and functions but with less boilerplate code, and none of the ridiculous cognitive overhead from Bjarne's ``advanced'' features.

Name: Anonymous 2010-10-01 23:28

>>76
Operator overloading, just like Sepples itself, can be good if used correctly. For example, the string class uses operators in a pretty intuitive way.

And what's wrong with templates?

Name: Anonymous 2010-10-02 1:24

>>77
Sure, if you think that left-shifting things onto a stream to print them is "intuitive".

And what's wrong with templates?
It introduces what's basically an additional language with totally different binding semantics. That's a lot of complexity to deal with.

Name: Anonymous 2010-10-02 9:17

>>77,78
Okay bitches, the FQA is there for a reason. Please don't waste any more infospace with any more redundancy.

Name: Anonymous 2010-10-02 12:55

FQA my anus

Name: Anonymous 2010-10-02 15:11

>>76

faggot

Name: Anonymous 2010-10-02 15:49

>>81
You must be one of those UNIX fans who thinks that using two or three hyphen-minuses is a good substitute for an em dash. It's not.

Name: Anonymous 2010-10-02 16:03

>>82
Shut up, Rosio.

Name: Anonymous 2010-10-02 16:19

>>83
I'm genuinely curious if you're a troll or really an idiot.

Name: Anonymous 2010-10-02 16:23

>>82
I'm a Unix fan, and I hate TeX dashes. In an ASCII-only context I can put up with two dashes as a substitute for an em dash and one as a substitute for an en dash, but that's it. I don't know why you think this behavior is more common in Unix fans, or why you think >>81 is anything but a Windows user who blew in from the imageboards.

Name: Anonymous 2010-10-02 16:23

>>83
Though I'm somewhat flattered you've mistaken me for Xarn, I am not him.

Name: Anonymous 2010-10-02 16:24

>>84
What about his a troll?

Name: >>81 2010-10-02 16:35

>>85
Listen here, you flaming cockpustule. I read /prog/ off my /dev/tty3, and that symbol looks PIG DISGUSTING. Because of pieces of shit like you, I'll have to make my reader script replace it with ``--'' everywhere. Fuck you.

Name: Anonymous 2010-10-02 16:43

>>88
It looks fine on my system. Maybe that's because I actually know how to configure it.
Stick to Ubanto, kid.

Name: Anonymous 2010-10-02 16:51

>>89
Bullshit. There's no way you can make ttys to display ``—'' as two characters. And before you mention it, I am not going to use the fb driver.

Stick to Ubanto, kid.
Fuck you. I'm going to kill that fucking horse you're sitting so high upon.

Name: Anonymous 2010-10-02 16:56

>>90
Yes there is. U+2014 → U+20 U+14 → " "

Name: Anonymous 2010-10-02 16:59

>>90
An em dash isn't supposed to be two characters wide. It's supposed to be the width of a letter M. Guess how wide that would be on a monospaced terminal.

Name: Anonymous 2010-10-02 17:06

>>92
I don't care how it's supposed to look like, all I care about is for it to look the way I'm used for it to look like. And since most text I've read during my life used a disproportional font, I'm used to reading it as ``--'', i.e. two en dashes.

Name: Anonymous 2010-10-02 17:09

>>93
So you're reading text in monospace that's meant to be read in a proportional font and whining that it doesn't look right?

Name: Anonymous 2010-10-02 17:32

>>93
You should stop calling other people faggots when you only have yourself to blame for your problems.

Name: Anonymous 2010-10-02 17:37

>>94
meant to be read in a proportional font
Where does it say that?

Name: Anonymous 2010-10-02 17:41

This discussion is almost as stupid as these ``What's your favorite[sic] <anything> and why.''.

Name: Anonymous 2010-10-02 17:52

This thread has been threadstopped and replaced with the following topic:

1 Name: Anonymous : 2010-10-02 13:53

   What's your favourite dash, and why?

Name: Anonymous 2010-10-02 17:56

/bin/dash

Name: Anonymous 2010-10-02 18:03

/usr/bin/dash

Name: Anonymous 2010-10-02 18:08

/usr/local/bin/dash

Name: Anonymous 2010-10-02 18:11

/home/sussman/src/dash/src/dash

Name: Anonymous 2010-10-02 18:39

./dash

Name: Anonymous 2010-10-02 19:27

C:\dash.exe

Name: Anonymous 2010-10-02 23:50

DASH MY ANUS

Name: Anonymous 2010-10-03 10:57

>>64
Which language has a good OOP system?

Name: Anonymous 2010-10-03 11:04

>>106
Io

Name: Anonymous 2010-10-03 11:43

>>106
BASIC

Name: Anonymous 2010-10-03 11:47

Name: Anonymous 2010-10-03 11:52

>>109
No, Trainers, you are the Lambda Calculus.

Name: Anonymous 2010-10-03 12:08

Name: Anonymous 2010-10-03 17:31

>>107
Io's object system is great until you get to the part where you must reprogram the environment via introspection methods for certain tasks. It's still better than many others, and what else can you do with a prototype system?

Name: Anonymous 2010-10-03 17:49

I agree with >>33 and add that passion and fanboyism give rise to low-quality software. Use whatever fits best, and mix different paradigms in the same project if you need.

Name: Anonymous 2011-02-03 4:49

<

Don't change these.
Name: Email:
Entire Thread Thread List