Press "Enter" to skip to content

Year: 2008

OCPython, anyone?

As dynamic scripting languages become more widely used, many developers are interested in using them to write “native” Mac OS X software, rather than having to learn Objective-C (which, of course, is a dynamic language in its own right). And in fact it is often possible to do so, using Apple’s BridgeSupport to generate the necessary metadata. Apple explicitly supports bridges for Ruby (RubyCocoa) and Python (PyObjC).

Nevertheless, there is necessarily an impedance mismatch between the runtime models — when passing objects to Cocoa, the bridge must convert the object from the dynamic language’s runtime to an Objective-C object derived from NSObject, and vice versa. This introduces a certain amount of inefficiency, which is not normally a big problem, but it would be desirable to avoid it.

Now, over the last few months, I’ve seen a variety of projects to do this by using the Objective-C 2.0 runtime to implement the object model for the dynamic language. In other words, objects in the dynamic language are subclasses of NSObject and no conversion is necessary.

These range from the venerable F-Script, which is even closer to Smalltalk than Objective-C, to Tim Burks’ original language Nu, which uses a Lisp-like syntax. I believe I’ve seen a reference to a JavaScript implementation as well, but I can’t seem to find it now.

The project that seems to be getting the most buzz in the Mac community right now is MacRuby, a port of Ruby 1.9 done by the developer of RubyCocoa (who is also an Apple employee). There was even a article about it featured on the Apple developer site recently.

Conspicuous by its absence from this list is my preferred dynamic language Python. I would love to see an implementation of Python hosted on the Objective-C runtime. I’ve always felt Python’s language model was a good match for Cocoa (of course, PyObjC not only predates BridgeSupport but even Cocoa itself, going back to the days of NextStep), and I’m personally more familiar with it than Ruby or other dynamic languages. So it seems like a logical step to take.

This project couldn’t be called MacPython, because that name has already been used to denote the Mac port of Python. For now I’m calling it “OCPython”, but I’m certainly open to a cleverer name (especially if there’s one that can riff on IronPython; unfortunately the element most associated with Mac OS X is Carbon, which is entirely wrong for this project).

I’ve been thinking about which version of Python to use as a jumping-off point; originally I was leaning towards 2.5 because it’s the version shipped with Leopard, but now I’m persuaded by Bill Bumgarner’s comment to use 3.0 and take advantage of the revised, less crufty implementation. (This is based on the stated goal of the 3.0 development project; I haven’t actually looked at the source code yet.)

I wish I could say I’m prepared to get the project off the ground myself, but right now I’m between jobs, as they say, and given the current financial situation I’m actively looking for full-time employment and can’t dedicate much time to something that won’t bring in any revenue. (Of course, if anyone out there would like to fund development of OCPython, contact me immediately.)

6 Comments

Visual Studio 2005: Not Ready To Lead

Glenn Howe writes of an anomaly in Visual Studio 2005’s C++ compiler:

… I discovered today (Friday) that if you compile something like:

double x = (false) ? 0 : 1.4;

that x will not equal 1.4 as most people (and the gcc compiler) would think, but rather it will equal 1.0. Why? Because it sees 0, interprets it as an integer and decides that if both halves of the : have to have the same type, then that type will be integer. The fact that this is in the middle of an assignment to double means nothing.

Yes, in fact it does mean nothing; the type of the lvalue on the left-hand side of an assignment expression has no effect on the type of the rvalue on the right-hand side.

He goes on:

I’m not even saying that Visual Studio is wrong. It’s different from gcc which leads to platform specific bugs, …

Well, I was a language lawyer in a previous life, so I can’t let it rest there. (And those of you out there saying “Of course Visual Studio is wrong!” should recall that gcc doesn’t always get it right, either.)

Where were we? The type of the conditional operator, right. To find what that type should be, we have to look at the definition of the operator.

In C99, this is pretty straightforward. Section 6.5.15, which defines the conditional operator, says the result of the expression “is the value of the second or third operand (whichever is evaluated), converted to the type described below”. Looking “below”, it further says when you have two operands of arithmetic type, the result type is the type that would be determined by the “usual arithmetic conversions” applied to the two operands.

Now a simple jump to section 6.3.1.8, which defines the “usual arithmetic conversions”, tells us: “… if the corresponding real type of either operand is double, the other operand is converted, without change of type domain, to a type whose
corresponding real type is double.”

OK, so that’s not completely straightforward, talking about “real types” and “type domains”, but basically we have two numbers, and if one of them is double the other is converted to double, and so that’s that; the type of the expression should be double, as we’d expect, and so Visual Studio 2005 is wrong.

If we’re in C.

C++ is more complicated.

(What a shock, right?)

Well, C++ has to allow for the possibility that either or both operand is a class type, and if so can it be converted to the other’s type, blah blah blah (section 5.16, if you’re following along at home).

Since we don’t have class type operands, we go on, applying the “standard conversions” to the operands (none of which apply here), and then, if “the second and third operands have arithmetic or enumeration type[,] the usual arithmetic conversions are performed to bring them to a common type, and the result is of that type.”

Hey, that was pretty simple after all. No, wait: are the usual arithmetic conversions the same in C++ as they are in C? Good question; let me see… (flip, flip, …) here we are, clause 5: yes, they are.

So from where I sit, Visual Studio 2005 is wrong in C++, too.

Wrong on conditional operators.

Wrong for America.

(I can’t wait for this election to be over…)

Comments closed

Will no one rid me of this troublesome plugin?

So, facing the “Would you like to install Flash Player 10?” message in the browser page at Adobe’s, I had a micro-aneurysm or something, and thought, my daughter spends all her free time playing Flash games, so I’ll need this soon anyway, right? So I clicked “Yes.”

[If you’re reading along at home: STOP! DON’T DO THIS!]

Whereupon Flash downloaded and tried to launch some oddly named helper program which bounced in my dock for about a minute, while Safari spun its rainbow pizza. Finally, the system asked me to confirm I really wanted to run this program downloaded from the Internet —

[Reader, I implore you again, turn back!]

— and finally launched the installer. Which proceeded to ask me to close all running browsers. OK.

No. Wait. I can’t close my browser BECAUSE YOUR STUPID PLUG-IN IS STILL SITTING IN A LOOP WAITING FOR THE HELPER PROGRAM, so it won’t respond to the quit request.

Criminey. Doesn’t anyone at Adobe ever test this stuff out?

I know, I must have this odd configuration where I’m running the latest update of the operating system with the standard system web browser. There’s no way they can be expected to test for that.

Comments closed

Insta-poll: Adobe Flash Player 10

Which slightly annoying and possibly overused net meme best describes this effort by Adobe to publicize the new features in Flash Player 10?

Adobe outlines Flash 10’s new features on a page that, for people running older Flash versions, leads off with the following instruction:

“To view the feature tour, please upgrade to Adobe Flash Player 10”

Is it:

  1. FAIL
  2. EPIC FAIL
  3. UR DOIN IT RONG

To be fair, when I tried it just now, I got a different result: a pseudo-dialog appeared in the middle of a gray box, with the message “This content requires Adobe Flash Player 10. Would you like to upgrade now?”

No. Not really.

Comments closed

Pirates! returns to the Mac

As noted here, Feral Interactive is bringing Sid Meier’s Pirates! back to the Mac. [Edit: updated game-specific link]

I was inspired by this news to send the following email to Feral:

I was excited to see the announcement of the latest version of Sid Meier’s Pirates! for the Mac. I was the developer of the Mac port of the original version of Pirates! when I worked at MicroProse Software in the 80’s, and it was fun to see the black-and-white screenshot from our version on your website. I look forward to playing Pirates! once again on my PowerMac and MacBook Pro in the near future.

I hope this leads to a successful line of “Legends” — I have always felt that there was money to be made by porting older successful versions of PC games for the growing Mac marketplace, and I’m pleased to see that Feral agrees with me. Good luck with your upcoming launch.

We’ll have to see how this works out. (I know my son would probably vote for Sid Meier’s Railroads! next, being a huge Thomas the Tank Engine fan.)

Comments closed

I have a bad feeling about this

Sometime when I wasn’t looking Apple posted the WWDC session schedule. I hope I’m wrong, but already I see the potential for some serious problems.

WWDC does not seem to have a big reputation for being well-run. I can’t speak to this personally with any great authority; I’ve only attended one previous conference, in 2006. I didn’t really know what to expect, and I was excited just to be there, but even still there were a few issues I noticed. That year the sessions on the newly-announced Objective-C 2.0 and garbage collection were scheduled in a room that clearly was too small for the amount of interest. I saw there was a problem and decided to bypass the sessions, even though I was interested, figuring I could read up on the material later.

Meanwhile, the session on application code signing had been put in Presidio, the largest room — which I interpreted as a sign of the importance of the topic to Apple — but there were well fewer than a hundred people there. So Apple’s track record on predicting attendance is suspect at best.

Now this year they’ve sold out the conference, so we know it’s going to be crowded, and we know many if not most of those people are there for the iPhone. Apple seems to have booked Presidio exclusively with the key iPhone sessions, which is wise, but I fear it won’t be enough. I imagine four or five hundred people lining up early Tuesday morning, parking themselves in Presidio, and staying there for three and a half days. People who try to come for a later session are going to be annoyed if they can’t get in — but if Apple tries to clear the room after each session, people will get really angry.

[In 2006 they apparently ended up “repeating” a few of the overcrowded sessions by replaying them on a video projector one evening. I didn’t go; if I remember correctly, that was Wednesday, the night of the Apple Design Awards and Stump the Experts, and I didn’t want to miss those. This time around I’d probably pass them up, though. For one thing, the former DTS engineer with whom I saw Stump the Experts, and who made it twice as much fun by filling in the back story for me, is probably not attending this year.]

As a would-be independent developer with interests in both desktop and iPhone software, I’m anxious about the scheduling. On the one hand, if the iPhone session fill up I can usually find other sessions of interest to me. On the other hand, the trip out to San Francisco from the East Coast is a big deal in both time and money, and it’s not clear when I’ll be able to do it again, so I’d like to take advantage of the iPhone sessions as much as possible, since they’re clearly of more immediate value. (After all, I’ve got my Hillegas third edition right here already.)

At least if I keep myself on Eastern Time I can show up early every morning and get in line. I’ll miss the evening socializing, but I’m pretty introverted and don’t know anyone in SF, so that’s not much of a loss for me.

I sure hope this works out…

Comments closed

Micro-huh?

As reported by Macworld: “Exec touts developing iPhone apps without SDK”:

There are more ways to develop applications for the Apple iPhone device than using the company’s beta iPhone SDK. Through a combination of Microsoft and other technologies, developers can build a Web application for the iPhone, according to a speaker at the VSLive conference in San Francisco on Wednesday.

How would you use Microsoft technologies to make an iPhone application? Oh, right: VSLive = Visual Studio Live. Got it. Know your audience.

“Don’t worry about rubber-tired vehicles,” said a speaker at this week’s blacksmith convention. “They can’t take you anywhere a well-shod horse can go.

“And besides, they won’t let you make your own tires, which I find kind of offensive.”

Comments closed

Little details mean a lot

I’ve just filed my 2007 taxes using the much-maligned TurboTax. (I filed my 2005 taxes this past January, so I’m doing much better this year.)

TurboTax for the Mac appears to have been completely rewritten with an eye towards satisfying the Mac customer, which is a refreshing change for Intuit. (It will be interesting to see how their Financial Life product looks this fall.)

As a good example of leveraging the foundations of Mac OS X to provide specific functionality for the customer: I was pleasantly surprised to be given these choices for saving my return after filing:

  1. “Print returns” (I routinely “print” to PDF, but Mac OS X already makes this easy);
  2. “Backup to .Mac”: this puts a copy of my TurboTax data file, as well as a PDF with my return and all supporting worksheets, into a folder (Documents/TurboTax/2007) on my .Mac disk;
  3. “Burn to CD”: this uses the standard disc burning interface to put a copy of my data file as well as the TurboTax application (fully updated, as far as I can tell) onto a CD. Brilliant. (I can’t tell you how much time I wasted looking for the 2005 software. The fact that it wouldn’t run under Leopard once I found it is another issue entirely…)

These are the little details that Mac users expect in their software (otherwise they wouldn’t have bought a Mac), and companies that pay attention to things like this should be able thrive in the Mac marketplace. Granted, Intuit’s reputation on the Mac is in tatters (and deservedly so), but I’m much more inclined to check out Financial Life now than I was before.

Comments closed

I'm really trying not to be "smug"

… but news items like this one make it hard:

An insidious computer virus recently discovered on digital photo frames has been identified as a powerful new Trojan Horse from China that collects passwords for online games – and its designers might have larger targets in mind.

The virus … recognizes and blocks antivirus protection from more than 100 security vendors, as well as the security and firewall built into Microsoft Windows. …

Deborah Hale at SANS suggested that PC users find friends with Macintosh or Linux machines and have them check for malware before plugging any device into a PC.

As Gruber points out, it seems inaccurate to call this a “computer virus” and not a “Windows virus”.

Remember, folks, if you must use Windows … be careful out there.

Comments closed

Signs of the Apocalypse, part 12

Sending an S.O.S. for a PC Exorcist (New York Times):

I called John C. Dvorak, a prominent columnist for PC Magazine and a podcaster on the Podshow network. “I advise everybody to buy a Macintosh because Apple products are the easiest to use,” he said.

Wait a sec, let me double-check… yes, 2 + 2 is still 4, and the sun appears to have set in the west.

(Oh, yeah, the article? The author took delivery of an $1800 laptop running Vista, and less than three days later it wasn’t working — something about the anti-virus software — so he paid this guy another $800 to wipe the hard drive and reinstall Vista, and now he’s happy. Couldn’t make this stuff up…)

Comments closed