News for hackers. Stuff that matters.
Re:Nim Apocrypha, Vol. I by atombender on Wednesday December 23, 2020 @06:01PM (#25523296)
I'm not sure why any "citation" is needed here. C is widely accepted as being deeply unsafe language, and C++ has inherited those traits, and is still working on plugging the weaknesses some 35 years later.

Of course you can do things like bounds checking manually in C, and run with all sorts of warnings enabled, and you can use static code analyzers that uncover entie classes of bugs, but the whole point is to never get that far in the first place.

I worked with Borland's Pascal dialect for 10+ years, and it offered a great deal of protections while still allowing you to use unsafe constructs when you needed to get close to the metal (e.g. pointer arithmetic and even embedded assembly code). But "safe by default" solves a lot of problems.

Re:Nim Apocrypha, Vol. I by jstimpfle on Wednesday December 23, 2020 @06:15PM (#25523393)
Pascal's low-level semantics are comparable to C's. That's why I dispute that it doesn't have the same traps.

I agree that if you program C by emulating higher-level object systems, it becomes unmanageable and a lot of bugs around object lifetimes appear, and they're very hard to fix.

I personally don't have a great interest in such object systems, but fail to see how C++ should be any worse than Pascal in terms of perceived safety resulting from the higher level of abstraction.

Re:Nim Apocrypha, Vol. I by blackrock on Thursday December 24, 2020 @07:58AM (#25527058)
The problem that I see with Nim, is that it transpiles down to C.

So, does it mean, that Nim can inherit these unsafe behaviors of C? Or did the Nim language creators safely avoid the pitfalls of C?

Whereas a language like Zig and Rust, compiles its code down to LLVM.

Re:Nim Apocrypha, Vol. I by nimmer on Thursday December 24, 2020 @02:58PM (#25530888)
> Nim can inherit these unsafe behaviors of C?

Not at all. You could apply the same reasoning for assembly: just because you can write insecure assembly it does not mean that all assembly generated by compiler is using vulnerable coding patterns.

Re:Nim Apocrypha, Vol. I by pjmlp on Thursday December 24, 2020 @08:41AM (#25527342)
That is an implementation detail, nothing prevents a future release of Nim compiler to directly generate machine code.
Re:Nim Apocrypha, Vol. I by blackrock on Thursday December 24, 2020 @08:48AM (#25527394)
Fascinating. When will they do it? I would prefer it generate direct machine code instead.
Re:Nim Apocrypha, Vol. I by nimmer on Thursday December 24, 2020 @03:00PM (#25530901)
> I would prefer it generate direct machine code instead.

Why? C has been the best choice for Nim so far.

Compiling with Nim+GCC is much faster than Rust, it generates applications with comparable performance, and it supports way more architectures.