Fast Markdown libraries for Ruby: two for the price of one.
A gentle introduction to the world of UNIX IPC. Covers fork, signals, pipes, FIFOs, file locking, POSIX message queues, semaphores, shared memory segments, memory mapped files, UNIX sockets. Not a ton of depth, but that’s okay – you can read all of it in about 15 minutes and have a good feel for the pros and cons of all the different types of IPC.
Check out Beej’s Guide to Network Programming and Beej’s Quick Guide to GDB too.
That argument debunked for most real world applications.
I liked the way different types of boundedness were presented:
- I/O-bound. Completing a unit of work earlier just means waiting longer for the next block/message.
- Memory-bound. Completing a unit of work earlier just means more time spent thrashing the virtual-memory system.
- Synchronization-bound (i.e. non-parallel). Completing a unit of work earlier just means waiting longer for another thread to release a lock or signal an event – and for the subsequent context switch.
- Algorithm-bound. There’s plenty of other work to do, and the program can get to it immediately, but it’s wasted work because a better algorithm would have avoided it altogether.
As much as I agree with the thrust of the article, C programs really are faster in real life, but I think it’s because people who program in C are more likely to be familiar with common performance problems and tradeoffs. It’s hard not to be at that level.
I love stuff like this:
The unix-jun72 project has scanned in a printout of 1st Edition UNIX from June 1972, and restored it to an incomplete but running system. Userland binaries and a C compiler have been recovered from other surviving DECtapes.
There’s also a mirror on GitHub.
@paulsmith’s simple preforking echo server in C.
Unix Network Programming, volumes 1 and 2, and Advanced Programming in the UNIX Environment. Yes.
Joe Damato and Aman Gupta show why and how Ruby (MRI)’s thread implementation sucks. Great presentation with lots of useful examples of using tools like strace and gdb to figure out where a process is spending time. Warning: you will be depressed and embarrassed after reading this if you currently target Ruby MRI.
I didn’t know about this:
In Snow Leopard, Apple has introduced a C language extension called “blocks.” Blocks add closures and anonymous functions to C and the C-derived languages C++, Objective-C, and Objective C++.
They go on to list code samples in each language. The syntax is … not what I expected. Check out the section on LLVM and Clang also.
It’s important to understand how fork(2), pipe(2), and exec(2) work. I don’t want to hear anymore of this “fork is a hack” shit from any of you :)
Laurence Tratt: “I had implicitly bought into the idea that C programs segfault at random, eat data, and generally act like Vikings on a day trip to Lindisfarne; in contrast, programs written in "higher level” languages supposedly fail in nice, predictable patterns. Gradually it occurred to me that virtually all of the software that I use on a daily a basis – that to which I entrust my most important data – is written in C. And I can’t remember the last time there was a major problem with any of this software – it’s reliable in the sense that it doesn’t crash, and also reliable in the sense that it handles minor failures gracefully."
Yossi Kreinin: “But I miss virtual functions. I really do. I sincerely think that each and every notable feature C++ adds to C makes the language worse, with the single exception of virtual functions.”
Sometimes! Or, fork(2) is a very fast operation on legitimate operating systems. I didn’t realize it could be as fast as spawning a thread, though.
An implementation of Markdown in portable ANSI C that’s roughly 28.5x faster than the canonical Perl implementation on a 179K test file. Looks like a complete implementation; includes smarty and footnote extensions.
Aristotle Pagaltzis: “Not exactly as fast [as SBCS strlen], but if you write it in asm, it only takes one extra instruction to count characters in UTF-8 vs those in an 8-bit encoding, per character.”
What PrinceXML is coded in, apparently. It’s like Prolog for large systems: declarative, strongly typed and type inferencing, module system, closures, currying, lambdas, and with a strong determinism system. Compiles down to C (as a portable assembler).
“Between 1988 and 1991 I worked on the research program that led to the Mars Pathfinder rover […] All three of [the prototypes] were programmed not in Lisp, but in little mini-languages whose compilers were written in Lisp.”
“Like with unix, cells are not ‘spawned’ – they are forked. All cells started out from your ovum which has forked itself many times since. Both halves of the fork() are identical to begin with, but they may from then on decide to do different things.”
“maybe try coding something in c”
Java becomes 100% more viable. So simple — why didn’t someone do this in the very beginning?
jackpot.
“This document explains how to make extension libraries for Ruby.”
“Maybe if we took away these PL theorists’ Emacs and LaTeX packages for a while we’d get better results.”
the best shit ever
Perfect timing as I’m just about to write a little piece on how C is the only reason dynamic languages are viable…
Best Lambda Thread. Ever.