TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Subjective Charms of Objective-C

78 点作者 wmlive30 天前

14 条评论

jimbokun26 天前
Objective C was a far more elegant and powerful solution to the problem of extending C to be &quot;object oriented&quot; than C++.<p>The square brackets made very clear when you were engaging with SmallTalk style message passing semantics. But the language was still a full superset of C, allowing calling any legacy code you wanted. Or using C syntax for performance critical parts.<p>And for as much criticism as the language received, it was still the perfect fit for the original iPhone. Performance critical parts in C for the constrained hardware resources. But still allowed for rapid iteration on dynamic UIs for applications.
评论 #43728751 未加载
评论 #43729157 未加载
评论 #43729220 未加载
hgs326 天前
It&#x27;s a shame that Objective-C never really caught on outside of the NeXT&#x2F;Apple ecosystem. User interfaces benefit greatly from dynamism, and all the UI toolkits I&#x27;ve used for C and C++ try to emulate message passing in one way or another: from WinAPI&#x27;s SendMessage, to GTK and Qt&#x27;s signals and slots.<p>I&#x27;m surprised the wider FOSS community didn&#x27;t adopt the language. I&#x27;ve been building a GTK4 app recently, and the macro-heavy class boilerplate, C-style casting everywhere, and custom signaling mechanisms would all be far cleaner in Objective-C. It&#x27;s easy to imagine glib and GTK as what could have been a FOSS parallel to Core Foundation and Cocoa.<p>If you like C, then Objective-C is definitely worth a look. You don&#x27;t need a Mac to try it either [1].<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;gnustep&#x2F;libobjc2">https:&#x2F;&#x2F;github.com&#x2F;gnustep&#x2F;libobjc2</a>
评论 #43729622 未加载
评论 #43728451 未加载
评论 #43728516 未加载
评论 #43728601 未加载
评论 #43729057 未加载
评论 #43729551 未加载
评论 #43728518 未加载
评论 #43729118 未加载
JKCalhoun26 天前
A beautifully written piece.<p>And to some degree I echo the sentiment as well. While I was never in search of the <i>divine programming language</i>, I too felt that as Objective-C was being sunset and Swift was in ascendency, perhaps it was my time to also step out of my career — sunset myself so to speak.<p>Swift was something of a hard sell for me. It seem(s&#x2F;ed) to borrow everything from every popular language allowing two different code bases to look as though they might have been written in two different languages (depending on the preferences&#x2F;style of the two coders).<p>To be sure, a lot of the young engineers seem to have been drawn into the Apple ecosystem not because, like me, they grew up worshiping the user-interface brilliance of the Mac but because they are fans of the Swift language.<p>And like the author of the piece, I say, &quot;Knock yourselves out, kids. Sayonara.&quot;
评论 #43729260 未加载
VyseofArcadia26 天前
Having worked professionally with both C++ and Objective-C[0], I greatly prefer the latter. I&#x27;m not in love with either of them, but Objective-C feels so clean and well-thought out compared to the insanity of C++.<p>That&#x27;s ok, C++23 is going to add another group of features that will be half-adopted at best in legacy codebases that will totally fix everything this time for real.<p>[0] in the same codebase via the unholy chimera that is Objective-C++
msarnoff25 天前
The language is one thing, but the Objective-C runtime is brilliant. Read about the implementations of key-value-coding, key-value-observing, and bindings to get a sense of the bonkers things that have been done with it.<p>And ARC (automatic reference counting) blew my mind when it was first released. Rust was a blip on the radar, so the idea of automatic memory management, handled at compile time, without GC, was amazing.
HexDecOctBin26 天前
What a coincidence! I have been struggling to get Objective C going on Windows for a few days now to test out some ideas I had regarding a LINQ like language in C, and it&#x27; has been an ordeal.<p>The only worthwhile runtime available (that doesn&#x27;t depend of MinGW or some such) is libobjc2 from GNUstep. I decided to not use the full GNUstep Foundation since it is clearly bloated and reflects a very Java-esque sensibility of the 90s, not to mention it depends on third party libraries like libcurl and whatnot. However, it turns out that the root class NSObject is defined in Foundation itself, and you need a root class to get anywhere with the language.<p>Fine, I decided, I&#x27;ll write my own lightweight root class. That turned out to be so much more than I bargained for. In the end, I have one that supports manual reference counting and ARC (GC would&#x27;ve meant dealing with Boehm, one problem at a time). <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;forksnd&#x2F;264d80858ee98e6d44e89e8972c0b5f0" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;forksnd&#x2F;264d80858ee98e6d44e89e8972c0...</a><p>However, it is clearly not done. I can&#x27;t invoke an arbitrary method on an object through the smalltalk syntax (get compilation error) and trying to do it through objc_msgSend fails silently. I was just trying to get the method tracing working, but it seems like it requires pthread (so Linux only then?).<p>It&#x27;s insane how trying to get a minimal working workspace in this language is so difficult. No, I don&#x27;t want a huge framework, all I want is inline SmallTalk in C. No wonder this language never found any footing outside of Apple&#x27;s walled garden.
评论 #43728353 未加载
评论 #43729400 未加载
KerrAvon26 天前
Cold take: Objective-C was best appreciated by using Interface Builder back before iPhones, CoreAnimation, and autolayout. As Interface Builder became less useful and more painful, the dynamic nature of the language became a liability instead of an essential attribute.
评论 #43730072 未加载
pjmlp26 天前
In an kind of ironic way, my graduation thesis was to port a particles engine from Objective-C&#x2F;OpenGL into Windows 9X&#x2F;Visual C++&#x2F;OpenGL.<p>At the time my supervisor wanted to save the research done in 3D visualisation techniques with particles engine, developed on a NeXT Cube, and the Apple&#x2F;NeXT acquisation was yet to happen.<p>The department was ramping down their use of NeXTSTEP, was it was clear the OpenSTEP efforts were also not going to save the company.<p>Thus several students got to rewrite applications from Objective-C into something else.<p>Had they known what would happen with NeXT&#x27;s reverse acquisition of Apple, and OS X, most likely those thesis proposals would never happened in first place.
mistrial930 天前
&gt; Objective-C came up in the frenzied early days of the object-oriented programming era, and by all accounts, it should have never survived past it.<p>this is deeply uninformed, with bald prejudice added.
评论 #43688652 未加载
评论 #43729337 未加载
markus_zhang30 天前
Never used Objective-C or have done any serious programming (I work as a DE which mostly do data modelling, so I don&#x27;t consider myself a serious programmer), but I feel the same as the author.<p>The work has bogged down whatever interest I have in programming, and the only sane solution is to somehow magically remove all financial burdens, go into a cabin in a mountain, and program my own projects and read some science, preferably with a dog and a fire.
评论 #43730130 未加载
dmurray26 天前
<a href="https:&#x2F;&#x2F;archive.is&#x2F;DBalW" rel="nofollow">https:&#x2F;&#x2F;archive.is&#x2F;DBalW</a>
Simplestas26 天前
Distributed Objects &#x2F; XPC is genius stuff powered by ObjC. Nothing else comes close.
vaxman30 天前
I had read a book about Objective C in the 1980s and towards the end, was in with the Sybase crowd, so I did see NeXTStep (which had adopted it) back in its prime and instantly realized the potential --NeXTStep let &quot;business analysts&quot; visually create graphical database apps using pre-manufactured components written in Objective C (more than this really, there is also the concept of Responders which are like in-line services that can be arranged to create reusable value).<p>The problem Steve had with that nice ObjectiveC system was that the fools who ran Corporate America were from the generation that was still &quot;shell shocked&quot; from all of the vendor lock-in that went on during the wars between DEC, IBM, HP, Spurrows (Unisys) and smaller players like Nixdorf, none of which were software (or hardware) compatible with each other, meaning their customers were held hostage, often with incredibly expensive long term contracts on less than state-of-the-art machines. In the new Desktop era (that had just begun), for a short while at least, they wanted &quot;cross-platform apps&quot; that ran on universal hardware (think PC and Mac &quot;clones&quot;) and that meant using object oriented frameworks and the only OOP systems that were mature enough to have platform-specific GUI libraries for DOS, Windows and Mac were some interesting Smalltalk packages and some exotic C-macro based systems like Neuron Data&#x27;s Open Interface Toolkit and eventually Microsoft MFC (which was available for Classic Mac and all the versions of Microsoft Windows). Of course, as Windows took over the game, the need for cross-platform apps ended --just as Visual Studio, Microsoft FoxPro&#x2F;Access and Visual BASIC were cleaning up and really locking everyone in for the decade. There was no more need for object oriented systems like NeXTStep or Smalltalk.<p>But then the WWW became a thing and NeXT made a bold move with WebObjects, which allowed their ObjectiveC visual tools (Project Builder) to output HTML in realtime. About the same time, Sun Microsystems launched Java with a really terrible UX library, but the promise of the portable Java interpreter (which was similar to the promise of UCSD p-code back in Steve&#x27;s earlier Apple days) and that meant Java could &quot;run (ugly looking but portable) code&quot; in web browsers on any hardware. Oh happy days, a way to get back into Corporate America without the word Microsoft on your business cards. While the FIRST end of ObjectiveC is described in the article (before NeXT picked it up), Steve saw the potential to replace that ugly Java UX library with their WebObjects masterpiece and pivoted to rewrite WebObjects to output Java --and that was the SECOND end of ObjectiveC.<p>Somehow my Dad&#x27;s old colleague working with Rear Admiral Grace Hopper on behalf of CalPERS was able to bail the shareholders of NeXT and Apple out. But NeXT was all about WebObjects by then and you couldn&#x27;t run Macs with WebObjects (that would be a &quot;thin client&quot; which was a much maligned concept and offered no value-add for Apple), so that meant Avie Tevanian&#x27;s team had to hold their nose and fuse the stinking classic Mac operating system into NeXTStep, breathing new life into ObjectiveC.<p>As that post-NeXT Mac operating system was &quot;forked&quot; to make battery powered phones, the idea of allowing developers to write apps in ObjectiveC became a liability. Suddenly they had a class of &quot;fart apps&quot; that were draining batteries, closing unexpectedly, heating up devices in people&#x27;s hands, etc. --and to a casual user with limited computer experience, that looked like an iPhone problem. Apple had the incredible app-review process going on, but it&#x27;s not the correct prescription for curing stupid programming. They needed a solution like Java (being used by their competitor and embroiled in litigation involving Sun&#x2F;Oracle&#x2F;Microsoft&#x2F;Google) or even their old UCSD p-Code interpreter that ran Pascal, a language that had long been obsoleted by Ada, which everyone with half a brain hates. So..<p>&gt; The end came for Objective-C in June of 2014, when Apple announced the debut of Swift<p>I wouldn&#x27;t say that the THIRD death of Objective-C happened in 2014 nor is it upon us in 2025. Aside from a lot of existing code and performance reasons to use Objective-C, there is also the fact that the popular AI coder models were all trained on GitHub 2023 and the Swift code that&#x27;s out there is from six different versions of the language, mostly written by people who were just learning it (so it&#x27;s not leveraging Swift&#x27;s value prop much). Cross-platform Linux&#x2F;Mac code, like Moonlight for iOS, is also written in Objective-C (that had superior C++ integration than Swift until very recently). It&#x27;s possible to remove ObjectiveC from Apple&#x27;s product line, but it can&#x27;t be a priority given the industry move to agentic-apps.
ramesh3126 天前
One of the coolest parts of Obj-C is that it&#x27;s the only &quot;dynamic&quot; language that includes header files (AFAIK). This means you can use agentic coding tools way more effectively. Instead of having to shove the whole implementation into context, it can just work off the interfaces. Result is that even with just a few hundred K of context, the agent can reason about an entire large codebase. And because all interop between objects is based on interfaces and protocols, refactoring of implementations becomes trivial.