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

Pages: 1-4041-

why do you guys hate c++?

Name: Anonymous 2010-08-27 18:56

apparently one of you was in /v/ a day ago going on a little tirade against c++. why would it be so popular if there was "absolutely nothing good about it" like you said?

Name: Anonymous 2010-08-27 19:00

how cute

Name: Anonymous 2010-08-27 19:01

Typically, the people who really hate C++ that much never really understood C++, they either didn't want to put in the effort, they aren't good programmers, or they suffer from OCD and the inconsistencies in the language really get to them. The people who do understand C++ do hate certain aspects of the language, but learn to look past the bad at the good.

Name: Anonymous 2010-08-27 19:10

>>1
Ah, yes, C++ is good for domain-specific solutions, but it doesn't adequately address the issue of multiple inheritance out of the box.

Name: Anonymous 2010-08-27 19:14

>>4
What are you babbling on about? Domain specific solutions? And what issue of multiple inheritance? Multiple-inheritance has limited use anyway, most developers use it in a restricted manner (the mix-in's idiom or like interfaces in Java or C#).

I call troll.

Name: Anonymous 2010-08-27 19:17

>>5
Now I'm free to eat ice cream sandwiches!

Name: Anonymous 2010-08-27 19:44

Less of this

Name: Anonymous 2010-08-27 20:50

Name: Anonymous 2010-08-27 22:37

TROLL MY

Name: Anonymous 2010-08-27 22:40

>>5
most developers use it in a restricted manner
That's because it's been inadequately addressed by their language.

Name: Anonymous 2010-08-28 0:20

>>10
No it has been adequately addressed by the language. You need to use virtual inheritance to avoid the dreaded diamond of doom, when you inherit from two different base classes that share the same base class.

For the record, not many other object-oriented languages even offer multiple inheritance.

Name: Anonymous 2010-08-28 0:38

>>11
According to Wikipedia, these languages implement multiple inheritance:
Eiffel, C++, Dylan, Python, Perl, Perl 6, Curl, Common Lisp (via CLOS), OCaml, Tcl (via Incremental Tcl), and Object REXX (via the use of mixin classes)

Name: Anonymous 2010-08-28 0:42

>>12
Racket also offers mixins.

Name: Anonymous 2010-08-28 0:59

>>11
the dreaded diamond of doom
Tell me support is adequate again.

Name: Anonymous 2010-08-28 7:09

>>11
How is this diamond a problem?

Name: Anonymous 2010-08-28 9:55

because it fuckin sucks dick.

Name: Anonymous 2010-08-28 11:22

Well, it's like this;

I was taught assembler in my second year of school.
It’s kinda like construction work — with a toothpick for a tool.
So when I made my senior year, I threw my code away,
And learned the way to program that I still prefer today.

Now, some folks on the Internet put their faith in C++.
They swear that it’s so powerful, it’s what God used for us.
And maybe it lets mortals dredge their objects from the C.
But I think that explains why only God can make a tree.

For God wrote in Lisp code
When he filled the leaves with green.
The fractal flowers and recursive roots:
The most lovely hack I’ve seen.
And when I ponder snowflakes, never finding two the same,
I know God likes a language with its own four-letter name.

Now, I’ve used a SUN under Unix, so I’ve seen what C can hold.
I’ve surfed for Perls, found what Fortran’s for,
Got that Java stuff down cold.
Though the chance that I’d write COBOL code
is a SNOBOL’s chance in Hell.
And I basically hate hieroglyphs, so I won’t use APL.

Now, God must know all these languages, and a few I haven’t named.
But the Lord made sure, when each sparrow falls,
that its flesh will be reclaimed.
And the Lord could not count grains of sand with a 32-bit word.
Who knows where we would go to if Lisp weren’t what he preferred?

And God wrote in Lisp code
Every creature great and small.
Don’t search the disk drive for man.c,
When the listing’s on the wall.
And when I watch the lightning
Burn unbelievers to a crisp,
I know God had six days to work,
So he wrote it all in Lisp.

Yes, God had a deadline.
So he wrote it all in Lisp.

Name: Anonymous 2010-08-28 12:25

>>15

Only in languages that have crappy support for multiple inheritance.

(Background: The diamond problem is a simple multiple-inheritance problem. You have 4 classes A,B,C,D. A is a base class, B and C inherit from A and D inherits from both B and C. A has a method, B and C override that method somehow, which method would be used for D? A's, B's or C's?)

In some languages the problem doesn't exist at all. For example, in Common Lisp, you have a variety of options for deciding the effective method. The default behaviour would be to select the most specific method, and use the class order in the inheritance list (for class D) to decide wether to use B or C's (using class A is possible using . Besides that, you can control method combinations in a lot of ways (combinations provided by default), or even define your own combinations which can do just about anything you desire, and if that isn't enough you can rewrite the entire damn object system using the MOP. So the user is given a good default resolution with the option to customize it as much as it wants. The good default is possible because classes and methods are separated (meta) objects (methods can specialize on classes, but classes themselves only contain data, methods are not just directly associated with just one class like in single-inheritance languages (however, if you wish to write in the simple single-inheritance style, nothing prevents you from doing that, it's very simple, just you'll notice there are usually much more flexible ways to do things), instead they can specialize on classes, and even built-in data-types...) each serving different, but interconnected purposes.

Anyways, I was a bit bored, and decided to show off a few such features CL has:


;;; Define the classes, A, B inheriting from A, C inheriting from A,
;;; D inheriting from B and C (or in the latter example, from C and B)

(defclass a () ())
(defclass b (a) ())
(defclass c (a) ())
(defclass d (b c) ())

;;; Define 3 methods on each class

(defmethod meth ((x a)) (print "From A"))
(defmethod meth ((x b)) (print "From B"))
(defmethod meth ((x c)) (print "From C"))

;; Show how the diamond inheritance works by default in CL
;; using standard method combination with no qualifiers
;; or other significant specializers.
;; The order of superclasses is what is used: (b c)

(meth (make-instance 'd)) ; => "From B"

;; Reverse the order and observe new results:

(defclass d (c b) ())

(meth (make-instance 'd)) ; => "From C"

;; what if we want to perform something in `meth' that applies to everything
;; inheriting from A?

(defmethod meth :before ((x a))
  (print "Before A"))

(meth (make-instance 'd)) ; =>
                          ; "Before A"
                          ; "From B"

(meth (make-instance 'c)) ; =>
                          ; "Before A"
                          ; "From C"

(meth (make-instance 'b)) ; =>
                          ; "Before A"
                          ; "From B"

(meth (make-instance 'a)) ; =>
                          ; "Before A"
                          ; "From A"

;;; There are also :after and :around qualifiers for the standard method
;;; combination, which offer you a lot more control
;;; :around allows fully overriding the method, while
;;; :after allows you to run some code after it (like :before)
;;; see the Hyperspec on the exact details on the order of methods

;;; Since we're doing this in a runtime system, we'll remove the :before
;;; method at runtime (you can of course just unintern the class or use
;;; the inspector to do it for you, or just reload everything):

(remove-method #'meth (find-method #'meth '(:before) `(,(find-class 'a))))

(meth (make-instance 'a)) ;=> "From A"

;; a standard way to chain methods using the standard method combination

(defmethod meth ((x b))
  (print "From B")
  (call-next-method))

(defmethod meth ((x c))
  (print "From C")
  (call-next-method))

(meth (make-instance 'd)) ; => "From B" "From C"  "From A"

;; reversing the order the effective method is chosen by using an alternate method combination

(defgeneric meth2 (x)
  (:method-combination or :most-specific-last))

(defmethod meth2 or ((x a)) (print "From A"))
(defmethod meth2 or ((x b)) (print "From B"))
(defmethod meth2 or ((x c)) (print "From C"))

(meth2 (make-instance 'd)) ;=> "From A"

;; a simple, but very violent/destructive way to to call A's
;; method directly (convert the class to a base class):

(defmethod meth ((x d))
  (meth (change-class x 'a)))

(meth (make-instance 'd)) ; => "From A"


;; a proper way to directly call the method specialized on A,
;; bypassing other "next" methods using the MOP:

(require :closer-mop)

(defmethod meth ((x d))
  (funcall (c2mop:method-function
        (find-method #'meth '() (list (find-class 'a))))      
       (list x) '()))

(meth (make-instance 'd))        ; => "From A"

;; What if we want some crazy arbitrary, runtime determined way of picking
;; which method to run? Here's an example which picks
;; a random method to run at runtime!

(define-method-combination :random ()
  ((methods *))
  `(ecase (random ,(length methods))
     ,@(loop for i from 0
         for method in methods
         collect `(,i (call-method ,method ',(remove method methods))))))

(defgeneric meth3 (x)
  (:method-combination :random))

(defmethod meth3 :random ((x a)) (print "From A"))
(defmethod meth3 :random ((x b)) (print "From B"))
(defmethod meth3 :random ((x c)) (print "From C"))

(meth3 (make-instance 'd))
;=> prints "From A", "From B" or "From C", depending on the current random state


;;; Either way I could go on showing standard CL, MOP, method combination,
;;; specializer tricks and many others which show that you have complete
;;; liberty in choosing any method you want despite multiple inheritance,
;;; however such tricks are countless and you could easily see them
;;; by reading the AMOP and a good CL book, so I won't bother showing
;;; any more here.

;;; However, I tend to find the defaults sane, and I can't remember resorting
;;; to most of the tricks I presented here in my day to day coding, but
;;; the point is that these features are there in case you need them
;;; and not only that, you can pretty much redefine the OO system
;;; in itself in almost its entirety using the MOP, if you so need.

Name: Anonymous 2010-08-28 12:35

I dont think its a matter of hating C++, C++ is pretty much the only game in town as far as writing large scale compile-to-platform apps. I think the problem is that OOP got oversold in the 90s as "an improved methodology of programming". OOP is just a tool that fits certain situations, it doesnt improve anyones ability to program, it certainly does not make the procedural programming of C obsolete but is really an extension of it. Classes are just structs with functions added as a data type. People who blindly accept OOP in Java invariably end up writing bloated and over complicated programs and then blame C++ for being a over complicated language. There is too much hype surrounding C++ to prevent this from happening. Only the smart people will discover K&R and use that as a foundation to understanding C++.

Name: Anonymous 2010-08-28 12:44

People who blindly accept OOP in Java invariably

whoops, mistake...OOP in C++ invariably

Name: Anonymous 2010-08-28 22:11

>>19
Classes are just structs with functions added as a data type.
And much nicer inheritance.

Name: Anonymous 2010-08-29 17:10

>>19
Typical Ctard, unable to understand OOP.

Name: Anonymous 2010-08-29 17:13

>>22
Since he thinks Sepples does OOP, he's more likely to be one of your lot than one of ours.

Name: Anonymous 2010-08-29 17:19

>>22
He's unable to grasp basic punctuation, it is highly unlikely that he can program in C.

Name: Anonymous 2010-08-29 18:11

>>21
Inheritance is just "compiler, you there, copy everything according to a compile time modifier into the new class because I'm a lazy shit who can't copy + paste".

Name: Anonymous 2010-08-29 18:40

>>25
Yeah, maybe in your shitty non-prototype based OO

Name: Anonymous 2010-08-29 18:50

>>23
Who but a Ctard would think Sepples does anything properly.

Name: Anonymous 2010-08-29 20:05

>>27
Anyone but a Ctard might think Sepples does anything properly. That much should be obvious.

Name: Anonymous 2010-08-29 20:30

>>25
One point is that there is minimal code duplication and optimal reuse of the module in other places such as other projects.

Name: Anonymous 2010-08-29 20:39

>>12
Haskell also has multiple inheritance.

Name: Anonymous 2010-08-29 20:58

>>30
How so? Do you mean that a datatype can be a part of one or more typeclasses, or that a type can be a subtype of two or more types?

>>12
Another data point, R6RS Scheme's conditions (and srfi 35) kind of have multiple inheritance, but normal record types don't. It's also supported in various CLOS-like Object systems, but they're nonstandard.

Name: Anonymous 2010-08-29 21:39

>>19
I agree with you to some extent. C++ has it's own idioms as to how to best program with it across multiple paradigms. Look at the Boost libraries for example.

I think the saying, "When in Rome, do as the Romans do" is applicable to C++. Far too many novices approach C++ and expect it to work like Java on one end, or like C on the other, and they ultimately fail.

If you're going to program in C++, you should program like other competent C++ programmers.

Name: Anonymous 2010-08-29 22:00

competent C++ programmers
Pull the other one!

Name: Anonymous 2010-08-29 22:50

>>33
There are otherwise intelligent people who have learnt C++ to some degree of intimacy for pragmatic reasons, typically to work on existing projects for the money or the challenge. Much like the situation with Perl and COBOL, really.

Name: Anonymous 2010-08-30 0:24

>>32
The best methodology for C++ is to quickly create a scheme interpreter, then use scheme.

Name: Anonymous 2010-08-30 0:50

>>28
C programmer wants to think he's different from the Sepples faction of Ctards.

Tell you what, when you coin terms, you can decide what they mean.

Name: Anonymous 2010-08-30 2:06

Anyone who thinks C++'s templates are a good solution to any problem needs to get the fuck out.

Name: Anonymous 2010-08-30 2:08

Anyone who thinks C++ is a good solution to any problem needs to get the fuck out.

Name: Anonymous 2010-08-30 2:36

>>37
Agree with this, 100%, unfortunately.

>>38
I agree with this maybe 70%.  There are quite a few problems out there where C++ is at least an acceptable solution and maybe even bordering on "good."  Writing games for Windows is probably the easiest example.

Name: Microsoft 2010-08-30 2:41

>>39
We'd much prefer that you used C# or VB.NET, thank you very much.

Name: Anonymous 2010-08-30 4:08

>>40
Those languages are far too bare-metal to be secure.  Always just use a drag-and-drop game maker tool to be safe.

Name: Anonymous 2010-08-30 9:14

>>18
If you're trying to say "the problem doesn't exist" because you can customize it, well yeah, C++ does the same thing. You can specify the order of your base classes, and you can specify a base class as using virtual inheritance, and you can always just overload a method to specify a superclass if you want to override the default order.

Languages like Python have much bigger problems with multiple inheritance than C++ because all bases are virtual by default and there is no way to configure it; the MRO is done by C3 linearization. There are an amazing number of pitfalls in Python inheritance; for instance even if you specify no base class (i.e. just subclass object), your __init__() still needs to always take *args and **kwargs, popping the arguments it wants, and it still needs to call super(Foo, self).__init__(*args, **kwargs). Otherwise if your class is used in a multiple-inheritance scenario it won't call the next __init__() in the MRO chain.

So yeah, as painful as the syntax is in C++, its semantics for multiple inheritance are actually fairly sane. Language designers don't generally dispute this actually; they usually leave out multiple inheritance because it's easier on compiler writers. Just ask James Gosling; that's really the big reason why Java does not have multiple inheritance. He was just lazy.

I am in support of multiple inheritance because a class should be able to include many interfaces that add code (not just prototypes.) Many modern languages support this sort of paradigm, though they call it different things (like type traits). It's sort of a half way between multiple inheritance and simple Java-style interfaces; you get code but not class fields.

Name: Anonymous 2010-08-30 9:58

42 posts and you shitbrains can't even briefly summarize why sepples sucks.

Name: Anonymous 2010-08-30 11:03

>>43
Obviously this means it doesn't.

Name: VIPPER 2010-08-30 11:12

>>44
someone prove him wrong, i am too lazy to do that.

Name: Anonymous 2010-08-30 13:05

>>43
The C++ FQA was written so no one would ever have to again.

Name: Anonymous 2010-08-30 15:54

SEPPLES just wasn't fucking asked for.

Name: Anonymous 2010-08-30 22:26

>>36
Your post smells like Smalltalk.

Name: Anonymous 2011-02-04 18:45


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