პროგრამირების ენა Buk.
რატომ კიდევ ერთი სისტემური პროგრამირების ენა? Rust-მა პრაქტიკაზე დაამტკიცა, რომ უსაფრთხო სისტემური პროგრამირების ენების შექმნა garbage collector-ის გარეშე შესაძლებელია და ეს ნიშა ძალიან მოთხოვნადია. C/C++-ზე დაწერილმა პროგრამებმა ათწლეულების განმავლობაში ათასობით კრიტიკული შეცდომა დააგროვეს, რის გამოც ხდებოდა უამრავი exploit-ის შექმნა, სისტემების გატეხვა და ასე შემდეგ. მეხსიერების ბაგები არის…
Buk, a program written in a language called Rust, is an example of a system programming language designed with memory safety without the need for a garbage collector. Rust's compile-time memory safety, achieved through ownership and borrowing concepts, prevents bugs that have led to critical failures, exploits, and system instability in languages like C/C++.
Ownership in Rust refers to a value having an owner, which is the part of the program responsible for the value and its resources. For example, `let document = LoadDocument();` assigns ownership of the returned `LoadDocument` value to the `document` variable, making it the exclusive owner of that value.
Borrowing allows for temporary access to a value without transferring ownership, enabling read-only or exclusive mutation access. The compiler ensures no dangling references, misuse of already mutated values, or conflicting access. It checks various aspects of ownership and borrowing at compile time, preventing runtime errors.
In Buk, manual memory management is manual, with garbage collection disabled. Ownership and borrowing concepts help maintain memory safety at compile time. Each owning value has an owner, and the compiler verifies the ownership and borrowing relationships during compilation.
The four main operations in Buk are Look (shared read access), Change (exclusive mutable access), Take (complete ownership transfer), and Validate (ownership transfer check). The compiler controls these operations to ensure memory safety, preventing issues like dangling references, misuse of mutated values, and conflicting access.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.