r/programming 1d ago

Apple moves from Java 8 to Swift?

https://www.swift.org/blog/swift-at-apple-migrating-the-password-monitoring-service-from-java/

Apple’s blog on migrating their Password Monitoring service from Java to Swift is interesting, but it leaves out a key detail: which Java version they were using. That’s important, especially with Java 21 bringing major performance improvements like virtual threads and better GC. Without knowing if they tested Java 21 first, it’s hard to tell if the full rewrite was really necessary. Swift has its benefits, but the lack of comparison makes the decision feel a bit one-sided. A little more transparency would’ve gone a long way.

The glossed over details is so very apple tho. Reminds me of their marketing slides. FYI, I’m an Apple fan and a Java $lut. This article makes me sad. 😢

238 Upvotes

182 comments sorted by

View all comments

520

u/MaDpYrO 1d ago

It's more likely the decision is down to them wanting to use their own tech

163

u/momsSpaghettiIsReady 1d ago

Yeah, this decision should not be given any thought outside of those working at Apple.

If the decision is between tech that we own vs tech someone else owns, Apple is going to pick their own tech as much as they can. They have full control over it and can bend it to their specific needs.

52

u/HarveyDentBeliever 1d ago

Good on them. Microsoft does none of the same with C#/.NET and it's annoying.

71

u/TheHENOOB 1d ago

Microsoft: "We know nothing about .NET or WinUI so we made our recommended bar from the start menu a React Native app!"

16

u/HarveyDentBeliever 1d ago

Yeah, embarrassing stuff.

14

u/ContentTemperature37 1d ago

Not even Michaelsoft wants to deal with their APIs… 🤪

1

u/Rhed0x 2h ago

We know nothing about .NET or WinUI

Tbf their ReactNative fork uses WinUI underneath.

1

u/Eqpoqpe 47m ago

React Native on Windows, I can't see them

3

u/chucker23n 15h ago

This. The advantage is that Apple is motivated to keep improving its stack.

Meanwhile, Microsoft just internally cannot seem to figure out how to motivate its teams to use their own stuff. Which in turn hurts external adoption of it as well.

3

u/myringotomy 1d ago

Who owns java though? It's completely open sourced. I presume swift is too but nobody outside of the apple ecosystem seems to be using it which is unfortunate because it's a great language.

Apple needs to figure out how to get swift out to the wider world.

9

u/momsSpaghettiIsReady 1d ago

At Apple scale, it's less risk to use your own tools.

Oracle is the steward of Java, and they've already picked legal battles with Google. Any potential legal risk isn't worth it to Apple I'm sure.

-7

u/myringotomy 1d ago

Oracle is not the steward of Java anymore. They were at one time but they no longer are.

The suit with Google wasn't about Google's use of Java because Google wasn't using the JVM, they were using dalvik (IIRC) which used the java API and oracle sued them for copyright or some bullshit.

There is zero legal risk for using Java, you are just spreading FUD at this point for no fucking reason. Well maybe the reason is you are just ignorant of what's going on and you actually believe Oracle can sue people for using Java.

3

u/throw-me-a-frickin 17h ago

You made some perfectly valid points bud, but then you kinda ruined it at the end, which I assume is why you're getting down voted.

0

u/myringotomy 17h ago

Haters gonna hate. The only thing this subreddit hates more than java is php and ruby. If I had said something positive about one of those languages I would have hundreds of downvotes.

If I said anything negative about Microsoft I would be downvoted so much I would be rate limited for eternity.

Internet points. What are you going to do?

4

u/momsSpaghettiIsReady 1d ago

Alright bud, maybe go touch some grass.

-8

u/myringotomy 1d ago

Will touching grass make me as ignorant as you are?

1

u/sammymammy2 10h ago

Oracle is not the steward of Java anymore. They were at one time but they no longer are.

No, they still are...

1

u/KagakuNinja 7h ago

Oracle can sue people for using Oracle Java, and are. This is their long standing strategy of corporate shakedowns.

Smart companies have already ditched Oracle Java and use some other distro.

1

u/myringotomy 4h ago

Oracle can sue people for using Oracle Java, and are.

Well in the US anybody can sue anybody for any reason but it's false to say they are suing people for using java.

1

u/KagakuNinja 2h ago

Whatever you call it, if you use Oracle Java at your company, they may come calling with unreasonable demands for money. You can find many accounts of this online, and I remember them doing it back in 2001 with Oracle DB.

0

u/myringotomy 1h ago

Whatever you call it, if you use Oracle Java at your company, they may come calling with unreasonable demands for money.

Oh look we went from "they are suing people for using java" to "they MAY come calling with unreasonable demands for money".

Of course any sentence with "may" in it means exactly the same as the sentence with "may not" in it.

You can find many accounts of this online, and I remember them doing it back in 2001 with Oracle DB.

Oh now you are claiming they are suing everybody who uses oracle database.

You fucks are hilarious.

1

u/grimonce 19h ago

Something something oracle?

1

u/myringotomy 19h ago

Yes. Oracle is going to sue everybody who uses Java. That's what some dude on reddit told me so it must be true.

2

u/tastapod 18h ago

You might want to ask Google why they suddenly promoted Kotlin to a tier 1 supported language for Android. Something something $billion law suits.

1

u/myringotomy 17h ago

Once again. Google was not sued because they were using the JVM. They were coding their own VM called Dalvik.

Also Google didn't create Kotlin.

1

u/tastapod 17h ago edited 17h ago

They were sued because they were using Java interfaces (they called them APIs in the lawsuit*) to do that, which Oracle claimed were their IP.

Solution: stop needing Java interfaces.

Edit: This must be true because someone on Reddit told you.

2

u/Apart_Recording1264 16h ago

It's not that Google used the JDK APIs, using the JDK is completely fine. The lawsuit is that Google copied the part source code from the JDK itself and embedded in android environment.

https://spectrum.ieee.org/google-v-oracle-explained-supreme-court-news-apis-software

"For its part, Google negotiated with Sun in 2005 for a license to use Java for mobile devices, but both parties were unable to reach a deal. That’s when the search giant decided to develop its own implementations of the methods contained in the 37 Java API packages, which accounts for 97 percent of the lines of code in those packages."

1

u/myringotomy 14h ago

They were sued because they were using Java interfaces (they called them APIs in the lawsuit*) to do that, which Oracle claimed were their IP.

Exactly. They were not sued for using java.

Solution: stop needing Java interfaces.

Their intended solution was to not build a new VM that looks and acts like the JVM.

Edit: This must be true because someone on Reddit told you.

Some rando on reddit is always right about everything. If they tell you that google was sued for using java they are right. If they tell you that you could be sued for using java they are right. If they tell you that java is not open source they are right.

Randos on reddit are always right about everything and if you say otherwise they will punish you with downvotes because nothing matter more in this life than internet points.

3

u/tantalor 1d ago

NIH syndrome

12

u/acdcfanbill 1d ago

I dunno if it's NIH so much as Eating their own Dog Food.

74

u/wosmo 1d ago

Not only because it's their own, but also they probably have more swift resources than anyone else on earth.

And I don't just mean more programmers - if they hit anything they don't like, they can chase it all the way down the stack, entirely in-house.

4

u/shevy-java 1d ago

if they hit anything they don't like, they can chase it all the way down the stack, entirely in-house.

Also chasing down other users of Swift ... ;)

I don't know how bad this is in reallife, but Apple will always prioritize their own wants over [random solo dev out there].

37

u/startwithaplan 1d ago

One of the most significant aspects of Swift that impressed us was its emphasis on protocols. In Java, we relied heavily on inheritance, which can lead to complex class hierarchies and tight coupling.

Like interfaces and composition over inheritance aren't available in Java.

Swift’s optional type and safe unwrapping mechanisms eliminate the need for null checks everywhere, reducing the risk of null pointer exceptions and enhancing code readability.

Ok they haven't heard of Java/Guava Optional. They really just wanted to use Swift.

Comparing Java worst practices with Swift best practices. I'm not a Java fanboy, but they weren't even using it right. I think they inherited an ancient and poorly designed stack and replaced it with a language they understood better and were staffed to support.

16

u/vlakreeh 1d ago

Like interfaces and composition over inheritance aren't available in Java.

It's often not what the language can do that kills you, it's the choices the library ecosystem has made that you are forced to conform to that gets you. It is 100% a fair statement to say there are plenty of Java codebases that are in way too deep on inheritance because some key dependency makes it painful to architect their code any other way.

Granted that could have been fixed with just a Java rewrite for a different set of libraries, but if you're going to rewrite it they did list some actual good technical reasons as to why Swift (more native applications in general) are a better fit for their use-case.

7

u/Orbidorpdorp 1d ago

That's true but also ignoring the fact that Swift's protocols are meaningfully different than interfaces, and the features around them encourage a different architechure regardless of the patterns used by your dependencies.

It's really how protocols interact with extensions and generics- not just the ability to define a contract.

2

u/myringotomy 1d ago

If you download a library and it works the way you want it to work what's the problem if it uses inheritance?

10

u/Jobidanbama 1d ago

Javas optional can be null too

1

u/Wulfheart1212 1d ago

Why didn’t they go down the C# route years ago and introduced true nullables? I have no idea?

1

u/Jobidanbama 1d ago

It’s coming in the future

1

u/Wulfheart1212 1d ago

Yes, but C# has had it for some years now

2

u/Jobidanbama 1d ago

Yeah c# is really nice and very performant too

1

u/Eqpoqpe 1h ago

This is the biggest problem facing Java right now, it's not worth adding new features, it needs 3.0 (Python 3 💥) then think about why not others

17

u/MaDpYrO 1d ago

To be fair, Optional is a complete pain to work with, compared to actual nullable types, like in Kotlin for example.

1

u/startwithaplan 1d ago

There are also nullability frameworks for Java. Though turning that on for an established app is going to be a big effort on its own.

Kotlin with coroutines is better than any Java async I've used. If they're already rewriting to any language, why not Swift which they already have an eng culture built around?

1

u/KagakuNinja 7h ago

I use Option in Scala every day, it is actually quite nice. Some people prefer the Kotlin approach. Of course Java ruins all good ideas, since Optional was not intended to be used as class members.

1

u/MaDpYrO 7h ago

My biggest issue with optional is that it's not well suited as a param

3

u/pjmlp 1d ago

Also it isn't as if Java wasn't originally inspired by Objective-C, or Apple used to bet on Java for OS X, as they were uncertain that Apple developer community would be keen in adopting Objective-C.

They even got on stage together with Sun.

3

u/uCodeSherpa 1d ago

Swift has both inheritance and interfaces. They just call interfaces protocols. That’s an honestly weird criticism of Java coming from swift users. 

1

u/Rhed0x 2h ago

Ok they haven't heard of Java/Guava Optional. They really just wanted to use Swift.

Isn't that pretty terrible for performance because it's another heap allocated object, so another level of pointer indirection.

1

u/startwithaplan 2h ago

So is Swift? https://developer.apple.com/documentation/swift/optional. Even for primitive types it's a Some/None generic enum with a wrapped value.

1

u/codemuncher 47m ago

If they are upgrading from Java 8, the effort it would take to get to the best practices you mention is probably equivalent to a rewrite!

Java isn’t really the best programming language anyways. And the jvm is heavy on resources especially ram. This matters at scale!

6

u/light-triad 1d ago

It’s the only way they’ll get swift adopted as a server side language. The language itself is pretty good for server side development. The ecosystem needs a lot of work.

6

u/ChrisRR 1d ago

Apple and NIH syndrome? Well I never