Reputation
3,175
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
12 17
Newest
 Nice Answer
Impact
~151k people reached

13h
comment Word game algorithm
More space-efficient, for sure (you're trading an M-character string for a single character and a small-ish integer)
14h
comment Interview question on accessing variable with pointers in c
Or possibly p--, depending on the direction of the stack. It is, however, relying on undefined behaviour, so...
Jan
14
comment Is it effective to review code in language I don't know?
@BЈовић Nope, it's not the worst you can find, but it is pretty close to "the smallest thing found that is still worthwhile".
Jan
14
comment Is it effective to review code in language I don't know?
@BЈовић And if the only comment is of the form "wouldn't variable flugh be better named bloops, as you have typed it as a bloop and it's an array?" ?
Dec
31
comment Does it make sense to use the term “Space Leak” with regard to Java?
I tend to use one of "unintentional liveness" (there's one or more references to an object, keeping it live, even though it is no longer needed) or "GC bug" (if the object is no longer reachable, but still cannot be collected).
Oct
28
comment Does extending a ruby class violate the LSP?
I suspect Cat and Mammal are better examples than Room and House. Sub-classes should, in general, follow an "is-a" relation (so, neither a "has-a" or "exists-in").
Oct
16
comment How does google calculate travel distance/time
@HugoDelsing Have a couple of tens of thousands of "route-finder nodes", able to speak a common RPC protocol. Send "navigate from A to B" to a couple of hundred (with different biasing), have them compute routes and send best-so-far route (and cost) back to the controlling node. Periodically update them with cost of cheapest route found so far. Allow, say, 0.5 - 1 s from "start of tracking" to "you're done now". Pick the cheapest route found. Don't underestimate what you can do when you can throw insane amounts of CPU, disk and RAM at problems.
Oct
16
comment How does google calculate travel distance/time
@HugoDelsing "Cheapest route between A and B" is a completely different problem from "Cheapest route between N points". The first has some pretty good applicable heuristics ("never move sufficiently straight back to A" would be one), the second is NP-complete.
Sep
22
comment Why does `length - 2` recursively give you the center of a linked list?
@OmarK No, you subtract two because the list you are interested in is two elements shorter (it is without "the first" and "the last" element). This is independent of if the list "index" (these look as if they could well be implemented with linked lists) being 0-based or 1-based. After all, if I have a list [1, 2, 4] or a list [0, 1, 2, 3] (both length 4) both [2, 3] and [1, 2] are lists of length 2, as well as being the previous lists with the first and last element removed.
Sep
4
comment Is recursive-descent parsing a panacea for DoS threats posed by 'Evil' regexes? Or does evilness stem from the grammar?
@DavidBullock It... depends. You may end up with a better memory characteristic, but similar run-time characteristics, especially if you want to consider all possible matches.
Sep
3
comment Why does ISO 8859-1 contain letter-free diacritics?
I have seen CRT terminals that do (this may be due to font hackery internal to the terminal, but the effect was quite startling).
Aug
29
comment Is there any practical trick to remember the difference between big-endian and little-endian?
@JoonasPulakka Big-endian and Little-endian really started out as machine-oriented specifics, rather than as "Pure Theoretical CS notions", so I guess I could argue this both ways. Unless we're looking at bit-level transmissions, I guess the endian-ness of octets very rarely matter on most modern machines.
Aug
8
comment How should I structure these Python classes?
There's nothing stopping you from writing an "abstract service base class" that does this through-wiring for you, but whatever lets you express what you want, with the minimum maintenance hassle 2-3 years down the line.
Jul
22
comment Why is String immutable in Java?
Technically, Common Lisp has mutable strings, for "string-like" operations and symbols with immutable names for immutable identifiers.
Jun
9
comment To which extent can one take ideas from programs under GPL in developing a commercial app?
@Trilarion The way you do it if you're "sufficiently paranoid" and "have enough resources" is having one team studying the source code and provide API documentation to another team that don't look at the source and write your code.
May
1
comment Why is negative zero important?
If the particular example is "1 / 0.0" / "1 / -0.0", 0 is a branch cut for 1/x and the limit depends on if you approach it from below or above.
Nov
11
comment Reference counting & GC in LISP
It only can with weak references, which is a higher cognitive load on the programmer.
Nov
11
comment Reference counting & GC in LISP
But that means you need to have two types of references, where a single type of reference would have sufficed, with a more advanced (and not necessarily any slower) GC. Remember that updating a reference count MUSt be lock-protected, so any "reference or de-reference any other object" is suddenly a lock acquisition, instead of amortised at GC time.
Nov
4
comment Undefined behavior, in principle
Or even "may produce different results in consecutive runs of the same binary, resulting from a single compilation".
Oct
21
comment Robustness and pointer safety in C++
I agree that code is vastly more likely, but even in the face of perfect code...