RUST programming language elevates System Programming needs, Reliability & make programming FAST. Fast as in Development, Distribution and Performance.
I am writing this article in a developer hat. While, I was trying some simple initial concepts, I noted some pointers. It is an as-is dump of those notes.
Let’ go!
- RUST is memory efficient and has no runtime/garbage collector.
- It tries to make System Programming like Embedded/OS programming more accessible to developers who usually avoid it for many reasons.
- From CLI, to web development to embedded programming, it stand on all grounds. It also integrates with other languages.
- It’s ahead-of-time compiled programming language i.e. it needs code compilation to access the executable (end product) of your source code.
- RUST to me looks like a boring language, until we hit the world of CARGO and CRATES. It’s where the fun starts.
- CARGO tool is used to build, check, run & test RUST softwares. Its also your dependency manager.
- CRATES are collection of RUST source code files that you can import. They go as dependencies in your Cargo.toml file in a cargo project.
- All crates come from Crates.io which is somewhat like NPM registry for Node or PyPI index for Python. Fun fact: People behind NPM use RUST somewhere in their stack.
- It’s very easy to convert a plain RUST project into a CARGO project by just moving your source in src directory at root directory of your project direction and add a CARGO configuration file called as Cargo.toml which is TOML configuration of project and its dependencies. A cargo project can be created by using ‘cargo new‘ command.
- Cargo is delivered by default in official installation of RUST (mainly rustc compiler). So, one can build using rustc compiler and then run the executable manually. But, using Cargo is a much clean way as it takes of care of all of it in a single command and works same on all OS environments. It’s +1 for me in as a developer.
- Cargo provides a mode to build for production which places optimisations on priority. Both kind of outputs are stored in special directories. For normal builds the executables go into target/debug and for release they end up in target/release.
- On coding side, most commenting options are similar to that of Javascript
- It uses a MAIN function as execution entry point. Much like in Java/C language.
- It uses semi-colons to separate programming instructions and promotes 4 spaces over tabs for indentation. To ensure integrity of, it also provides a tool for same. Haven’t checked it yet.
- RUST supports functions as well as macros (meta-programming). Syntax difference:
doIt!(‘This is macro syntax’)
doIt(‘This is function syntax’) - All variables and references are immutable by default. One can explicitly set them as mutable. That’s a safety masterstroke. If LESS code by default is a SAFE CODE, it definitely ships a great piece of product end of the day, makes CODE REVIEW process much easier.
- Calling external library functions in RUST has a little different syntax. Just as example: jQuery(‘p’).hide() in javascript will be expressed as jQuery::hide(‘p’) in RUST. Assuming, jQuery will be imported with help of ‘use’ statement & will be included in Cargo configuration if its an external library (CRATE).
- Abilities which are not available in default preludes/functions, can be imported via ‘use’ keyword. This is somewhat like import, #include, require, etc. way from other languages used to import external libraries.
- If you don’t handle a possible ERROR situation, RUST compiler tells you of such before hand as a WARNING.
- Dependency management here is also a RELEASE SAFE process. It’s made sure that the dependencies are NOT AUTO UPDATED referencing the configuration file (development) changes unless explicitly told using ‘cargo update’ command to update the Cargo.Lock file. The lock file store dependency version state of the project for reproducing the build on other systems.
- We can refer the documentation of any used or imported libraries in our cargo project using ‘cargo doc —open’ command.
Conclusion
Overall this language is definitely a positive advancement. It makes some tough things in traditional system programming languages a bit easy to use as it promises to be. This is based on a quick run through till chapter 2 of THIS book. While there are other areas to look further like Data Types, Control Flows & most importantly RUST ownership concept which ensure thread and memory safety; I will keep that for some other article/video in future.
Till then, stay fit, happy coding, stay smiling.
Leave a Reply