3 ms·
We need a language with Haskell syntax, Rust memory management and Typescript toolchain/ecosystem :))
by fbn79 2y ago
We need a language with Haskell syntax, Rust memory management and Typescript toolchain/ecosystem :))
- joelthelion 2y agoI'd argue the syntax is the worst part of haskell. In particular, the lack of object notation for accessing fields (e.g. car.doors) is particularly frustrating. I still love the language, BTW.
- gtf21 2y agoYou can have that syntax if you want it via `OverloadedRecordDot`. I actually really like the syntax as it makes it easy to write DSLs which are actually just Haskell functions.
- rebeccaskinner 2y agoThere is an extension that lets you do this now (OverloadedRecordDotSyntax) but truthfully I think it’s a really bad idea. The (.) operator already has a very concrete meaning in Haskell, and record dot notation means that you suddenly need to care about the specific details of how values are calculated. Field accessor functions are much better imo even if they seem a little odd.
- swiftcoder 2y agoI feel like you've specifically picked the worst part of each language here. Haskell's syntax, like many FP syntaxes, is inscrutable on first acquaintance. There's a reason hybrid languages like Elixir thrive... Rust's memory management is a great boon for a close-to-the-metal language, but if all your types are immutable you don't actually need/want to deal with the borrow checker. Typescripts toolchain and ecosystem are... ok, at best? I'd give a solid pitch for the Rust ecosystem having reproduced the best parts thereof (and there is still room for improvement even so)
- fbn79 2y agoHaskell have a garbage collector (and it have a lot or work to do). So even if you are in the context of immutability, if you don't want a gc, you still need to take care of memory yourself using RAII like Rust or any other low level technique. About syntax for me haskell is beautiful. But maybe it's just my love for having type notation aside from function declaration and not mixed.
- swiftcoder 2y agoGarbage collectors can really be very efficient in languages that are both strongly-typed and truly immutable. The type system means you don't have to worry about folks hiding pointers in arbitrary pointer-sized integers, so you know all the roots ahead of time. Immutability means you can only ever create references in one direction (i.e from new objects to old objects), and you can't ever create cycles. This lets you do fun shit like a mark&sweep garbage collector in a single pass (rather than the usual two) - and if you have process isolation guarantees (a la Erlang), you don't necessarily have to suspend execution while it runs. Or maybe a generational collector where the generations are entirely implicit.
- fbn79 2y agoThe GC could be very smart and optimized, but at the end... "Any sufficiently complicated program in a garbage-collected language contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of malloc and free". https://news.ycombinator.com/item?id=22802451 https://news.ycombinator.com/item?id=22802451
- empath75 2y agoI think you just want Rust. You can write extremely haskell-like code with Rust. Here's the first example in rust: fn safe_head<T>(list: &[T]) -> Option<&T> { match list { [first, ..] => Some(first), [] => None, } } fn print_the_first_thing(my_list: &[String]) { match safe_head(my_list) { Some(something) => println!("{}", something), None => println!("You don't have any favourite things? How sad."), } } fn main() { let my_favourite_things = vec!["raindrops on roses".to_string(), "whiskers on kittens".to_string()]; let empty_list: Vec<String> = vec![]; print_the_first_thing(&my_favourite_things); print_the_first_thing(&empty_list); } (of course Rust has a lot of helper functions that avoid all that verbosity -- you can do the whole thing in one expression, if you want) println!( "{}", my_favourite_things.get(0).map_or( "You don't have any favourite things? How sad.".to_string(), |something| something.to_string() ) );
- rebeccaskinner 2y agoHaskell has linear types now, which can give you something similar to rusts affine types. The library ecosystem for it isn’t very mature yet though.