u/Hixon11

▲ 183 r/rust

Do you write Rust for a living?

I feel that it's super hard to find any jobs where people write Rust, or at least write Rust 50%+ of their coding time.

If you are one of the lucky guys or girls who get paid to write Rust, is it embedded software, or API services? Did your company move from C++ or something else, or is it a brand new startup (e.g., database / distributed systems) where Rust was the initial choice?

I'd really like to hear stories about how people ended up writing Rust for a living (and not just as a weekend hobby).

reddit.com
u/Hixon11 — 7 days ago
▲ 69 r/rust

How hard do you lean on Rust type system to encode your logic and constraints?

In a recent episode of the Rust in Production Podcast, the guests spoke a lot about encoding business logic and domain constraints via the type system:

  • Newtypes with private fields + smart constructors — wrap a primitive (NonEmpty<T>, Email, Port) and only let it be built via a function that validates. The invariant holds for the rest of the program by construction.
  • Zero-sized types as proofs: struct AdminProof(()) with a private field. Functions that need authorization take &AdminProof, and only auth::check_admin() can mint one. Compile-time capability, zero runtime cost.
  • Typestate via PhantomData<S>: Connection<Disconnected> -> Connection<Connected> -> Connection<Authenticated>. Methods only exist on the right state, so misuse (send on a Disconnected) won't compile.
  • Phantom units / phantom tags: Length<Meters> vs Length<Feet>, Id<User> vs Id<Order>. Same runtime layout, different types — mixing them is a compile error.

It sounds super awesome. However, I can see that it requires extra mental effort from the developer to come up with the right types. There's also an ongoing cost when working with these types, you often need to convert one thing into another, or figure out how to use the API in the first place.

So I'm wondering, what do people actually do on production projects? Are you more of a Go / Java / C# kind of developer, sticking to basic structs, or do you actually express constraints in the type system? (I've never really tried this in production code). Which techniques do you use?

reddit.com
u/Hixon11 — 13 days ago
▲ 42 r/java

I don't see much usage of WebAssembly in Java projects around me. One of the obvious reasons may be the lack of native support for compiling Java to WASM, which other languages already have (the most notable ones are Rust, Go, and C++, with some effort in C# and Kotlin as well).

Based on my knowledge, we have a few actively developed WASM related projects as of now:

  1. GraalWasmhttps://www.graalvm.org/webassembly/ — a technology that allows you to run arbitrary WASM bytecode (e.g., compiled Rust/C++ code) inside a Java app.
  2. Chicoryhttps://github.com/dylibso/chicory — similar to GraalWasm; it is a WASM runtime that allows you to run WASM inside Java apps.
  3. Babylon and Leydenhttps://openjdk.org/projects/babylon/ and https://openjdk.org/projects/leyden/ — I guess these could become the official way to compile/run Java to WASM in the future, but there's nothing to use right now.
  4. GraalVM Web Imagehttps://www.graalvm.org/latest/reference-manual/web-image/ — a technology that should allow compiling Java to WASM in the future (based on my understanding, it is experimental as of now).
  5. TeaVMhttps://github.com/konsoletyper/teavm — a technology that allows you to run Java in the browser by AOT compiling it. The cool thing is that they have started integration with WASM GC — https://github.com/konsoletyper/teavm/blob/master/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java — which should provide decent performance for Java apps.
  6. CheerpJhttps://cheerpj.com/ — another way to run Java in the browser. Based on my understanding, TeaVM compiles Java directly to WASM, whereas CheerpJ builds a virtual machine in C++, compiles it to WASM, and uses it to run Java bytecode. So, even though they provide similar capabilities, their implementation details are quite different.

As we can see, there are a few active/developing projects in the WASM area. It would be interesting to hear if you have already used Java with WASM in some way. For example:

  1. Have you run WASM bytecode inside your Java app (maybe you can share why you decided to use WASM instead of Groovy or JavaScript in this case)?
  2. Have you compiled Java to WASM and run it in the browser (it would be interesting to know what problem you were solving)?
  3. Have you compiled Java to WASM (WASI) and run it in a WASM runtime outside the browser (e.g., edge compute)?
reddit.com
u/Hixon11 — 21 days ago
▲ 37 r/golang

Let's share our favorite podcasts or Youtube shows (as long as they can be listened to without watching).

They don't have to be strictly about Go, it can be anything related to our work is (backend development, distributed systems, cloud-native topics, and so on).

reddit.com
u/Hixon11 — 21 days ago