An effort to create community-driven systems programming language. It is an Implementation Language, so know why you do what you do first. It is already a much better language than C++. But feels Rubyish due to a syntax clutter and lack of uniformity, like in ML or Haskell.
It is much less minimalistic, disciplined, uniform and less polished than Standard ML or even Go. It is much more like Ruby (compared to Python which is a high-skilled and principle-guided community effort), than PHP (a crowded bazaar of ignorant amateurs).
It has Sum types as Enums, so algebraic data types are there
No objects. No classes
It has a few fundamental concepts out of which programs should be build:
- Structures (values)
- Traits (composable Interfaces)
No objects, no classes, only values and only composition. This is a right approach.
Immutability by default
All mutations must be explicitly marked, so they are available to the type checker.
mv instead of ln or cp
- A variable is dropped when a scope is exhausted (got out of scope).
- Implicit (automatic)
RAIIbased on a Lexical Scoping rules.
Values are moved between variables (box-like containers) instead of being linked (referenced) or copied.
Copyable or Movable
- A type is Copyable if it implements the
- A type is Moveable if it implements the
Passing a variable to a function will move or copy, just as ordinary assignment does.
- assigning a value to another variable moves it.
- returning a value of a Moveable type transfers ownership.
&x is a reference to variable (a box)
x (a pointer to
x, an address which is merely an offset)
Only immutable aliasing
- At any given time, you can have either one mutable reference or any number of immutable references.
- only one mutable reference (
&mut x) to a particular piece of data (a box-like variable) in a particular scope.
Mutable reference is basically an mvar of functional languages - a value wrapped into a closure.
Code written so that each invocation only modifies what it owns is almost as good as purely functional code.
Rust compiler tracs a life cycle of each mutable variable, including when it left the scope - being passed to (or borrowed by) another procedure.
This makes an imperative language memory-safe, which means, that wrong code (like accessing a variable after it left the scope) will not compile.
$ cargo install --force racer $ cargo install --force rustfmt # optional
(package-install 'lsp-mode) (package-install 'lsp-ui) (package-install 'lsp-rust) (package-install 'rust-mode)
git clone git://github.com/rust-lang/rust.vim
git clone git://github.com/autozimu/LanguageClient-neovim.git cd LanguageClient-neovim cargo install --force