News for hackers. Stuff that matters.
Re:Portable software is more complex than you think by nynx on Tuesday December 07, 2021 @01:27PM (#29476271)
Portability of software is a language problem. Some languages make it extremely easy. Others, like C and Go, make it difficult to be correct across all platforms.
Re:Portable software is more complex than you think by omnicognate on Tuesday December 07, 2021 @02:23PM (#29477021)
I wrote an iOS app. I ported it to Android. The only part that didn't need to be rewritten from the ground up (and it worked completely unmodified) was the part written in C.

If you have the same APIs available (OpenGL in this case) C is the most portable language there is. Which proves it's not a language issue, it's a platform issue.

In fact the owners of the platforms care so little about (indeed actively oppose) compatibility between them that increasingly they make their higher-level APIs only available to a single language so you can't even share the parts of your code that aren't dependent on their APIs. Unless of course you drop into the one language that works everywhere and which they have no choice but to support: C (or something else that compiles natively and can present a C API like C++, Rust or Kotlin native).

Java's "write once run everywhere" has become a sad joke.

Re:Portable software is more complex than you think by rectang on Tuesday December 07, 2021 @03:40PM (#29477926)
> the one language that works everywhere and which they have no choice but to support: C

I've been tinkering with Rust bindings for Apple Core Audio. AUGraph, which has a C interface, was deprecated a few years ago. Its replacement, AVAudioEngine, has an Objective-C/Swift API. :(

There are a lot of generalized cross-platform libraries for guis, audio engines, etc, which attempt to abstract over the differences between native libraries. While noble, these are always going to be very limited and difficult because the library interfaces may make radically different assumptions and have very different high-level structures.

To me it seems as though the best strategy to help programmers who want to do cross-platform development similar to you is to focus on providing complete bindings for the platform-specific native libraries (for me the bindings language is Rust but it could theoretically be another one like Go). Once those exist, it expands the amount of code you write that can be shared. It also becomes more straightforward to write cross-platform abstraction libraries.

However, my sense is that the platform vendors are heading towards a future where C ABIs are eschewed and where sharing code will be utterly impossible.

Re:Portable software is more complex than you think by weq on Thursday December 09, 2021 @01:52AM (#29494611)
Exactly what Microsoft does with Xamarin, has extensive tooling to generate platform bindings on every update. I can interop with RUST with no-low overhead as needed.
Re:Portable software is more complex than you think by pjmlp on Wednesday December 08, 2021 @06:17AM (#29483438)
Here is another one for you, the modern networking stack is also Objective-C/Swift.
Re:Portable software is more complex than you think by weq on Thursday December 09, 2021 @01:51AM (#29494603)
Id argue C# is THE portable version of C

if you wrote your iOS app in Xamarin, u could today run it on .NET6 pretty much unchanged. I maintain multiple store apps where i share 90% of the code across all platforms (iOS/Android/Win/macOS) that have extensive integrations with the OS. I can even drop down to native obj-c, java, win32, macos apis as required using the same syntax as any other library thanks to the code-gen MS does. I use powershell for scripting. Dont need a full app? I can have native islands as well or be an island in another native App.

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

Re:Portable software is more complex than you think by sumtechguy on Tuesday December 07, 2021 @03:58PM (#29478144)
At one point I was porting between different C stacks. I found they would compile just fine. It was when you looked into the details of the different CRT functions you would have some real fun. For example printf is an evil function of randomness, where the parameters are identical but the way it would decode that input string was highly dependent on when it was written and which stack it was in. Now today you have basically 3 different compilers you have to worry about and they mostly act the same now. It is just as you move between libs that it can sometimes get a bit crazy if they use any sort of if/def to change the way some features work (glaring at you pthreads).
Re:Portable software is more complex than you think by pjmlp on Wednesday December 08, 2021 @02:10AM (#29482023)
You were lucky that iOS and Android devices share endianness and CPU families, and use the same C compiler.

Had this not been the case and even your C code would have been touched.

Re:Portable software is more complex than you think by junon on Tuesday December 07, 2021 @02:02PM (#29476751)
> Portability of software is a language problem

I think this is one of those statements that sounds good at face value but doesn't stand up to scrutiny.

Re:Portable software is more complex than you think by Hooray_Darakian on Tuesday December 07, 2021 @02:11PM (#29476882)
Hard disagree there. Trying to write cross distro cli tools can get really hairy really fast when you need to deal with distro inconsistencies in file locations, default configs/permissions, systemd vs not (maybe that one is past now), etc...
Re:Portable software is more complex than you think by rectang on Tuesday December 07, 2021 @01:29PM (#29476302)
C and Go got nothing on Swift. Or .NET which is tantalizingly partially portable.
Re:Portable software is more complex than you think by sdfdf4434r34r on Tuesday December 07, 2021 @03:00PM (#29477458)
C is the most portable language in practice, so that can't be true.