14,270 reputation
13459
bio website
location
age
visits member for 4 years, 5 months
seen 2 hours ago

10h
comment Fastest way to determine if a value is in a list?
@Neil As long as the number fits into 64 bit (which 10^12 does, with plenty of breathing room), most things you'd do with it in a hash table implementations are ALU operations which process the entire word in parallel and are thus faster than doing even, say, five of the cheapest operations possible. Everything you write seems to completely ignore how real machines actually work. Even ignoring cache which (as explained above) I think spells failure for any kind of naive tree approach anyway.
11h
comment Fastest way to determine if a value is in a list?
Given that you want to reject non-existing elements quickly, then a bloom filter is exactly what you need and you definitely want to use it in addition to whatever exact data structure you end up using.
11h
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).
12h
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."
2d
comment Foreign characters display like junk on the screen
No encryption algorithm that is any good at all cares about characters or the order of characters. They all operate on uninterpreted streams of bits. Get your crypto act together and the problem goes away.
2d
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
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.
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
20
comment How come the computer doesn't have to read the entire table when the column is indexed?
@gnat That is a rather different breed of index, for (sub)text search, while this is an ordinary data base index on the exact value of some column. The concept is related, but the algorithms and data structures are very different.
Mar
17
comment When is it a good idea to force garbage collection?
@Doval I was also including soft real time, video games are the real time systems I know most about. On a graphic-intense game, the heap will be in the gigabytes and a GC of any significant chunk of that may cause noticeable stutter. Doesn't cost lives or anything, but it's a pretty major defect for a game.
Mar
17
comment When is it a good idea to force garbage collection?
@Doval If you're under a real time constraint and the GC doesn't provide matching guarantees, you're between a rock and a hard place. It might reduce undesired pauses vs. doing nothing, but from what I've heard it's "easier" to avoid allocating in the normal course of operation.