9,102 reputation
63882
bio website
location
age
visits member for 3 years, 7 months
seen 20 hours ago

0x2B | ~0x2B


Jan
2
comment What is eventual consistency?
The questions look like they've been copied and pasted from some homework text.
Jan
2
comment What is the use-case to use C++ friend class?
@btilly: If you want to inject a mock you can use a parameter in the constructor, no need to access the internals of the class.
Dec
30
comment Why is Scheme my first language in university?
@FelixDombek: "almost every real-world programming job employs an imperative language": This is indeed true and sad at the same time.
Dec
28
revised Haskell's ':' operator
deleted 7 characters in body
Dec
28
answered Haskell's ':' operator
Dec
28
awarded  Notable Question
Dec
28
comment Why C language is taught as the basis of Computer Programming Languages?
By "esoteric" you mean "non-mainstream"?
Dec
26
comment JUnit3 and JUnit4 in the same project (but different module)?
@DavidCowden: What I mean is that some programmers might find JUnit 4 more useful than JUnit 3 and move to it, and some others might not need the new features and find JUnit 3 perfectly OK for their needs. I do not think that the latest version of any framework is automatically the best choice for all users. It is not always black or white.
Dec
25
comment Why lambda/closures expressions came so late to C++?
@ThomasEding: Maybe the concept of a closure has been adapted lately to accommodate the C++ view. In the commonly accepted notion a closure extends the lifetime of captured variables. See e.g. the discussion under "Implementation and theory" in en.wikipedia.org/wiki/Closure_(computer_programming)
Dec
25
comment JUnit3 and JUnit4 in the same project (but different module)?
What do you mean by end-of-life? If a framework is mature and does not need maintenance, everybody is free to use it as long as it fits their needs.
Dec
25
reviewed Leave Open What natural language has the advantage when it comes to programming?
Dec
25
reviewed Leave Open Need an example of a real backlog task or how elaborate must it be?
Dec
25
reviewed Leave Open Is checking return values always required?
Dec
24
comment Why lambda/closures expressions came so late to C++?
@Jörg W Mittag: I am not sure if they did much research related to RAII and closures. AFAIK, in C++ a closure works somewhat like an object that captures variables passed to its constructor and assigns them to its fields. If such variables are passed by reference, then the fields will point to invalid memory locations as soon as these variables have been disposed of. Then, invoking a method on that object that accesses those fields can crash the program. A closure that captures expired variables will have a similar behaviour. IMO the safest approach it to capture only smart pointers.
Dec
24
comment Why lambda/closures expressions came so late to C++?
@Doval: "a closure forces the variables that were closed over to stay alive for as long as the function does": This is true in most languages: you can capture a variable from its lexical scope and keep it alive as long as the closure lives. In C++ it is different: if you capture a stack variable by reference and invoke the closure after you have exited the parent function, you get a crash. So, with C++ you cannot do common FP tricks that involve passing closures around at will: you can easily cause a core dump if you are not careful enough.
Dec
24
comment Why lambda/closures expressions came so late to C++?
@DeadMG: C++ lambdas are more general than Delphi's but also less safe: they can crash the program if invoked too late, which is against the common intuition closures have in most other programming languages. But without a garbage collector in place you either have unsafe closures (C++) or restricted ones (Delphi). See also programmers.stackexchange.com/questions/189856/…
Dec
24
comment Why lambda/closures expressions came so late to C++?
Closures have become popular in recent years thanks to languages like JavaScript and maybe C#, and to the FP-hype (I am a big fan of FP, but IMO there is also a FP-hype going on). IMHO they are out of place in C++, and they are difficult to get right, but everybody must have closures nowadays.
Dec
24
comment Functional programming for loop side effect
+1. Among the advantages of using high-order functions such as takeWhile, fold, filter, map, (i.e. declarative style) is that you also stop thinking in terms of "Compute something by destructively updating memory locations". In this way, the result does not depend on the history / exact sequence of the computation steps.
Dec
23
comment Non-Object Oriented Programming in Object Oriented Language
"It doesn't mean if you use non OOP approach you can never upgrade your project but then it would be a tedious thing to do.": OOP helps to extend your project when most extensions involve adding new classes (e.g. adding new widgets to a GUI). When most extensions involve adding new operations, then a procedural design can be more effective.
Dec
23
comment Why is *declaration* of data and functions necessary in C language, when the definition is written at the end of the source code?
@user31782: Writing a small snippet and compiling it with -S (if you are using gcc) will allow you to look at the assembly code generated by the compiler. Then you can have an idea of how return-values are handled at run-time (normally using a processor register, or some space on the program stack).