Showing posts with label who knew. Show all posts
Showing posts with label who knew. Show all posts

08 July 2011

Appalachians

I've been reading about geology, the most epic of the sciences.

Long ago, the continent of Africa collided with what’s now the east cost of North America. The collision lasted for, oh, eighty million years and left behind... the Appalachian mountains.

The Appalachians you see now are not the originals, though. Those were some serious, Himalayan-scale mountains, but time and water wore them away to level ground. The current Appalachians are made of more of the same rock that was left underground, untouched by erosion, and uplifted quite recently, no more than sixty million years ago.

The Earth is at a rolling boil.

11 January 2011

Things I learned recently

Handmade paper does not have a grain. The fibers stretch out in random directions. But factory-made paper uses a process where water flows across the surface of the paper as it forms. Take any sheet of printer paper and you'll find that you can curl up the long vertical edge over using less force than the shorter horizontal edge. Even though you're bending more paper the long way, you're bending fewer of the paper's fibers by going with the grain.

According to the Wikipedia article on shmoon, “The word ‘shmoo’ has appeared in nearly 700 science publications since 1974; it is used in labs studying the bread-and beer-making species Saccharomyces cerevisiae.”

The geoid is the shape of the mean sea level of the earth. It is not an ellipsoid. Gravitational forces due to variations in the earth's density subtly distort the geoid. This is why a GPS device can tell you you're 20 meters underwater when you're at the beach: GPS measures your altitude above a reference ellipsoid, not the true geoid. The difference can be much greater in magnitude than the tides.

13 September 2009

Prehistory, continued

I guess I always thought of technology as strictly cumulative, but reading a little about the Stone Age dispelled that notion. Archaeologists have had to reverse-engineer, from the artifacts they left behind, the toolmaking skills and technology of extinct cultures. How did Cro-Magnon mammoth hunters store meat? Wouldn't it spoil? Well, we really don't know that sort of thing anymore, but there's a way to find out:

[U. Michigan researcher Dan] Fisher butchered a draft horse using stone tools he'd knapped himself, then cached the meat in a stock pond. Naturally preserved by microbes called lactobacilli in the water, the flesh emitted a faintly sour, pickled odor that put off scavengers even when it floated to the surface. To test its palatability, Fisher cut and ate steaks from the meat every two weeks from February until high summer, demonstrating that mammoth hunters might have stored their kills in the same way.

Tom Mueller, “Ice Baby”. National Geographic, May 2009.

People showed up on Australia forty thousand years ago. Even though the sea level was lower then, they would have had to cross a channel 55 miles wide to get there. It's a little mysterious to me, as the oldest boats ever excavated anywhere are dugout canoes at most nine thousand years old.

So the first real agriculture (planted fields) happened about ten thousand years ago, dogs were domesticated about fourteen thousand years ago, but apparently people were exploring the South Pacific in logboats, miles from shore, forty thousand years ago. (The oldest stone tools predate H. sapiens and appeared 2.5 million years ago.)

11 September 2009

This week I learned...

It's prehistory week at the jorendorff household. This week I learned:

  • The fossilized skeletons of a 14-foot Xiphactinus (a mean-looking Late Cretaceous fish) and its last meal, a merely 6-foot bony fish which it swallowed whole, are on display at the Sternberg Museum of Natural History in Hays, Kansas.

  • Woolly mammoths had a three-inch-thick layer of fat underneath thick skin, fur, and long shaggy hair. (Yet their environment was such that occasionally one would be flash-frozen, without spoiling the meat, to be eaten by modern dogs ten thousand years later.)

Last week:

  • The original Nintendo GameBoy had an 8-bit processor with a HALT instruction which games were supposed to use to wait for interrupts. At least one game would sometimes busy-wait instead (yuck!).

  • There's a tool, dwarfdump, that dumps DWARF debug info from an executable or object file.

  • On Mac there's a lazy debug-info-linking scheme that causes dwarfdump not to see any DWARF in compiled executables. The Mac tools that come with Xcode are aware of this magic, but dwarfdump isn't.

Earlier still:

  • The Spiral of Theodorus shows that the square roots of integers can be constructed with straight edge and compass.

  • According to Tim Sweeney, quoted in this DDJ article:

    Any loop written in a traditional programming language can be vectorized, to execute 16 iterations of the loop in parallel on Larrabee vector units, provided the loop body meets the following criteria:

    • Its call graph is statically known.
    • There are no data dependencies between iterations.

    So compilers will be able to do a lot more vectorization.

09 May 2009

Recently I learned...

  • Your browser uses the public suffix list to determine whether two web sites may share cookies. This is not very robust but better than the previous strategy.

  • If you take a long strip of paper, fold it in half as many times as you can, and unfold it, it'll make an approximation of the fractal shape called the Heighway dragon.

  • If you take two fractions, say 1/2 and 1/3, and add the numerators and denominators, you get the mediant, in this case 2/5. I don't know much about the mediant, but it is linked to Ford circles in a way I don't really understand, and I'm told mediants give a startling way of approximating the value of continued fractions.

  • glibc's qsort only does an actual quicksort as a last resort. If there's enough memory, it does a merge sort.

    This is old news, and I kind of figured it was the case, but I never looked at the source code before.

And I was reminded that complex numbers are key to quantum mechanics, something I missed when I was writing about complex numbers a year or two ago.

We've been unpacking books that have been in boxes for a year and a half. It's like meeting old friends. I read the epic of Gilgamesh, the book of Joshua, and Six Easy Pieces. I love small books.

18 November 2008

Recently I learned...

  • Some people are, at this moment, running around the world. As of this writing they're about 16% done.

  • Seattle is farther north than Montréal. It is in fact farther north than all but the northernmost tip of Maine.

  • Someone with a browser history like mine is more likely female than male.

    (My history includes a lot of pages on bugzilla.mozilla.org and developer.mozilla.org, which should peg me as a male nerd with high confidence. But that page only checks whether you've visited the front page of a few very popular sites.)

  • In 1905, the President of the United States threatened to abolish football unless something was done to reduce the number of fatalities. Colleges established a rules committee and made radical changes to the game. Hurdling (jumping feet-first over other players) was banned. Roughing penalties were introduced. Six men were required on the offensive line. The forward pass was added.

    [T]he new rules committee further opened up the game by requiring the offense to advance ten yards in three tries for a first down instead of five yards, which previously had been a great inducement for bruising, battering line play from which no form of mayhem was barred.

    Principles of Coaching Football by Mike Bobo and Spike Dykes, citing 100 Plus Years of Football by Jerry Brondfield, 1975.

    This, in addition to earlier reforms banning things like piling on the ball carrier and the flying wedge (in which offensive players would build up momentum before the play started by charging en masse toward the line), made football the genteel pastime it is today.

I'm starting to learn random stuff by reading source code. Technically I've been doing this for ten years or more, but I recently have made a conscious effort to be more aggressive.

  • lighttpd has a very simple scheme for exploiting multiple CPUs. After binding the server socket to an address, it simply forks a few times. All the worker processes do the same thing: listen on the socket and serve HTTP requests. There's no load balancing and no communication between the parent process and the worker processes.

  • On x86, at least in glibc's implementation, setjmp saves five 32-bit words of state: three callee-save registers and the caller's stack pointer and instruction pointer.

I also learned a lot last week about David Humphrey's awesome Mozilla project course at Seneca College. It builds on a foundation of C, C++, and UNIX knowledge that Seneca's CS program lays down in required freshman courses. It has a lecture component and a lab. Any time you spend on your project is on top of that. It has a reputation as a killer course.

24 July 2008

Last week I learned...

  • When volcanic eruptions created the island of Ferdinandea in 1831, it was quickly claimed by Italy, France, the UK, and Spain. While they were arguing, the little island eroded away.

  • How to put this? Language isn't what I thought it was. (This definitely falls into the category of thought-provoking stuff I won't pretend to understand.)

    A little background. Before your third birthday, you subconsciously achieved a thorough familiarity with the grammar of the language spoken in your home. Never mind that you said I've sawn instead of I've seen. That's small stuff. You knew when to use the and when to use a. You knew which of they run and they runs was right, that big green circle sounds better than green big circle, how to figure out what it means in context, and much more. You will never have conscious understanding of all the syntactic rules you already had subconsciously at three. No one does. Not even people who make a career out of studying exactly that.

    Linguists aren't dumb. Why is it that toddlers are able to do this amazing thing that all the linguists in the world, given several decades to work, can't do?

    Beats me, but there's something else kids do that's even more amazing. They invent grammar.

    I'm tempted to block-quote about a page out of this book I'm reading (Foundations of Language by Ray Jackendoff). It's fascinating stuff. “Derek Bickerton documents in detail that children of a pidgin-speaking community do not grow up speaking the pidgin, but rather use the pidgin as raw material for a grammatically much richer system called a ‘creole’.” If adults could do that, there wouldn't be a pidgin phase. The kids do it. Where does that come from?

    Communities can exist for millenia without developing writing. They don't go without grammatically complex spoken language. Hmmm.

    Even better, there's a school for the deaf in Nicaragua where the kids, unprompted, made up their own sign language. “Besides offering the wonder of a whole language coming out of nowhere, Nicaraguan Sign Language sheds some light on questions about creole. Evidently a community is necessary for language creation, but a common stock of pre-existing raw material is not.” I always assumed the syntax of a language like English comes together incrementally, over thousands of years. Shows what I know. It was probably invented in a single generation.

  • Parahã, a language spoken by a few hundred people in Brazil, contains, according to Wikipedia, “two very rare sounds, [ɺ͡ɺ̼] and [t͡ʙ̥]”. In case you don't have the fonts I do, that first one looks like two upside-down lowercase rs with a squiggle underneath like a bird in flight, and a arc over the top; and the second one looks like tB with a dot under the B and an arc over the top. I wonder how they're pronounced.

  • In the version of g++ that ships on the Mac these days (GCC 4.0.1), you can get the old-school SGI STL hash_map container by doing #include <ext/hash_map> and using __gcc_cxx::hash_map;. But the GCC guys have already replaced the hash_ containers with newer standards-track containers, unordered_map and friends, which you can get in a more recent libstdc++.

  • In C++, a class's private members are not entirely hidden from code that uses the class. It's possible for public names to collide with private names. For example:

        class A { private: void f(); };  // This method is private, but its name matters...
        class B { public:  void f(); };  // ...because it'll conflict with this one.
        class C : public A, public B {};
    
        C().f();  // Error: request for member ‘f’ is ambiguous.

    Leaky abstractions make me sad. This doesn't seem to come up often in practice, but I think it's one reason STL implementations tend to contain lots of extra underscores. Another reason for that, as Blake Kaplan pointed out to me, is that a standard C++ program can do:

    #define n 3
    #include <vector>

    and the headers should be able to cope with that.

23 July 2008

Stuff I learned recently

  • Twelve thousand years ago, a gigantic dam of solid ice blocked the Clark Fork River, creating Glacial Lake Missoula.

    The lake was almost 2,000 feet deep.

    And periodically the dam would explode, laying waste to parts of what's now Montana, Idaho, Washington, and Oregon.

    Thundering waves and chunks of ice tore away soils and mountainsides, deposited giant ripple marks, created the scablands of eastern Washington and carved the Columbia River Gorge.

  • Mendellsohn's Wedding March has about 50 times more notes in it than I had realized.

  • “Between 1958 and 1992, Russia dumped 18 nuclear reactors into the Arctic Ocean, several of them still fully loaded with nuclear fuel,” writes Scott G. Borgerson. The article also points out that last summer, “[f]or the first time, the Northwest Passage—a fabled sea route to Asia that European explorers sought in vain for centuries—opened for shipping.”

  • Calque is a loanword and loanword is a calque. (Source.)

  • Recent Linux and Windows operating systems implement address space layout randomization. The goal is to prevent certain security attacks that depend on specific code being in predictable memory addresses.

  • According to a 2005 research paper by Richard Haier et al, women's brains have about 10 times the amount of white matter related to general intelligence (that is, in areas whose size correlates with IQ) as men's. Contrariwise men have have about 6.5 times the amount of IQ-correlated gray matter. I find that pretty startling.

    Here are some of Haier's own words on brains and genes.

01 June 2008

Facts

David Macaulay wrote and illustrated a book entitled Castle. If you have a child four or older, you have a perfect excuse to buy it. Mill is fascinating, too.

That “if Microsoft designed the iPod package” video was commissioned by Microsoft. To my mind, that makes it even cleverer.

In an underground passageway somewhere near Shinjuku, there is a machine that cleans your glasses.

A hot-air balloon that can carry 8 people costs “all your money”. Or if you prefer, about a hundred thousand dollars.

You can write a regular expression that matches only strings of a composite number of x's. (Hint: Too easy for a hint.)

I knew that Galileo discovered the first four of Jupiter's moons, the Galilean moons. I didn't know that the fifth known moon wasn't discovered until almost 300 years later, when Tennesseean E. E. Barnard discovered Amalthea.

And it took me completely by surprise to learn that Richard Feynman ever worked at a computer hardware startup, Thinking Machines Corporation.

06 April 2008

This week I learned...

  • In the children's section of the Nashville public library, the mother lode of folk tales is in the nonfiction section. Aha!

  • There's a whole family of egg-eating snakes that swallow eggs bigger than their heads, squeeze out the insides, and spit out the shell.

  • According to this blog post, native speakers of Chinese are gradually forgetting how to write.

  • According to Jared Diamond, out of 148 species of large, wild, terrestrial herbivorous mammals, only 14 have ever been successfully domesticated. (Guns, Germs, and Steel.)

Every time I go to the Nashville library, I leave feeling like I've just picked somebody's pocket. It's a wonderful library. (I don't know that it's particularly unusual in this regard.)

04 April 2008

This month I learned...

The past three or four weeks are a bit of a blur, but:

  • Just before he died, Beethoven claimed to be working on a Tenth Symphony. Fragments of this were discovered among Beethoven's sketchbooks in the 1980s (!), and musicologist/composer Barry Cooper stitched together a highly speculative, but performable, first movement.

  • I knew that John Harrison invented the first clock that could keep time on a ship and that such clocks cracked the longstanding problem of determining longitude at sea, leading to the first accurate maps. (H1 was his first attempt; his masterpiece, H4, was a 5-inch watch with a diamond-studded movement.) I didn't know that Harrison faced competition from an astronomical method relying on careful on-ship measurements of lunar occlusions of certain stars, huge tables of laboriously pre-calculated data, and maybe four hours of additional calculations to be done on the ship. It was a usability disaster, as one might expect. But at the time, the idea of making a clock run reliably on a pitching, rolling ship apparently seemed even crazier.

  • Bill McCloskey's memoize is a replacement for make in a few lines of Python. The complete source code fits on my screen. This is the coolest hack I've seen all year.

  • The word goodbye comes from the saying “God be with you”. According to the American Heritage dictionary's etymology note, “A letter of 1573 written by Gabriel Harvey contains the first recorded use of goodbye: ‘To requite your gallonde [gallon] of godbwyes, I regive you a pottle of howdyes,’ recalling another contraction that is still used.”

  • According to Wikipedia, the lungfish has the largest genome of any vertebrate. But as of today, Wikipedia does not say anything about the lungfish's lungs! (I usually try to contribute in cases like this, but here I haven't a clue.)

  • On the Mac, if ls -l output has an @ symbol here:

    -rw-r--r--@   1 jason  jason     54838 Sep 27  2007 #tamarin 9-25-07.colloquyTranscript

    then the file has extended attributes. These are used, for example, to mark files as “saved from the web”, triggering a warning if a user tries to open the file.

29 February 2008

This week I learned...

I spent most of this week sick in bed, but I did discover that:

  • According to the Jameel Poverty Action Lab at MIT, the cheapest way to improve attendance in Kenyan schools is mass deworming.

  • There's a guy removing Garfield from Garfield comic strips. The result: “an even better comic about schizophrenia, bipolar disorder, and the empty desperation of modern life”.

  • Guy Steele wrote The TELNET Song. Before webcomics, if hackers wanted to laugh without leaving the net, they had to make their own humor.

Also, I like this poem: “The Trash Can”.

23 February 2008

This week I learned...

  • A shibboleth is language that sends cultural signals beyond its plain meaning. The word comes from a fairly amazing Bible story.

    Now I want a word for language invented to annoy, like “Democrat Party”.

  • Aristotle believed slavery to be “expedient and right”. All the best arguments by learned apologists for slavery in the U.S. South were from his writings, particularly in the Politics.

  • Incidentally, Aristotle thought democracy was a crummy form of government. And, in his ideal society, homeschooling would be banned.

  • There are expressions of the Golden Rule in the scriptures of many religions.

  • I don't understand what this means, exactly, but the x86 instruction set contains an FNOP instruction. The manual describes it as a floating-point no-operation instruction. How this might be different from a regular NOP I don't know.

  • So there's a widely known interview question: write a function to count the number of bits of a 32-bit int that are set to 1. This function is called the population count—that link describes a surprising use for it.

    The last time I tested this, summing 4 queries into a 256-value lookup table is fastest for 32-bit integers, faster than the awesomely clever bit-twiddling solution. I shouldn't have been surprised. The lookup table fits easily into cache. The bit-twiddling solution has a lot of dependencies; the CPU can't find any instruction-level parallelism there.

    Anyway, what I learned a week or two ago is that future Intel chips will have an SSE instruction, POPCNT, that does this, in parallel, for several words at a time. (Someone I mentioned this to commented that he doesn't want to be fired for pronouncing that.)

  • Often when I write these blog entries, I'm still unsure of the significance of some of the things I've just learned. For example, I learned something about Java monitors (or pthreads condition variables, which are the same thing). When thread 1 notifies, waking thread 2 on a separate CPU, the lock associated with the monitor ensures that CPU 1's writes are flushed to main memory and CPU 2 sees them before thread 2 starts running. There's no need for write-barrier magic in Object.notify itself.

  • Apple's Shark profiler has a feature that lets you compare two profiles. But the result is calculated by comparing percentages, not comparing the absolute number of samples. So, for my purposes, useless.

  • The .mshark files produced by Shark are gzipped binary property lists, but the actual samples are stored in there as raw binary data which I haven't tried to decipher.

08 February 2008

This week I learned...

Special double issue! Two weeks' worth of trivia, including a week spent in Mountain View.

  • Most Japanese streets do not have names.

  • With GNU Radio, you can buy some cheap hardware, plug it in, and your computer becomes a GPS receiver, a garage door opener, an HDTV tuner, an AM/FM radio, a cell phone. This is subversive technology. Hollywood wants regulations that would ban such nonsense.

  • Radio waves bounce off meteor trails. This is actually usable as an alternative to satellite communications, depending on the application. For example, the USDA has a network of solar-powered snow depth sensors that use meteor trails to phone home.

  • On the Mac, Alt+[ types a left double-quote mark and Alt+{ types the right one. Much better than typing &ldquo;.

  • GCC generates a floating-point instruction for isnan(x); it amounts to x != x (NaNs are not equal to themselves). Intel engineers claim integer instructions can be much faster, on x86 at least, due to floating-point exception nastiness.

  • Xavier Leroy has written a provably correct “lightly-optimizing” back-end that compiles a subset of C to PowerPC machine code. Sandrine Blazy and Zaynah Dargaye have hooked it up to a provably correct front-end.

    A little background here. A compiler works by lowering code step by step from relatively high-level internal representations, like parse trees, to successively lower-level representations, until it gets down to machine code. At each level it can apply optimizations: some optimizations, like common subexpression elimination, work at a very high level, and some work at the machine-code level. Stack up enough lowering passes and optimizations, and you've got yourself a compiler. There's considerable interest these days in using formal methods to prove the correctness of program transformations. First you define mathematically what it means for two programs to be equivalent. Then you prove that a given transformation always produces a result that's equivalent to the original. Stack up enough provable lowering passes and optimizations, and you've got yourself a provably correct compiler.

    This kind of work has been done for subsets of Java, but C's pointers and undefined behavior present some nasty problems. Leroy's work is hedged in with disclaimers, but it's still pretty amazing stuff, and an interesting read. For example, he proposes the following sneaky technique. Write your compiler pass however you want, and don't bother proving it correct. Then just verify the correctness of the transformation afterwards (for the particular program being transformed). It's apparently much easier to prove a verifier correct than the transformation code itself. Plus, you can then tweak the transformation without redoing any proof work. The only risk is that your transformation is incorrect, in which case your compiler flunks out with an internal error at compile time.

  • The PDP-11 had probably the nicest of all the widely used CISC instruction sets.

  • emacsclient is my new EDITOR. It connects to my existing Emacs process, if any (I had to put (server-start) in my .emacs file) and loads the file there.

  • Speaking of emacs: M-/ is the autocomplete key. It's moderately smart. You also want to know C-x r SPACE x (save current cursor position in x) and C-x r j x (jump to the position saved in x).

  • When you run a configure script, it generates a config.status file in the build directory. That file is helpful when debugging stupid build problems.

  • In the late-1990s, there were two computer science research projects called Dynamo, both involving dynamic optimization: one at Indiana University and of course the awesome one, at HP Laboratories.

25 January 2008

This week I learned...

  • NestedVM can take any program that GCC can compile and run it in a Java VM. It does this by compiling the program to a MIPS executable and then translating the MIPS machine code to Java bytecode. Now, there isn't any high-level type information in a MIPS binary, so there isn't any in the bytecode. Instead each instruction is translated to something that bangs on some large int arrays that represent virtual memory. (The sbrk system call is implemented using new int[].)

    The paper has sentences like, “The NestedVM runtime fills the role typically assumed by an OS kernel.” :)

    I think the point of this, aside from being cool, is to make C++ code run anywhere Java does. I don't know how many platforms have JVMs but not gcc back-ends, though. (GCC actually has a back end for Java, but it can't handle C++.)

  • So if you know C, you know that && has short-circuit behavior: if the left-hand side is false, the right-hand side doesn't get evaluated. This week I learned that if the right-hand side of && is simple enough and has no side effects, as in x > 0 && x < N, a good compiler emits code that evaluates it anyway, essentially treating the && as &. A conditional branch is slower than a few redundant instructions.

  • Objective C exceptions on Mac are implemented using setjmp/longjmp. They don't cooperate with C++; if you throw an Objective C exception across a frame containing C++ objects, the destructors don't get called. This triggered some bugs in Mozilla, which apparently has Cocoa GUI code or something. (Sorry, I don't pay much atttention to that stuff. :))

  • If you compile with gcc -g3, then gdb can print expressions that use macros! I knew Jim Blandy had implemented this but I never actually went and dug up the magic to make it work. This will make my life a lot easier, at least for a year or two.

  • The gcc compiler itself uses a garbage collector. I'm told the GC is autogenerated from the source; so the gcc source distribution actually includes a bunch of autogenerated code.

  • gcc -S prints Intel assembly code with the operands reversed. I don't remember if I ever knew this or not. What a pain.

  • And some more about GCC internals, from here.

18 January 2008

This week I learned...

  • The Phaistos Disc is a mysterious clay disc, about 3400-3850 years old, discovered in the basement of a Minoan palace. It is imprinted with hieroglyphic symbols. It is the earliest known instance of movable-type printing, which would not be seen again until woodblock printing appeared in China some 1600+ years later.

  • Poseidon was believed to have created the horse. (I didn't even know that Pandora was a Greek legend. In my brain she was curiously detached from any specific culture.)

  • For some reason, Wikipedia's pages on Greek mythology are very often vandalized.

  • And I learned more about SpiderMonkey split objects than any human being should know. But I still don't understand them very well, as that page (which I wrote) indicates.

    I've been learning (and documenting) a lot about SpiderMonkey and its API, which may be why the pickings are so slim otherwise.

07 January 2008

This week I learned...

  • Before desktop computers were widely used in China, telegraph operators there had to memorize every Chinese character's GB 2312 character code.

  • Moleskin is made from cotton, not moles. (In other news, guacamole is made from avacados.)

  • Garbage collection in Erlang is per-process. This seems weird—are messages copied from process to process?—but as that article explains, there are advantages, too.

  • The Haskell standard library contains over 100 operators— that is, functions whose names consist of ASCII symbols, like .| and |. and @?= and @=?. Someone must stop these madmen.

  • I learned a few very basic odds and ends of category theory.

    The book I'm reading (by Benjamin Pierce) offers “injective functions are monic in Set; surjective functions are epic” as a mnemonic, you know, to help you remember monic and epic. This has to be the worst mnemonic of all time. I just don't see anything helpful about it. Sur- means “under”. Epi- mean “on top of”. I can never remember the difference between injective and surjective to begin with.

04 January 2008

This week I learned...

  • A chipotle is a jalapeño that has been smoked.

  • There are lots of ways to tile a regular dodecagon with sides of length s using only rhombi with sides of length s. My favorite so far:

    I speculate all such tilings use exactly this many rhombi of each shape—six skinny diamonds, six fat ones, and three squares. It would be really cool if I were wrong. Calculate the area of each shape to see why I think this.

    (Pictured: Melissa & Doug pattern blocks. Great toy.)

  • Basic stuff about the Erlang programming language. If you set aside the concurrency features for a second, Erlang looks like ML without static typing or refs. In a word, yuck.

  • Haskell has concurrency libraries that I should look at (while I'm learning about language-level approaches to concurrent programming).

    Incidentally, if you're a Haskell programmer, see if you can spot the unintentional self-parody in that blog post. Hint: it's in the sentence “So let's do something useful with this, how about a little program that computes primes and fibonacci numbers?”

This week I started looking for elementary school curriculum materials. My son is four years old. We will probably homeschool him, and I want a head start on this one. Not a lot of luck searching so far. There are a lot of individual lesson plans; for example, PBS has some science lessons. On the other end of the spectrum, I found the What your nth-grader needs to know books and ordered one. We'll see. I really want a variety of textbooks and workbooks.

21 December 2007

This week I learned...

  • A five-step checklist saved about 1,500 lives in Michigan intensive care units in 18 months. It lists the five steps a physician should take, when putting a tube into a patient, to prevent infection.

  • Simple array lookups like arr[i], where i is an int, are troublesome for x64 compilers. This is because int is a 32-bit type, while arr is 64 bits. To generate the fastest possible code, the compiler must prove that the high 32 bits of the register containing i are all zeroes.

  • OpenGL is horrible for 2D graphics because 2D graphics are usually plainer and stay on the screen statically for a lot longer than 3D graphics. So a little imprecision is a very bad thing, especially for text. 3D cards don't have a whole lot of DWIM in them; if your use of an API is the slightest bit off, you can get bizarrely ugly results, and it's very hard to debug.

    This is an instance of a principle that I think works against efforts like bug.gd: the most perplexing things computers do don't come with error messages. Instead it just behaves funny, and gives no indication that it even knows it's doing it.

  • An interference graph is a way of thinking about scheduling constraints. For example, many compilers use an interference graph to assign variables to CPU registers. The vertices of the graph are the variables. Each edge connecting two vertices indicates that those two variables cannot live in the same register—their lifetimes overlap; they would interfere. The problem of register allocation is just a graph coloring problem on the interference graph.

    Graph coloring is NP-hard, though. Some JIT compilers do a linear scan instead, plopping each variable into the next available register. This may not get every variable into a register, even in cases where graph-coloring would. But it's fast.

Phone interviews are educational. :)

Merry Christmas!

14 December 2007

This week I learned...

  • This T-shirt claims that “Under extreme stress, an octopus will eat its own arms.” According to Wikipedia, this is a “common belief”, though I'd never heard of it. I'm suspicious.

  • Thanks to johnath, I now know that self-actualization tops Maslow's hierarchy of needs.

    The Internet, incidentally, is all about self-actualization. Depending on my mood, this strikes me as either dumb or moderately profound.

  • Good Lisp compilers, I'm told, do fancy escape analysis on closures, so they can detect when the upward funarg problem doesn't occur and in those cases stack-allocate the captured variables. Nice one. In Python, by contrast, all captured variables become heap-allocated “cells”. I hear SpiderMonkey still keeps the whole activation record alive. I had thought that practice was long dead; I know I've seen it characterized on Lambda the Ultimate as “stupid”.

  • I knew this was there somewhere. In gdb, the commands command lets you specify debugger commands that run when a breakpoint hits. For example, you can have gdb print some variables and continue. Useful.

  • Also in gdb: set scheduler-locking on prevents other threads from running while you're stepping in a thread. Not available on all platforms, apparently; but this is the only sane way to debug a multithreaded program.

  • Also in gdb: thread apply all runs a debugger command on every thread in the process you're debugging. I have yet to use it without crashing gdb, though.

  • Even in a very simple 3D model, physics is very hard to get right. I think faking it using an easing function would get better results. Kind of sad.

...and more about static single assignment form, but I have much more to read there.