News for hackers. Stuff that matters.
Re:The eero programming language - a dialect of Objective-C by jballanc on Saturday July 07, 2012 @01:26PM (#4212174)
Perhaps a matter of taste, but it seems everything you dislike about the Obj-C runtime are the things I enjoy:

> It is effectively an extremely simple dynamic dispatch runtime

Yup! Just the way I like it. It's practically lisp-like in its minimalism. Just the minimum you'd need to get the job done.

> reliant on the OS memory management

This, actually, is one of my favorite points. Letting the JVM grab a giant allocation at startup is fine if all you're going to do with your machine is run JVM programs (i.e. a server), but it sucks when you've got multiple apps all trying to play nice together. The OS has a memory management system for a reason. I'd much prefer my runtime use the existing system, than re-invent the wheel (as it were).

> with reference counting

Right, well...I did mention that the lack of a GC kinda sucks. I suppose it's a trade-off that one must make if you are going to rely on the OS to manage memory. Still, I can't help but feel that some sort of opt-in system could be made to work at runtime.

> zero support for any complex runtime state inspection (say, to support breaking reference cycles)

Of course, the flip-side to this is that runtime performance is more predictable, since the runtime isn't attempting to do anything overly complex. I can see how you might argue this either way: more runtime introspection eases the burden on language implementors, but it also is a sunk cost whether you want it or not.

> The class registration system has hardly changed in 20 years

"It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away"

> has no support for namespaces

I'm not completely convinced this is a problem domain that I want my runtime solving for me. The addition of two-level namespacing to Mach-O addresses the only time I can think that I definitely want runtime managed namespacing. If I want namespacing to be part of my object model, let me determine how it should work. (It's always mildly annoyed me that Java's reverse-DNS-style bleeds into almost every JVM-based language.)

> the type encodings available at runtime are complex-to-decode-strings

The type encodings are simple C strings!

> the whole thing is, quite honestly, the kind of rickety design you'd expect to emerge from C hackers in the late 80s early 90s

If by that you mean that the central message dispatch routine is hand-optimized assembly for each platform the runtime is available on... I'll have some more of that, please!

Edit: Oh, and about the "like" part...I was being mildly facetious. There are aspects of all 3 languages that I enjoy, but I doubt they'd have become as popular as they have on their merits alone. (Well, ok, given the landscape at the time, Java's popularity could be said to be fairly won...)

Re:The eero programming language - a dialect of Objective-C by cageface on Saturday July 07, 2012 @11:29PM (#4213486)
It's practically lisp-like in its minimalism.

So why not go the extra yard and make it properly homoiconic and reap all the benefits of such a rigid, simplistic syntax? The current syntax is the worst of both worlds - painful to read but disallowing macros.

I don't want Apple to turn Obj-C into Perl but Obj-C is badly in need of a little syntactic sugar. Thankfully some of this is coming in the new collection literals and operator overloads.

Re:The eero programming language - a dialect of Objective-C by jballanc on Sunday July 08, 2012 @03:13AM (#4213964)
Have you seen Nu? http://programming.nu/index
Re:The eero programming language - a dialect of Objective-C by cageface on Sunday July 08, 2012 @05:54AM (#4214212)
No but it looks interesting. Thanks for the link.
Re:The eero programming language - a dialect of Objective-C by flatline3 on Saturday July 07, 2012 @01:56PM (#4212244)
> This, actually, is one of my favorite points. Letting the JVM grab a giant allocation at startup is fine if all you're going to do with your machine is run JVM programs (i.e. a server), but it sucks when you've got multiple apps all trying to play nice together. The OS has a memory management system for a reason. I'd much prefer my runtime use the existing system, than re-invent the wheel (as it were).

The OS memory management system is as general-purpose as possible. At the kernel/process interaction level, the APIs are thin abstractions on the underlying VM page mapping system. Below that, at the malloc level, malloc is designed to be as general purpose allocator as possible, without introducing complexity unsupportable in C, such as migrating allocations across generations.

The JVM's lack of ability to rededicate pages to the OS is a failing of Sun's particular implementation, and is not strictly inherent in the design of generational collectors.

Your argument dismantles Sun's architectural choice when used on mobile hardware, but does not address the relative merits of alternative allocation/collection schemes.

> In regards to the class registration system: "It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away"

That response has little substance. It's not perfect, or even great, it's merely functional. I would be enthralled if Mach-O two-level namespacing worked with ObjC classes, but it can not.

> The type encodings are simple C strings!

They're C strings, not particularly simple. Try decoding (with lackluster documentation) a complex structure return value. Modern runtimes use much more cleanly structured, cross-referenced data here.

> If by that you mean that the central message dispatch routine is hand-optimized assembly for each platform the runtime is available on... I'll have some more of that, please!

No, that's not what I mean. You'd find just as much complex hand-optimized assembly code in other runtimes, likely more.

I'm referring to design choices such as the use of unnecessarily complex data structures with minimal if not outright missing API to access them, poorly abstracted implementation details (such as exposing C string type signatures as the highest-level representation of a type encoding), minimal/missing/poorly-defined metadata.

An example is the failure to encode type data in blockrefs in the first public release of blocks for ObjC, which made it impossible to implement imp_implementationWithBlock(), due to the need to differentiation between stret vs non-stret return types and select the appropriate trampoline. This required changes to both the compiler and the runtime, and meant that prior to those changes' introduction by Apple, it would have been impossible for an external entity to implement similar functionality.

This sort of hackish minimalism is the polar opposite of the careful considered and long-term focused design that Microsoft (and even Sun) applied to the core of their platform. Compare the completeness (and longevity) of the JVM Virtual Machine specification to the ObjC runtime. Over roughly the same amount of time, Apple has had to introduce complete ABI-breaking fundamental changes of to their runtime to implement extremely basic language enhancements. In contract, the JVM specification has not, to my recollection, been broken once over the course of 20 years. Additions have always been forward-compatible.

An example of the above would be the addition of non-fragile base classes through the use of minimal ivar access indirection. This required a wholesale breakage of the entire language, and thus could only be introduced on 64-bit Mac OS X and on iOS.

Apple's language and runtime design is hackish at best.

Re:The eero programming language - a dialect of Objective-C by comex on Saturday July 07, 2012 @04:57PM (#4212702)
I don't buy the comparison. It's a lot easier to avoid breaking things when you're not compiling to native code, but compiling to native code is one of Objective-C's biggest advantages.
Re:The eero programming language - a dialect of Objective-C by flatline3 on Saturday July 07, 2012 @05:45PM (#4212829)
In contrast, I don't buy that dichotomy. The Objective-C runtime is runtime-heavy, generates a slew of runtime-interpretable data, and yet is compiled "natively" insofar as the body of functions-nee-methods is native.

Instance variable access from native code is done through indirection with metadata maintained on their type and offset, dispatch is done through indirection from native code using class metadata, instantiation is done through indirection using the global registration of class metadata.

The problem has consistently been in the non-forward-looking design of that structured data, not in the fact that they generate method bodies as native machine code.

Re:The eero programming language - a dialect of Objective-C by comex on Tuesday July 10, 2012 @04:29AM (#4222668)
Since I've been tired the last few days, here's a late reply:

Direct pointer offsetting of fragile base classes and statically generated copy/destroy code for blocks in lieu of type information would be fairly unthinkable in a managed language, whose bytecode probably wouldn't be low level enough to even express those designs; it would still have been a good idea to think ahead and use indirection for ivars and include full type information in blocks, but managed language designers never really had the chance to make such mistakes in the first place. For other Objective-C changes, like garbage collection, the changes to code generation would have been unreasonable to make "in advance", but it's hard to imagine an analogous change in a managed language that would require an ABI break. Though Objective-C could have done better, it's a bit unfair to compare it to something like the JVM.