Apple’s use of Swift and SwiftUI in iOS 15
blog.timac.org
blog.timac.org
Xcode, of course is a big wildcard. Often times I find myself spending more time just fighting with the IDE than getting any real work done. Maybe I’m just used to Visual Studio, but Xcode has some really baffling design decisions or omissions that never fail to confound me.
SwiftUI is really cool and it’s really simple to string together some pretty UX. I really like its approach to data binding and sharing. It makes it really easy to share models across many different views with minimal fuss. That being said, it still feels immature with its out of the box controls. Just the other day I found myself wanting a simple wrapping horizontal stack control only to find nothing like this was provided out of the box. Layout can also be really frustrating - getting things where I want them is often very fiddly.
Swift itself is also quite nice - although it’s evolving really, really fast and tutorials/howtos and such go stale really quickly. Swift can and will drop language feature at the drop of a hat. Just today I wanted to do a simple C++ style for loop only to find this was removed completely from the language.
I’m also perpetually frustrated by the terseness or incompleteness of Apple’s docs. I would prefer to read docs rather than watch hours of WWDC presentations just to understand how something works but that seems to be the best way to get this information.
Is that what you need?
I eventually found a package on GitHub called WrappingHStack that did exactly what I needed but this struck me as odd that something like this wasn’t out of the box functionality.
I don't know what you mean by "and similar content" but even though I agree that Apple's own documentation could be a lot better (though it is gradually improving), there is an enormously vibrant and flourishing ecosystem of learning materials at all levels, including people like Paul Hudson's Hacking With Swift (with website, tutorials, videos and books), Sean Allen (with YouTube videos and extensive Teachable tutorial courses), expert and in-depth discussions on SwiftUI from the programmers on pointfree.co, other in-depth resources including weekly video tutorials and books from the amazingly smart Chris Eidhof and Florian Kugler at objc.io, video tutorials and in-depth articles from Bart Jacobs at cocoacasts.com, not to mention the very advanced blog-posts from John Sundell at Swift by Sundell.
There are probably hundreds of other blog-resources - definitely more than I can keep up with on a weekly basis.
So lack of learning resources is definitely not a problem for Swift and SwiftUI if you just use some initiative to find it.
PS: people here often mention raywenderlich.com but my own experience is their content often boils down to "for networking use this external library..."
Coming from C# you should feel right at home (though the documentation seems better).
If I compare the C# code I was writing 12 years ago to the current one, it feels like 2 different languages.
For contrast, Swift will drop support for features that can render old code samples useless. I’ve written code fails to compile with an error literally saying what I am trying to do was removed from the language in version X. Things like that can be aggravating for a newbie like me to deal with.
PHP in the late 90s did it right (and probably still does today), ruby gets it mostly right, although it, like python, somehow still hasn’t figured out how to get Google to rank the most recent version higher than the one that’s a decade out of date.
The popularity of video tutorials is baffling. Is it because it’s the only way to earn money with this content? Anyway, I’ll just add the observation that the three communities that seem to really embrace the format are QAnon, “men’s right’s”, and WordPress.
And yes, versions, as you said. I don't like moving targets. I enjoy stability. Java changes, but it at least does so carefully and doesn't drop features (but does sometimes drop obscure parts of the standard library). You can usually compile and run Java 6 code unchanged with JDK 17 just fine.
I like it when there's a clear line between the language itself and its standard library. Swift doesn't have one, neither does Kotlin.
Well, it is a new language
>I could see the field I needed in the object in the debugger, but for the life of me couldn't figure out how to get it.
I would need more context to help you out here. You had SomeObject with a child SomeChild and couldn't do
let a= SomeObject.SomeChild ? Perhaps I'm misunderstanding.
>I had to write some really weird `if let ...` thing that would extract those fields into local variables that I could then use.
Sounds like this is importing from some file or something, and whoever wrote the code below you just made everything optional and chucked all the responsibility for that up the chain. I'd have to see the code but it sounds like bad design.
>Also, immutable everything by default. You can't overwrite function arguments within the function itself, like you could in Java and C++. And unwrap, unwrap, unwrap, unwrap, unwrap everything.
That's a feature not a bug. Maybe I'm misunderstanding you, but if you have
func twoStrings(a: String, b: String) -> String, _why on earth_ would you ever want to be able to override that func's params and feed it something else? a/b would be a completely unexpected type and blow up/fail to compile. If you're routinely needing to do this, you haven't embraced static typing I think. Swift Generics are a potential option.
I think that dev called that "enum case with parameters" or something similar. Don't really remember at this point.
> _why on earth_ would you ever want to be able to override that func's params and feed it something else?
No, I meant overwriting function arguments within the function itself to avoid rewriting the code below that point. I do sometimes do that in Java and I find it a sensible thing to do. For example
public String doSomethingWithTwoStrings(String a, String b){
if(some condition){
a=something else;
}
// do something with (possibly overwritten above) a and b
return result;
}
I'm used to treating function parameters as pre-populated local variables. Swift compiler gets in the way and doesn't let me do that because immutability. Comparing with Java, it's as if everything is `final` by default.This is just my opinion but doing that seems to be very dangerous. You're probably fine for small functions with single-developers, but once you get complex and have multiple people working on the code it seems easy for one dev to confuse another.
If you insist on that pattern (lets call it the local variable method) you can define vars such as
var localA = a
var localB = b
at the top of the function and work on it there. Personally I prefer function arguments to be immutable, so that any time you call them you know what you're working on is what the function was given. Forcing you to declare a local var makes the code much more explicit and easy for another human to reason about what you're doing, whereas they could very easily miss an "a=something else".
E.g.
enum Animal {
case lion
case tiger
case bear
case ohMy(Int)
}
The case `ohMy(Int)` means that it has an associated value so when you want to get at it from a variable, say: var a:Animal
switch a {
case .ohMy(let value):
// do something with `value`
...
}What are you talking about? Swift has had (and still has) basic for loops since 1.0. What am I missing here?
There were plenty of alternative ways to accomplish my scenario but they ended up being pretty clunky and overly expressive for what I was trying to do at the time.
It seems like the Swift language designers have no qualms about removing language features and breaking old code as a result - which is certainly their prerogative but it’s not something I’m accustomed to.
What production code was even using swift back then? The vast majority of people didn't _start_ using swift until 3.x.
I know we're supposed to take the best-possible interpretation of someone's comments here, and in my opinion a joke is the best possible take on the above post. The alternative is you're being disingenuous.
I’ve said before that Swift is a relatively new language to me. I’m not up to date on its many “evolutions” or particularly familiar with its history and nuances. I am not even sure what Swift version I’m on right now other than “whatever the latest version of Xcode uses”. I’m just trying to learn the Swift/SwiftUI stack by writing some code for MacOS and iOS as part of a hobbyist project that I’m working on during my downtime.
When I was trying to do something that’s worked fine in many other languages the Swift compiler literally told me “no” because it had been removed from the language in version X. I mean whatever - I found how to work around this - it was a kind of clunky and overwrought one versus the simplicity of the original code but it met my needs and it was a teachable moment.
My overarching point originally wasn’t meant as a hard criticism of Swift. I’m fact I quite like it. It was an observation that Swift is unlike other languages I work with regularly where it’s rare that language features are ever removed (or at worst hidden behind compiler or feature flags).
Swift’s designers clearly think it’s ok to remove things they don’t like or they don’t think meets their vision. That’s fine and valid. My point was that as a result of this stance that means tutorials and samples can become stale in a way that I don’t see with the other languages I work with where you’re more likely to be using old methodologies or obsolete APIs - that can/should emit compiler warnings or IDE refactor hints - but otherwise won’t fail to compile because something was removed completely.
The port of Swift to Windows barely functions and in every dimension is in worse shape.
It's a shame b/c the language is truly beautifully designed.
It does though. As least for me. Better support on Windows and Linux would increase the number swift developers which would the in turn result in more and better open source libraries.
For Apple this could mean that their own open source libraries could get better, they have more tools/libraries to choose from, or simply that they have a greater pool of talent for hiring.
Looking at Go (and Rust) I think this is somewhat shown. There are a lot of different factors, but I think the development tools of Go is the #1 reason why it is basically the only "new" language in a long time that gained a large enough popularity to become mainstream - as in you actually find jobs developing in Go. Which is in some ways sad. It seems like Swift could be the very good fit for backend/serverless development.
I guess the real question is how much effort would it take to get the development tools like editor support to the next level?
I have programmed for the last 4 years or so almost exclusively in Swift, but I am now switching to TypeScript in general. Writing my libraries in TypeScript, I will still be able to access them from Swift and other languages via embedded browser engines.
Because it's useless save for a single kind of development (websites) and the main issue is not even in spitting out WASM but making the language runtime and libraries work in the browser. Most languages have no first-party WASM or Typescript support either.
You are right, Apple has no interest in supporting Javascript, what good would it do them except more work and hassle?
It would help many programmers though, to make their code more portable and available on more platforms. It would not be that easy to do, but also not that difficult. Rust is supporting WASM, Scala is supporting Javascript. Kotlin as well. Apple can't do it? Come on.
Just stating the obvious: The interests of Apple and programmers are aligned in some aspects, and opposed in others.
I have since moved away, but current company wants to move from RN to Native dev so i'm confused if i should be onboard with mobile or move to other dev teams.
I find it weird how big companies like Microsoft and Apple have these small flaws. Apple has really bad docs, but good in using its own tech. Microsoft on the other hand has good docs, but almost never uses its own tech (yes, i'm talking about xamarin).
Worst part of it is the lack of a full open source stack and build speed / xcode stability for swift, but its not bad if your just 1-5 engineers in one app. But if you scale to 30+ with +1 million lines after a few years it starts getting real bad unless you architect your app with devapps like airbnb did: https://medium.com/airbnb-engineering/designing-for-producti...
Swift is its own language and libraries, but I can't seem to find stuff in apple's website. I remember many times I am literally stuck, don't know where to read the definition or how to do stuff, then I end up having to ask people in reddit / SO. I actually still find people constantly complaining about the the docs in reddit every now and then.
Docs is really really important, having developed with laravel, moved to django, and react for FE, I just realise that their docs are really really good
1: By exists I mean a public API. Even some APIs that aren't intended to be used by applications have documentation. Eg: RtlGenRandom.
It has always been comprehensive.
The problem I have found lately is some of the more esoteric stuff seems to have disappeared. That and the urls changing and poor SEO.
That much is fairly true now though. It just doesn't make sense to build an enterprise app that is windows native and can't run on any other OS/be accessed via web.
I know that the docs were so bad, that one chap wrote this site and app: https://swiftui-lab.com
They are really nice.
Actually I think it was more of a strategic move to "own" mono runtime and provide a starting point for Visual Studio for Mac (which is anyway being rebuilt).
The fact that Xamarin is now trying to be Swing for .NET 7, and still failing on Linux (if the community wants they should build it), and on macOS (using Catalyst instead of proper Cocoa APIs), doesn't seem it is getting that much love overall.
Specially now apparently we should all be using Blazor either directly on the browser, via Electron or WebWidgers as per their own marketing.
In the end it boils down that there are many UI teams, each of them trying to make a point of still being relevant to managment while fighting for resources.
89% are using Objective-C
17% are using C++
13% are using Swift
8% are entirely written in C
2% are using SwiftUI
Objective C looks healthy.
I think a language that's simultaneously productive at this two extremes is impossible, but it was their goal.
[1] https://developers.slashdot.org/story/17/01/23/085232/slashd...
“In short, I would NOT say that Swift is an extremely compelling systems programming or scripting language today, but it does aspire to be great for this in the years ahead.”
Jan 2017
I can see it as a backend/systems language. It is not a scripting language.
The issue is the stewardship of the ecosystem.
The fact the Foundation library is closed source is a complete joke in this day and age.
Apple’s lack of effort towards fostering a broader community for its language is a comedy of errors.
A Swift developer will spend much time dealing with undocumented closed source packages.
It’s almost comedic how retro it is. It’s like coding in the 1980s.
Foundation is open source https://github.com/apple/swift-corelibs-foundation
> Our primary goal is to achieve implementation parity with Foundation on Apple platforms. This will help to enable the overall Swift goal of portability.
The Apple versions of foundation have to be compatible with the Foundation/CoreFoundation equivalents. They also have more than a decade of binary compat to maintain
And Foundation itself isn't written in Swift, a good portion is written in C.
> A significant portion of the implementation of Foundation on Apple platforms is provided by another framework called CoreFoundation (a.k.a. CF). CF is written primarily in C and is very portable. Therefore we have chosen to use it for the internal implementation of Swift Foundation where possible. As CF is present on all platforms, we can use it to provide a common implementation everywhere.
https://github.com/apple/swift-corelibs-foundation/blob/main...
Swift needs some work to get there. There are a huge number of gaping holes, but these would be a start:
- scripting: a native RegEx literal type
- systems: replace Codable with something easier to use/more performant
- systems: better logging interface
Edit: formatting
On the other hand, the Smalltalk model would not have worked for SwiftUI. It really feels like Apple has bet the farm on the next generation of libraries/frameworks.
Or at the very least, use Swift + UIKit rather than SwiftUI.
Apple is writing 'more Obj-C' because it's their incumbent language, and they are 'writing a lot more software'. As the basis expands, it's going to expand along the normative vector, which is ObjC.
But for outside devs, Apple has almost frozen ObjC in favour of Swift, and Swift is 100% the future for apps built for iOS/MacOS.
Even externally, ObjC will probably be supported for a 'very long time' and maybe even perpetually at this point, it's really not the future.
Internally, the sands have not shifted, but I suggest that within about 5-7 years Swift will be on even footing with ObjC even within Apple.
So if you're an Apple focused Dev. not working for Apple ... then Swift is probably your #1 focus with a 'Healthy Knowledge' of ObjC - at least enough to access arcane and un-ported APIs as a nice thing to round out your skills.
ObjC is losing popularity, it will be a 'well supported' niche language going forward. You can probably bank on your ObjC skills for a long time to come, but in a more narrow range of opportunities.
In my experience, Apple doesn't even have to freeze anything because the iOS developer community (outside of Apple) is full of proud Early Adopters. Sometimes it feels like a race to use the latest tools on day one. I haven't seen anyone looking for ObjC developers from the day Swift was announced.
Modules that are complicated and not broken, are extremely expensive to fix esp. when they need to develop new stuff.
Legacy and backwards compatibility have a way of keeping things around.
It’s not in maintenance legacy mode. It’s thriving.
My bet is that even then, most ObjC use is due to legacy - most of those binaries are probably related to apps that are already in ObjC.
I looks like they plan to keep it around for the foreseeable future, but I wonder if it will mostly be eventually replaced by Swift for new starts.
Within 5-7 years Swift will rival ObjC within Apple, and from then on it's hard to tell.
There are no foreseeable plans to rewrite the OS, and so ObjC has to stay around, but that's in a clearly limited capacity.
[1] https://www.benfrederickson.com/ranking-programming-language...
But Metal will eventually be re-written. Not for a while, but eventually.
Objective-C will be just the same at Apple, specially since their creators decided to go search for other adventures outside Apple.
Very few companies can.
It will be worth looking at the stats again in 2024, 10 years after Swift was introduced.
I would be weary of any team who decided to rewrite an OS in an emerging language.
/System/Library/PrivateFrameworks/CloudKitCodeProtobuf.framework/CloudKitCodeProtobuf |Swift
https://blog.timac.org/2021/1219-state-of-swift-and-swiftui-...For a Swift-first app or binary, there are a few reasons that you might see ObjC as part of the binary:
- easier interop with ObjC
- Xcode code generation (CoreData, Intents, etc)
- legacy code (no real benefit to rewriting if it works fine with Swift)
I’d expect most Swift-first binaries to have even a small amount of ObjC for one of the reasons above. I’d also expect that binaries already containing ObjC would rarely drop it, even if new development is done in Swift.
it's still a apple frontend PL only. There are absolutely no story for cross-platform development, not even business logic (foundation on android is non-existent).
After 18 months developping a first version of an app using swift ( for optimal performance and OS integration) i am now investigating more seriously the different options for reusing the maximum amount of code, and so far the result is : 0.
0 code reuse in today's world is absolutely unbearable. I'm at the point where i'm seriously thinking about tools for automatically converting the code to kotlin.
https://www.swift.org/ > a programming language to empower everyone to turn their ideas into apps on any platform.
https://www.swift.org/about/ > the best available language for uses ranging from systems programming, to mobile and desktop apps, scaling up to cloud services
> a web-based REPL can when working with Linux server-side code
> it is now free to be ported across a wide range of platforms, devices, and use cases. Our goal is to provide source compatibility for Swift across all platforms ... extend the cross-platform capabilities of Swift ... source compatibility for Swift code across all platforms ...
> Open-source Swift can be used on Linux to build Swift libraries and applications
> We’d love your help to bring Swift to even more computing platforms.
Apple used an 100% in-house solution but with the official long-term of having it run on the widest range of platform, and an open-source model. In reality, the language is driven toward things nobody gives a damn (swiftUI would have been almost just as good without the syntax sugar), whereas the official initial goals don't have any steam from Apple.
Which is yet another reason why clang is now lagging behind the other compilers, for Apple C++17 is good enough[0], and all other contributors don't seem to be in a hurry to contribute C++20 features to upstream.
[0] - IO and driver Kit use the embedded C++ subset, whereas MSL is a C++14 dialect.
I'm a little bias because I really like Swift as a language but Vapor is growing and there are lots of plugins to fill the gaps.
I'd love to see sourcekit-lsp (the swift lsp) to further develop. Though last time I checked it wasn't exactly usable day to day.
(add-to-list 'exec-path "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin")
(use-package lsp-sourcekit :ensure t :after lsp-mode :config (setq lsp-sourcekit-executable "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"))
(use-package swift-mode :hook (swift-mode . (lambda () (lsp))))
The good news is that server side on Linux is still working well, Vapor 4 is solid, growing and looks like it has a bright future and Perfect is still going too, though Perfect seems disjointed from the main community. IBM's Kitura and involvement with Swift is over though. Server side seems like it's best future right now, since it's more performant than Javascript and uses less cycles, which can have a lot of cost benefits.
Static site generation looks good too, Publish by John Sundell being the most famous (https://github.com/JohnSundell/Publish) but a lot of others have started springing up lately.
"Swift for Tensorflow" by Google has been shut down. Though that was mostly Google giving advice on how to evolve Swift to work better for ML. It's a shame too, since it felt like Fast.Ai was adopting it and starting to teach it at one point, so the shutdown felt a bit premature, but this is Google after all, shutting things down is what they do.
Swift 5.0+ seems to have stabilized the language quite a bit too(ABI Stability and other things), which is a good thing, as hopefully the tutorials/docs from now on should remain more consistent. The built in package manager "Swift Package Manager" seems to be working better too, though there are still a lot of complaints/missing features, but on the whole I like it.
Swift on Linux seems to be officially supported by more flavors of Linux than it used to be. Meanwhile Swift on Windows works right now but I wouldn't use it in production yet, it throws errors that are the sort that if you ask anyone they will answer "that's normal, ignore that". Some have even gotten modern Swift to run on older MacOS's leveraging LLVM.
Swift WASM seems to have had a big update with Swift 5.4 https://forums.swift.org/t/swiftwasm-5-4-0-has-been-released... though I've not yet tried it having given up on Swift WASM about a year ago.
Youtuber Stega's Gate(https://www.youtube.com/channel/UCBXFkK2B4w9856wBJfCGufg) is building a cross platform game engine in swift.
IntelliJ has a decent alternative to Xcode now too, using Clion with an app made by them(though it's still not as integrated as Xcode, nothing would be).
Getting it to run on android is technically possible, but the workaround it too much, but that's mostly on Google actually, since the support for writing things in C for Android is so depreciated it's a joke.
The Docs are still terrible though, have been to my knowledge since 3.0 became outdated. That said the official books are alright and there are tutorial communities that are pretty good too, but it's shameful that the docs should be that useless.
So yeah, Swift is nearly viable for non Mac things, but there aren't much for libraries outside of backend. Some are tinkering and making cool stuff, but at times it's difficult when even the non app related programming tutorials for those are like "let's do it on MacOS using Xcode".All of that said, it's my favorite language, I want it to have a community similar to Rust's but I don't think Apple supports it the right way for that happen, they seem ok with it staying inside their ecosystem, like they are ok if the community does stuff outside of it, but they aren't helping it or encouraging it, is the general feeling. Ironically I was recommended to Swift initially because of the community that it had at the time, the caveat being "if you want to make apps for Apple's ecosystem", which isn't terrible, but it's not what I want. I'll probably give up on it if it doesn't change in the next year or so and go all in on Rust is likely what will happen, but again it's a shame.
https://old.reddit.com/r/rust/comments/7qels2/i_wonder_why_g...
tl;dr it has nothing to do with the relative merits of the two languages
---
Edit: I watched a couple of Lex Fridman podcasts this week with Chris Lattner (creator of Swift) that I thought were interesting
Chris Lattner: Compilers, LLVM, Swift, TPU, and ML Accelerators | Lex Fridman Podcast #21
https://www.youtube.com/watch?v=yCd3CzGSte8
Chris Lattner: The Future of Computing and Programming Languages | Lex Fridman Podcast #131
What a great statement!
Even so, a C Audio API like AudioGraph was deprecated a few years back and its replacement, AVAudioEngine, is Objective-C/Swift.
The skills that you develop while working with one of these platforms, the familiarity you develop with the libraries, the conventions, the ecosystem, the tools, none of that effort is portable.
I have to say reading through this thread I am so glad I didn’t go down the Swift route it sounds incredibly frustrating which is honestly the opposite of what my Flutter journey has been so far.
My hunch is that older binaries will stay Objective-C forever, until the app is completely replaced. It will linger around, similar to C and C++. There is no major win to just write something in a different language, but using he same frameworks/ui system. Swift is used in brand new apps, and eventually will take over.
Swift UI is just too immature, and it is still doesn't provide some of the more advanced components. Great for a toy app, but not for a production level. I hope Apple keeps improving on it, and it doesn't return another niche like IB (Interface Builder), which is used only for small apps, and larger corps just don't use it.
----- Out of all the binaries in iOS 15:
89% are using Objective-C
17% are using C++
13% are using Swift
8% are entirely written in C
2% are using SwiftUI
If Swift was a better designed language, it would have taken over by now. The fact that after 7.5 years, Objective-C still persist, means Swift has soured many devs by its complexity, and sheer amount of shortcuts, (like Scala), and it is not necessary loved or is that much more productive, or gets people exited for. *but used a necessary tool as it is the way most community will move forward.
So, a company that is selling over two hundred million devices per year that depend on a stable software stack, should have thrown away millions of lines of working code just to port it all over to a language that was still undergoing massive evolution over that 7.5 year period. Really? Sorry, but that would have been a disaster.
It even forced MSFT to create .NET.
That's the hallmarks of a good/revolutionary language for the time. It got adoption even in places that wasn't meant to.
Swift has failed in the web, and in AI/ML. That's the hallmarks of a mediocre language, that people have to use it because the platform. It doesn't stand on its own.
Sun made a lawsuit against them and won, thus .NET was born and there was even J# as transition period to port J++ code into .NET.
In fact most Java devs could code in C# 1.0 almost without bothering to read any manual, just by changing the capitalization.
Ironically, Microsoft is now an OpenJDK contributor and owns a Java distribution (after buying jClarity), whereas Google is cheered for creating their Android Java coffee flavour.
By 2001, in just 5-6 years Java became the de-facto language of the Web Services (php, and python were relegated to smaller web pages).
What has Swift realized in 7 years? It failed in the web, and also in AI/ML framework. It is being used because you have to use it. While both Java and Python flourished everywhere because people wanted to use them as they were good languages.
More importantly, your statements are clearly a selection bias to confirm your subjective conclusion. You're picking 1 language out of thousands to reassert your statements instead of taking a step back and rethink your conclusion.
7.5 years might seem like a long time but it isn't possible to rewrite a stack like Apples in under a decade or two. I also suspect that Swifts lack of interoperability with C++, which is required for audio, video, and math-heavy libraries such as Accelerate, means a layer of Objective-C is still needed to make use of those APIs.
Java, JDK 1.1. was released in 97. It was the first fully featured version of the language. Java was not initially meant for the web (but for midlets, and such), but by 2001 it took over all web services. Then mobile (with J2ME). It even forced MSFT to create its copycat, .NET.
Python has survived and thrived in many places that people 'don't have to use it by force'. That's the hallmarks of good languages and people like using.
Swift failed outside the iOS/MacOs ecosystem. it is a mediocre/overcomplicated language. It is like Scala, which introduced lots of concepts, but went overboard with them and made the language too complex to use.
Things were very different 24 years ago, the language ecosystem was not as competitive as it is today. There are more people writing code today and a greater variety of use cases when it comes to web services. Python is even older than Java (1991). A language being developed today must pass a higher bar.
For example Rust has nowhere near the same level of adoption as Java did back then, but it is by no means a mediocre/overcomplicated language for systems programmers. Same with Go for web services and many others.
> It is like Scala, which introduced lots of concepts, but went overboard with them and made the language too complex to use.
What concepts are you referring to here? I'm not deeply familiar with Scala.
Sure, .NET and C# are technically cross-platform, but in reality they're almost exclusively used by Windows-based developers. Especially in the case of .NET Core, it was only released as a cross-platform framework because Linux servers have been replacing Windows Servers in data centers ever since the Web 2.0 era. Microsoft knows that Windows Server is not the future of the company, Azure is. That's why they happily make tools like VSCode, PowerShell, and .NET Core for Mac and Linux.
Swift is used in Apple's ecosystem because it was designed for Apple's ecosystem. That business decision has nothing to do with the merits or demerits of its language design.
If you look closely at the most used languages in different domains right now it'll become clear that the design is not what led to their wider adoption.
That would require distinguishing the code emitted by the swift compiler from that emitted by clang. I don’t know how hard that is. Are function prologues and epilogue different, for example? Can we semi-reliably infer that from function names? Do they prefer using different registers first?
Lots of people want them to go away, but we don't always get what we want.
Yes and now. Apple still has and uses private APIs, which by license agreement 3rd party developers cannot and should not use.
Additionally SwiftUI is only ~3 years old, so it does not yet have 1:1 parity needed to fully migrate all of Apple's apps over.
That said, I to was disappointed that Microsoft had their own internal UI libraries for WindowsPhone7/8 which were not exposed to developers, such as the Map tile libraries.
SQL Server Studio used MFC until it was rewriten in WPF.
The Ribbon on WPF was originally designed on Office, then made availalble as a COM library on Windows 7 and wrapped as WPF bindings.
MFC was replaced by ATL, given how much Windows and Office teams love COM, and they keep loving it, via WRL and now C++/WinRT and WIL.
Slightly OT, but when might one choose to write part of a new app in Objective-C instead of Swift? From my understanding, Swift can call any ObjC code.
That is something I wouldn't have thought I'd hear one day ;-)
For example, this the AppKit API for pulling a URL off of the pasteboard:
+[NSURL URLFromPasteboard:]
It's easy to find, since it has both URL and Pasteboard in the name.The Swift version gets melted down to this:
URL(from:)
which is obfuscated nonsense. Unless you already know that API exists, you'll never find it.The Swift version of AppKit is littered with this kind of obfuscation. Since I don't code in AppKit very regularly, I usually just throw my hands up and switch to Obj-C whenever I start running into these kinds of road blocks.
The Obj-C naming convention has advantages and disadvantages, but has always been considered verbose. The Swift designers considered this a problem in need of a solution. As is almost always the case in software development and language design, the solution was a giant overreaction and overcorrection that just replaced one problem with another.
The Swift API is
init?(from pasteBoard: NSPasteboard)
Which should autocomplete/hint while writing code. The documentation is in the type, not littered within the function name. Much more easier to read and write. The "pasteboard" is still very much in the function declaration.Compared to the obj-C version:
+ (NSURL *)URLFromPasteboard:(NSPasteboard *)pasteBoard;
Not sure why they insist on no spacing, or sane formatting, for Obj-c. I still can't read most Obj-c - it's horribly designed.It does not. Parameter types and alternate parameter names are ignored by Xcode autocomplete.
If you want to use init(from:), you have to already know that it exists and does something good. Typically, you only find a method like that by looking at the Obj-C header. And that method is declared in the NSPasteboard header, not NSURL.
Or is it impossible to write a good auto-completer for Swift because Swift is rather unique in splitting function names into multiple strings?
IIRC, Xcode uses LSP; is that a bottle-neck?
I also occasionally need to use C++, which ObjC makes easy in the form of Objective-C++. Swift doesn’t (yet?) have any ability to interface with C++.
I don't get to use macOS anymore, but i'm envious of them whenever i need to write some UIs
native, fast, memory efficient, memory safe and easy to build nice things
Think of it as "Swift + Objective-C + C++ + C" versus "Objective-C + C++ + C".
And after about 7 years only 13% of the iOS binaries are in Swift?
Quite ironic considering Apple is constantly deprecating stuff and pushing everyone to the latest thing.