5,037 reputation
11024
bio website
location
age
visits member for 2 years, 7 months
seen 3 hours ago
stats profile views 392

Jun
14
comment Languages that compile to C
Well, compiling to C doesn't avoid writing a code generator. The only advantage is that you can write a C code generator instead of a assembler/machine code generator, which may or may not be easier depending on how well your implementation strategy maps to C.
Jun
13
comment Mnemonic for always overriding equals when you override hashCode?
Forget mnemonics, learn how hash tables work ;-)
Jun
13
comment .c FIle Dedicated to Data
No, there is one hard fact in favor of not starting them with underscores (as I mentioned before): Such names are reserved by the standards; a compiler, run time library, standard library module, etc. may use that name. Consider that the collision may only occur in a particular version of a particular tool chain which you don't test your code with but which is used to build your code a year later. It's indeed "just a convention", but an overwhelmingly superior one.
Jun
13
comment .c FIle Dedicated to Data
Include guards should not start with underscores (and once you get rid of those, the trailing underscores look silly). Names starting with double underscores, or a single underscore and a capital letter, are reserved for the implementation. Just use #ifndef MY_MODULE or MY_MODULE_H
Jun
12
comment What features should a programming language have to say it has good reusability?
"Composition over inheritance". That doesn't mean inheritance has no place (though some recent languages get along rather well without it), but it shouldn't be your go-to solution for code reuse.
Jun
9
comment beginner question about compiler
Code::Blocks isn't a compiler. It's an IDE. An IDE merely delegates to a compiler (and Code::Blocks bundles one in its Windows installer).
Jun
9
comment Is it ok to use Arrow keys in VI?
See superuser.com/questions/599150/… (it's also more on topic over there).
Jun
5
comment How do you hide error handling?
Both are bad in that they silently mask errors, so the caller can't react to errors.
Jun
4
comment Unit tests and language-native function calls
Use a language where those functions aren't magic, or otherwise different from user-defined functions. Then you can just do whatever you do with your own stuff ;-)
Jun
1
comment What is early and late binding?
@tdammers C++ actually does need a run time library, though not for virtual calls. If you read carefully, you'll notice that this answer says the compiler "injects code to look up the address of the correct function [...] at runtime".
May
31
comment Is it useful to use encapsulation in dynamic typed, interpreted programming language?
This is unrelated to the question, but your Python example in 3. confuses me. I've never heard of such a feature in past, present or future versions. A leading _ is a convention and nothing special. A leading __ (double underscore) invokes name mangling, but that doesn't cause a warning when overriding, it's just a hack that makes accidental overwriting much less likely by incorporating the class name into the attribute name.
May
30
comment Using <= for every dependency in case of following semantic versioning idea
Technically, Lib (>= 2.x, < 3) where x is the minor version that introduced the latest feature you rely on (perhaps a patch version too if you depend on a recent bug fix) would be safer, as it rules out 2.(x-1) which your code wouldn't work with.
May
30
comment How does a program's virtual address space get translated to physical address space on the stack?
The stack is, in this regard, simply yet another bunch of memory.
May
30
comment Making Simple IF Statements Shorter
As I have written under another answer, the difference in IL may not mean anything. The JIT compiler can and most likely will eliminate any difference. I'd also like to object to your last point: If the condition is that complex, it is hard to read regardless how what you do with it. Solving that problem by extracting subexpressions into aptly-named variables improves readability in either case.
May
30
comment Does Turing-complete implies possibility of malware?
There are perfectly definitions of malware. They are not even remotely formal enough to be mentioned in the same paragraph as turing completeness though. This is not a bad thing in general, but it is a problem if you wish to discover mathematical truths.
May
28
comment Is there a compliance test for C++ compilers?
Boost works in major C++ compilers. Perhaps not ancient versions of those compilers, and perhaps not in a comparatively obscure compilers your company is relying on, but just look at that huge list of tested compilers in the release notes. And that's just the ones the Boost guys tested themselves! Boost is in no sense of the word academic, and you don't need to to evaluate compilers to dismiss that statement.
May
26
comment Why don't computers come with specialized hardware such as sorting networks?
@WorldEngineer I don't see how that enters the picture. Your average user doesn't know what 80% of the things in a modern CPU are for, they're happy because they are told it makes their programs faster (and this has a kernel of truth). If sorting was indeed as common as OP supposes and could be optimized by dedicated hardware, they'd put it next to the branch predictor ("what's that, gardening?"), issue a press release saying they made applications X and Y 5% faster, and sell it.
May
26
comment Why don't computers come with specialized hardware such as sorting networks?
Hardware isn't magic. Many things can't be accelerated much (or at all) by specialized hardware, and even if it can, existing hardware often has to be adapted (or at least re-compiled). See yosefk.com/blog/its-done-in-hardware-so-its-cheap.html
May
25
comment Is the Javascript bet a loser or a winner one?
70% of the question appear to be a rant that should be removed. And while I'm here: Your characterization of asm.js is inaccurate, it's not limited to porting C and C++ code and is independent of LLVM, Mozilla, etc.
May
24
comment Is there a specific name for the “Square inherits from Rectangle” paradox?
@MarkCanlas The problem is unarguably a violation of the Liskov substitution principle. It may not be a violation of other principles, but nobody claimed that. When the problem does not occur because the contracts do not include any invariant that would be broken (though I fail to imagine a useful model where this is true), there may not be a violation of the LSP, but that doesn't mean the problem, when it occurs, isn't due to a LSP violation.