top | item 16899658

Bringing Objective-C to the Amiga

137 points| Midar | 7 years ago |heap.zone

112 comments

order

mpweiher|7 years ago

Funky!

I "brought" Objective-C to the Amiga sometime in ~1986/1987.

I had recently acquired one of the first Amigas in Germany, still a US NTSC model, and also seen Objective-C discussed in a BYTE article. The beautiful OO structure of the Amiga Exec kernel and the higher OS levels built on top of those abstractions (except the abomination that was AmigaDOS) was almost certainly an inspiration.

Having also recently purchased my first C compiler, Manx Aztec C, I initially had some fun with implementing OOP via some Macros and the Amiga shared library mechanism, which was essentially an array of function pointers/C++ vtable.

I don't quite remember when I got the crazy idea of actually implementing an Objective-C runtime and preprocessor, before or after getting the book. I do remember that it felt very much "here goes nothing", and it really was nothing. I was in high school, I had no CS training, didn't know about compilers, hadn't programmed in C for more than a couple of months.

So I wrote a weird lexer that used a bitmap and two counts to cover all the regex cases, a syntactic recognizer that could tell the Objective-C constructs apart most of the time (it had a hard time distinguishing a method send with a cast from indexing into the return of a function call). And a runtime and basic object library. My dictionary implementation turned out to be ordered almost by accident, I have grown very fond of ordered sets and dicts. It also had automatic serialization ("passivation" as it's called in the book), something Apple has only gotten around to just now, and only for Swift.

It worked and I never looked back. I later ported it to i386 and QNX + MS-DOS for a project, replacing the assembly-language messenger function with a pure ANSI-C one returning the function pointer of the method (a technique later rediscovered for the GNU runtime).

When NeXT came out I knew I had to have one. And ditched my implementation in a heartbeat: SEP!

Interestingly, there was another Objective-C implementation from Germany in around the same timeframe called M:OOP, which actually got a little bit of press coverage:

https://ekartco.com/wp-content/uploads/2012/11/m_oop.pdf

As far as I could tell, it never got the fully generic objc_msgSend() running, with only a limited number of arguments supported.

Fun times, but also valuable lessons:

- Go tackle "crazy ambitious" projects.

- A language that can be implemented by a kid with a C compiler is a gem.

- An architectural approach to language is really valuable.

alxlaz|7 years ago

Hey, I remember M:OOP!

Many, many years later (~2003 I think, I was barely in high school) my dad brought me a small book, edited by one of the local universities, which was essentially a student's guide to the diploma exam (sort of like a BSc thesis + a written exam, for our American friends -- this system used to be a lot more popular in Europe back then).

It included various study guides, example questions and -- my favourite -- a bunch of recommended subjects for the diploma thesis. "Projects" as in practical things you would study and implement, proposed by every department in the university. I think there were hundreds of them.

One of the was an Objective-C runtime implementation for Linux systems (I got the book in ~2003 but it was older, from around 1996 or 1998, I think, when GNUStep was just becoming a thing). I had read an article about Objective-C and spent a load of cash at the local internet cafe trying to figure out how I could do that.

I lost interest quickly enough when I realized one is already available and it turned out that writing stuff with GNUStep was a lot more fun than figuring out how it worked.

But I did stumble upon a couple of articles about M:OOP. Unfortunately, I don't speak German at all, but a very kind IRC user (whose name I've long forgotten, sadly) basically translated them for me. I found the whole thing absolutely amazing; I was already interested in low-level programming at the time, and this made me even more interested.

Midar|7 years ago

That all sounds too familiar. When I was still a little kid going to school, I was using Linux and found Objective-C. Really liked the language and concepts, but lacking a framework for Objective-C on Linux. So I started ObjFW a few years later. Seems you had the same experience before I was even born, except on Amiga :).

jmpt|7 years ago

Marcel, you rock! :) BTW, love your book.

mhd|7 years ago

It's interesting to see that ObjC has some heritage on the Amiga. That explain why MorphOS (one of the Amiga ecosystem fragments) is doing something similar[1] these days.

[1]: http://morphos-team.net/guide/objective-c

bwldrbst|7 years ago

This looks fun, considering how much of an influence Next seems to have had on OS 2 & 3. And not just the colour schemes either, BOOPSI (https://en.wikipedia.org/wiki/BOOPSI) looks like an attempt to get some ObjC features into plain old C.

adamnemecek|7 years ago

How can I run Amiga os on sometthing less exotic?

Midar|7 years ago

This is actually a port to the real Amiga, and not one of those new exotic Amigas. But if you want to run AmigaOS 3, you can just use FS-UAE. In fact, that screenshot is from FS-UAE, as always copying things over to a real Amiga can be quite annoying during development :).

mveety|7 years ago

For AmigaOS proper, you'll need emulation. You can run AROS on just run of the mill x86 hardware, though, which is a pretty good alternative. It's source compatible with AmigaOS, and there's an Amiga emulator that lets you run 68k programs more-or-less transparently. It's a pretty good alternative.

Fjolsvith|7 years ago

I use the Amiga Forever package to run AmigaOS on my Windows 10 computer. Installation is quick and works flawlessly. I'm even able to remote in using Remote Desktop and access my AmigaOS from my laptop. There are 3 different versions with varying prices. (http://www.amigaforever.com/)

It uses the WinUAE emulator, which you can download for free. (http://www.winuae.net/) You would need to purchase roms to go with this though. The Amiga Forever distro includes roms.

Edit: Shameless plug: I used to run a CNet BBS back in the day and I got back into that scene by setting up another CNet bbs on my virtual Amiga. You can telnet to it at chksmak.cnetbbs.net:2600

apple4ever|7 years ago

Very cool!

I ported ObjFW to the Omega2 (still have some things to clean up before releasing it to the public).

Midar|7 years ago

Hm, Omega2 seems to run OpenWrt, if I see it right? In that case, it should even just work.

Alternatively, if you want to avoid OpenWrt, there's also ObjFW on bare-metal ARM: https://heap.zone/blog/?68

blackrock|7 years ago

Does anyone else look at Objective-C code, and just want to puke?

iainmerrick|7 years ago

Not me. Objective-C is lovely.

For me the addition of Automated Reference Counting was key. That took a while bunch of tedious but essential boilerplate out of the language. Before ARC, Obj-C was a weird but interesting language that I didn’t want to use. With ARC it all came together into a nice expressive high-level language with raw C power available when you need it.

keyle|7 years ago

It's certainly a bit different but it's not puke-worthy. For someone who writes Obj-C daily, I'm sure Swift feels pretty different.

Try reading your own perl script you wrote in the 90ies, that's fun.

_diyu|7 years ago

I actually prefer Objective-C to Swift.

IncRnd|7 years ago

I started programming objc on NeXT and still remember the book by Brad Cox. No, I don't want to puke when I see objc.

kenver|7 years ago

It’s not puke inducing, but it is verbose. The language designers just took a different approach to how to write code. Just for some background, it came out at a similar time to c++. Both were designed to be a ‘better c’

jmpt|7 years ago

No, and if you do, then I suggest you visit a doctor.

Rant:

Objective-C is a wonderful language, once you learn it properly. There's a lot of Swift fanboiism (is that a word?) and a lot of Objective-C hate. I have an opinion on why.

The vast majority of people that used Objective-C were drawn to the success of iOS. They were developers, used to languages like Javascript, Java or C++. Coming to Objective-C, their immediate reaction was "WUTT??? Brackets!" Instead of properly learning the idioms, they fought the language on a daily basis and cursed Apple for forcing them to use a language unlike the one they were used to, in order to jump on the iOS bandwagon. These people, once Swift was released, jumped boat immediately because they never really understood Objective-C and Swift is familiar.

Another group of people: the seasoned Objective-C developers, with a clue, went: "hmmm... this doesn't solve any of my real problems," but they weren't stupid and Apple was quite clear that Swift was the future. They learned Swift, got used to the bad, learned how to like the good and went along their business.

Another group of people actively dislike Swift, and really enjoy Objective-C. These are considered dinosaurs and have to either hide their opinion or face hiring difficulties, or even dismissal from companies where they are currently employed. Hiring managers, usually incompetent and non-technical in nature, ask: "Do you use Swift? Do you like it?" If you want a job, you must say yes. Disagree with me? Try a no.

All new documentation is Swift oriented. All conferences and talks are in Swift. All new books are in Swift. You would have to be crazy to stick to Objective-C, but not for technical reasons.

The Objective-C vs Swift debate is similar to vi vs emacs, except that vi and emacs would be built by the same company and that company explicitly said "emacs is the future."

Nat, went like: screw this, and built https://www.mulle-kybernetik.com/weblog/2015/mulle_objc_a_ne...

Objective-C has warts. It is also fast. And stable. And quick to compile. Did I mention stable? It is also: stable. My code from 20 years ago still runs.

Objective-C is a marriage of my two favorite programming languages: C and Smalltalk.

Objective-C is message oriented, like Alan Kay envisioned, instead of object oriented. The focus should be messages and messaging to nil is a FEATURE. I actually quite like it.

In Objective-C you can drop to C at any given time and have access to all the insanely fast libs. You can also write such insanely fast code yourself.

Swift is immature, unstable, bloated, overengineering and extremely complex as a language. Complex as in C++ complex, but without the speed.

Ever heard of Objective-C++? Yup. Everything I said, except exchange C for C++.

Swift sacrifices LOTS of things and introduces new ideas that have yet to be proven efficient, and you get to rewrite your code all the time. Have something you wrote 2 years ago? Good luck with that.

All productivity "supposedly" gained by Swift is lost to slow compiles, rewriting older code and migrating to the new version when it comes out.

Swift is safe and everything. Right. Except developers with deadlines will just ! all the optionals when they get in the way.

Prototype a new idea? Prepare to fight the compiler the entire time.

Now, Swift does have some cool things, but so could a new version of Objective-C. In fact, ARC, which is pretty cool was born out of the development of Swift.

In my opinion, Swift is not a great language. I would even say that it's not good. It's OK. Maybe one day it will be good, but this day is not today.

All the love I hear is based on developers that resist learning something new (like Objective-C's way of doing things) and that's a good thing?

I love Cocoa. There's an impedance mismatch between Swift and Cocoa. Objective-C + Cocoa is wonderful.

Oh well. Objective-C is as good as dead and I'd rather write Go, Kotlin, C, Ruby, Erlang or even C++ than Swift.

DrJokepu|7 years ago

Beauty is in the eye of the beholder.

coldtea|7 years ago

A few people. I would call them shallow in this regard, but that would imply there was something bad with the code in the first place, even if shallow.

amiga-workbench|7 years ago

Yes, but then after 6 months using it, it really doesn't bother me anymore.