Reputation
9,185
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
2 39 56
Newest
 Good Answer
Impact
~628k people reached

Jul
12
awarded  Good Answer
Jun
22
awarded  Notable Question
Apr
25
awarded  Good Answer
Mar
16
comment Limitations of Polymorphism in statically typed languages
@supercat I’d argue that the correct (I’m refraining from saying “the only correct”, but I’m hinting at it) way of doing this is via a tagged union and a visitor, as explained in my own answer. Unfortunately most modern mainstream languages have limited syntactic support for this.
Mar
16
comment Limitations of Polymorphism in statically typed languages
@supercat I agree that for such purposes a fat interface (or better, a mixin) would be entirely appropriate. But consider OP’s example, where something like this wouldn’t work, and many methods would by default have to throw some kind of NotImplementedException. This is actually a thing in some .NET libraries.
Mar
15
comment Overused or abused programming techniques
@Brett You’ve missed the gist of my comment. The “opinion of languages” is irrelevant.
Mar
14
comment Is every language written in C?
“time travel is physically impossible” — That’s a highly contentious claim. Doesn’t detract from the value of this answer of course.
Mar
3
awarded  Announcer
Jan
27
comment Why is it (or was it) important to separate CSS from HTML?
The canonical answer to this is csszengarden.com
Jan
13
comment Why Garbage Collection if smart pointers are there
@supercat Do you have an example of such a system? Note, this may be very obvious, and I’m not contesting your claim at all. In fact, my comments above are probably quite specific to GCs such as those found in C#/.NET and Java.
Nov
13
comment Why are pointers not recommended when coding with C++
@VF1 std::unique_ptr. Also, why not ptr_vec? But usually a value vector with will still swap faster (especially with move semantics).
Nov
12
comment OOP CLI menu structure organization?
@Doval I’d argue that until C++11, C++ supported generic programming much, much better than OOP, simply because you cannot do OOP reasonably when you have to worry constantly about your pointers leaking. This has been somewhat alleviated but compared to other mainstream languages C++ simply sucks at OOP. Compared to almost all mainstream languages, C++ is the only one with reasonable generic programming support.
Nov
12
comment OOP CLI menu structure organization?
@Doval OCaml notwithstanding, C++ is simply the only actually used too which offers overhead-free abstractions. Yes, it kind of sucks but it also kind of works. Generic programming is used extensively in C++, and you can actually specify the interface if you’re not afraid of a bit of hackery (C++17 will hopefully make this much, much easier). “Templates are a bitch to work with” – right, but they are actually much simpler than they’re often made out to be. Not great, but a-okay.
Nov
12
comment OOP CLI menu structure organization?
@Doval Algorithm-based programming and the related generic programming. Read the interview with Alexander Stepanov, the inventor of the STL. The interview is quite long; the relevant part discussing OOP and generic programming is mainly in the middle; search for “object oriented” to jump there.
Nov
12
answered OOP CLI menu structure organization?
Nov
12
comment OOP CLI menu structure organization?
My point was (and remains) that moving everything from one function to another does not make sense. And that’s what you’re doing (modulo some unimportant stuff). And it really makes no difference whether it’s in a function called main or a function called run. In particular, having a function “a couple hundred lines long” is simply always bad. Likewise, having a class with only one member function just doesn’t make sense – just use a regular function instead, without the class.
Nov
9
comment What's wrong with statically linking the STL into multiple shared libraries?
@Sjoerd ah yes, of course. Thanks.
Nov
9
comment Including extra headers that I do not really need
“If you are unlucky, there might even be a small runtime-penalty on startup, shutdown and in memory-footprint for the program.” – this needs explaining, because there are very few situations that I can think of where this would be the case (and it’s unrelated to templates, and the same as in C).
Nov
9
comment What's wrong with statically linking the STL into multiple shared libraries?
I’m unclear what “string” refers to here. If the talk is of a std::string then the problem simply does not exist: either libB.so receives a copy of the string, with memory managed in its own memory, or it will receive a reference/pointer to the string in libA.so, and won’t attempt to remove the string from its own memory.
Nov
9
comment OOP CLI menu structure organization?
What benefit does it have, in your opinion, to move the code from one function (main) into another one (run)? For that matter, what benefit does using a class have here? The answer to both questions is, of course, "none". Merely moving a code into a class doesn’t make the code OOP.