Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
psykotic
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
59 ms
·
511.
▲
by
psykotic
15y ago
I actually know and appreciate Clojure rather well. This isn't really about Clojure; I just think Tetris and similar kinds of programs are ideally suited to C and its level of abstraction.
512.
▲
by
psykotic
15y ago
> Would you be able to maintain it in half a year? Would anyone except you at the moment of writing be able to understand it? A C programmer? Yes and yes.
513.
▲
by
psykotic
15y ago
Let's call it 150 or so with a simple framebuffer and keyboard interface. And that's with lines of code that are a lot less semantically dense than either of the two Tetris programs in Clojure that were posted.
514.
▲
by
psykotic
15y ago
That's much better. But they're still writing programs in 250-300 lines of code using fancy libraries in a higher-level language that would take around 100 lines of simple and direct C code.
515.
▲
by
psykotic
15y ago
> 2) It obscures the connection to B-trees, which is what leads one to derive all of the special cases after all. You mean 2-3-4 trees rather than general B-trees. Anyway, that is true of all implementations of red-black trees I have se
516.
▲
by
psykotic
15y ago
Another reason: Wrap-around with modular reduction is a snug fit, so it's L[i % n] rather than L[1 + i % n]. You could have taken 1, 2, ..., n or indeed any set of n integers with distinct residue classes modulo n as the representatives, bu
517.
▲
by
psykotic
15y ago
Depends on what you like. Permutation City and Diaspora are fan favorites. They are heavy on idea porn but not very good yarns. That goes for most of Egan's books. His short stories are probably his most polished works because the form's co
518.
▲
by
psykotic
15y ago
Yes, Manber derives the linear-time algorithm for the maximal subsum problem exactly like that in his textbook. As you say, if x is involved in a maximal subsum, it must extend the tail's maximal prefix sum, so you return that in addition t
519.
▲
by
psykotic
15y ago
It's also his most tautly plotted novel because of the detective noir framework. Altered Carbon by Richard Morgan and the earlier Vlad Taltos books by Steven Brust also used detective noir conventions to great effect. It's a writer's crutch
520.
▲
by
psykotic
15y ago
No, r has the same type as x. The logic behind that probability split is simple: We have r' (the random sample taken from the tail list xs) and x, and we have to choose between them with some probability based on n. Clearly x should occur w
521.
▲
by
psykotic
15y ago
The algorithm for the simplest variant of that problem (take a single random sample from a list of a priori unknown length) can be derived by simple inductive reasoning. If the list has size 1, the problem is trivially solved. Otherwise sup
522.
▲
by
psykotic
15y ago
> I'm a huge Knuth fan, but I don't see his work as fundamental to computer science You're talking about the guy who invented LR parsing.
523.
▲
by
psykotic
15y ago
Yeah, I had a conversation a few weeks ago with a coworker where he misremembered that as being what was in the lcc book. I actually posted about this here (including an excerpt from Steele and Harbinson) ten days ago: http://news.ycombina
524.
▲
by
psykotic
15y ago
It's interesting to see the range of proposed solutions to this issue. Here's a few from memory. Koenig's C Traps and Pitfalls does the opposite of what you'd expect by making the recursion work with negative integers and reducing the posit
525.
▲
by
psykotic
15y ago
Me too. I knew this was undefined in theory because C treats any kind of signed overflow as undefined behavior, but I'd never run into this specific issue. Trapping it is a denial-of-service risk but at least it won't subtly break downstrea
526.
▲
by
psykotic
15y ago
> More importantly, cmpxchg8b is essentially useless without lock prefix. I haven't looked at this for a while but I'm pretty sure cmpxchg8b nowadays has an implicit lock prefix.
527.
▲
by
psykotic
15y ago
No, he was referring to the 32-bit to 64-bit mode switch. I was talking about entering 32-bit protected mode from real mode for the first time, typically right after boot-up. As another posted mentioned, once you're in protected mode, you c
528.
▲
by
psykotic
15y ago
Thanks, that makes sense. My ARM knowledge has been either second hand or from book reading, so this is good to know. > No ARM processor has ever had a "post-ALU" shift. Typo. I meant pre-ALU.
529.
▲
by
psykotic
15y ago
I agree it isn't bizarre. But... > Every CPU I know of with more than one mode implements switching with some kind of jump instruction. So you don't know x86? You enter protected mode by manipulating the cr0 register.
530.
▲
by
psykotic
15y ago
How so? The table of cycle timings on ARM's website agrees with what he said: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.... On the classic ARM processors like ARM9TDMI, I think post-ALU immediate shifts were free and reg
531.
▲
by
psykotic
15y ago
My least favorite part when reading and writing x64 code has to be the calling conventions.
532.
▲
by
psykotic
15y ago
Unfortunately, there are tons of people out there still running 32-bit Windows. Microsoft had a chance to cut the cord with Vista and 7 but they blew it.
533.
▲
by
psykotic
15y ago
> They're hardly modern CPUs They're annoying to program but why aren't they modern? You're just redefining terms to try to win an argument. They were intentionally scraped down to lower power consumption and manufacturing costs. That d
534.
▲
by
psykotic
15y ago
> Shift and add are both one cycle on all modern CPUs. It's common for variable-length shifts to be slow on modern CPUs once you move outside of the x86 space. On the PS3's PPU and the Xbox 360's PowerPC cores they are very slow and to
535.
▲
by
psykotic
15y ago
> What kind of periodic interval can you recommend that would be generally applicable, how should the deadlock handler react in such a situation etc. periodic detection will make the deadlock handler harder to write. The question of how
536.
▲
by
psykotic
15y ago
> So lock acquisition is now O(n) instead of O(1). You can do incremental deadlock detection in O(1) time per waiter assuming you are okay with treating hash table operations as O(1), so that successful lock acquisition takes O(w) time
537.
▲
by
psykotic
15y ago
That's not right. Surrogates are code points. That's the whole idea! It means you can express characters beyond the BMP with legacy encodings that were designed back when the entire code space could be coded in 16 bits. Newer encodings like
538.
▲
by
psykotic
15y ago
> The Plan 9 code has some very clean code I'd love to hear others' recommended "classic" works..? The lcc compiler. It's written as a literate program. Read A Retargetable C Compiler by Hanson and Fraser.
539.
▲
by
psykotic
15y ago
Yeah. The dual file format trick reminded me of the GIFAR exploit where you take advantage of the fact that GIFs are header-based and JARs are footer-based. In the present case, one format (PNG) is header-based and the other format (HTML) i
540.
▲
by
psykotic
15y ago
Very few things are truly necessary to know, so I was working from the premise that such studies would be undertaken as a way of rounding out someone's knowledge. The direct practical applications of that knowledge to programming are rare,
More ›