5 ms·
Start at 29:31 to skip past 'what is an os?' history lesson. > Go, JavaScript and others are garbage collected, making interacting with C either impossible or
by karmakaze 8y ago
Start at 29:31 to skip past 'what is an os?' history lesson.
> Go, JavaScript and others are garbage collected, making interacting with C either impossible or excruciatingly slow.
I don't see why interacting with C is a requirement. Android (SDK) could be considered an OS that doesn't have this either.
- ldng 8y agoHumm, I don't think you can equal an SDK to an OS. Before getting this high level, you really have to start with a kernel to handle/manage device. And this as a lot of constraint that yous simply can not fulfill with a garbage collected language. edit: I wasn't at the point you mentioned yet. Well, IMHO, it is not just the GC, it is not having access to native pointer prevent you to implement algorithm that are keys in term of performance for a kernel. IIUC more savvy dev than me it might not even be possible to implement a kernel in Rust without "unsafe" (which give you access to those raw pointers) Happy to be proven wrong though.
- littlestymaar 8y agoAlso, Android is more than the SDK: almost every game running on this platform uses the NDK.
- ldng 8y agoThe NDK is a wrapper above a slew of C/C++ lib and those are not garbage collected. It make me think of PHP. The language is actually really slow but because most of it's standard library are wrappers around actual C library, a lot of people perceive it as a really fast language. But compared to raw C/C++/Rust, it is still slow.
- pjmlp 8y agoThe NDK is very limited, its sole purpose is for 3D, real time audio, ML and porting ISO C and ISO C++ code into Android, everything else requires JNI, even reading files outside the APK sandbox.
- karmakaze 8y agoOK that was a bad example. I just meant to say that C compatibility is an over-specification. We just need machine level interfacing like maybe locking to hardware threads, fixed address referencing, etc. Edit: I don't know much about this but it might be a better example "GRiSP 2 – Erlang and Elixir on bare metal." I'm assuming this is possible and includes the BEAM VM with GC. https://news.ycombinator.com/item?id=19358133 https://news.ycombinator.com/item?id=19358133
- brightball 8y agoThe BEAM GC is a little bit special because there’s not a shared memory model. Millions of little Erlang processes will be GC’d independently which simplifies things a ton. That isolation model probably wouldn’t translate to the greater code ecosystem even though it’s very effective for BEAM applications.
- ldng 8y agoOh I see, you mean "unvirtualizing" the VM and run on the hardware that comply to the VM spec. I was under the impression that generally VM are idealized hardware that is friendlier for software development but they would make terrible actual hardware. I suppose it also depend on the language/VM. But I'm totally out of my comfort zone. Let wait and see if someone more knowledgeable chimes in :-)
- badsectoracula 8y agoGC doesn't prevent you from writing an OS, see Project Oberon[0] for an example of a system with its own CPU (implemented in FPGA), OS, language and applications by Niklaus Wirth which actually does use a system-wide garbage collector. The language does allow for direct memory access though through some special functions that the compiler converts to direct memory accesses. [0] http://www.projectoberon.com/ http://www.projectoberon.com/
- samus 8y agoThere are Java APIs that give access to raw memory. It's one of the infamous, largely undocumented sun.misc-stuff though. There are libaries that used it to implement efficient off-heap data structures. Because of modularization its future looks grim though. After all, Java was not designed with having an unsafe subset of language constructs like Rust has. It would degenerate to C++ in terms of safety.
- arghwhat 8y agoIt is not technically a matter of interacting with C, but rather a matter of being able to interact in a very controlled fashion. Both JavaScript and Go are fantastic of examples of languages deeply incompatible with OS work, as they expect the ability to manage threads, memory, and even networking as a core part of their language runtime and feature-set. None of this is going to work when you're trying to implement those building blocks itself. It is also not acceptable for a language to decide to do something else outside of the authors' control when working on a kernel, like both JavaScript and Go wishes to do. Attempts to write kernels in Go have been made, but doing so involves defining a subset of Go so small that what you end up with is really just a small new language with a Go-ish syntax, without any of the features. So no, C interaction is by itself not a requirement, but it's more of an indicator for the ability to be in control.
- badsectoracula 8y ago> they expect the ability to manage threads, memory, and even networking as a core part of their language runtime and feature-set. These can be implemented using a subset of the language that does not need them, pretty much like C++ requires 'new' but when writing a kernel you do not have enough functionality to use it - so you don't, until you have provided enough infrastructure for its use. Or in a similar fashion... > None of this is going to work when you're trying to implement those building blocks itself. ...most C stdlib functions are also not available when writing a kernel in C (e.g. malloc/free, fopen/fclose, etc) and you simply do not use them until you have enough infrastructure in place to implement them.
- arghwhat 8y ago> These can be implemented using a subset of the language that does not need them, pretty much like C++ requires 'new' but when writing a kernel you do not have enough functionality to use it - so you don't, until you have provided enough infrastructure for its use. Or in a similar fashion... Definitely. That subset for languages like Go and JavaScript is, however, so small that nothing is left. And for a kernel, that subset would have to be used in the vast majority of the code base. If your goal is to write C with Go/JavaScript syntax, then that might be good enough for you, but that's hardly the point of "Should we rewrite in Rust" talks. > ...most C stdlib functions are also not available when writing a kernel in C (e.g. malloc/free, fopen/fclose, etc) and you simply do not use them until you have enough infrastructure in place to implement them. Of course, that's also how you'd do it in Rust: Don't use things that aren't there. The Go runtime won't give you that choice, though, so you'd have to remove that, which removes pretty much all the language features that makes Go... Go.
- jhasse 8y agoThere's the Android NDK though.
- pjmlp 8y agoWhich is very constrained and requires JNI to interact with OS APIs. Even the stable NDK APIs are actually JNI wrappers, with exception of the 3D and real time audio ones.