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.47
Apple Inc.
+2.71
MSFT
$44.88
Microsoft Corpora
+0.80
GOOG
$526.54
Google Inc.
+5.70

MacTech Search:
Community Search:

Software Updates via MacUpdate

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
RestoreMeNot 2.0.3 - Disable window rest...
RestoreMeNot provides a simple way to disable the window restoration for individual applications so that you can fine-tune this behavior to suit your needs. Please note that RestoreMeNot is designed... Read more
Macgo Blu-ray Player 2.10.9.1750 - Blu-r...
Macgo Mac Blu-ray Player can bring you the most unforgettable Blu-ray experience on your Mac. Overview Macgo Mac Blu-ray Player can satisfy just about every need you could possibly have in a Blu-ray... Read more
Apple iOS 8.1 - The latest version of Ap...
The latest version of iOS can be downloaded through iTunes. Apple iOS 8 comes with big updates to apps you use every day, like Messages and Photos. A whole new way to share content with your family.... Read more
TechTool Pro 7.0.5 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PDFKey Pro 4.0.2 - Edit and print passwo...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Yasu 2.9.1 - System maintenance app; per...
Yasu was originally created with System Administrators who service large groups of workstations in mind, Yasu (Yet Another System Utility) was made to do a specific group of maintenance tasks... Read more
Hazel 3.3 - Create rules for organizing...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a... Read more

Latest Forum Discussions

See All

Swap Heroes (Games)
Swap Heroes 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: **Half price for a limited time only** Swap Heroes is a casual turn-based strategy adventure. Form a group of heroes and guide them... | Read more »
Ghost Blade (Games)
Ghost Blade 1.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.1 (iTunes) Description: Get the most outstanding 3D Action Game from App Store NOW! For those who dare pursue dreams. Masterpiece of Yu Shi Game ---China... | Read more »
Fiete – A Day on a Farm Review
Fiete – A Day on a Farm Review By Amy Solomon on October 21st, 2014 Our Rating: :: A MEMORABLE EXPERIENCEUniversal App - Designed for iPhone and iPad Fiete – A day on a farm in an interactive app for young children full of... | Read more »
Tilt to Live: Gauntlet’s Revenge is Almo...
Tilt to Live: Gauntlet’s Revenge is Almost Here Posted by Jessica Fisher on October 21st, 2014 [ permalink ] One Man Left has announced the official release date of Tilt to Live: Gauntlet’s Re | Read more »
Sago Mini Monsters Celebrates Halloween...
Sago Mini Monsters Celebrates Halloween with Fun Costumes and Special Treats. Posted by Jessica Fisher on October 21st, 2014 [ permal | Read more »
Inferno 2 Review
Inferno 2 Review By Andrew Fisher on October 21st, 2014 Our Rating: :: TWIN STICK GOODNESSUniversal App - Designed for iPhone and iPad With tight controls and awesome, stark visuals, Inferno 2 is loads of fun.   | Read more »
Clips Review
Clips Review By Jennifer Allen on October 21st, 2014 Our Rating: :: CONVENIENT PASTINGUniversal App - Designed for iPhone and iPad Making copying and pasting more powerful than usual, Clips is a great way to move stuff around.   | Read more »
MonSense Review
MonSense Review By Jennifer Allen on October 21st, 2014 Our Rating: :: ORGANIZED FINANCESiPhone App - Designed for the iPhone, compatible with the iPad Organize your finances with the quick and easy to use, MonSense.   | Read more »
This Week at 148Apps: October 13-17, 201...
Expert App Reviewers   So little time and so very many apps. What’s a poor iPhone/iPad lover to do? Fortunately, 148Apps is here to give you the rundown on the latest and greatest releases. And we even have a tremendous back catalog of reviews; just... | Read more »
Angry Birds Transformers Review
Angry Birds Transformers Review By Jennifer Allen on October 20th, 2014 Our Rating: :: TRANSFORMED BIRDSUniversal App - Designed for iPhone and iPad Transformed in a way you wouldn’t expect, Angry Birds Transformers is a quite... | Read more »

Price Scanner via MacPrices.net

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
Deals on 2011 13-inch MacBook Airs, from $649
Daily Steals has the Mid-2011 13″ 1.7GHz i5 MacBook Air (4GB/128GB) available for $699 with a 90 day warranty. The Mid-2011 13″ 1.7GHz i5 MacBook Air (4GB/128GB SSD) is available for $649 at Other... Read more
2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
Updated iPad Prices
We’ve updated our iPad Air Price Tracker and our iPad mini Price Tracker with the latest information on prices and availability from Apple and other resellers, including the new iPad Air 2 and the... Read more
Apple Pay Available to Millions of Visa Cardh...
Visa Inc. brings secure, convenient payments to iPad Air 2 and iPad mini 3as well as iPhone 6 and 6 Plus. Starting October 20th, eligible Visa cardholders in the U.S. will be able to use Apple Pay,... Read more
Textkraft Pocket – the missing TextEdit for i...
infovole GmbH has announced the release and immediate availability of Textkraft Pocket 1.0, a professional text editor and note taking app for Apple’s iPhone. In March 2014 rumors were all about... 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.