2 ms·
Anecdotally, if you are coming from Java, then changing your brain to think like Rust (functional) is a paradigm shift. (in true sense of word paradigm, a shift
by FrustratedMonky 3y ago
Anecdotally, if you are coming from Java, then changing your brain to think like Rust (functional) is a paradigm shift. (in true sense of word paradigm, a shift in perspective). Until the grok happens, yeah, it probably seems stupid and pointless.
(but yes, it seems to be 'object' v 'functional' language war critiques again)
- fnordpiglet 3y agoRust is more imperative with a functional nature, and has no meaningful runtime reflection and fairly weak object nature making it a real shift for Java developers, but a more natural shift for C developers who are familiar with basic functional programming.
- Sharlin 3y agoJava is, in fact, roughly as functional as Rust is! * Lambdas/closures: Java has had them since day one, albeit with horrible syntax. Nice syntax since Java 8, almost ten years ago (indeed predating Rust 1.0!). Some functional patterns are even easier in Java thanks to GC of captured variables. * Lazy lists, combinator chaining: Rust has iterators (and with rayon, parallel iterators); Java has streams, parallelizable by design, since Java 8. * Closed sum types: Rust has enums, Java 17 has sealed interfaces (semantically equivalent albeit much more verbose to define). * Pattern matching: Rust has `match` (and `if let` et al.), Java has `switch` which although not nearly at Rust's level yet, has been gradually gaining extra matching powers (JEPs 440 and 441). The real stumbling blocks for a Java developer are a lack of GC, the sharing XOR mutation paradigm, and lack of support for some common OOP patterns. Also a lack of reflection is a pretty big thing.