Writing Chat in Rust라는 글에서,
http://nbaksalyar.github.io/2015/07/10/writing-chat-in-rust.html
But arguably the most common pitfall is the memory safety. It is the root cause for a class of bugs such as buffer overflows, memory leaks, double deallocations, and dangling pointers. And these bugs can be really nasty: well known issues like the infamous OpenSSL Heartbleed bug is caused by nothing more than the incorrect management of memory — and nobody knows how much more of these severe bugs are lurking around.However, there are several good practice approaches in C++ such as smart pointers[1] and on-stack allocation[2] to mitigate these common issues. But, unfortunately, it’s still too easy to “shoot yourself in the foot” by overflowing a buffer or by incorrectly using one of the low-level memory management functions because these practices and constraints aren’t enforced on the language level.Instead, it’s believed that all well-grounded developers would do good and make no mistakes whatsoever. Conversely, I do believe that these critical issues have nothing to do with the level of skill of a developer because it’s a machine’s task to check for errors — human beings just don’t have that much attention to find all weaknesses in large codebases.That’s the major reason of existence for a common way to automatically handle the memory management: the garbage collection. It’s a complex topic and a vast field of knowledge in itself. Almost all modern languages and VMs use some form of GC, and while it’s suitable in most cases, it has its own shortcomings — it’s complex[3], it introduces an overhead of a pause to reclaim unused memory[4], and generally requires intricate tuning tricks for high-performance applications to reduce the pause time.
인간이 방대한 코드베이스의 모든 약점을 찾는데 주의를 기울여야 한다고 생각하지 않는다.
21세기적인 프로그래머 마인드라서 마음에 든다. ^^
그리고, GC가 대부분의 경우 적합하지만 한계가 있다는 것을 알아야 한다.
Rust takes a slightly different approach — basically, a middle ground: automatic memory and resources reclamation without a significant overhead and without the requirement of a tiresome and error-prone manual memory management. It’s achieved by employing ownership and borrowing concepts.
그래서, Rust 가 채용한 방식은 수동과 자동을 섞은 것이다.
ownership 개념과 borrowing 개념을 도입한 것이다.
http://nbaksalyar.github.io/2015/07/10/writing-chat-in-rust.html
rust를 학습하고자 한다면, 지루하게 rust by example을 보는 것보다, 요 링크를 먼저 한번 쭉 읽어보시길 권한다. rust를 배우고자 하는 동기부여도 될 것이고, rust에 대한 전반적인 이해가 될 것이다.
댓글 없음:
댓글 쓰기