Archive

LLVM generates code that generates code

Back from last week’s LLVM developer’s meeting, I’d like to talk about one of my favorite features of LLVM .

LLVM is the compiler infrastructure that underlies Clang, Vuo, and many other projects. It’s a set of libraries to help you build compilers (and more). Among other things, LLVM provides a C++ API for generating LLVM Intermediate Representation (LLVM IR) code. LLVM IR is an assembly language for a hypothetical computer. LLVM IR code can be either interpreted or compiled down to native code.

So LLVM provides this C++ API for generating LLVM IR code — but it doesn’t stop there. LLVM can also generate C++ code that generates LLVM IR code. In other words, LLVM can literally write part of your compiler for you!

Kosada is Developing a Next-Generation Programming and Performance Environment for Multimedia Artists

Kosada is developing Vuo, a next-generation visual programming environment. It will enable multimedia artists to create powerful real-time audiovisual projects, data visualizations, and apps — all without writing code.

With Vuo, non-programmers will be able to create their own multimedia software for interactive art and music performances, animations, visualizations, games, special effects, museum exhibits, kiosks and other artistic projects. Rather than writing code in a traditional computer language, the composer will drag and drop building blocks onto a canvas, connecting those blocks with cables to create the composition. Unlike most programming environments, artists will be able to interact with their Vuo compositions while they are running, allowing for live improvisation.

Compiling code with the Clang API

Have you tried Clang yet? Clang is an open-source compiler, under active development, that aims to replace GCC for compiling C, C++, and Objective-C. Compared to GCC, Clang is faster, while generating comparably fast code, and prints more useful error messages.

Clang is also better for developers who want to compile code programmatically. Unlike GCC, Clang is designed to be both a tool and an API. That makes Clang’s source code easier to understand and reuse. And, for those of us working on projects incompatible with GCC’s GPL license, it’s good to know that Clang is distributed under the BSD license.

Kosada is working on a cool new project that’s built on top of Clang and its underlying framework, LLVM. While using Clang for this project, I’ve been pleased to see how simple it is to write code that builds other code. Simple in retrospect, anyway! The code I wrote turned out to be simple, but it took lots of digging through the Clang source code to figure out what to write. So here’s my first contribution to the Clang community: two examples of using the Clang API to build code programmatically.

Taxonomy Views Browser of Arbitrary Depth

Here’s a way to create a View (Drupal 7, Views 3.x) that lets you browse an arbitrarily-deep taxonomy hierarchy. With this type of browser you can link, oh, say, a large collection of videos, or photo galleries, or any kind of huge list of content categorized in a nested tree.

First, an simple static taxonomy term browser:

Add or remove fields in a Views display and override the Defaults display

A quick tip for Views newbies…

In Views 2.x (Drupal 6.x), if you want to add or remove fields in a Views display, and you want that to override the Defaults display instead of updating it:

  1. In the display, click the Rearrange button next to Fields.
  2. Click Override, then Update.
  3. Add or remove any fields you want.

An Introduction to Objectivist-C

Let me introduce you to the best language you’ve never heard of: Objectivist-C.

Although academic computer scientists have generally dismissed Objectivist-C, it has a zealous following among self-taught programmers and college sophomores.

Objectivist-C was invented by Russian-American programmer Ope Rand. Based on the principle of rational self-interest, Objectivist-C was influenced by Aristotle’s laws of logic and Smalltalk. In an unorthodox move, Rand first wrote about the principles of Objectivist-C in bestselling novels, and only later set them down in non-fiction.

Here’s what you need to know to program in Objectivist-C.

Drupal Queue API example: enqueue in form submit handler, dequeue when cron runs

Need to store up some items and process them en masse in a cron job? That’s a perfect use case for the Queue API (for Drupal 7+) or the drupal_queue module (the backport for Drupal 6).

Concrete example: One of our consulting clients was using a synchronous webservice for their retail store locator. We needed to create a form where store owners could change whether they’re listed in the store locator. When a store owner submits the form, should she have to wait around while our site sends her change to the store locator webservice? We didn’t think so. So we decided to use Drupal’s Queue API, which lets us save up all the store owners’ changes and send them to the webservice in a batch.

Here’s a simple example of adding items to a queue in a form submit handler and processing them in the next cron run.

The pseudo-science and pseudo-feminism of Women Don't Ask

“You should read this book,” a friend told me. “It says that women don’t make as much as men because they don’t negotiate their salaries.”

The book was Women Don’t Ask: Negotiation and the Gender Divide, by Linda Babcock and Sara Laschever, published in 2003. The notion that “women don’t make as much as men because they don’t negotiate their salaries”, it turns out, is a myth — a myth spun from the sloppy science and sexist assumptions of Women Don’t Ask.

Announcing: iOS Development on 1 Page

When you’re getting started with iOS development, it’s hard to figure out those first steps. What developer tools do you need? What are some good tutorials to start with? Where to begin delving into Apple’s thousands of pages of documentation?

That’s why I created iOS Development on 1 Page — a not-overwhelming guide for iOS newbies.

Is there any essential info about iOS development that should be added to iOS Development on 1 Page? Let me know!