Learning Objective C - Weird Syntax, Same Concepts
August 18, 2021
2 min read
I’ve decided to learn some iOS programming at Facebook during my Bootcamp. Because well, it’s just another tech stack to learn, right? And learning new stacks is fun ;)
Part of learning iOS means learning an entire new language: Objective C.
Yes, I know that Swift is the way to go but Facebook’s codebase is huge and hard to port to a new language.
Learning a new langauge can seem intimidating, but really there isn’t actually that much new to learn. A quick read of the Objective C wiki page and I was good to go.
Objective C has weird syntax, think
YES/NO for bools, but if you squint hard enough you’ll see it kind of looks like Java but with some C
alloc and pointers. Just that the names are slightly different, e.g.
and syntax is also different. Okay, there’s some stuff about message-passing that seem a bit different, but it’s still a classic object-oriented language.
So what gives? Well Objective C’s roots actually hark back to Smalltalk (one of the classic languages that introduced object-oriented programming, along with Simula), and of course C. Smalltalk has influenced other languages like Java, hence the similarities. So really Objective C might have some new syntax, but the concepts that underly the language predate it.
We covered Smalltalk in a lecture course called Concepts In Programming Languages during my computer science degree at Cambridge and I think it really is a microcosm of the value of a computer science degree. Yes it is theoretical, and you would think knowing about an old, practically dead language like Smalltalk would be useless, but it turns out the concepts you learn provide a solid foundation to help you learn new skills quicker.
this.propName actually accesses the getter / setter method for the field that stores the value
this._propName. And if you’ve seen Python or JS, you’ll be familiar with the convention of prepending an
_ to indicate a field should be treated as private.
Objective C isn’t the first language that course helped with. Indeed I used it to pick up the programming language Hack. If you squint hard enough it seems like a mash-up of a bunch of languages. Pretty cool right?