TweetFollow Us on Twitter

Winter 91 - THE VETERAN NEOPHYTE

THE VETERAN NEOPHYTE

LISP, COLOR ICONS, AND LAYERS

DAVE JOHNSON

I recently started learning Lisp, in order to write a color icon editor for a project in ACOTSM (that's Apple Classroom of Tomorrow). The people behind ACOT are creating an environment in which kids can build and explore simulated ecologies, and I wanted to help, but didn't know Lisp well enough to be of much use. A color icon editor was needed, and it seemed like a straightforward and painless little project to cut my Lisp teeth on. Hah.

I did learn lots of Lisp, but I spent a disproportionate amount of time learning the low-level system interface in Macintosh Allegro Common Lisp (MCL) and wrestling Color QuickDraw to the ground. For you CopyBits fans, did you know that CopyBits always assumes that the destination PixMap is on the current GDevice? I guess I already knew this--it's documented all over the place--but the implications never affected me before. I needed to convert a 4-bit PixMap to 8 bits, so hey, let's use CopyBits, right? Wrong. The colors got munged every time, because color mapping kicked in and the source's color table didn't match the GDevice's. For the gory details, see Technical Note #277, especially the section on color mapping. If you like CopyBits, you'lllove this tech note.

I was curious what others thought of Lisp, so I asked around a little. Here are some of the responses I got:

Functional languages are cool if you have good libraries, but all those parentheses are a pain in the ass.
-- Bryan "Beaker" Ressler, C programmer.

It's the shortest distance between conception and realization.
-- Matthew MacLaurin, self-admitted Lisp junkie.

I hate it.
-- Neil Day, who was forced to write the Tower of Hanoi iteratively in an introductory Lisp course.

It's a great productivity tool, and Common Lisp provides a rich (though perhaps Byzantine) programming environment.
--Gregg Williams, technical writer and sometime Lisper.

(expectant look)
-- Natty, my dog.

There are several immediately apparent things about Lisp that are foreign to people used to C or Pascal. Data typing is nonexistent unless you want it: Any variable can hold any type of data at any time. Functions can be data, too, and can be passed around all over the place. Everything is cozily wrapped in parentheses many levels deep (after a while, this is somehow comforting). Context is all important and omnipresent. Changes can be immediately tried out, so forprototyping (and for those of us who thrive on immediate gratification) it's a joy to work in. For those lacking in discipline, Lisp can help to create a real mess (of course, any language can do that for you, it's just easier in Lisp). Because it is so forgiving, it encourages my own built-in "middle-out" design

strategy, which in the long run isn't terribly efficient, although lots of fun. With a little self-control, of course, this problem would go away (left as an exercise for the reader).

Writing Lisp code that is QuickDraw intensive is kind of a pain at first. MCL provides great libraries for basic QuickDraw tasks, but if you want to get fancy, you have to do it yourself. For the icon editor, I needed lots of little utility routines to do stuff like find a particular color's pixel value in the color table, add a color to a color table, copy a cicn, change the depth of a cicn, build new cicns from scratch. Nearly half my code consists of these little utilities. They'd be needed regardless of the language, I guess, but writing them in Lisp required me to learn the low-level system interface much more thoroughly than I originally intended. This made me grumble a little, but after I'd gotten over the initial syntactical hump, low-level access became transparent and largely effortless.

The other half of the code was much Lispier. I used the built-in object system (Object Lisp, since I was using MCL 1.3.2. Now, in MCL version 2.0, it's the Common Lisp Object System, or CLOS), and I found that it successfully isolated me from most of the grungy system details like events and window handling (that's what it's supposed to do, right?). I haven't done a lot of object programming, so I can't make incisive comparisons with other object systems, but I liked it.

The sort of layered, threaded structure of Lisp, and the continual "level switching" I had to do during development, got me thinking about how the machine is getting progressively more distant from the software I write. It seems that I write software to live on top of other software, not software to live on a machine. Object programming is a kind of layer creation, in that a well- designed object hides lots of details from the user of the object. MacApp is a layer (a thick one), HyperCard is also a layer (a really thick one), the Mac ® Toolbox is a layer, and so on.

More and more, programmers need to be comfortable stuffed between these layers. Here's the hard truth: YOU NO LONGER HAVE TOTAL CONTROL OF THE MACHINE. Once upon a time, in the dim and distant past, programmers had absolute power over every aspect of the computer. There wasn't even any such thing as a user! A programmer was God in a monotheistic universe. Now there are all sorts of software smoke screens between your code and the machine itself. You are no longer God; at best, you are a minor demigod in charge of shoes, or something. A long time ago I read a discussion of Macintosh programming, and one person compared it to sitting in a dark closet by yourself, and occasionally answering a note that is passed under the door from the outside. I think that's exaggerating a little, but the point is valid. You no longer need to know everything that's going on in the house; you can just be responsible for your own room. At least, that's the idea . . .

One persistent problem is that you have to depend on the reliability of the other code. When my icon editor was almost done, I found a memory leak. Two tiny handles were left on the heap after closing the editor. It took me almost a week (and some expert help) to track it down to a bug in the MCL object system. Obviously, this diluted the benefits gained by using the system.

Overall, though, I really do think that this division of labor, this layering, is a good thing. It lets people find the niche they like best, and ignore much of the rest if they want to. Often it is an incredible time-saver to learn to use others' code rather than learning to do what they did from scratch. Ideally, the layers will insulate you completely from irrelevant detail, and allow you to focus on your task. We're not there yet, but someday, maybe, you can actually stop inventing the wheel.

 
AAPL
$102.99
Apple Inc.
+0.52
MSFT
$44.38
Microsoft Corpora
-0.50
GOOG
$532.71
Google Inc.
+6.17

MacTech Search:
Community Search:

Software Updates via MacUpdate

jAlbum Pro 12.2.4 - Organize your digita...
jAlbum Pro has all the features you love in jAlbum, but comes with a commercial license. With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code!... Read more
jAlbum 12.2.4 - Create custom photo gall...
With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code! Beginner-friendly, with pro results Simply drag and drop photos into groups, choose a design... Read more
ExpanDrive 4.1.7 - Access remote files o...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
Evernote 5.6.2 - Create searchable notes...
Evernote allows you to easily capture information in any environment using whatever device or platform you find most convenient, and makes this information accessible and searchable at anytime, from... Read more
OmniOutliner 4.1.3 - Organize your ideas...
OmniOutliner is a flexible program for creating, collecting, and organizing information. Give your creativity a kick start by using an application that's actually designed to help you think. It's... Read more
BBEdit 11.0 - Powerful text and HTML edi...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
Apple Security Update 2014-005 - For OS...
Apple Security Update is recommended for all users and improves the security of Mac OS X. For information on the security content of this update, please visit this website: http://support.apple.com/... Read more
EyeTV 3.6.6 - Watch and record TV on you...
EyeTV brings a rich TV experience to your Mac. Watch live TV on your Mac. Pause, rewind, and record whenever you want. EyeTV gives you powerful control over what you watch and how you watch it. Put... Read more
RapidWeaver 6.0 - Create template-based...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
NTFS 12.0.39 - Provides full read and wr...
Paragon NTFS breaks down the barriers between Windows and OS X. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS, providing full read and write access to... Read more

Latest Forum Discussions

See All

Felllice (Games)
Felllice 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: EXCLUSIVE PRICE DROP! 50% OFF FOR A LIMITED TIME! EAT EAT EAT AND GROW ! | Read more »
The Arrow Game: by Grazie Media (Games)
The Arrow Game: by Grazie Media 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Guide a flying arrow through skyscrapers and city streets to hit a distant target. Experience an endless... | Read more »
Worldly (Games)
Worldly 1.2 Device: iOS Universal Category: Games Price: $2.99, Version: 1.2 (iTunes) Description: | Read more »
Money Pro - EASY! Bills, Budgets and Acc...
Money Pro - EASY! Bills, Budgets and Accounts w/ Sync 1.0 Device: iOS Universal Category: Finance Price: $4.99, Version: 1.0 (iTunes) Description: Manage money like a pro. Money Pro is the next generation of Money app (over 2 million... | Read more »
Pro Strategy Football 2014 (Games)
Pro Strategy Football 2014 2014.141001 Device: iOS Universal Category: Games Price: $4.99, Version: 2014.141001 (iTunes) Description: Take the proven strategy of the PSF franchise and add in Casual Play, improved graphics and... | Read more »
Super Glyph Quest (Games)
Super Glyph Quest 1.01 Device: iOS Universal Category: Games Price: $2.99, Version: 1.01 (iTunes) Description: Adventure is back Questers! Combine elemental glyphs together to cast powerful spells and vanquish adorable monsters in... | Read more »
Fighting Fantasy: Caverns of the Snow Wi...
Fighting Fantasy: Caverns of the Snow Witch 1.0 Device: iOS Universal Category: Games Price: $5.99, Version: 1.0 (iTunes) Description: Travel to Northern Allansia’s perilous Icefinger Mountains to defeat the wicked Snow Witch in this... | Read more »
Star Warfare 2: Payback Review
Star Warfare 2: Payback Review By Blake Grundman on October 22nd, 2014 Our Rating: :: ONE-TRICK PONYUniversal App - Designed for iPhone and iPad Unfortunately, it doesn’t take long for Star Warfare 2’s free-firing fun to turn into... | Read more »
TinType by Hipstamatic (Photography)
TinType by Hipstamatic 1.0 Device: iOS iPhone Category: Photography Price: $.99, Version: 1.0 (iTunes) Description: Create hauntingly beautiful, soul capturing portraits with TinType by Hipstamatic. Inspired by daguerreotypes,... | Read more »
The Latest Update for Heroes of Dragon A...
The Latest Update for Heroes of Dragon Age Introduces Daily PvE Challenges Posted by Ellis Spice on October 22nd, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Save with Best Buy’s College Student Deals
Take an additional $50 off all MacBooks and iMacs at Best Buy Online with their College Students Deals Savings, valid through November 1st. Anyone with a valid .EDU email address can take advantage... Read more
iPad Air 2 & iPad mini 3 Best Tablets Yet...
The new iPads turned out to be pretty much everything I’d been hoping for and more than I’d expected.”More” particularly in terms of a drinking-from-a-firehose choice of models and configurations,... Read more
Drafts 4 Reinvents iOS Productivity App
N Richland Hills, Texas based Agile Tortoise has announced the release of Drafts 4 for iPhone and iPad. Drafts is a quick capture note taking app with flexible output actions. Drafts 4 scales from... Read more
AT&T accepting preorders for new iPads fo...
AT&T Wireless is accepting preorders for the new iPad Air 2 and iPad mini 3, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB... Read more
Apple offering refurbished Mac Pros for up to...
The Apple Store is offering Apple Certified Refurbished 2013 Mac Pros for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The... Read more
Select MacBook Airs $100 off MSRP, free shipp...
B&H Photo has 2014 a couple of MacBook Airs on sale for $100 off MSRP. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels Desktop and LoJack for... Read more
13-inch 2.5GHz MacBook Pro on sale for $100 o...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Strong iPhone, Mac And App Store Sales Drive...
Apple on Monday announced financial results for its fiscal 2014 fourth quarter ended September 27, 2014. The Company posted quarterly revenue of $42.1 billion and quarterly net profit of $8.5 billion... Read more
Apple Posts How-To For OS X Recovery
OS X 10.7 Lion and later include OS X Recovery. This feature includes all of the tools you need to reinstall OS X, repair your disk, and even restore from a Time Machine backup. OS X Recovery... Read more
Mac OS X Versions (Builds) Supported By Vario...
Apple Support has posted a handy resource explaining which Mac OS X versions (builds) originally shipped with or are available for your computer via retail discs, downloads, or Software Update. Apple... Read more

Jobs Board

Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.