Things I did not say in Surpass:
- That Objective-C will be taken out back and shot.
- That Apple will need to drop C-based languages.
- That Apple will need to drop Objective-C.
- That Apple will need to stop supporting Objective-C as a language for application development.
- That Objective-C sucks.
- That Cocoa needs to be laid to bed.
- That Cocoa needs to be rewritten.
- That people would need to use either xlang or Objective-C to write one program.
- That xlang is basically { LISP, Nu, Smalltalk, Ruby, Python, … }.
My premise was always what I’m about to describe, but I think I didn’t explain it well enough. Let’s start by saying that Apple would keep Objective-C on-board. The xlang scenario is sufficiently fantastic that them just dropping their existing environment would be too incredible, beyond plain stupid. I’ve been thinking — and hoping — that Apple may be doing something like it for years. I’ve been finding it more and more plausible since at least 2005. The scales dropped in my mind when I saw the WWDC advances not because they were big changes, but because they were the right kind of small changes, the right sort of hints.
Most people don’t get why I see the need for a new language at all. And they’re half-right, even: the intersection of a well-supported, stable MacRuby and an Xcode with less brittle and better implemented Objective-C support (including refactoring) would serve the vast majority of my own needs in languages I already enjoy. I think there’s an angle to why Apple would want to do this, I think that angle is interesting and I think it’ll have consequences for me when it happens. If. When.
Here’s the thing, again. Imagine Objective-C. Imagine Objective-C without C. Can you do it? I can’t. Objective-C is a layer on top of C. It never got to define its own primitives, it never gets to escape the pile of rope that is C pointers, and backwards compatibility limits what can be added on top.
Blocks are a good example of the position Apple is in – they did manage to add them, for which I am eternally grateful. But look at the collateral damage: you have to copy the block if you pass it elsewhere, you have to reference count it, you have to swallow, count to three and close your eyes every time you want to define a block variable, typedef or parameter due to the consistent but horrible syntax. You have to cast, or explicitly specify BOOL, every time you want to return boolean, because BOOL is just a typedef’d signed char, YES is just 1 cast to BOOL, and type inference isn’t smart enough to figure it out. There are worse things in programming, and my point isn’t that I can’t handle nuisances, but that blocks aren’t all they could be. For example.
So imagine what the good things from Objective-C would look like if Apple could define the entire language. Imagine what they would stick in, knowing what they do now about being tight on memory, fast on dispatch, and consistent on asynchrony as a good, overriding paradigm for scalable programs. That’s what I hope xlang is.
It’s also entirely possible for this to be mixed with Objective-C within one app — Objective-C and MacRuby get along fine, don’t they? When I said “surpass”, I did qualify it as “their intended, primary, publicly recommended programming language”, never as the “only” one. Let’s again take Blocks; you can write Snow Leopard or iOS 4 code without using them, but they help greatly. Let’s also take QuickTime: when they added a 64-bit API, it was only accessible through QTKit. People working with 32-bit QuickTime didn’t lose anything, but Apple didn’t have to keep doing things the same way as in their oldest surviving non-deprecated API.
C isn’t going to go away. Objective-C isn’t going to go away. There’s a way to recognize both those things and see that a new language could be modern, stable, small, fast, and provide better models and abstractions.
I actually spent a fair bit of time over many months, trying to design such a follow-on language, which I called Objective-CX. (X for extended.)
The general idea was to bring all the C-level constructs up to Python-level semantics, and do some unification.
So, e.g.,
a[i]
would mean (and still be expressible as either
[a objectAtIndex: i]
or
[a valueForKey:i]
depending on a’s type, etc. (All to be done by adding Obj-CX-specific methods to the built-in types, just like Python’s internal methods for a[i].)
It would implement full lambda’s without the current Obj-C block restrictions, etc.
The problem I kept running into is that, ultimately, Obj-C is just Smalltalk with C control structures, so while things like a[i] might be more “natural” to Python/Ruby fans, you’re still falling back all the time on the more verbose versions of those methods, and the mixture just looks too macaronic.
So, in the end, it looked like you could gain some small wins over Obj-C but nothing truly compelling.
Plus, there’s the obvious problem of interfacing to the OS X/iOS APIs, many of which require C-level structures (pointers to pointers, etc.). Only Apple could solve this problem, as they could augment their current APIs with alternate, higher-level, memory-safe APIs.
So, yes, in the end, I agree with you. I think Objective-CX/xlang is something they should by all logic be working on right now.
By Chris Ryland · 2010.07.06 20:44
Not to sound glib, but isn’t it pretty easy to imagine what Objective-C would look like without C? It’s essentially the fusion of two older languages, so take out the one and you get the other.
By Chuck · 2010.07.06 21:10
Chuck: So let’s say I reformulated it as “without the old”. I don’t mean by that that Smalltalk is “old and shouldn’t be used”, just that I hope we won’t have to pretend we have to stop inventing stuff since the 70s have ended.
Chris: Ding! Thanks. That’s exactly the kind of thing I’m after.
I also think they’re after doing something else while they’re doing this, and that’s what’s driving this. Some kind of new overriding construct. They always do. Just ending up with an Objective-C-flavored Python, even one that officially goes deep within the system, isn’t a big enough trick or payoff.
By Jesper · 2010.07.06 21:18
Although it’s taken until now for a lot of the programming arguments of the late 70s/early 80s to become mainstream. It’s taken a long while for the appetite to build for something like Ruby or Python.
Unfortunately the move to personal computers prioritised code performance (C++) over the programming productivity (perhaps that’s why there’s been more innovation in that respect on the server side, where the cost of programming relative to hardware is more significant).
But I agree that it’s frustrating that we’re still back in the syntactic world of C.
By JulesLt · 2010.07.06 22:14
Chuck: You can’t just take out C from Objective-C, or all you’re left with is a way to make Smalltalk-like method calls but with no control structures and no data declarations, etc.
Jesper: Right, I didn’t mean to imply Obj-C-flavored Python at all.
I was envisioning something with general Obj-C syntax, somewhat extended and simplified at the same time, with “Python-level” operators ([ ] . etc) but minus the C details, and with no (or maybe optional) type information.
E.g., here’s something from the RubyCocoa tutorial re-coded in this mythical Obj-CX language. Note that the message-passing brackets are now optional, and we’re using both dictionary {:} and set { } literals, etc.
By Chris Ryland · 2010.07.06 22:19
Argh, tried using “code” html but it didn’t take…
By Chris Ryland · 2010.07.06 22:20
Chris: Fixed that. Sorry.
By Jesper · 2010.07.07 00:11
My issue with “Surpass” is that I just don’t see the signs that you saw at WWDC which point to there being a new language. Quite the contrary, the years of investment in Clang and the continuing changes to Objective-C suggest Apple is committed to C-based languages for the foreseeable future. What exactly is it about Objective-C that is holding people back? It’s easy to use and has fast, native performance over something like Ruby.
It’s also a little strange to keep referring to this imagined thing named “xlang” as if it’s been verified to exist. ;)
By Preston · 2010.07.07 05:44
I agree completely, Jesper, xlang is not meant to replace Objective-C. I believe this language is JavaScript and have posted reasons why on my blog. What’s missing is a better bridge between Objective-C and JavaScript.
By Charles · 2010.07.07 08:02
For me the sings where in the “Developer Tools State of the Union” – session.
By Florian · 2010.07.07 15:08
Preston – MacRuby also offers native performance (unlike classic Ruby it’s compiled, and executes on the same runtime as ObjC).
See Jesper’s post for valid criticisms – it’s a large number of small things – it’s the amount of ‘ceremony’ that C-based languages require, in return for a level of power most of us do not need, most of the time.
It’s a language being constrained by the (rightful) design decision that it should be a pure superset of ANSI C. It cannot remove anything, or rationalise duplications between the two levels.
A contrast would be a language like Oberon, which is actually smaller, and in many senses less powerful than it’s predecessors (Algol, Pascal, Modula 2). Instead it recognises that lower level programming should be conducted in C and exposed to Oberon as libraries. I’m not proposing Oberon would be a good fit (it’s modular rather than OO in the classic sense).
Go is a good example of trying to create a modern low-level/systems language rather than presuming C/C++ to be the last word in systems programming.
There has to be some possibility in creating something that actually takes the conceptual underpinnings of Cocoa & the Obj-C runtime in a similar way – i.e. what would you get if you created a language from scratch from the requirements of the Obj-C runtime?
By JulesLt · 2010.07.07 18:57
Preston: “Mythical, proposed, hypothetical successor-to-albeit-not-slayer-of Objective-C programming language” is a bit of a mouthful.
Also, the status quo can always be improved. Certainly, Objective-C, like every language, can always be improved, but you can’t improve it beyond a certain point without starting from scratch. Things don’t have to be in tatters to be worth investing in. Maybe it’s time.
By Jesper · 2010.07.07 20:23
Charles: I saw that post and I think it’s interesting. They will need a good set of tools and a good implementation of JavaScript and they already value it highly, but I think it has too much baggage and is too tethered.
By Jesper · 2010.07.07 20:25
Preston, I agree, openCL and GCD is also testimony of this, and the whole llvm in depth session. At the lowest level there needs to be a language that adopts itself to the reality of the hardware. C is perfect for this with the aim of being a portable assembly. Anything in C’s place would be a very similar language, but with the tradeoff of being completely new and unsupported. The way obj-c is implemented on top of c gives the best of both worlds. I want my knife to be sharp.
By foo · 2010.07.07 20:45
Comment № 3, response to Chris… “Some kind of new overriding construct. They always do…” Regardless of the balance of the article, I completely concur with this statement. It absolutely is the “Apple Way” to do exactly that, time and again on the important things.
By JT · 2010.07.09 03:41
foo: Which is why Objective-C won’t be going away.
By Jesper · 2010.07.09 06:19