hobbs
Reputation
803
Next privilege 1,000 Rep.
 1d comment Why is negative zero important? @jpmc26 (i.e. in every other multiplication of two numbers, the sign of the result is the xor of the sign of the multiplicands, and the magnitude is the product of the two magnitudes. In real life this works for -1 * 0 = -0. But if zero with the sign bit flipped was some special nonzero value, every product that could produce 0 would have to check and make sure it doesn't produce that special value by mistake.) 1d comment Why is negative zero important? @jpmc26 I think there actually is some truth to that, in that not forbidding it means not requiring implementations to have a special case. As it is, every number has a sign bit and can be negated by toggling the sign bit. Even NaNs are signed, and implementations can (but aren't required to) choose an appropriate sign when producing a NaN. If negative zero didn't exist, every calculation that resulted in 0 would need to do extra work to fix up the sign bit, etc. Apr 28 awarded Yearling Apr 18 comment Could Hindley-Milner inference work for the Go language? This is also why Go devs pretend that FP of all sorts is bad; Go has first-class functions with lexical closure, and with that the ability to create higher-order functions, but it's impossible to put them to any good use because the types of such basic functions as `map`, `filter`, and `reduce` are all inexpressible within Go's very limited type system. Apr 18 comment Could Hindley-Milner inference work for the Go language? @bishop It's "reasoned" for infinitesimally small values of "reason". Feb 26 comment Will a computer attempt to divide by zero? @Bergi yeah, although the version that's prone to looping forever is probably too inefficient to use much in practice. The constant-time ones that are commonly used look like they would give a quotient of -1 (or maxint) and a remainder that looks like the original dividend. Jan 26 comment Can the “level 256 bug” in the game of Pacman be considered an unhandled segfault? @Snowman there is no such layer on a Pac-Man machine. There's no loader — the game is in execute-in-place ROM. There's no memory management — everything is static. There's no "services"; the game accesses hardware directly and there isn't a byte of code on the system that isn't part of the game and written for the game. Jan 23 comment Efficient Repeating Alarm Clock in Low Level Language like C Most systems have at least one external interrupt somewhere, so on embedded, the best solution can easily be to spend \$1 on a real-time-clock chip and program it to raise an interrupt at a certain time. And then, if you have nothing else to do, put your CPU entirely to sleep. :) Jan 22 comment Is it good practice to avoid warnings and notices? Warnings in production should go to the logs, not to the user! Errors should go to the logs, not to the user. A website that doesn't trap errors, log them, and serve up a user-suitable error page instead isn't production ready. PHP makes it very easy to do this wrong, but you should still do it right. Jan 21 comment If a number is too big does it spill over to the next memory location? @MatthieuM from a language perspective, that's true. In terms of execution on a given system, which is what we're talking about here, it's absolute nonsense. Dec 31 revised Does it make sense to use the term “Space Leak” with regard to Java? added 39 characters in body Dec 31 answered Does it make sense to use the term “Space Leak” with regard to Java? Dec 9 comment When should I use Perl's DBIx::Class? This is obvious to you, but probably not obvious to many readers (I say, having spent years in `#dbix-class` and `#catalyst`) — the key to the "don't leak the abstraction" bit is that every single thing you're working with in DBIC is a subclass of something that provides the cookie-cutter behavior. You're strongly encouraged to add methods to your subclasses, and unless you're doing a Q&D job, only the methods you wrote should be part of your public interface. Nov 25 comment Would UTF-8 be able to support the inclusion of a vast alien language with millions of new characters? It's not strictly necessary for the number of following bytes to always be one less than the number of leading ones in the first byte. Perl actually supports (since 2000) an internal variant of UTF-8 where the 5, 6, and 7 byte forms are the same as this answer, but `FF` introduces a 13-byte code unit capable of storing 72 bits. Anything over 2^36 is uniformly very expensive, but it allows encoding a 64-bit int and then some. Oct 30 comment How are comments usually parsed? @ArtB in general, "parsing by substitution" gets very tricky down the road with edge cases and interaction with other features, and is best avoided from the beginning. Oct 23 comment Does an interpreter produce machine code? @JonPurdy I would agree with that, but I would also add a class, "traditional interpreters", that don't make use of intermediate representations beyond perhaps a tokenized version of the source. Examples would be shells, many BASICs, classic Lisp, Tcl prior to 8.0, and bc. Oct 3 revised In layman's terms, what is left recursion? added 103 characters in body Jun 13 comment Why do programs use call stacks, if nested function calls can be inlined? Can someone apply some better tags to this? The only tag on the question, "functional-programming", is clearly not appropriate. Jun 13 comment How Do News Websites E.g. Forbes / Zdnet Seamlessly Merge One Webpage into Another? @KRyan it just modifies the `offset` param that skips a certain distance into the resultset. Since the default sort order seems to be "popular all time" the results are probably somewhat stable, but definitely not if you switch the sort order to "newest" and search for something popular. Jun 13 comment How Do News Websites E.g. Forbes / Zdnet Seamlessly Merge One Webpage into Another? @OllieFord that's what the history API stuff is for. `history.pushState` and `history.replaceState` let you change the URL in the address bar without navigating away from the current page. It's the more modern replacement of the older trick of changing the URL fragment (`#something`), with a big advantage being that the history API lets you push "real" URLs that the server can participate in generating, while the fragment thing has to be supported completely from the client side.