30 ms·
On Apple's Love Affair with Swift
- sheeshkebab 8y agoSwift is nice, although it’s too close to objc. I think it’s time for Apple (and Google) to embrace JavaScript as the app development language.
- thosakwe 8y agoWhy JavaScript, out of all languages in the world? I don’t think that’s a particularly great choice.
- jmpt 8y agoLarge headcount of developers. Everybody and their dog does Javascript.
- AsyncAwait 8y agoUs holdouts would like to have somewhere left to run to too.
- izacus 8y agoSo by that metric, Java is a significantly better choice still ;)
- scarface74 8y agoThere are all sorts of optimizations that are much harder to do in a non statically typed language. There are also all types of guaranteed safe automated refactoring you can do with a statically type language. I shutter to think about using a non type safe language with a large code base.
- DannyBee 8y agoIf that's your metric, java has many more developers (millions more, in fact).
- tabs_masterrace 8y agoJavascript is just a platform to run transcompiled stuff on these days, not unlike the name giver's JVM
- staticassertion 8y agoJavascript would not meet the 'fast' requirement, as expressed in the linked article.
- redial 8y agoThe only requirement Javascript meets is being included by default in web browsers.
- douglaswlance 8y agoJavascript is not a good choice. It's both verbose and unsafe.
- staticassertion 8y agoJavascript meets the 'safe' definition in the article - memory safe.
- spunker540 8y agoIt’s still fairly easy to have subtle memory leaks in JavaScript code due to the way closures can keep variables in scope indefinitely. https://blog.meteor.com/an-interesting-kind-of-javascript-memory-leak-8b47d2e7f156 https://blog.meteor.com/an-interesting-kind-of-javascript-me...
- dbaupp 8y agoMemory leaks are memory safe, or, at least, don't lead to memory corruption like other violations of memory safety. https://huonw.github.io/blog/2016/04/memory-leaks-are-memory-safe/ https://huonw.github.io/blog/2016/04/memory-leaks-are-memory...
- rmrfrmrf 8y agoApple already has with JavaScriptCore.
- scarface74 8y agoAnd what few people know, is that Apple already had a platform where all of the “apps” were written with JavaScript + TVML (a proprietary Apple markup language) - the 3rd Gen AppleTV. If I’m not mistaken, you can still write apps for the ATV4 that way. Plex was ported to the 3rd Gen AppleTV as an unofficial app just by running a server on your computer and redirecting DNS to it. https://github.com/iBaa/PlexConnect/wiki/Install-Guide https://github.com/iBaa/PlexConnect/wiki/Install-Guide
- tomwilson 8y agoYou can still on the current Apple TV. In fact if your app is just full of video content or similar then you probably should.
- scarface74 8y agoWow. That looks easy..... https://www.raywenderlich.com/372-tvos-tutorial-using-tvml-templates https://www.raywenderlich.com/372-tvos-tutorial-using-tvml-t...
- pavlov 8y agoChris Lattner writes: ”One of the best and most annoying things about Objective-C is that it has C in it. This has been hugely important for Objective-C in practice, because if you run into a performance problem with objc_msgSend, you can always rewrite that algorithm in C. That’s really, really, really important for Objective-C being successful in both in the days of NeXT on 16 MHz processors and also today for the low-level code that people are writing.” This is indeed a great thing about Objective-C: it’s an improved C with a tight set of runtime features that help build interactive applications. There’s a need for such a language, and I’m sad that so much of the rhetoric from Apple and the Swift community is working on the assumption that Obj-C should be completely replaced by Swift. Swift is not a compact language like Objective-C. It’s more like C++ in how it tries to incorporate every programming paradigm that can possibly fit. The heavy focus on complex upfront typing is not necessarily the best choice for iterative app development. Swift is useful in many places, but personally I found Objective-C’s “Smalltalk-flavored C” to hit a sweet spot for my GUI needs where integrating with C and C++ libraries is usually required all over the place.
- lmm 8y agoThose 16MHz processors were two or more orders of magnitude slower than anything anyone's running Objective-C on these days. Is there really a need for C any more?
- ziotom78 8y agoThis is true, but consider that today we are using computers fo to run tasks much more complex than 30 years ago. Rendering a complex HTML page with CSS and Javascript is an herculean and time-consuming task, which is why Firefox and Chrome are written in C++; and don't forget deep learning! Plus, low-level languages like C are sometimes the only way to go if you are writing for embedded systems with slow CPUs.
- pjmlp 8y agoOnly if one doesn't look into the right place. Mikroelektronika has Basic and Pascal compilers, in addition to C, for all those slow CPUs that are market relevant. https://www.mikroe.com/compilers https://www.mikroe.com/compilers And they aren't the only ones still alive.
- deleted 8y ago[deleted]
- twic 8y ago> I think that Swift is more interesting than Rust in some of the higher-level application demands, but we’ll see What does "higher-level application demands" mean?
- bluejekyll 8y agoI’m assuming they mean that Swift generally is easier to use with dynamic types than Rust. Rust has dynamic polymorphism like Swift, but Swift you opt-out with final (correct me please if I’m wrong here), whereas in Rust you need to promote to a trait object. This is a small difference, but means you’re starting with different principles available to you out of the box. Personally I prefer Rust’s opt-in to complexity model, but I can see why people see that as a hinderence, even if it’s technically just as possible to do in Rust.
- dep_b 8y agoExpressing business logic. Which is probably true (but I don’t have real Rust experience)
- pjmlp 8y agoThe memory management is more developer friendly and it doesn't get into the way like it still does in Rust, even with the upcoming NLL improvements, not all productivity use cases are covered, e.g. self referential references to fields in struct methods. Then there are Swift Playgrounds and REPL for quick prototyping and those still aren't a thing in Rust.
- makecheck 8y agoThere has definitely been this period of inconvenience where a language-in-progress started taking over all the blogs, became the default language for documentation and code snippets, etc. and even StackOverflow answers. And using Objective-C becomes surprisingly inconvenient with extra barriers to finding help because lots is changing in Cocoa APIs too, etc. during the time that Swift wasn’t fully baked.
- saagarjha 8y agoBut it’s pretty easy to translate between the two?
- makecheck 8y agoTo a point perhaps, and at least the official documentation can toggle between them. After the Great Renaming though, things start to look different and reading something like a code snippet is just a lot of mental translation.
- sandbags 8y ago"It’s really about taking the best ideas from where we can get them and assembling them together." ~ Chris Lattner I think this is the root of my dislike of Swift. "Assembling" together the best ideas, which may only be 'best' within a specific context does not suggest the kind of design principles I am looking for in a language. I was looking for a quote and it seems it was Antoine de Saint Exupéry who said something like "It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to remove." So I contrast Lattner/Swift with Hickey/Clojure: a small set of coherent design choices that lead to a language that is simple but deep. It's by no means all things to all women and that's a good thing.
- sandbags 8y agoI should add I am not trying to make a comparison between Swift & Clojure but between what I see as a fundamental difference in the design principles that lead to those languages and why they might matter.
- wild_preference 8y agoClojure clearly assembles various ideas as well, so your criticism is only effectively leveled at a quote from Lattner which feels very superficial. Surely every language designer including Hickey thinks they are assembling the best set of features for their goals.
- sandbags 8y agoI guess I am struggling to get across what I mean. I see Hickey as having a specific, focused, goal about enabling simplicity (given his specific meaning for that word) and yes I totally agree that every designer, including Hickey, does as you say. What I was trying to get across was that I don’t see the guiding principle that guide the selection of those “best” features to include so much as “there’s this great stuff” that we must include. Does that make more sense? Or should I put down my shovel?
- bgongfu 8y ago
- jmpt 8y agoAll women? What's your point there?
- johneth 8y agoWhat's yours?
- jmpt 8y agoMy point is that society is drilling people in the head 24h a day to be gender neutral and then SJWs make the point of using feminine forms to fight sexism with sexism. That's my point. Enjoy your avocado.
- m_b 8y agoOh please, just STFU lil’ broflake we aren’t interested in your pov.
- deleted 8y ago[deleted]
- stukh 8y agoIronically, your question is the point.
- cube2222 8y agoWell said, to the parent: https://www.phrases.org.uk/meanings/29250.html https://www.phrases.org.uk/meanings/29250.html There's a phrase "all things to all men", he/she just decided to swap out men with women to achieve more gender equality. He could've just said all people tho. (EDIT: to the replies, I'm not saying it has been achieved, just that this was the probable intention, which wasn't obvious to me as a non-native speaker)
- jmpt 8y agoYea, "all things to all people" is really hard to type. Also "he decided?" You have no idea if the OP is a he. You are part of the problem that the OP is fighting poorly.
- AsyncAwait 8y agoTo me, Swift is an ideal blend of FP/OOP for application programming. A lot like Rust, but higher level. I understand that it's not for everyone, (Objective-C isn't going away), but I really think this is the right design approach modern languages should take.
- protomyth 8y agoThey could have at least kept the clean messaging syntax of the Objective-C (Smalltalk). The hybrid they chose was just painful. Plus, what is this fascination with the comma. Adding commas has been a pain when trying Swift as I am constantly skipping them. They could have cleaned up all Objective-C and built a much nicer language, instead we get a improved Java / C++.
- saagarjha 8y agoWhat commas are you talking about?
- protomyth 8y agosomePoint.moveBy(x: 2.0, y: 3.0) as opposed to [somePoint moveByX: 2.0 y: 3.0]; most Objective-C code would get rid of the space too [somePoint moveByX:2.0 y:3.0]; Its just painful to type extra characters that don't do anything and don't help readability. Plus the weird splitting of the moveByX is still odd. I still am mystified why they didn't just start with: somePoint.(moveByX: 2.0 y: 3.0) to keep it inline with Objective-C and start working on giving the method names an overhaul that would benefit everyone including the Objective-C programmers.
- deleted 8y ago[deleted]
- batteryhorse 8y agoThe ones in between the arguments. The beauty of sending a message to an object has been replaced with a function call with a horrible syntax. I guess that's what makes Swift a modern language.
- spenrose 8y agoThis is awesome: watch Lattner reverse the meaning of "working fast" to say that the way to get something working fast is to prevent it from working at all until you chase down all the corner cases. Slow is fast! Refusing to compile is working! Up is down!: -------------- Swift ... really is designed and optimized for, as a programmer, you can spend the least amount of time to get to a working program as fast as possible. Getting to a working program includes the time it takes to debug something, to iterate and develop and fight the type system, and all the other things you have to do. But that time you spend having to fight the type system or figure out optionals or things like that pays itself back because your program works more often. You’re actually not spending time chasing own dangling-pointer bugs
- flipgimble 8y agoLattner takes "working" software to mean something that can be shipped to production and used in the real world, as opposed to the classic "works on my machine" definition that second rate developers hide behind. It takes a certain maturity and experience shipping to recognize the long term benefit that approach. As the head of Apple developer tools (at the time), his job is not to cater to the hobbyist working on his fun software project, but improve quality of software on his company's platform.
- spenrose 8y agoIf you remove the value judgments from your comment, you and I are saying the same thing. Many developers say they want to "get something working quickly", where "working" means "executing and performing some simple I/O, etc". Some developers don't value that stage, and prefer to develop until a piece of code is ready for wide-scale production. And that difference in values is just fine. Lattner used rhetorical slight of hand to assert, in effect, "you 'working quickly' developers need first to adopt my values; only then can you be admitted to the conversation." C.f. Yegge on liberal-vs-conservative developers. [1] Lattner (along with you) is adopting a position towards the conservative end of the spectrum, which is cool. What's not cool is gaslighting the existence of a liberal perspective. [1] https://plus.google.com/u/0/110981030061712822816/posts/KaSKeg4vQtz https://plus.google.com/u/0/110981030061712822816/posts/KaSK...
- vilhelm_s 8y ago> There’s a number of things that rolled out over the years, and it was really funny at the time because the Objective-C developers externally and even internally to Apple always accused the compiler and language team of taking Objective-C on this random walk, and they didn’t know how it all fit together, and where’s the strategy, and why are you guys working on this and why aren’t you working on some other syntactic sugar that I want? Of course, we could never tell them, but there was a good reason. Here it seems like Apple's culture of secrecy just hurt them for no reason. No really, Apple, you can just tell people what your plan is.
- mamcx 8y agoTo me, the thing that will make swift the ideal language is solid support outside the Apple ecosystem: https://www.reddit.com/r/swift/comments/8zb9y1/state_of_swift_for_androidlinuxwindows_on_2018/ https://www.reddit.com/r/swift/comments/8zb9y1/state_of_swif... I'm playing with rust to solve my use case, but is certainly hard. Is very unlikely you can build a team of mixed developers and use it. Swift is more forgiving, yet you can get great results anyway.
- m23khan 8y agogoogle’s push for kotlin and apple’s push for swift seems like ego-ism and aiming for glory to me. What new does kotlin or swift offer which python or ruby can not? Why reinvent the damned wheel for syntax sake when they could have worked for their device centric compiler for creating binaries out of python or ruby?
- Matthias247 8y agoPerformance. Concurrency. In Google/Kotlins case compatibility with existing Android APIs and a very low adoption cost.
- jzoch 8y agoThose languages dont have many of the features that both apple and google were going for when creating these languages, so why would they use them? For example, python isnt statically typed, nor is it typically compiled. Can you do these things? Yes. But it isnt the normal way its done, and is bolted on as an afterthought. This is just a superficial example but it goes much deeper. They have a set of needs and these languages fulfill them. Google didnt even make Kotlin, so why is that ego?
- bjt 8y agoGoogle didn't write Kotlin. Maybe they're aiming for glory with Go or Dart, but their adoption of Kotlin feels much more like humility than ego-ism to me.
- solidsnack9000 8y agoKotlin and Swift are in a different family of languages from Ruby and Python. The whole family that Kotlin and Swift are in — static languages — offers much better performance and error detection than the family Ruby and Python are in. Compared to Ruby and Python they doubtless seem a little verbose. Type system features like genetics, which help to make Kotlin and Swift “expressive” in their family of languages, seem pointless from the standpoint of Ruby and Python. So there are two aspects to this: * What makes Swift or Kotlin compelling relative to other languages in that family? * Why use that family instead of languages outside it like Ruby and Python? People have been promoting dynamic languages as an alternative to static languages for many decades but it doesn’t seem like performance has ever truly caught up enough.
- Froyoh 8y agoI thought you were Stefan Esser (https://twitter.com/i0n1c https://twitter.com/i0n1c) for a sec
- amaccuish 8y agoThe podcast itself: http://atp.fm/episodes/205 http://atp.fm/episodes/205
- lerno 8y agoI find myself wondering how many Swift converts actually wrote Objective-C like it was supposed to. I’ve run into a lot of programmers that worked with ObjC as they would Java or C++, that is, using very small and fine grained objects to divide up the problem. It’s the standard way in Java. It’s also the opposite of how ObjC is supposed to be, which is ”a few big classes” that uses message passing as glue. How many former ObjC programmers actually heard of ”Software IC”? Using ObjC like Java/C++, the language quickly becomes unwieldy and verbose. If you do that, then obviously Swift feels like a huge improvement. On the other hand, if you essentially write C and let ObjC be your reusability layer, then Swift might feel like you’re back to working inefficiently in Java / C++ with objects all over the place.
- batteryhorse 8y agoI definitely agree with you. The way that I write Objective-C is to use 'id' for everything and have as few classes as possible, mostly I just add methods to the existing classes mainly NSString, NSArray, and NSDictionary. Objects are interchangeable as long as they can respond to certain messages. For example, any object can be an array as long as it responds to objectAtIndex: and count. There was a whole discussion above about how Objective-C doesn't have generics, but this completely misses the point because Objective-C doesn't even need generics. "Modern" languages are not necessarily an improvement, software generally does not get better over time, it reaches a peak then it declines. Objective-C is one of the best languages I have ever used, but the vast majority do not understand it, even the ones who say that they used to write Objective-C for X amount of years but now love Swift. The truth is, they never understood the beauty of Objective-C. I consider Swift to be a language for large teams of average programmers, reading Lattner's response to Swift's criticisms tells me that he is a compiler guy, but that expertise does not carry over at all to programming languages. I don't really like the direction they were taking Objective-C anyway, so in the end it doesn't matter. I'm against things like dot notation for accessing properties and ARC, I don't use either when I program in Objective-C. Those recent changes end up making the compiler more strict and a pain to deal with.
- lerno 8y agoInterestingly generics seem to drive the addition of type inference in order to avoid having to write too complex types, losing the self documenting nature of the static type, but still not avoiding the problem entirely. Consider the types of some template generated pointers, or just something like std::unique_ptr<std::vector<std::shared_ptr<Foo>>> (which isn’t a very far-fetched example). This is ”the generics problem”, where it actually starts having an obscuring effect. ObjC is immune to the problem since it lacks any need to do do the specialization. Unlike Java where you needed a lot of manually inserted casts without generics, ObjC doesn’t need them at all. Like you say, dot notation, ARC, stricter resolution of dynamic messages etc were weakening the strong points of the language and would push the programmer towards a Java-like object model - which is very far away from how the language ideally should be used.