2,110 reputation
11020
bio website jalf.dk/blog
location Denmark
age
visits member for 3 years, 9 months
seen Aug 22 at 10:39

Hi!

I'm on twitter. And I have a blog, as linked to elsewhere on this page.


Jun
19
awarded  Nice Answer
Nov
24
awarded  Yearling
Apr
22
comment Is Learning C++ Through The Qt Framework Really Learning C++
Well, the simple answer is "because the guy who invented OOP says that it is what SmallTalk (and Obj-C) does and which Java does not (primarily being based on message-passing). I could also say that Java's approach is flawed because it fails to achieve the goals you mention. If I want polymorphism, Java is pretty much the last language I'd choose to use. Inheritance is an implementation detail, not a "pillar of OOP". It is one (not very good) way in which some of the OOP goals can be achieved.
Apr
21
comment Is Learning C++ Through The Qt Framework Really Learning C++
At the same time, Qt clings to the idea that C++ must be OOP and nothing else, and not even correct OOP at that, because it tries to emulate Java, rather than SmallTalk.
Apr
21
comment Is Learning C++ Through The Qt Framework Really Learning C++
The other part of my point can basically be summarized as "screw OOP". Not everything has to be OOP, and OOP is far from always the best paradigm. C++ has realized this, and while it was born out of a desire to "OOP-ify C", it quickly turned into a multi-paradigm language, one in which OOP is not especially prominent, not for ideological reasons, but because when other paradigms are feasible to use, programmers naturally gravitate towards the best, most convenient, powerful, flexible and expressive option. And in practice, this means modern C++ is rarely very OOP.
Apr
21
comment Is Learning C++ Through The Qt Framework Really Learning C++
@Mikey: I said nothing about object references or the heap being the problem, and I never claimed that C++ has a less flawed OOP model. It doesn't. It uses fundamentally the same model, but with a more half-assed implementation. Java (and C++ and the rest of this family) fundamentally misunderstood what OOP was supposed to be. Look at Smalltalk, or for a more modern example, Objective-C. Those (more or less) got OOP right. They have countless other flaws, of course, but they actually implement something like what the inventor of OOP says OOP is.
Apr
21
comment Is Learning C++ Through The Qt Framework Really Learning C++
@Mikey: or maybe there's just a lot of flawed code around. Are you seriously pretending that there isn't? (And perhaps all those complex systems would be less complex if they'd chosen a better programming language) And if your best argument is an appeal to popularity, then pardon me for not, well, being impressed. Perhaps you could instead tell me what's not-flawed about it. Why it is better than the alternatives.
Nov
24
awarded  Yearling
Nov
13
awarded  Nice Answer
Sep
1
answered Should I continue my self-taught coding practice or learn how to do coding professionally?
Aug
29
comment Compilable modern alternatives to C/C++
@Coder: you answered your own question: because in most other languages, I do not need to "read a few books" in order to get it. A trained monkey can practically write a Java or C# program. In C++, you have to read a few books, as you say. Really, whether or not C++ is "easy" is subjective. But it is obviously true that C++ is much, much harder than most other mainstream languages. You might still find it easy, but let's not pretend that other languages are not easier
Aug
4
comment What backs up the claim that C++ can be faster than a JVM or CLR with JIT?
@luiscubal: your terminology is unclear. The JIT doesn't act at what I'd consider to be "compile-time". You're right, of course, given a sufficiently clever and aggressive JIT compiler, there's effectively no limits to what it could do. But C++ requires this behavior. Further, C++ templates allow the programmer to specify explicit specializations, enabling additional explicit optimizations where applicable. C# has no equivalent for that. For example, in C++, I could define a vector<N> where, for the specific case of vector<4>, my hand-coded SIMD implementation should be used
Aug
4
comment What backs up the claim that C++ can be faster than a JVM or CLR with JIT?
Of course, in simple cases, we might be able to determine which type the object actually is, so we know which foo to call, so it can be inlined even if it is virtual. But in the general case, you don't know which function is called until the code is executed. And by then, it is too late to inline it. ;)
Aug
4
comment What backs up the claim that C++ can be faster than a JVM or CLR with JIT?
@user946850: it'd be more accurate to say that virtual functions can't always be inlined. Sometimes they can. But assume a naive compiler comes across a call to a function foo() on an object of type B. If foo is not virtual, then it is known at compile-time which function is to be called (B::foo()), so it is trivial to inline. If foo is virtual, then the function being called might be B::foo(), but it could also be D::foo(), the overridden function in a derived class. We know which function to call at runtime, but at compile-time it's not clear
Aug
4
comment What backs up the claim that C++ can be faster than a JVM or CLR with JIT?
Fair point, bad example then. It would have made more sense to use two reference types. I am aware that primitive types avoid being boxed in C# generics. My point was that the same code path is taken regardless of type (and I believe that is mostly true for primitive types as well). C++ templates are effectively expanded at compile-time, yielding completely separate data structure for every type. (For better or worse. In addition to giving the compiler room for aggressive optimization, it can easily cost you in code size)
Aug
4
comment What backs up the claim that C++ can be faster than a JVM or CLR with JIT?
@luiscubal: no, in this respect, C# generics are very Java-like (in that the same "generic" code path is taken no matter which types are passed through.) The trick to C++ templates is that the code is instantiated once for every type it is applied to. So std::vector<int> is a dynamic array designed just for ints, and the compiler is able to optimize it accordingly. A C# List<int> is still just a List.
Jul
17
awarded  Nice Answer
Jun
8
awarded  Caucus
May
9
awarded  Nice Answer
Feb
8
comment Why is CS taught to be memorized?
@DeadMG: Note that I didn't say anything about memorization (that's why I posted a comment, not an answer). My degree didn't favour memorization either, and as the OP isn't actually studying at university, I thought I would rather clear up a misconception he seemed to have about CS than specifically discuss memorization