Archive for November, 2009

Go Systems Programming

No Comments »

With countless new languages hitting the scene, it is refreshing to find one that clearly states its domain (systems programming) and a realistic set of goals. Leave it to Google to roundup some smart and experienced people, to create this new language, they dubbed Go (mainly because “Ogle” would be a good name for a Go debugger).

“Go was born out of frustration with existing languages […] One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python […] Go is an attempt to combine the ease of programming […] and safety […] with support for networked and multicore computing […] it is intended to be fast” [Language Design FAQ]

Obligatory “Hello World” example:

package main
import fmt "fmt"
func main() { fmt.Printf("Hello 世界!\n"); }

Nerd Test

No Comments »

“The following gdb script will handle this:

# Trace objective-c messages. - nemo 2009
b dyld_stub_objc_msgSend
        set $id  = *(long *)($esp+4)
        set $sel = *(long *)($esp+8)
        if(*(long *)($id+8) != 0)
                printf "[%s %s]\n", *(long *)($id+8),$sel
        set $isx = *(long *)($id)
        printf "[%s %s]\n", *(long *)($isx+8),$sel

We could also implement this with dtrace on Mac OS X quite easily.

#!/usr/sbin/dtrace -qs
/* usage: objcdump.d  */
    self->isa = *(long *)copyin(arg0,4);
    printf("-[%s %s]\n", 
        copyinstr(*(long *)copyin(self->isa + 8, 4)),

Let me correct myself on that, we /should/ be able to implement this with
dtrace on Mac OS X quite easily. However, dtrace is kind of like looking at
a beautiful painting through a kids kaleidescope toy.”
(nemo) [The Objective-C Runtime: Understanding and Abusing]

If you are only interested in the above text you are a halfling, if you just hit the link to RTFA, you are a nerd, if you think you could write the article, you are a script-kiddy, and if you go WFT, you are a n00b. But if you do read it, you might learn some new debugging techniques.

Block Level Deduping in ZFS

No Comments »

zfs_thumb“File-level deduplication has the lowest processing overhead but is the least efficient method. Block-level dedupe requires more processing power, and is said to be good for virtual machine images. Byte-range dedupe uses the most processing power and is ideal for small pieces of data that may be replicated and are not block-aligned, such as e-mail attachments. […] ZFS provides block-level deduplication, using SHA256 hashing, and it maps naturally to ZFS’s 256-bit block checksums. The deduplication is done inline […]” (Chris Mellor) [ZFS gets inline dedupe]

“Good for virtual machine images.” I’d like to nominate this remark for the understatement of the year contest. Note it would also be great for vectorized OLAP. Also note that compression engines like LZW use “byte-range dedupe” on a data stream. … Implementing byte-range dedupe on a random access system won’t be easy. … Besides performance might suffer, if the contents of every block is expressed in terms of other blocks. … Probably a dynamic dictionary is worth a try. … Somebody stop me!

Recursive With Clause

No Comments »

with x( s, ind ) as
( select sud, instr( sud, ' ' )
  from ( select 
  '53  7    6  195    98    6 8   6   34  8 3  17   2   6 6    28    419  5    8  79'
  sud from dual )
  union all
  select substr( s, 1, ind - 1 ) || z || substr( s, ind + 1 )
       , instr( s, ' ', ind + 1 )
  from x
     , ( select to_char( rownum ) z
         from dual
         connect by rownum <= 9
       ) z
  where ind > 0
  and not exists ( select null
                   from ( select rownum lp
                          from dual
                          connect by rownum <= 9
                   where z = substr( s, trunc( ( ind - 1 ) / 9 ) * 9 + lp, 1 )
                   or    z = substr( s, mod( ind - 1, 9 ) - 8 + lp * 9, 1 )
                   or    z = substr( s, mod( trunc( ( ind - 1 ) / 3 ), 3 ) * 3
                                      + trunc( ( ind - 1 ) / 27 ) * 27 + lp
                                      + trunc( ( lp - 1 ) / 3 ) * 6
                                   , 1 )
select s
from x
where ind = 0

(Anton Scheffer) [Solving a Sudoku using Recursive Subquery Factoring]

Impressive code from our amici over at Amis. But also an impressive example of how far one can go outside the original domain of a language. I mean recursive queries? On the other hand this algorithm does not look too good in Scala or in Perl either. The mathematics of Sudoku are studied in depth. Sudoku has been shown to be NP-complete and of the many ways of solving Sudoku, dancing links and constraint programming seem to be very popular. (Typically, it takes milli seconds for a computer to solve a Sudoku.)