Reputation
32,206
Next tag badge:
119/100 score
18/20 answers
Badges
3 54 127
Newest
 Good Answer
Impact
~1.7m people reached

Apr
29
comment What's your strongest opinion against functional programming?
A lot of the "follow the leader" mentality is (I think) more a matter of marketing (but: BCPL actually didn't require semicolons in many cases). I can see similarity between C#, Java, and Scala class hierarchies; C++...a lot less so. From a practical viewpoint, I think the syntactical similarity is more a asset than a liability in most cases (e.g., if Java hadn't looked extremely familiar, nobody would have bothered).
Apr
29
comment What's your strongest opinion against functional programming?
@cat: In any case, your "all just boring iterations of C that don't solve the real problems" just shows pretty much the same attitude: narrow-minded certainty that you know the real problems with C, and the people who designed all these are ignorant, stupid, or for whatever other reasons missed the ultimate truth to which you are privy. This despite the fact that many of them are routinely used (and can even work reasonably well) for tasks to which C would be extremely poorly suited at best.
Apr
29
comment What's your strongest opinion against functional programming?
@cat: partly true, but definitely only partly. For one thing, in the case of procedural languages the gratuitous proliferation doesn't generally result from failure to compromise, but from sheer ignorance and stupidity (e.g., PHP) or from marketing at the expense of technical mediocrity (e.g., Java). The question wasn't about the problems with procedural programming languages though, so that would have been off-topic.
Apr
7
comment How to write unit tests for network client?
If you want to badly enough, you can mock. Have your HTTP client use (for example) a Socket class, and by providing a mock Socket class, you can look at what gets sent, send mock replies, etc.
Apr
6
comment Why were variable length arrays made optional in C 2011?
@jxh: Fair enough--it certainly looks/seems like library to me, but I guess I can see a viewpoint from which it would seem like the core language. In any case, it's the name of a function, not the expressions/statements you can write in that function, which is the difference here. I think there'st waning concern over subsets though. When C89 was new, BASIC and Pascal had both fragmented badly, part due to a number of dialects of each (if memory serves, at least three standards each, all ignored in the wider market).
Apr
6
comment Why were variable length arrays made optional in C 2011?
@jxh: As originally envisioned, freestanding and hosted implementations used the same core language. The differences were restricted to the library. In the case of VLAs, there's a difference in the language itself that (at least some vendors felt) wasn't really suitable to smaller embedded systems. As far as embedding the size goes: no, it's probably never absolutely necessary, but may be the easiest way (e.g., a few bytes of storage for the size might avoid many bytes of code to compute it).
Apr
6
comment Why were variable length arrays made optional in C 2011?
@gnasher729: That's not entirely true. If you use sizeof on a VLA, the size has to be computed at run time, so you typically have either extra data to store the size, or extra code to compute it. Either way, there's at least some possibility of code and extra storage being used.
Apr
2
comment C Language - K&R 1st vs 2nd Edition?
@MarkAmery: Even today, calling it obsolete is a bit premature--there are still a fair number of processors with floating point hardware, but not 64-bit integers in hardware. On such hardware, a double will still usually be substantially faster than a long long.
Apr
2
comment Why double colon instead of dot?
The horrible ugly proliferation of Mason Wheeler's senseless attacks on C has no name, because such evil must not be dignified with a name!
Apr
2
comment C Language - K&R 1st vs 2nd Edition?
@MarkAmery: Please at least attempt to get your facts straight before posting. You're apparently referring to the addition of long long, but that didn't exist until C99. Also note that the question in this case was only which to choose between the first and second editions of the book. I'd tend to agree that if a third edition existed, it would probably be preferred to the second--but as-is, if you're going to read K&R at all, your only choices are the first edition or the second--and between them, the second is clearly preferable.
Apr
1
comment In which process does syntax error occur? (tokenizing or parsing)
@PaulDraper: The fact that they can be combined doesn't make them the same, any more than the ability to dissolve salt in water means there's no fundamental difference between salt and water.
Mar
31
comment In which process does syntax error occur? (tokenizing or parsing)
@FZE: You could think that way, but it's misleading. Lexing is not "just a parser optimization". Rather, lexing maps a physical representation (some sequence of characters) into a logical representation (the tokens represented by those characters). This isolates the parser from minutiae like how the end of a line is represented, or whether you decide to represent a logical-and as and or && or something else. It's (mostly) separate and different from parsing. Optimization (if any) is an almost accidental side effect.
Mar
22
comment How does the C++ standards committee test their design ideas?
@MSalters: Boost has also acted as a prototype for a fair number of core language improvements (e.g., boost.lambda => C++11 lambda expressions).
Mar
22
comment Unique pointer initialisation
If conversion is needed, a constructor is selected, and: "In certain cases, an implementation is permitted to eliminate the copying inherent in this direct-initialization by constructing the intermediate result directly into the object being initialized; see 12.2, 12.8." §12.8 says: "when a temporary class object that has not been bound to a reference (12.2) would be copied/moved to a class object with the same cv-unqualified type, the copy/move operation can be omitted by constructing the temporary object directly into the target of the omitted copy/move". If that's not met, copy is required.
Mar
22
comment Unique pointer initialisation
@NicolBolas: No--for T t = T();: "If the initialization is direct-initialization, or if it is copy-initialization where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of the destination, constructors are considered. [...overloads are resolved, then] The constructor so selected is called to initialize the object, with the initializer expression or expression-list as its argument(s)." This doesn't require an available copy ctor.
Mar
17
comment How do I model similar types that have different data?
@Auberon: Specifying the type of reference would mean that you have (for example) a text field to specify the reference itself, and some associated field (possibly an enumeration) to tell how that would be interpreted (plain text, URI/URL, etc.)
Mar
17
comment How do I model similar types that have different data?
@SebastianRedl: It's certainly true that I haven't attempted to design an entire bug tracking system in one comment thread. That does't mean the design is broken. It just means I haven't solved every possible problem here. But I agree that there are probably references needed for states other than "Closed" (e.g., when confirming a bug, a reference to a test that shows it).
Mar
17
comment How do I model similar types that have different data?
@SebastianRedl: A fair number of "closed" reasons are going to have references to "other stuff"--another ticket in the case of a duplicate, a hash in the case of fixed, a design document in the case of not a bug, etc. So basically, for any disposition you have a Boolean to say whether a reference is needed, and possibly some way of specifying the type of the reference (but possibly not--you might just use a URI for all of them). Bottom line: you're going to have to solve the general problem for disposition anyway.
Mar
17
comment How do I model similar types that have different data?
Represent "Duplicate" separately from other tags. Its nature is entirely different. The actual tag that goes with is "Closed". Separately from tracking the progress, you want something to track why a ticket was closed: fixed, not a bug, could not duplicate, duplicate, new feature, will not fix, etc.
Mar
17
comment Why is there a need for reference parameters in C++?
I didn't downvote it, but I'd hazard a guess that it's largely because it doesn't show why you need references vs. pointers (which C already had).