In userspace, sure. I mean what's Android.I think they said the same thing about Java.
In userspace, sure. I mean what's Android.I think they said the same thing about Java.
Still reliant on the NDK for many of its underlying libraries.In userspace, sure. I mean what's Android.
Indeed. And C reaching further still (including deep into the JVM that is primarily written in it).IMO that's just a symptom of Java not reaching far enough down. Hence stuff like Rust and Golang.
I work on plenty of substantial projects that are pure Java. They're not open source.Just look at any substantial project and you will see a tonne of jni and native C/C++ libraries. Turns out Java wasn't a better tool.
Its actually the mud you want to focus on more to understand Rust's limitations. With C you can tap into the underlying OS directly, using its C APIs. opcodes are easy, it is the muddy layers in between that is complex to interface with if you are using the wrong language the underlying OS API was written for. This is why Rust's crates.io is filled with C bindings rather than tapping into i.e inline assembly directly.You seem intent on muddying these things. Rust and goes as far as C does before both of them have to bang rocks together to run an opcode.
No, Rust has the same complexity as C++ does with JNI. One of the main use-cases of C is because languages can bind against it easily. With C++ and Rust you have no stable ABI for one. Passing an std::string or equivalent is also no good.Rust from Java should be as easy as a C JNI.
Yep, hence why I stated both directions. Rust has no native JNI of its own and never can, so is at a big disadvantage to C (and close supersets) there.Java from Rust is going to be difficult to do in order to reconcile memory models. Directions matter.
Rust indeed has some fairly minor inbuilt "mud" for libc. But when was the last time you have been able to write a large program using *just* libc?You're telling me Rust doesn't access libc unless it's through "mud"?
No difference. Its all the same. Bindings, whether fat or thin.Maybe the problem is what is this "mud" and how is it different than a "shim" or a "wrapper", or "glue."
Absolutely. I don't think anyone likes shims, wrappers or glue. Especially when they tend to rot and go unmaintained quite often.Is "mud" just a "shim" for things people don't like?
On Android? That is surprising.I work on plenty of substantial projects that are pure Java. They're not open source.
I have never actually tried it. Frankly the java-like build systems scare me off before I even get to the languages XDKotlin is just the latest Scala, Clojure, Groovy, etc. Some lame semi "functional" or "declarative" language bolted on to the JVM badly. Hard pass.
Nope. GUI programming in Java is a joke. Then again, looking at things like Electron, maybe it's not so bad.On Android? That is surprising.
Yeah, they're a nightmare. One of the original sins of Java was to break the invariant that 1 source file = 1 compiled file. It was a side effect of trying to simplify by eliminating header files. That made it apparently impossible to write a reasonable build tool becauseI have never actually tried it. Frankly the java-like build systems scare me off before I even get to the languages XD
javac foo.java
can wind up generating any number of .class
files.javac MyTest.java
java -cp . MyTest
I see. Yep, one I used to run into was that "anonymous inner classes" generate extra .class files that the build tool doesn't know about (and can't infer). It makes it a pain to even use Makefiles with it. That said, computers are so fast now and Java compiles relatively quickly that I would be tempted to still use Makefiles and just compile up the whole module per change, keeping the build system simple (probably why I am never invited to join Java projects ).Yeah, they're a nightmare. One of the original sins of Java was to break the invariant that 1 source file = 1 compiled file. It was a side effect of trying to simplify by eliminating header files. That made it apparently impossible to write a reasonable build tool
Heh, for some (annoyingly veteran) developers, If you know more than "Just click the green "play" button" to build. You are basically a wizard.You wouldn't believe how many times I've had trouble explaining how to build a simple test case I'd written in pure core Java by running
Yep, but that's not the only problem. Consider the following trivial Java classesI see. Yep, one I used to run into was that "anonymous inner classes" generate extra .class files that the build tool doesn't know about (and can't infer).
class Foo{public static void main(String[] args){Bar.mess();}}
class Bar{static void mess(){System.out.println("Hello, world!");}}
javac Foo.java
you'll notice that both Bar.class
and Foo.class
are generated. If you compile Bar.java
first, its .class file will just be used without updating it. Thus the objects generated by compilation depend on the order in which things are compiled!javac
both a compiler and primitive build tool. The intention was good. There were a lot of ugly pre-processor mazes in the '90s that caused many, many hard to debug problems. However, this violation of the principle to do only one thing and do it well makes it impossible to come up with a nice clean DAG for Java builds. Hence the proliferation of monstrous and abstruse build systems for it.As discussed, unfortunately not. But it can help maybe ~30% of the way.I was thinking "isn't this a thing you could just do automatically?"
For people that don't understand the "mud" involved in Rust->C integration, here's my simplest explanation of it: you have to re-implement headers in Rust for any functions or structs that you use, and you have to keep those definitions up-to-date with any changes in the underlying library. aka bindings
C, C++, Go, and Zig are the only languages I know of that can include C headers directly without having to define bindings.
You can add V to your list.C, C++, Go, and Zig are the only languages I know of that can include C headers directly without having to define bindings.
Sometimes, maybe.I was thinking "isn't this a thing you could just do automatically?"
Sometimes, maybe.
I admittedly haven’t used rust-bindgen (or maybe I have, I don’t remember). I used an auto-convert-c-header-to-bindings library in some language on a more complicated file (maybe jail.h) and it OOMed after about 20 minutes.
For super simple includes, sure those tools work no problem. But include files can include other files, and can get big, and the tools can struggle with them.
Agreed. Almost similar to .NET IL, it would provide the benefit that any language could consume any language.You really want to go all the way here and have the LLVM libraries do the C (or C++) "analysis".
Yeah. The package set I use on this workstation required compiling three different versions of LLVM. Please don't add 5 versions of Rust to the mess.Tightly depending on LLVM is risky(ish...) but is a good first step for Rust if it wants to make progress outside of C's (slightly janky) shadow.
The package set I use on this workstation required compiling three different versions of LLVM.
LLVM_DEFAULT
? One thing I've not yet tried is setting LLVM_DEFAULT
to 17... hopefully the packages check for a version >= rather than ==?