Most active commenters
  • em-bee(9)
  • mpweiher(7)

←back to thread

107 points wmlive | 30 comments | | HN request time: 0.635s | source | bottom
Show context
itslennysfault ◴[] No.42129253[source]
So, this is why the abomination that is Obj-C is/was used for iPhone/Mac apps. I can't overstate how much I hate Obj-C. I'm so sooo happy Swift has pretty much entirely taken over.

Side note... I feel similarly about the Java to Kotlin transition. Sooo much better. Although, I don't hate Java NEARLY as much as Obj-C.

replies(5): >>42129327 #>>42129817 #>>42130011 #>>42130250 #>>42130804 #
ramesh31 ◴[] No.42129327[source]
To each their own. I'm convinced it's just a visceral reaction to the square bracket syntax. Obj-C remains my favorite language of all time (although I haven't written it in years). Having a high level language that allows you to seamlessly drop into C felt like magic.
replies(5): >>42129520 #>>42129543 #>>42129839 #>>42130389 #>>42130417 #
1. itslennysfault ◴[] No.42129839[source]
Interesting, I guess that part was missed on me since I only really ever used it for iPhone apps and never really had a need to use C directly.

Also, you're 100% right. The square brackets are what immediately repulsed me and continued to befuddle me even after years of experience with it. Also, everything just feels "backwards" to me if that makes any sense. Coming from Java/C#/JavaScript everything just seemed unintuitive to me at all times. Also, I think this was heavily compounded by using xCode which (at the time) was incredibly laggy. So, I'd mess up the Obj-C syntax and the IDE wouldn't tell me for what felt like forever. Often I'd make a change and hit "play" before the syntax highlighting caught up and that always felt infuriating.

I last used xCode about 4 years ago and it was still an issue then (even with swift).

replies(3): >>42130086 #>>42130409 #>>42131134 #
2. ramesh31 ◴[] No.42130086[source]
>"Also, everything just feels "backwards" to me if that makes any sense."

Because it is. Obj-C comes from the Smalltalk lineage by way of Alan Kay, using message passing [0] versus method invocation. It's a subtle difference with huge implications to how you design systems. Method invocation won out mostly because of Java and C++, but there was a time it wasn't clear which was the better OO paradigm.

[0] https://en.m.wikipedia.org/wiki/Message_passing

replies(3): >>42130432 #>>42130874 #>>42132104 #
3. robenkleene ◴[] No.42130409[source]
I've been an Mac and iOS engineer for over a decade, and none of this makes any sense to me. Everything you listed (besides the brackets) is worse in Swift than in Objective-C (Swift has real problems with live error checking in Xcode in particular, due to the additional compilation complexity since it's a significantly more complicated language).

I've observed some folks have a visceral reaction to having to use Xcode, I don't really understand it myself. I can understand being annoyed at having to use a specific IDE to write iOS and Mac apps, e.g., it's harder to bring your own text editor like you usually can, it's going to make your life a lot harder if you try to to avoid using Xcode. But comparing Xcode to any IDEs like the JetBrains IDEs I've used (mainly the discontinued AppCode), Android Studio (also JetBrains under the hood), or other similarly complex development environments like Unreal or Unity, I don't see any of these as a clear winner. Personally I'd prefer using Xcode to any of those. I suspect this comes down to just whether you like native Mac apps or not, Xcode is a native Mac app and if you like that aesthetic than you'll like Xcode. I suspect most of the dislike for Xcode is really just folks who dislike the Mac platform (e.g., the UI toolkit) overall.

replies(1): >>42130827 #
4. bunderbunder ◴[] No.42130432[source]
Message passing belongs up there with lisp, forth and pure functional programming as paradigms that are worth learning for "the profound enlightenment experience you will have when you finally get it." But I often see that my peers in the profession lack the kind of growth mentality that enables a person to see past the alienness of less algol-y languages.

Quote from "How To Become a Hacker" by Eric S. Raymond: http://www.catb.org/esr/faqs/hacker-howto.html

replies(1): >>42132261 #
5. pjmlp ◴[] No.42130827[source]
I think it comes from the folks that aren't really into Apple culture, rather they buy Apple because of UNIX, or want to target iDevices without culture background on the ecosystem.
replies(1): >>42132219 #
6. pjmlp ◴[] No.42130874[source]
Java is heavily based in Smalltalk and Objective-C, even if it has a C++ like syntax for mainstream adoption.

https://cs.gmu.edu/~sean/stuff/java-objc.html

Even Java EE was actually a rebooted Objective-C based project done internally at Sun during the OpenSTEP days, aka Distributed Objects Everywhere.

7. neverartful ◴[] No.42131134[source]
The square brackets can be a huge impediment when first working on Obj-C (it was to me). I found that after some period of time to acclimate they eventually felt 'normal'.
8. em-bee ◴[] No.42132104[source]
i have learned smalltalk, common lisp, java, python, ruby, perl, php, C, javacript and a few other languages, and i still do not understand the difference between message passing and function invocation. they look the same to me. according to wikipedia the difference is

"In contrast to the traditional technique of calling a program by name, message passing uses an object model to distinguish the general function from the specific implementations. The invoking program sends a message and relies on the object to select and execute the appropriate code."

Method invocation won out mostly because of Java and C++

but according to the wikipedia article java uses message passing.

supposedly the distinction is that i can have a generic method that gets called if a named method can not be found. in smalltalk that's doesNotUnderstand: in ruby it's method_missing. javascript used to have __noSuchMethod__, in php i can overload __call, in pike i do the same with defining a method called `(), and many more.

so are they all using message passing? and then if java is supposed to use message passing and javascript removed __noSuchMethod__ it seems that alone can't be the distinction.

if there is a distinction at all then it look more like an implementation detail that does not actually affect what kind of code you can write, and more importantly, based on that it is not at all clear that method invocation won out.

replies(3): >>42132608 #>>42133455 #>>42137340 #
9. nullpoint420 ◴[] No.42132219{3}[source]
Bingo. I'm tired of people claiming that macOS (XNU more specifically) is just BSD under the hood. It's called X is not Unix for a reason!

I feel like so much awesome engineering in XNU around security and portability, as well as innovations like IOKit are swept under the rug because "it's just FreeBSD."

I still think it's a shame that more people don't take advantage of the Mach side of XNU more. Launchd and Mach ports are a powerful combination IMO.

10. em-bee ◴[] No.42132261{3}[source]
see my comment above: https://news.ycombinator.com/item?id=42132104 i can't tell the difference and therefore i don't see what profound enlightenment experience i am supposed to have.
replies(2): >>42151321 #>>42229232 #
11. astrange ◴[] No.42132608{3}[source]
The difference is NSInvocation. A function pointer doesn't capture the arguments to the function, but a message does.

Also, you can change the destination of a message send at runtime, but you can't change the destination of a function call unless you're dtrace and can do code patching.

replies(1): >>42132712 #
12. em-bee ◴[] No.42132712{4}[source]
ok, so that means message passing needs a runtime, and it can be assumed that pretty much every language that has a runtime uses message passing. more evidence that it is message passing that won out.

and the profound enlightenment ( https://news.ycombinator.com/item?id=42130432 ) is not specific to message passing but about a dynamic language runtime. being able to intercept messages/function calls is just one of the benefits of that.

replies(1): >>42133600 #
13. kazinator ◴[] No.42133455{3}[source]
If the "message passing" implementation blows the stack when something sends a message to itself, then you know that they are calling function calls "message passing".

Bona fide message passing is asynchronous. A message is sent and the send operation immediately returns, without blocking for a reply.

Nothing else should be called "message passing".

replies(2): >>42135421 #>>42170548 #
14. astrange ◴[] No.42133600{5}[source]
Not sure if objc_msgSend is a runtime, but it does require malloc, so there are limits to how low level it can be.
replies(1): >>42170568 #
15. em-bee ◴[] No.42135421{4}[source]
i agree with that definition but then smalltalk nor any other language are using message passing for regular method calls because they are not asynchronous unless they use explicitly asynchronous methods.
16. bunderbunder ◴[] No.42137340{3}[source]
This is another example of where you've got to read Wikipedia with a skeptical eye. That one in-passing mention of Java is incorrect. I don't know why it's in there, WikiBlame indicates that it's been there since 2004, which was the early days of Wikipedia when it was particularly unreliable.

So, the gist of the difference is this: object-oriented programming is, at its core, about late binding. Specifically, delaying decisions about what code will run when until run-time. But there's still some wiggle room to decide how late certain decisions are made. Most mainstream object-oriented languages like Java and C# more-or-less wait until the start of run-time to decide, but at that point the mapping from argument type to which code is run is pretty much settled. (This isn't necessarily 100% true, but it's the general rule.)

In a system that uses message passing, it's pushed even later, to method invocation time. Basically, each object (actor, whatever) gets to decide what code will be executed to handle a message every time it receives a new message, even for messages of the same type. In practice, most the time it's always the same code. But the point is that this level of dynamicism is a first-class language feature and not just a thing you can accomplish with hacks.

replies(1): >>42145739 #
17. em-bee ◴[] No.42145739{4}[source]
i understand your explanation, but i still don't see how i am supposed to tell the difference as a programmer. to be a first class language feature it has to be something the programmer can see and use consciously. the only feature there is the ability to have catchall methods, but while the existence of such a feature is an indication that very late binding happens, the absence of it does not indicate otherwise. so it goes back to pretty much all dynamic languages with a runtime probably use message passing because they either do have such a feature or could have it. but i don't see that claim supported anywhere. everyone just seems to talk about how smalltalk is somehow different, but i can't see how it is different from javascript, php, pike or other dynamic languages.

and i believe what you say about java and wikipedia. it just shows again that the distinction is not obvious.

i found this discussion on stackexchange: https://softwareengineering.stackexchange.com/questions/3352...

but reading that doesn't help me to tell the distinction between java and smalltalk either. the point appears to be that all OO is message passing, and the only distinction as far as i can tell is that java doesn't have extreme late-binding of all things, but that is something i can't know just by looking at the language. it's a hidden implementation detail. not being able to tell how the message is processed is another feature that message passing is supposed to have, btw.

the stackexchange answer however also shows why i am not seeing any revelation when using smalltalk. if all OO is supposed to be message passing then it's no wonder, it all looks the same to me.

note that i don't want to argue either way. i don't know enough about this to make any kind of argument. and i am trying to figure out the right questions to ask so i can learn and understand more. your comment did help me move forward at least. thanks.

18. mpweiher ◴[] No.42151321{4}[source]
If you can't tell the difference, you didn't actually learn it.

Doesn't mean you have to like it, but they are different.

replies(1): >>42156273 #
19. em-bee ◴[] No.42156273{5}[source]
you may want to read the whole discussion following the linked comment to understand what i learned. if you have any additional insights i'd appreciate your input.
replies(1): >>42161058 #
20. mpweiher ◴[] No.42161058{6}[source]
What makes you think I didn't?
replies(1): >>42163197 #
21. em-bee ◴[] No.42163197{7}[source]
well, if you did, then can you please tell me what i am missing? i have written a decent amount if smalltalk code, and even held workshops teaching smalltalk to others. and i have written lots of code in many other languages.

i did see differences. the most awesome was when i wrote some code to respond to an http request, the code failed, the http request stalled, i fixed the code live, and then the http request resumed.

but i can do the same in pike if i tried, and i expect in lisp and other languages too.

and if that is the case then it supports my understanding that most OO languages use message passing. where then is the great revelation that comes from smalltalk?

replies(1): >>42170518 #
22. mpweiher ◴[] No.42170518{8}[source]
>> i can't tell the difference

> i did see differences.

Spot the difference. ;-)

> but i can do the same in pike if i tried, and i expect in lisp and other languages too.

Absolutely you can! You can even do it in C: write yourself a message-passing library in C. You might want to call it Objective-C. Or do a VM for Smalltalk.

> where then is the great revelation that comes from smalltalk?

The claim was not that the great revelation came from Smalltalk, but that it came from message passing:

>>> Message passing belongs up there with lisp, forth and pure functional programming as paradigms that are worth learning for "the profound enlightenment experience you will have when you finally get it."

Smalltalk isn't even mentioned in that little section about the enlightenment.

And in fact, Smalltalk's form of message-passing is pretty limited, it only just extends beyond method invocation and it certainly can be (and is) frequently used just like method invocation. If you want to do more sophisticated things, you mostly have to go via the DNU handler, which is a bit hacky.

And in fact, Alan Kay's famous OOPSLA '97 quip "I made up the term object oriented. And I can tell you I did not have C++ in mind." was followed immediately with the slightly less famous "So, the important thing here is: I have many of the same feelings about Smalltalk". https://www.youtube.com/watch?t=634&v=oKg1hTOQXoY&feature=yo...

And even message-passing is much broader: for example, with Higher Order Messaging, you can control how messages are delivered: to collections, on different threads, delayed, distributed (combine distributed + delayed and you get TeaTime/Croquet), conditionally only if the receiver understands the message, etc.

https://en.wikipedia.org/wiki/Higher_order_message

https://www.youtube.com/watch?v=GBtqQwcJoN0

And even that just scratches the surface. When you look at something like the Enterprise Integration Patterns, that's distributed asynchronous messaging, which opens up a whole other universe. Also: Erlang.

https://www.enterpriseintegrationpatterns.com

https://stackoverflow.com/questions/3431509/is-erlang-object...

replies(1): >>42171329 #
23. mpweiher ◴[] No.42170548{4}[source]
Nah...IMHO message-passing is a generalization.

The point is that it encompasses all of these things: synchronous, asynchronous, local, distributed, late-bound, early bound, point-to-point, broadcast, multicast.

And ideally, you should be able to select which kind you want on a case-by-case basis. With ease.

Rather than having to choose a different programming language.

24. mpweiher ◴[] No.42170568{6}[source]
> objc_msgSend [...] does require malloc,

Are you sure about that?

    ]pwd
    objc4/runtime/Messengers.subproj
    ]rg malloc
    ]
The two variants I implemented way back when also did not require malloc.

And of course NeXT used objc_msgSend() in the kernel, to good effect, so that's pretty low-level.

25. em-bee ◴[] No.42171329{9}[source]
thank you. so really the problem is that nobody seems to be aware that most OO languages are actually using message passing. unfortunately that results in that quote becoming meaningless because it tells people to do something that they are already doing, and then they wonder why they don't learn anything. it's like telling people that they need to add H₂O or aqua to their diet.

>> i can't tell the difference

> i did see differences.

Spot the difference. ;-)

well the first refers to the difference between message passing and function calling. which i couldn't see because all languages i worked with are using message passing.

the second refers to the difference between smalltalk and other languages, which owes to the particular implementation of smalltalk, and not just message passing.

in summary, you are confirming what i thought i understood. it appears i need to do the reverse and actually explore languages that don't do message passing to see the difference.

replies(1): >>42177918 #
26. mpweiher ◴[] No.42177918{10}[source]
> so really the problem is that nobody seems to be aware that most OO languages are actually using message passing.

That turns out not to be the case. C++ is not. Java is not.

Of course, many would say that those two are not object-oriented, so that way around you can make it work.

> which i couldn't see because all languages i worked with are using message passing.

That still is not the case. So your explanation for the contradiction in your statements also makes no sense.

> in summary, you are confirming what i thought i understood.

No, I am most emphatically not doing that, and what I've written makes that very, very clear. There is little I can add to that, I could only repeat myself.

Have a nice day.

replies(2): >>42179158 #>>42179190 #
27. ◴[] No.42179158{11}[source]
28. em-bee ◴[] No.42179190{11}[source]
That turns out not to be the case. C++ is not. Java is not.

i meant all the languages besides those. if you make a list of all known OO languages, most of them will be dynamic languages with message passing. C++ and java and a few others will be the exception.

> which i couldn't see because all languages i worked with are using message passing.

That still is not the case

do you know which languages i have worked with? which of those do not use message passing?

what I've written makes that very, very clear

well it appears we are talking past each other, and therefore it doesn't.

replies(1): >>42181028 #
29. mpweiher ◴[] No.42181028{12}[source]
> well it appears we are talking past each other, and therefore it doesn't.

Well yes, you've basically ignored everything I've written and then blithely claimed the opposite.

30. igouy ◴[] No.42229232{4}[source]
fwiw

'what matters about an object is its protocol: the set of messages that it understands, and the way that it behaves in response to those messages. Nowadays, this is sometimes also referred to as the objectʼs interface. The key idea is that when we use an object, we focus on how it appears from the outside, and “abstract away from” its internal structure: more simply, that the internal structure of an object is hidden from all other objects. Thatʼs why I said “the set of messages that it understands,” and not “the set of methods that it implements.” In many languages they are the same, but I wanted to emphasise the external rather than the internal view.'

"Object-oriented programming: Some history, and challenges for the next fifty years" Andrew P. Black

https://doi.org/10.1016/j.ic.2013.08.002

So, a matter of emphasis?