Reputation
15,845
Top tag
Next privilege 20,000 Rep.
Access 'trusted user' tools
Badges
1 39 63
Newest
 Good Answer
Impact
~215k people reached

Apr
28
comment Fastest way to determine if a value is in a list?
Faster than a traditional hashmap? Are you sure? You have only a heuristic argument guaranteeing balance, based on an implicit assumption, and unless you have a clever way to layout out the tree consecutively in memory, lookup will cause about log n cache misses, or in any case more than one (especially if the access pattern is n, n+1, n+2, ... because then search paths already diverge at the root node because you start with the lsb).
Apr
28
comment Fastest way to determine if a value is in a list?
Even if you have the megabytes, consider packing eight bits into one byte. Reading the packed table needs about three extra ALU instructions (table[i] versus table[i >> 3] >> (i & 7)). Because it is more compact, it will use the cache up to eight times more effectively, which will more than make up for the extra instructions if access is indeed "usually roughly in the same place each time with only a gradual deviation in the target area."
Apr
26
comment If Scala runs on the JVM, how can Scala do things that Java seemingly cannot?
Turing completeness is a red herring though. Real cross-compilers (and the interpreter equivalent, whatever you want to call it) don't just need semantic equivalence, they also want reasonable performance and implementation effort and interoperability. For example, despite all their superficial similarities, properly compiling Python to JS amounts to re-creating a whole Python implementation in JS, and that is only barely practical because emscripten already exists. And that doesn't even give you a fraction of the Python-JS interoperability Scala and Java have.
Apr
24
comment Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?
Oh, nevermind about #1, I misread. And it's not about who gets to use = but that there are three options to begin with. Each and every language feature has to pull its weight, and two of these three do not IMHO.
Apr
24
comment Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?
@supercat Of course I would be opposed, first because of what I wrote in the question, second because two additional syntax constructs has all the downsides of one additional syntax constructs, only more so, and third because your case (1) strikes me as underachieving: If such a check is made, it can and should be made before execution.
Apr
22
comment Advantages of having numeric data types as classes rather than primitives
It's basically a dirty hack when your language design doesn't allow arbitrary types to have the benefits of unboxed/value types but you want the micro benchmark performance for the most common types. (That is not to say that "hack" can't be better than extending the language or giving up on that performance boost, but I do have a distaste for it.)
Apr
21
comment provability of while loop vs for loop
I agree with Kilian. It makes no sense that there should be a difference, as for (init; test; step) { body } has a trivial desugaring to while: {init; while (test) { step; body }}.
Apr
16
comment Why was the Itanium processor difficult to write a compiler for?
All very interesting, but you mostly explain why Itanium failed, whereas the question was about Intel's strategy in pushing Itanium. There is a hint in "Intel would have been happy to have everyone [...]" but it's not clear to me if you're implying whether this was a deliberate decision by Intel (and if so, what you have to support this assertion).
Apr
16
comment Why was the Itanium processor difficult to write a compiler for?
Really-low-level IRs (that are actually specified beyond being internal to one compiler, and intended to be compiled onto specific hardware rather than interpreted portably) are a more recent invention AFAIK. That's not to say they didn't exist at all, but I think the idea was not at all obvious or well-known for quite a while. I mean, most people still associate "bytecode" with "interpreter".
Apr
10
comment Advantages of the imperative style over the functional style
The keyword they'd take issue with is "simpler", which you wisely edited out ;-)
Apr
10
comment Advantages of the imperative style over the functional style
I think FP advocates would contest the first two, though the first only because of different definitions of simpler (you refer to implementation, FP advocates look at denotational semantics or something similar).
Apr
10
comment Why server-side repository merge is a terrible idea in git?
How would that even work? SSH into the (presumably headless) server and do the merge there? What advantage does your colleague hope to gain from that?
Apr
8
awarded  Good Answer
Apr
7
comment difference between generics and interfaces
@scriptin In several languages generics can put bounds on the generic type parameters, which means that the generic can only be instantiated with types fulfilling certain constraints (such as implementing some interface). Since there's no language tag, I assume this is pseudo-code.
Apr
7
awarded  Nice Answer
Apr
7
answered How much work should I place inside a lock statement?
Mar
31
revised is a DoS attack a good analogy of Dining Philosophers?
added 188 characters in body
Mar
31
answered is a DoS attack a good analogy of Dining Philosophers?
Mar
28
comment Should I modify an algorithm I coded for my employer if I remember the code perfectly and want to reuse?
Deliberately introduce changes that improve code clarity. I'm only half-joking. Virtually everything can be made clearer and doing so puts you in a win/win situation.
Mar
22
answered How hidden classes allows faster access to properties in google's V8?