Object.-oriented programming (54)

1 Name: !WAHa.06x36 05/01/10(Mon)16:07 ID:E5bmKDvc

We need a good flamewar in here.

Thus! Object-oriented programming: Does it suck or what?

2 Name: !#usr/bin/anon 05/01/10(Mon)20:25 ID:Heaven

Ruby lol

3 Name: MAD-Leser!r4YvKJpWUc 05/01/10(Mon)21:50 ID:nGxHCmQO

just imagine what ruby would be without OO concepts! instead of

if patterns.any? {|pattern| elementAtHand =~ pattern}
# do stuff
end

you'd be writing, taking some pseudocode as an example,

my $atLeastOnePatternMatches;
foreach(@patterns) {if ($elementAtHand =~ $_) {$atLeastOnePatternMatches = true; last}}
if ($atLeastOnePatternMatches) {
#do stuff
}

or something. this would be just like writing in perl! think about it for a minute and the answer to the initial question should become clear.

4 Name: !#usr/bin/anon 05/01/10(Mon)22:50 ID:Heaven

faps to NeXTSTEP

5 Name: dmpk2k!hinhT6kz2E 05/01/10(Mon)22:51 ID:U/4Lko+c

I personally don't like it, but I try to avoid letting personal preference get in the way. My main problem with it isn't the concept itself, but rather people who attempt to turn a simple abstraction into a religion.

Use the right tool for the job. For some things OO is great, for others it's a poor choice.

6 Name: !WAHa.06x36 05/01/11(Tue)13:20 ID:E5bmKDvc

if grep { $elementAtHand =~ /$_/ } @patterns
{
# do stuff
}

That has nothing to do with object-orientation and everything to do with syntax.

And what I was meaning to say was pretty much what >>5 said. OO programming lends it self elegantly to certain tasks - game programming and GUI programming come to mind. However, many other kinds of programming suffer from being forced into OO form - you end up writing object wrappers for the smallest little pieces of code, bringing no clarity or structure to the code. Java especially suffers horribly from this, because it only allows OO style. C++ is much more flexible, letting you mix and match.

7 Name: MAD-Leser!r4YvKJpWUc 05/01/11(Tue)14:35 ID:N25MaRMf

i wasn't being serious since you mentioned "flamewar", looks like you guys are agreeing instead :o.
to get back on topic, i personally think that whether OOP sucks or not also depends on the language you use. some let you implement and especially use classes as well as other OOP concepts easily, while others are rather chunky and require some extra keyboard and brain combo-action. of course, the using part does not hold true if you don't put much brainpower into a piece of code.

8 Name: hk0!0khonVgaHI 05/01/11(Tue)19:49 ID:vsz+JQjs

What. Ever.
So functions can be treated as data members (statically or as closures...). And what, you don't want dynamic type resolution?

Give me a break. There is nothing wrong with languages that have OOP features, and you can easily ignore them.

And just because java is severely crippled to try to prevent you from doing so doesn't mean you can't.

9 Name: !#usr/bin/anon 05/01/12(Wed)14:20 ID:Heaven

>>8

But why does a programming language need to make key things that are needed so goddamn difficult, or if not difficult, so much of a work-around? A given code solution in any problem should be as simple as possible for efficiency to both the programmer, but to the poor bastards debugging it, and to the community using it.

10 Name: !#usr/bin/anon 05/01/15(Sat)03:54 ID:QazvwL+X

The oop people are fapping to it and thinking it the greatest thing when it is just horribly restrictive.

It restricts your thinking process.

Hierarchies and everything is an object sucks much.

11 Name: hk0!0khonVgaHI 05/01/19(Wed)12:32 ID:TSs2/DJW

Well, unless you're about to bless us with a programming language that can implement the full expressiveness of an entity-relationship model... do you have any better idea?

12 Name: !#usr/bin/anon 05/01/19(Wed)14:06 ID:Heaven

I think a big problem I see with a lot of OOL's is efficiency. Lets look at "top end" languages. Machine code, ASM, C. From what I know of these languages they are all instructions, keeping the OO down. Its only until you get into the interpretted languages, Python, Ruby etc does the amount of OO in the language become greater. What's my point? Well, interpretted languages, and especially OO interpretted languages take more process time, more CPU cycles and less efficiency to get a task done. A compiled language that is low on OO tends to be a more efficient.

Proove me wrong.

13 Name: !WAHa.06x36 05/01/19(Wed)15:59 ID:bNuPpcyM

The overhead of OO semantics in languages like C++ is minimal. Virtual functions require an extra memory lookup for each function call, and that's about it.

What might be argued is that the OO metaphor encourages people to write less efficient code. The program flow is obscured, and people do not realize how much code they are invoking.

14 Name: Ichigo Pie!5ouPkmz/WI 05/01/19(Wed)20:04 ID:xstxecE7

Doesn't the same go for functional programming too, though? I could make a function that consist of 700 lines of code, in which it's calling other functions which also consist of 700 lines of code (it'd be an extremely stupid way of programming, both in functional as in OO programming, but for the sake of argument...).
Unless the people using that function in their code goes through the sourcecode where that function is defined, they will have no idea how much code they're invoking.

15 Name: !WAHa.06x36 05/01/19(Wed)20:35 ID:IjYVi0nq

That would be procedural, not functional - you're going to make the LISP people cry.

Anyway, yes, the same is true for procedural coding but it doesn't reinforce this kind of design to the same extent that OO programming does. OO favours making generalized objects when more specialized code would have sufficed, and also makes program flow more opaque by hiding code inside object constructors, and nested superclass calls. Under some circumstances, this creates more readable and structured code, but it seldom makes for more efficient code.

However, if you're using an interpreted language, you've thrown effiency out the window already, so this isn't as much of a problem there.

16 Name: Ichigo Pie!5ouPkmz/WI 05/01/21(Fri)20:39 ID:W8KGnHVC

>That would be procedural, not functional - you're going to make the LISP people cry.

I always confuse those two for some reason... probably because in LOGO subroutines are called procedures while in C they are called functions =/

>OO favours making generalized objects when more specialized code would have sufficed

Depends on the way the program is designed, really... for example, say in a program, there's an object that's an 'Image' object which has a method PaintMe(), that renders the image on the screen. In this case, then indeed, the image would always use the exact same code to render itself, and you wouldn't be able to use any specialised code.
However, if the 'Image' class is purely a entity class and only contains things like the image data, size, and location and let the rendering be done by Render objects, you could have multiple Render classes and use the right class for the right situation.

17 Name: dmpk2k!hinhT6kz2E 05/01/22(Sat)03:05 ID:MqSnWd5S

I think you may have inadvertantly supported the assertion that OO favours making more general objects. For example, why have multiple Render objects? Why not just embed them into the Image class itself? Or make one Render class that handles all cases?

I think OO has been given a bad rap by the overzealous and by Java though. If you shut the silver-bullet types up, and ignore Java in general, there are some rather elegant solutions to problems using objects (and prettier languages to boot).

The one thing OO is good (and bad) at is abstraction. It's good for formalizing interfaces between code. It's bad because it can have hidden effects. It's good because it protects data. It's bad because you'll have individuals using objects to keep integers in a linked list. It all comes down to the discipline of the coder.

18 Name: !#usr/bin/anon 05/02/14(Mon)10:45 ID:Heaven

oo is like trying to use smooth wheels instead of toothed wheels as gears

19 Name: #!usr/bin/anon 05/02/20(Sun)12:56 ID:vhVfve6s

I always say:
Java (as a language AND a runtime) = good idea, horrible implementation.

Making it worse are the so-called 'guides' and 'best practices' which serve to do nothing but make it worse ("hay guys, let's take something sinple and make them jump through a millions hoops before they can use it"). You can't imagine how glad I was when I tried C# and .NET and found how much more practical they were. Your classes, interfaces and objects should be the right size for the right job. Unfortunately Java advocates tend to advocate you to take a jackhammer to everything.

20 Name: !WAHa.06x36 05/02/20(Sun)14:43 ID:dTU3xCXx

To be fair, bringing Java into a discussion about the merits of OO programming is just being plain unfair, like using FORTRAN 77 to argue against procedural programming.

21 Name: #!usr/bin/anon 05/02/21(Mon)18:12 ID:R9y8gAFF

true, OO is useful, Java is not ;)

22 Name: #!usr/bin/anon 05/02/27(Sun)18:28 ID:srA8Twi0

I'd have to agree. As far as OO comes, both Java and C++ are crippled.

23 Name: #!usr/bin/anon 2005-03-05 02:39 ID:Heaven

This isn't a very exciting flame war. Are there any LISP weenies around to troll?

24 Name: #!usr/bin/anon 2005-03-10 22:24 ID:CJ6CcYgp

What is the difference between functional programming and procedural programming?

25 Name: Albright!LC/IWhc3yc 2005-03-11 07:36 ID:1wnJZZGc

http://en.wikipedia.org/wiki/Functional_programming
http://en.wikipedia.org/wiki/Procedural_programming
...though these articles can be a bit tough to follow if you're not a huge programming dweeb. It would be nice if perhaps someone who knows about this stuff could write a simple app in both functional and procedural pseudocode, so that we may see where they compare and contrast? (It could be contributed to those Wikipedia articles as well.)

26 Name: dmpk2k!hinhT6kz2E 2005-03-11 07:58 ID:yg1znv3H

Procedural is program state and statements that change that state. Ie, you make step-by-step instructions to do what you want.

Functional is the evaluation of (math) functions. Ie:

force(mass,acceleration) :- mass * acceleration;

Everything is written in terms of functions.

Procedural:

int factorial(int n)
{
int i, k = 1;
for (i = 1; i <= n; i++) k *= i;
return k;
}

Functional:

factorial (n) :-
if n = 1 return 1;
return factorial (n - 1) * n;

Note how the functional version doesn't have any assignment (ie: i = 5). This (and other) lack of side-effects makes the function easily provable.

27 Name: #!usr/bin/anon 2005-03-12 01:22 ID:Heaven

Most languages aren't strictly procedural, of course.

int factorial(int n)
{
return (n == 1)?n:factorial(n-1)*n;
}

28 Name: !WAHa.06x36 2005-03-12 02:35 ID:LNsQqHln

As >>27 points out, many functional concepts can be quite easily used in procedural languages, but the opposite is not true. This, in my mind, is a good argument against functional programming.

29 Name: dmpk2k!hinhT6kz2E 2005-03-12 08:08 ID:VGG09wok

If you wanted to make C behave like a functional language you could do it without too much difficulty. The worst you'd ever face is using function pointers to emulate higher-order functions (you might need a garbage collector too). Obviously, not all imperative languages can do this.

The odd thing with that though is that it hints something else: functional and imperative are provably the same. It's just that they have different strengths, which is why some functional languages include some elements of imperative (the ML family), and imperative languages are incorporating ideas out of functional (tail-recursion elimination), as pointed out by >>27.

IMHO, imperative is good for I/O and functional for algorithms. Functional does have the nice attribute that it's easier to write bug-free code in (and prove, but who does that?). It's just that it's unpleasant for anything involving external state.

30 Name: !WAHa.06x36 2005-03-12 15:38 ID:LNsQqHln

I find the whole idea of eliminating state to be kind of ridiculous. A computer is nothing but state, and trying to abstract that away seems awfully counterproductive at best, and like theoretical wankery at worst. Sure, you may gain some mathematical advantages, but you lose so much more and get lost in pure theory with no real application.

As purely theoretical research, there is a little bit of value to functional programming - some functional concepts have found their way into imperative langauges that can actually be used - but to suggest that one actually use functional programming for real programming doesn't sit right with me.

31 Name: dmpk2k!hinhT6kz2E 2005-03-13 00:16 ID:TmOhxCjw

Is it just state? Maybe. Or maybe it's a glorified calculator. Or maybe it's both.

You don't actually lose anything. Lambda calculus and Turing machines are provably equivalent, so it may be more accurate to regard them as two aspects of the same thing. As such, pick that which is best suited to what you're attempting to do, otherwise there will be more pain than necessary.

I learned this the hard way when working on some projects with prolog. While prolog is not functional (and I really don't like the language either), it's proof enough to me that there are some problems I'd rather not do in imperative.

However, you may point out the things I was working on were fairly esoteric, and you'd be right...

32 Name: (27) Mr VacBob!JqK7T7zan. 2005-03-13 04:01 ID:ikqD7kaP

>and imperative languages are incorporating ideas out of functional (tail-recursion elimination), as pointed out by >>27.

I wouldn't call this a language feature; it's a general optimization you can apply to anything. The only thing a language can do is make it impossible, by forcing stack frames to always work in a certain way or something.

Someone once tried to tell me that one of the failures of C was that it "wasn't tail-recursive" (he was a Scheme/Haskell nut).

33 Name: !WAHa.06x36 2005-03-13 13:05 ID:LNsQqHln

>>31

What are registers and memory but one big state? You can freeze a computer at any point, write down the contents of its memory and registers, take an identical computer, write the same data into it, and it will continue working as if nothing happened. What you wrote down is state, and that is all there is.

34 Name: dmpk2k!hinhT6kz2E 2005-03-13 22:17 ID:jcgWc2SM

But that's only one way of looking at it. The state is the IP and instructions/data. But what does that state represent? You could do the exact same thing with functional - freeze the machine, copy over all the algorithms, and restart it. A computer may be all state, but so is a rock. It's what that state represents that matters.

I understand where you're coming from, and to a certain extent I agree. When confronted by most real-world problems I have no idea where I'd start with a functional language. I just disagree that functional is useless. Witness the Lisp Machines (now dead lol).

There are certain other benefits to the elimination of explicit state: it makes automatic parallelization and concurrency considerably easier. This will probably become increasingly more important in the future.

35 Name: !WAHa.06x36 2005-03-13 23:48 ID:LNsQqHln

>>34

In theory, that's only one of several ways to look at it, sure, but in practice, you've got bits in RAM. You can pretend it's something else, and implement everything you need for this, but that won't change the fact your computer is one big state machine.

Parallelization is important, though, and a pain in the ass when dealing with state. You're definitely right about that one, and I'm inclined to agree we'll be seeing more parallelization in the future. Physics is gonna start kicking our asses pretty soon when it comes to hardware design.

36 Name: dmpk2k!hinhT6kz2E 2005-03-14 06:25 ID:gtF14Giy

It'll be entertaining when the standard answer is no longer: "get a faster CPU."

Therein lies another pet peeve of mine...

37 Name: Mr VacBob!JqK7T7zan. 2005-03-14 17:44 ID:B3K9rGZO

You don't always have to. I've redone a few of the more important really slow bits in mplayer because I can't afford a faster laptop.

38 Name: dmpk2k!hinhT6kz2E 2005-03-14 21:15 ID:HXCVfVTL

>>37
The world needs a lot more people like you.

39 Name: Albright!LC/IWhc3yc 2005-03-16 17:38 ID:1wnJZZGc

>>36: Personally, I don't think that day will come in my lifetime... We've approached physical limitations in chip design before, but every time somebody figures out how to go ahead and make them faster and cheaper anyway. That being said, even if it does happen, who's to say it won't simply change to "get more CPUs?"

40 Name: Albright!LC/IWhc3yc 2005-03-16 17:38 ID:1wnJZZGc

Make that "faster and smaller"... not necessarily cheaper.

41 Name: !WAHa.06x36 2005-03-16 20:58 ID:LNsQqHln

>>39

That was the point - it is already changing into "get more CPUs", but this will be an incredible challenge for software design, because parallel code is much harder to write. Which, in turn, is why any kind of programming that makes parallelization easier will become more interesting. Which is what >>34-36 was about.

42 Name: Albright!LC/IWhc3yc 2005-03-17 02:21 ID:Heaven

> Which is what >>34-36 was about.

Oh, was it? Sorry, I couldn't really decipher all of the geeky blather about "state" this and "bits" that. :P

43 Name: !WAHa.06x36 2005-03-17 16:36 ID:ptdkkcQT

>>42

Yes, most of that discussion was left as implied.

44 Name: #!usr/bin/anon 2005-10-05 19:14 ID:Heaven

lol:

Subject: Wow Just Wow
http://4-ch.net/code/kareha.pl... People totally ignorant of OO or Functional Programming arguing over OO programming using functional examples to support OO.

WOW

45 Name: dmpk2k!hinhT6kz2E 2005-10-05 23:51 ID:Heaven

>>44
Plz 2 be enlightening the unwashed masses, oh great and mysterious master. Where are we wrong?

46 Name: #!usr/bin/anon 2005-10-06 00:39 ID:Heaven

>>45
Don't ask him, ask the guy who runs the "church burning tumblelog"!

It seems clear to me that anyone who runs a 'tumblelog' with such quality posts as "Doesn't this look like a huge ballsack?" obviously knows more about object oriented programming than you guys do. You'd better just accept that you're wrong about this one.

47 Name: 44 2005-10-06 05:11 ID:Heaven

Yes, I didn't write that one.

48 Name: dmpk2k!hinhT6kz2E 2005-10-06 06:58 ID:Heaven

Not another stupid meme word in the making:
http://www.google.com/search?q=tumblelog
Results 1 - 10 of about 890 for tumblelog.

Anyway, are you planning on pointing out our mistakes, or are your posts thus far representative of all you're capable of? This board needs a good flamewar, and I'm all for a bit of education.

yawn

49 Name: !WAHa.06x36 2005-10-06 11:49 ID:yKTzGd5r

Wait, so we're now coining a new word for what "weblog" initially meant?

(Jorn Barger coined the term "weblog" for his site, http://robotwisdom.com/, which appears to be exactly what this idiotic word "tumblelog" refers to.)

50 Name: #!usr/bin/anon 2005-10-06 13:56 ID:Heaven

I am thinking about starting a thread on /net/ for stupid terms of the internet. So far I have "blogosphere", "tumblelog" and "podcasting". Any more?

51 Name: #!usr/bin/anon 2005-10-06 14:53 ID:Heaven

Anything that involves "blog". God I hate that word.

52 Name: #!usr/bin/anon 2005-10-06 16:00 ID:Heaven

Maddox already did it, at least partially
http://www.thebestpageintheuniverse.net/c.cgi?u=banish
A whole slew of words that mean than same thing as other words that already existed because people are too dumb to know that they already existed because of their ivory tower existance

53 Name: dmpk2k!hinhT6kz2E 2005-10-06 17:01 ID:Heaven

I'm DQN. Ignore the second part of >>48. --;

54 Name: #!usr/bin/anon 2005-10-09 22:17 ID:jJ1D+9zK

>>50 AJAX-ing the open source cathedral model with ruby on rails and XML.

This thread has been closed. You cannot post in this thread any longer.