General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Mikko Rantalainen
ThePrimeTime
comments
Comments by "Mikko Rantalainen" (@MikkoRantalainen) on "If Go And Rust Had A Baby" video.
I think a lot of the Rust lifetime unreadability goes away if you start giving more descriptive lifetimes but 'a and 'b. For example, 'request, 'fileopen etc. Then your error messages will make more sense when it's obvious what the lifetime means for logic.
49
I think one shouldn't create new systems language that is not safe by default. However, doing intentional exceptions should be easier than with Rust. Rust basically only has unsafe block but what we would really need is ability to declare that some specific data structure fullfills some restriction that allows it to be accessed cross-threads in some way that wouldn't be normally possible. That way the Rust compiler (or any other language we're talking about) could be in safe mode at all times but follow the explicit extra assumptions you've declared. Right now Rust only supports totally safe or "trust me bro, I know what I'm doing" modes.
7
GC is basically a trick where you pretend that your computer has infinite memory and you keep doing new allocations and GC hopefully can figure out stuff that is no longer referenced anywhere and can be released. If your system has really lot memory, a good GC never does anything because NOP implementation can already pretend having infinite memory. The problem is that GC systems typically have practical 5–10x overhead meaning if your application really required 500 MB RAM, it requires 2500–5000 MB when executed with GC. However, if your developer cost is 5–10x less with GC, it makes sense if you pay for all the hardware. And if the customers pay for the hardware, GC is pretty much always a win unless you're seriously RAM limited (e.g. gaming). GC can be tweaked to run with very small RAM usage overhead but then it will use lots of CPU to continuously go through the memory and look for stuff to free.
6
@TurtleKwitty I agree that most Rust code uses just 'a but I fail to see why anybody considers it like the best possible implementation.
3
@TurtleKwitty Do you understand why lifetime annotations are used in Rust?
3
@TurtleKwitty I agree than when you can dump 'a everywhere and get the correct behavior, the compiler should be smart enough to do that automatically.
2
@thekwoka4707 I was thinking more along the lines "declare that variable X can be shared between threads without arc mutex" which would automatically only lift the requirements for needing to use arc mutex but that requirement would be lifted everywhere, not in a single unsafe block.
2
@Leonhart_93 That's true and with Rust, you can pretend that most of the memory is automatically garbage collected because it's internally either ref-counted or lifetime is decided during compile time. However, such solutions cannot handle with data structures that use reference loops. For those, you need to use some kind of manual book keeping such as weak pointers or manually breaking the loops.
1
@mayaens Yes, I meant &mut X but was too sloppy in communication. Thanks for pointing it out.
1