The
Ultimate
Business Machine

Technology, business
and innovation.

And, not least, about
the Mac.

Weblog Archive Cutedge

by: Bernard Teo








Creative Commons License

Copyright © 2003-2012
Bernard Teo
Some Rights Reserved.

Sun 26 Dec 2004

Cocoa Bindings

Category : Technology/CocoaBindingsAndJava.txt

I'm trying to understand Cocoa Bindings, to see if I can write less code. My starting point is Michael Beam's O'Reilly article, "The Cocoa Controller Layer". I've been playing around with extending the sample code and it's starting to become clearer - like when and how to step in and do custom things, like interfacing with a database.

This will make a great demo (of the jaw-dropping kind). But my databases are all accessed through Java JDBC drivers, and we've got tons of Java code I'd like to plug into. So, I started on a Java-Cocoa version and got things to the point where the Table View shows the right data but the application crashes soon after.

Reminds me of Aaron Hillegass' "Don't write Cocoa applications with Java" comment. It's a fair point. But you may have code that already work well in Java - modelling the business rules, putting stuff in and out of databases, running off web servers, and providing web services - and that's often the case in the enterprise.

It's possible to map out a large enough part of the Cocoa framework to allow Java programmers to work safely and predictably, putting Cocoa front-ends on top of their Java code. You don't have to be able to build things like Create and OmniGraffle. Enough of Cocoa already work well in Java to allow us to do productive things with it. If that could help us bring a lot of that enterprise data onto the desk of Mac users, wouldn't that be a good thing?

Downsides to Java-Cocoa at the moment - like poor documentation, bugs, and lack of speed - ought to go away with time. It shouldn't stop people doing Cocoa using Java.

But back to Cocoa Bindings. Other good sources of information include "Introduction to Cocoa Bindings", "Cocoa Bindings Examples and Hints", and the "Cocoa Bindings" discussion at cocoadev.com. I'll put up more links when I find them.

I'll leave you with another comment from Aaron Hillegass. Cocoa Bindings look great in demos, but may be less than useful in practice. However, this is a most interesting development with a lot of potential. Hope Apple continues to build on it.

When I was working at our Ministry of Defense, we used to put new hires in front of a Mac and watch their eyes - watch if they light up. If they don't, we didn't want them in the Technology Group. These Cocoa Bindings demos can serve the same purpose. Put a developer in front of these demos and watch his eyes. There's probably a measurable correspondence between intelligence quotient and the degree to which the eyes light up.

Posted at 11:37AM UTC | permalink

Fri 24 Dec 2004

Java on Mac OS X Course (Dec 21 and 22, 2004)

Category : Technology/JavaOnOSX2122Dec.txt

Usually, when you see a picture like this at Apple Singapore, you would think Final Cut Pro or QuickTime or iLife or, at most, an OS X Server Administration class is underway.

But we had about 18 people turning up at Apple Singapore for "Java on Mac OS X". Quite a lot of them were Java programmers - some new to the Mac, some already Mac users who will bleed in seven colours, having used the Mac since pre-OS X days.

Most are seeing the Mac do these things for the first time - Oracle running on a PowerBook, and an iBook and every other Mac in the room turned into Java 2 Enterprise Edition web servers. Also, by the middle of the second day, they're all not just able to build Cocoa applications, but Cocoa applications using Java. Surely, not your grandfather's Mac anymore.

If you put all these things together, it's difficult to deny that the Mac is a serious enterprise-class software development (and delivery) platform. Really, nothing else even comes close.

I think we're getting better at explaining things and getting people up to speed doing productive work during the two days they spent with us.

The feedback from the attendees has been pretty good and that meant a lot of us. We really put in a lot of effort designing the course so that the topics flow smoothly from start to finish. And all using original material, culled from the systems we have built, unavailable elsewhere on the Internet, at least not as the one single integrated whole - from command line, to Cocoa, and to the web.

There is a book in there somewhere.

Posted at 6:58AM UTC | permalink

Mon 20 Dec 2004

Java on OS X Course @ Apple Singapore

Category : Technology/JavaOnOSX21Dec.txt

We're setting up the equipment for tomorrow's Java on Mac OS X course at Apple Singapore. About 17 to 20 people are expected to come (and sit under the gaze of Einstein, Picasso, Gandhi, and company).

As with all the other sessions we've done at Apple Singapore, we get a wide assortment of Macs to try our stuff on - there're a couple of new PowerMac G5s with the liquid cooling system, the new iMac G5, and the new LCD displays.

This is what we hope to cover : Java from the OS X Command Line, Java with Cocoa, and Java on the Web.

The idea is to show how Java is implemented on the Mac, and how we can be productive re-using our code across all three interfaces.

And the sample code we're using as the basis of the exercises is not a toy. It's a complete Cocoa application in miniature - with check boxes, radio buttons, pop-up-menus, sheets, drawers, tables, data source, notification, and handling double-clicks on a table, multiple windows, and accessing a JDBC-compliant database - all callable from Java. Raw material to build a wide range of Cocoa applications from.

While building Cocoa applications with Objective-C feels more natural, is smoother, and is a lot more fun, lots of people have code in Java. And it makes a nice continuum being able to deliver enterprise-scale applications across the web and on the desktop, using a wide range of relational databases, including Oracle and MySQL.

Java is important for the Mac in the enterprise. But what will tomorrow bring?

Posted at 4:16PM UTC | permalink

Fri 03 Dec 2004

Cutting-Edge Objectives

Category : Technology/OOPs.txt

I'm re-discovering a book I bought in 1987 - "Object-Oriented Programming - An Evolutionary Approach" by Brad J Cox.

In it is a description of a language called Objective-C and how it could be used to control code complexity and aid programmer productivity. I re-read it now and come to appreciate, again, how powerful good ideas can be - in this case, ideas that were absorbed into NeXTStep and what is now known as Cocoa.

I'm reading all the Cocoa material I can find, to try to develop a style that will help us build applications as quickly as we can. I believe that the way to do that is to understand the philosophy underlying Cocoa's design, and write code that works with it rather than against it.

And, yes, I think there is such a thing as a philosophy to programming. And that's the kind of thing missing from the Windows world that makes it such an arid place to be in.

Putting aside the religious wars concerning Mac vs PC, let's remember why we're using computers, at least in a business setting. That's to allow us to systematise as many of the business processes as we can, so that the business can function like a machine, and so that we, the owners (and those we hire to run our business) won't have to work like machines.

Computers compute results, store data, and do all the steps required in an automated process tirelessly, effortlessly, and accurately. If you wield them well, you can really kill your competition.

Businesses ought to choose their computing tools the way Samurais choose their swords. You've got to be able to appreciate craftsmanship. You're going into battle, and you need a philosophy, for living and for fighting. Choose your sword well.

Posted at 7:05AM UTC | permalink

Wed 01 Dec 2004

The Geography of Thought

Category : Commentary/GeographyOfThought.txt

I was re-reading that last sentence in that previous post - "But part of growing up is to accept life for what it is and just move along." That's so typically Asian isn't it? That's what we teach our kids. And bind us to that peasant of long ago, bent beneath the weeping willow, resigned to eternal cycles of flood and famine, and taxation from the Yellow Emperor.

But, switching back to our modern age, if that were so, why not throw it all in and accept the dominance of Windows? Surely, resistance is futile. Why spend so much effort trying to change things?

I've picked up a book called "The Geography of Thought". It's an interesting discussion about the ways Easterners and Westerners differ in their patterns of thought - and why we differ and how we came to be so.

But what if we're tending towards a new synthesis, an amalgam of west and east? It may not necessarily be better, being neither here nor there, and it's quite possible we may end up with all the worst from both cultures.

It's quite interesting reading this book, living in Singapore. We're at the cross-roads, subjected to such a hodge-podge of influences that we could go either way. Or neither, and find something uniquely our own, for better or for worse. That's what we're going to leave our children. Because of that, we ought to give it some thought.

Posted at 4:26PM UTC | permalink

The Story of Audion

Category : Technology/audion.txt

This is a good story, relevant to all software developers, about Audion, the MP3 player on the Mac that almost became iTunes. I really love its tone - not bitter and very generous.

Posted at 6:09AM UTC | permalink

Java and Objective-C Development on Mac OS X

Category : Technology/JavaAndObjC.txt

Objective-C code may look daunting at first, but it's really mainly C code with extensions to the language to deal with objects and message passing.

Both Java and C are small, compact languages that can (each) be learnt in one weekend - that is, if you're determined and start on a Friday night. Good books to use include the "Java in a Nutshell" book from O'Reilly and the Kernighan and Ritchie book for C.

The "Java in a Nutshell" book contains a good introduction to object-oriented programming and the advantages of using this approach to control code complexity.

I've got a few books on Cocoa programming but I think the "Learning Cocoa" book from O'Reilly is actually good enough to get started (I have the original version that was much maligned but the second edition by James Duncan Davidson should probably be better). I found some of the explanations mystifying (in my original version of the book), at least initially, but it contained very good, useful, sample code that you can adapt quite easily to do your own stuff. And, after a few rounds, things do become clear.

The important thing is to learn by doing - to plunge in and set yourself something useful to do by modifying from the given examples. Then it rapidly becomes clear what it is that you don't yet know, and from filling in the pieces, you start to create a mental model of how Cocoa works. I think there's a certain point where everthing clicks and you start to see the patterns in the way Cocoa works and learn to flow with it. (That's why there is a book called "Design Patterns".)

Now, I think we (Hai Hwee - who wrote Luca - and me) took a longer (and much harder) route into Cocoa by starting with Java. Cocoa's native language is Objective-C, and, though it is possible to write Cocoa apps using Java, you always have to translate the Objective-C calls into their equivalent idiom in Java, and there are far fewer sources of information about writing Cocoa code using Java. (As Aaron Hillegass says, in his book "Cocoa Programming for Mac OS X" 2002 edition - "Using Java with Cocoa"? "Don't ...").

But we have a lot of stuff we've invested time in building (database and web server stuff that call Oracle and MySQL) and it was easier to extend the Java code to work with a Cocoa front-end than it was to rewrite all that stuff in Objective-C. And where was the database solution on Cocoa in Objective-C, then? Nothing, not a single thing at all. No wonder there was not much going on for business applications on Mac OS X.

But, now, there's the possibility of taking advantage of CoreData in Tiger. One of the problems we have with Luca (besides the fact, I think, that it requires a good inventory module to make the system really gell for an end-user), is that it's too big a download. We can't assume that a user has MySQL loaded on his Mac. That is the target database that Luca uses. So we include a MySQL download. Even if a user has MySQL, we often have problems making Luca work with that existing installation. So it'll be great if we can assume that there is a database that comes with every Mac. And target Luca (and any other business application that we hope to build) to work with that common platform. And our applications could then become smaller and be easier to download.

So that's why I think we could expect to see an explosion of business applications on the Mac. But it all depends on how good CoreData is.

I do wish Apple could stop re-inventing the wheel and re-use stuff that are already out there - like all that JDBC stuff that work with almost every relational database solution on earth. Or, choose MySQL to bundle in rather than SQLite. Or make Objective-C work a bit more like Java in terms of memory management (all that "release" and "retain" code give me a headache).

We've now got two great platforms to create applications with on Mac OS X - Java and Objective-C, and Cocoa. It'll be great to get the best of both worlds. But part of growing up is to accept life for what it is and just move along. So on we go.

Posted at 6:08AM UTC | permalink

Mon 29 Nov 2004

May a Thousand Applications Bloom

Category : Technology/thousandApps.txt

"Deeds, like grains of sand spilt into the sea, disappear, leaving only an empty hand."

- Han Suyin

It's really quick, how time flies. Especially when you're doing something engrossing.

I've finished the Objective-C version of Postfix Enabler and it works exactly the same way as the current AppleScript Studio version, which shouldn't be surprising because they're both calling the same Cocoa framework underneath.

But what was surprising to me was that it didn't take that much more code to do it - almost the same number of lines of code in Objective-C as compared to the AppleScript code, or maybe just a bit more.

And I've reached this conclusion - if you're building applications in Real Basic or 4th Dimension, you really ought to take a look at building them directly in Cocoa using Objective-C.

You'll be surprised at how much faster and more productive you can be. You'll be coding closer to the metal, so to speak, and so your applications will run faster. But it's not necessarily harder - in fact, the opposite may be true. I can't praise the Cocoa framework enough - or rather, the thought that went into its design. So many things would have made their way in there simply because a programmer would have needed it - to work faster.

And I believe now that there's a way to get going on Cocoa quickly - where you can do a lot of productive things right from the start, and where you won't be daunted by how thick the Cocoa API reference guides are. In fact, if you find a way to understand the key concepts and learn how to look for what you want, you'll start to feel reassured whenever you go through a long list of API's - because that will mean that you're that much more likely to find just the right piece of code to help you do what you want to do.

And that has been my experience so far. I've been able to find almost all the things I need - or at least enough to think that I'd be able build quite a wide range of stuff with it.

Computers become useful because of the applications that run on them. I go the retail stores that sell Macs here and they don't give enough reasons for anyone to buy a Mac - they're always opening and closing windows, showing the genie effect, and showing iTunes, iMovies, and all that old stuff. They're preaching to the converted (or to the ignorant).

But we should use the Mac simply because there are so many productive things we can do with it - things limited only by our imagination.

So, may a thousand Mac applications bloom, with Objective-C and Cocoa.

Posted at 11:07AM UTC | permalink

Sat 20 Nov 2004

Postfix Enabler in Objective-C

Category : Technology/PFEinObjC.txt

I've been building a version of Postfix Enabler on Objective-C. What started out as a peek into Tiger to see how quickly I can get Postfix Enabler to run on it got diverted into a challenge - to see how quickly I can take the Postfix Enabler nib (Interface Builder) file and wrap Objective-C code around it, rather than the AppleScript I was using.

How did I get to Objective-C? Must be the effect of all those WWDC DVD's I sometimes run in the background while working, especially those about Core Data. If it works the way it's supposed to, and Apple continues to build on it, it's going to be something we cannot afford to ignore. It'll make the Mac an even better platform to build business applications on. And, if it doesn't? Well, we still have Java.

I've developed an AppleScript Studio course around Postfix Enabler because, if you take a look at it again, you'll find it covers most of the interface elements you're likely to want on a Mac-based application.

There are drawers, sheets, pop-up menus, check boxes, radio buttons, alerts, tables, data sources, progress indicators, password fields, interfacing with Unix, an ability to launch web pages, and checking if you're an admin user. Once you know these, you can build any application. (OK, maybe not any - I don't do graphics or music or 3-D).

So, by the end of this exercise, I will have an Objective-C application that covers most of the same interfaces, and more (e.g., I've always wanted to be able to read the output of the Unix job asynchronusly - so that I can show the user what's going on, as it happens, and not only at the end of the job, as in the current AppleScript version of Postfix Enabler. With NSTask and NSPipe, I've finally been able to achieve that). This will be just right to be used as the basis of a "Cocoa Using Objective-C" course. Objective-C is really so fun.

Posted at 5:34AM UTC | permalink

The Bull and The Vegetarian

Category : Commentary/BullAndTheVegetarian.txt

"Expecting the world to treat you fairly because you are a good person is like expecting the bull not to charge you because you are a vegetarian."

... Rabbi Harold Kushner

I remembered a quote like that came across my mail box some time ago. Fortunately, I've kept most of my Postfix and Sendmail Enabler-related correspondence. I found it in a note from Terry Bain. True enough. But is there a place in heaven for vegetarians?

Speaking of heaven, it's different hearing Eric Clapton's "Tears in Heaven" when you're a father of a boy yourself. It's easy enough to feel that stab of pain in - "Would you hold my hand, if I saw you in heaven?".

Posted at 3:34AM UTC | permalink

Wed 10 Nov 2004

The Job of Art is to Chase Ugliness Away

Category : Commentary/JobOfArt.txt

"The job of art is to chase ugliness away", I thought I heard Bono say in the U2 iPod special event. I had to rewind to be sure. Yes, it's there and I think it's a wonderful statement.

I was watching the event on QuickTime, while I was coming to the end of the book I'm reading by Jeremy Rifkin, "The Age of Access", and I think it's one of those days when everything resonates.

I was writing the other day about the idea of key concepts - about how it's important to learn how to learn quickly from scraps of knowledge.

But when you've built lots of these key concepts, you need an overarching framework to tie everything together, so you get a holistic feel for how everything is going, and thereby make your own sense of what's happening to our world today.

Jeremy Rifkin's "Age of Access" is one of those rare books that come along that does a credible job of tying lots of diverse impressions into a central theme, where you're able to see the patterns and interconnections.

We're moving into a time where we value the ability to access an experience more than the possessing of physical goods. For example, when I hear Bob Dylan's "You're a big girl now", lots of memories come flooding back and that's feeling I live for, no matter if I hear it off a radio or an iPod. What's important is to have the rights to turn it on when I want to - I don't need or care to own the CD.

Another example - I like the ability to whisk my family off to a few places quickly over the weekend - but I hate the chore of owning and maintaining a car. I'd rather lease one and I can see a day coming when somebody will use the web to coordinate the logistics to make the system work better than it currently does.

And I've stopped buying books - I bought enough to fill two life-times and they are just so much baggage when we shift house or office. I never finished Rifkin's last book "The End of Work" and it's now just collecting dust. But I found "The Age of Access" in the library, and I thought the worse that can happen is that it'll just go back into the hole if it's no good.

So, I'm glad I read it. But I'm not going to attempt a synthesis; just wanted to make the recommendation. This, and other books like Leonard Shlain's "The Alphabet versus the Goddess", have shaped my thinking about why Apple, alone among the technology companies, have grasped the true signficance of what's changing in our world today, and it's the company that is doing the most interesting and relevant things against this backdrop.

In what is coined The Experience Economy, art, aesthetics and alignment with spiritual goals take center-stage. The job of art is to chase ugliness away. And we're willing to pay for it when it does.

Can anyone watching the Apple U2 Special Event imagine anyone other than Steve Jobs being there on stage with Bono and company - for example Bill Gates or Sim Wong Hoo? Banish the thought. That's why the iPod's success is more than just massive spending on advertising, as Sim Wong Hoo thinks and is now trying to emulate. This may be Creative's waterloo.

Posted at 9:12AM UTC | permalink

Tue 02 Nov 2004

UW/IMAP - Postfix Enabler 1.0.10 Released

Category : Technology/UWIMAP2004Released.txt

I decided to release the latest UW/IMAP POP3 and IMAP binaries that I had built inside Postfix Enabler 1.0.10. Nothing's changed inside 1.0.10 except for the new POP and IMAP binaries.

I had earlier wanted to collect a few new features to put together to make a new Postfix Enabler release but I realised I'll never find the time to do that over the next four weeks.

The new IMAP binary includes the oft-requested change made to where it stores its mail boxes (so that it doesn't clash with Mail.app). It works so well with Mail.app now. It's fair to say that this is the way it should have worked, from the start.

I'm sorry I took so long to fix it. That's why I decided to release it immediately. This makes working with IMAP a much better and smoother experience and I can now understand why people would keep coming back to bug me for it. I hope the users are going to be delighted.

Posted at 7:56AM UTC | permalink

Read more ...

Mac@Work
Put your Mac to Work

Sivasothi.com? Now how would you do something like that?

Weblogs. Download and start a weblog of your own.

A Mac Business Toolbox
A survey of the possibilities

A Business Scenario
How we could use Macs in businesses

VPN Enabler for Mavericks

MailServe for Mavericks

DNS Enabler for Mavericks

DNS Agent for Mavericks

WebMon for Mavericks

Luca for Mavericks

Liya for Mountain Lion & Mavericks

Postfix Enabler for Tiger and Panther

Sendmail Enabler for Jaguar

Services running on this server, a Mac Mini running Mac OS X 10.9.2 Mavericks:

  • Apache 2 Web Server
  • Postfix Mail Server
  • Dovecot IMAP Server
  • Fetchmail
  • SpamBayes Spam Filter
  • Procmail
  • BIND DNS Server
  • DNS Agent
  • WebDAV Server
  • VPN Server
  • PHP-based weblog
  • MySQL database
  • PostgreSQL database

all set up using MailServe, WebMon, DNS Enabler, DNS Agent, VPN Enabler, Liya and our SQL installers, all on Mavericks.