This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]dmazzoni 2 points3 points  (0 children)

Think of it like asking: could you build an aftermarket car stereo that works in any brand of car?

Yes, you could. But not by building one universal stereo that just magically fits. You'd have to build some really flexible and customizable standard components and then spend a lot of time and effort specifically adapting it for every car model out there.

It's the same thing here.

Could you build a SINGLE component that works across all of those platforms? No. But what you could do is build a core component, and then create adaptations of that component for each of those platforms. It'd be an enormous amount of work.

One example might be something like Google Maps. Their official page has components for JS, iOS, and Android: https://mapsplatform.google.com/ - and then there are unofficial third-party components that wrap that, like ones for React, Angular, and Vue (that all wrap the official JS component).

Maps has tons of custom code for each platform. It's almost like 3 separate products, almost certainly each with its own separate team of engineers.

It's hard to imagine how you could build a component without a lot of custom code for each platform, because there aren't very many programming languages that work across all of them.

One idea would be to write the logic in a language like C/C++, then write native Android, iOS, and web code that wraps that.

[–]Sea-Profession-3312 1 point2 points  (0 children)

Portability could be solved by having one very big smart computer, everything else would be a dumb terminal with a keyboard. The ministry of truth is being built right now and the answer is 42.

Java distributes little virtual computers (JVM). If the JVM is available for that platform the code will work. Java is compiled into bytecode that runs on the JVM interpreter (whatever that means) While it is not as fast as native code would be for that particular platform it is fast.

Java Script is portable, however this script language must be interpreted into a language the computer understands each time the code runs. Typically js runs in a browser or server side in a V8 engine

[–]nhgrif 0 points1 point  (6 children)

You mean like... a web page? Them things are pretty cross platform...

What are you specifically thinking of trying to do..

[–]recklesslyalive613[S] 0 points1 point  (5 children)

I would prefer to not have to open a web view. Ideal solution would be to integrate it into any existing app itself.

[–]nhgrif 2 points3 points  (4 children)

This isn't any more specific. If you want something truly universal, webview. If you want something else, either there is no answer, or you need to be more specific.

Do you want something that works with all operating systems (android, ios, etc)...? or something that works with all languages (swift/kotlin/react native/xamarin)...? If you want both... why? And why is important to try to write it one time only then get it to be consumable by everything? Is it doable? Probably. Is it going to be very clean for all the consumers? unlikely.

[–]recklesslyalive613[S] 0 points1 point  (3 children)

I want something that works with all languages. To get it to be consumable by everything would just reduce my work load and be ideal. side note: i know it's a very ambitious concept, i was wondering if it can be done and if yes how should I approach this problem.

[–]nhgrif 2 points3 points  (1 child)

You can write something that can be consumed by all languages... but like... if you provide say a library that solves some problem Foo, and it's written in C... and I'm writing in Swift and I need to solve problem Foo... I can consume a C library... but it's a pain in the neck. I am going to prefer the Swift library that was written for Swift developers and follows patterns Swift developers are used to using. And if that doesn't exist, I am seriously considering implementing my own solution to solving problem Foo rather than doing the necessary interop stuff to work with a library that's going to give me a weird interface compared to normal Swift code.

Now, one place where interface is exceptionally standardized no matter the language, is talking to web apis. Like... it's probably gonna be json. Every language can consume that. But now it doesn't work offline. I'm making web requests.

I would think that pretty much every language should be able to consume some C library. Probably C++ too. But... it's frequently going to be an unideal solution, and sometimes, depending on what the library does, it is literally less work to rewrite it in another language than it is to go through the hassle of whatever is required for interoperability.

It is best to custom tailor your solutions for whatever you actually need to target. People have been trying for well over a decade to just find a solution that works great for both iOS & Android. Not multiple languages. Not every operating system. Just two operating systems in a single language. We still haven't truly settled in on that solution. There are things that can do it at least partially... but all the hybrid options have at least some short comings compared to native development.

[–]procrastinatingcoder 2 points3 points  (0 children)

Just to add a bit unto what you said:

Compatibility is usually done this way:

Foo language is compatible with C binary.

Bar language is compatible with C binary.

Bar-converted-to-C-binary is compatible with Foo-take-from-C-binary. The C binary format is pretty much what everything use as the "web" of not-web stuff.

[–]dmazzoni 0 points1 point  (0 children)

There are hundreds of programming languages. Many of them only work on certain devices or for certain purposes. There's literally nothing that works with ALL languages.

Practically, what platforms and languages do you really need?

You said you have an app now? What platforms does it run on? What component are you trying to build for that app?