Hacker News new | ask | show | jobs
by pianoben 1648 days ago
> In my view, excessive syntax is a crutch to make the language parser's job easier, not making the thought to code job easier. Obj-C seems to suffer from the excessive syntax?

Another perspective is that the syntax of Obj-C exposes and supports the core model of the language, which is objects sending messages to each other. That it happens to be fast to parse seems secondary, and certainly further developments since version 2.0 have made parsing slower, not faster.

In my experience people complain about Obj-C syntax when what they actually dislike are verbose Cocoa/Foundation/etc APIs. Try their C Core* equivalents and you'll find you probably dislike those, too.

1 comments

> In my experience people complain about Obj-C syntax when what they actually dislike are verbose Cocoa/Foundation/etc APIs

If so, that’s a real shame. Foundation may be the single best-designed standard library for a (non-functional) language ever.

I agree, Foundation is a gem! The method naming is one of the assets - the names are clear, regular, and usually fairly obvious. The downside to that regularity and clarity is that the names are long.

One CoreFoundation example at random:

    CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef ref);
I think nearly everyone who reads that prototype will immediately understand what it does, but there's no denying it's a mouthful.

Tack on some unfamilar square-brackets and intersperse argument names, and it's understandable that people will conflate the syntax with the APIs.

For me Foundation lacks composability. This method should be really two: CreateCopy (I assume it already exist) and mutating DeleteLastPathComponent.

I don't mention immutable by default behavior because it was long ago and written in C.

CoreFoundation is not written in ObjC, it's C only (although toll-free bridged).