top | item 15915542

The Objective-C Runtime and Swift Dynamism

94 points| mrkd | 8 years ago |academy.realm.io

38 comments

order
[+] dep_b|8 years ago|reply
I still like Objective-C even if it isn't my go-to language anymore. It's quite elegant compared to it's peers from the 80's, it's a very small language yet you can achieve everything with it, even if it means dipping into C(++) for the parts that need to be really performant. But on the other hand seeing a different programming language when there's some optimization going on and having another programming language for business logic is a great thing too.

How many times don't we see bugs, errors or security issues stemming from the fact that business logic gets implemented in C?

[+] nerdponx|8 years ago|reply
What is cross-platform development like?

Also, what about Objective-C prevents business logic bugs?

[+] btreesOfSpring|8 years ago|reply
I'm getting the loading error, "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details."

Not sure if there is a mirror, a write-up, or another example anyone might be able to pass along.

edit: this google cache version is working[0].

[0] https://webcache.googleusercontent.com/search?q=cache:gXiqzW...

[+] tambourine_man|8 years ago|reply
You can watch the talk with google cache. It’s from 2016.

Basically, Swift dynamism is coming, hopefully safer than ObjC

[+] skue|8 years ago|reply
> Before we start, Objective-C is a runtime-oriented language, which means that all of the links between your methods and variables and classes are deferred to the last moment possible to when your app is actually running, and this gives you great flexibility because you can change those links. The alternative, where Swift is most of the time, is compiletime-oriented languages. So in Swift everything is a bit more harder bound, and you get more safety, but it’s less flexible.

> This is what this debate was all about.

Not just safety, but also performance. Swift offers significant performance gains when you don’t need the dynamism. Swift lets you opt into dynamic features (as he later explains), and you can seemlessly interact with Objective C on Mac platforms. But you don’t have to pay the penalty for dynamism in the vast majority of your code that doesn’t use these features.

Edited: I also pointed out some additional mistakes in the post, but removed that because this comment got too long.

[+] woolvalley|8 years ago|reply
Tooling and maturity are reasons why not currently, maybe give it a couple of years ;)

Debuggers can not work properly, xcode indexing can beachball, compile times are quite a bit longer, there is API churn from version to version, a lack of ABI stability forcing you to bundle swift with your app increasing binary size and other bugs.

[+] mpweiher|8 years ago|reply
> Not just safety, but also performance. Swift offers significant performance gains

This is a common misconception. It is not true. Swift is slower than Objective-C, typically significantly so.

[+] bogomipz|8 years ago|reply
>"Before we start, Objective-C is a runtime-oriented language, which means that all of the links between your methods and variables and classes are deferred to the last moment possible to when your app is actually running, ..."

I had not heard the term "runtime-oriented language" before. Is this really just another term for "supports reflection"? If not what would be other examples of "runtime-oriented" languages?

[+] panic|8 years ago|reply
The usual name for this is "late binding". It became popular because of Smalltalk, and it's a core principle of the "pure OOP" languages (like Self, Obj-C and Ruby) that Smalltalk inspired.
[+] chc|8 years ago|reply
I think it means "dynamic," in the sense that when you call a method, the object's class is looked up and the class's method list is looked up and the methods' implementations are looked up and the class is even given a chance to handle the lookup itself. It doesn't just support reflection, it reflects pervasively. This basically corresponds to what we usually mean when we say a "dynamic language."
[+] jernfrost|8 years ago|reply
Really just means a dynamic language just like smalltalk, LISP, python, Ruby etc. Like Objective-C all these allow you to add classes and method at runtime.
[+] dunham|8 years ago|reply
I think the author means "late binding" - the method lookup is done at invocation time rather than compile time. (There is caching, etc, to make it fast.)
[+] IMcD23|8 years ago|reply
It's important to note that this talk is from 2016. Since then, Swift 4 has been released, that added KVO and key paths to the language.
[+] fbgugli|8 years ago|reply

[deleted]

[+] tzahola|8 years ago|reply
Your comment reads like it was generated by an AI from the 90s.
[+] _sdegutis|8 years ago|reply
What silliness? What did MS do in the 90s? Why wouldn't you like all apps again? Care to elaborate?