Re:MiniJinja: Learnings from Building a Template Engine in Rust
by LudwigNagasena on Wednesday August 28, 2024 @08:33AM
(#41378739)
You've said it would be obviously wrong "even in a language with garbage collector, such as JavaScript." But, obviously, most modern GC can handle cyclic references just fine.
[ Parent
| on HN ]
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by oneshtein on Wednesday August 28, 2024 @10:24AM
(#41379880)
But even languages with Tricolour Mark&Sweep GC, which handles cyclic references just fine, it's still possible to make memory leak via a dangling reference to a node in a complex cross-linked graph, because language and GC allows that.
Rust by default forbids cyclic references, by forcing to use trees, which completely avoids the problem.
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by LudwigNagasena on Wednesday August 28, 2024 @04:06PM
(#41383670)
You can leak memory in any complex project, even if you only use safe Rust.
Linux kernel uses doubly linked lists, Redis uses doubly linked lists, V8 JS engine uses doubly linked lists. Have their authors chosen something obviously wrong?
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by oneshtein on Friday August 30, 2024 @03:12AM
(#41398380)
Rust uses double linked lists, they are not harder to implement in Rust than in any other language. Moreover, built-in borrow checker will help to implement them properly, without memory leaks or use-after-free. What is your point?
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by LudwigNagasena on Friday August 30, 2024 @09:35AM
(#41400584)
My point is that it's not obviously wrong to create cyclic references.
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by oneshtein on Saturday August 31, 2024 @01:21AM
(#41406726)
OK, it's was obviously wrong to create cyclic references few years ago.
Re:MiniJinja: Learnings from Building a Template Engine in Rust
by LudwigNagasena on Saturday August 31, 2024 @10:36AM
(#41409189)
But doubly linked lists use cyclic references…