General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Mikko Rantalainen
Low Level
comments
Comments by "Mikko Rantalainen" (@MikkoRantalainen) on "zig will change programming forever" video.
Even though I like C, I'd argue that it's impossible to practically write secure C programs. Linux kernel is written in C by elite programmers (let's face it, kernel mode programming is not for beginners) and all code is reviewed by other elite programmers before it is accepted in the Linux kernel. And yet we see a lot of security vulnerabilities in Linux kernel every year. If you write new C code, do you really think you can write much better code than Linux kernel developers? I think I'm pretty good with C but I don't pretend to be mistake-free. As a result, C shouldn't be used for programs that cannot contain memory safety issues or deadlocks – both of which are total non-issues if you're using Rust without unsafe blocks.
1
I'd recommend learning Rust first and then C++ if you still feel like it. C++ is very complex language and doesn't provide much value over Rust in my opinion. C++ does allow writing high performing code but it also hands you invisible shotgun with a hair trigger which makes it really easy to blow your foot off. With C++ you can have identical looking code that fails to handle errors and code that does handle errors. With exceptions, the calling code may look identical (identical source code at binary level!) but one variant fails to handle errors correctly. With Zig and Rust, the error handling is always visible. With idiomatic Rust, you use Result<...> enums and mark possibly failing function call explicitly with single character "?" and otherwise the code can match the C++ version. This extra explicit "?" character makes all the difference. That clearly marks all the locations in the code that can potentially fail but do not pollute the code any further if you don't need extra processing but logically rethrow the error out of your function. However, Rust forces you to always handle data ownership and lifetimes which may be quite hard to get right at first, especially if you're trying to re-implement some algorithm that doesn't directly map to these concepts.
1
@roiqk I agree that learning is always good, too, but I'd recommend starting with Rust if you don't know C++ nor Rust. Historically C++ has been the language to know but it's really complex language and still cannot provide many of the nice features that Rust has and both have nearly identical runtime performance.
1
@roiqk My opinion is that you have to think about the same thing that Rust borrow system does automatically while you program in many other non-managed languages. When you understand how Rust works, you can understand the same idea in well written C and C++ programs, too. Except the compiler doesn't help even a bit in case of C and C++.
1