If you use Nim with its default memory management system, you get Rust-style 
borrow checking with little effort, and you also get cycle collection which 
Rust doesn't have, meaning you're less likely to leak memory as a novice. If 
you stick to managed ref types instead of raw pointers and don't do 
concurrency, Nim is as safe as Rust.

If you throw concurrency in the mix without properly synchronizing things, you 
can expect crashes. I don't see Nim as a "fearless concurrency" language.

> And how safe is Nim with AMM disabled with pointers? Is it no safer than C or 
> C++?

You're going to leak if you use the stdlib with memory management disabled 
since it isn't designed to be used without any management, but you can use ARC 
as your memory manager, which is fully static and doesn't have any special 
runtime cost and works basically just like Rust's. So you don't really disable 
memory management to begin with, it's a bad idea.

More close to your implied question is yes, Nim has few safety advantages over 
C if you use only unmanaged pointers, although it's type system still keeps you 
safer than C because you can use generics instead of void*. You still have the 
freedom to use untyped pointers if you want, though.

Nim has no unsafe keyword, so you can introduce unsafe features at any point 
without signalling to the compiler that you're doing so. Unsafe features being 
ptr types (as opposed to ref types), the emit pragma (used for outputting C and 
asm), and UncheckedArray. The lack of guardrails when using these features does 
lend itself to more use, and while I can't empirically say that it directly 
leads to more crashes, it does seem that brazen use of them contributes to it.

> Nim uses exceptions. Exceptions are less reliable compared to modern error 
> catching methods.

I don't like exceptions either, but they are certainly reliable. You can 
reliably catch them, and they don't act in a way that would surprise anyone. 
I've never heard anyone call Java's error handling unreliable, and it's known 
for using exceptions.

Reply via email to