Skip to content
Snippets Groups Projects
Commit 63eea122 authored by Jonas Johan Solsvik's avatar Jonas Johan Solsvik :video_game:
Browse files

explain why Rust was chosen over Javascript

parent 2585868e
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,15 @@
# 1 Group discussion
## 1.1 Strengths and weaknesses of Rust
## 1.1 Deciding on the Rust programming language
### 1.1.1 Strength: Catches errors at compile-time
Based on our own preliminary research on what was already being done in the SSI community, a choice was made to develop the application DID CLI in the Rust programming language. Rust would give us strong community support, as multiple relevant community projects already was being developed in the language. An equally valid alternative was to use Javascript, which also had strong community support, which is why I have chosen to compare Rust and Javascript in some of the discussion-points below. In the end Rust was chosen over Javascript due to two reasons:
1. I wanted to learn a new programming language. I had a lot of experience from javascript and wanted to challenge myself.
2. Rust had an up-to-date implementation of the DIDComm v2 specification called `didcomm-rs`, whereas javascripts implementation of the same spec was outdated by 6 months. See https://github.com/decentralized-identity/didcomm-rs vs https://github.com/decentralized-identity/didcomm-js.
## 1.2 Strengths and weaknesses of Rust
### 1.2.1 Strength: Catches errors at compile-time
Here are some examples of errors caught at compile time:
* Type errors
......@@ -27,33 +33,33 @@ Here are some examples of errors caught at compile time:
Catching errors as early as possible saves development time and increases iteration speed. You could say that runtime errors are costly and compile time errors are cheap.
### 1.1.2 Strength: Fast
### 1.2.2 Strength: Fast
Rust is fast because it enables low-level programming and compiles all code ahead of runtime. No Just-in-time compilation. The Rust compiler is considered on par with any modern C compiler. Achieving this has been quite a feat for Rust, since C has been considered the state-of-the-art performance programming language for decades. Example benchmark of Rust vs C here: https://levelup.gitconnected.com/which-is-faster-rust-or-c-lets-find-out-who-is-the-usain-bolt-87495c774c8.
### 1.1.3 Strength: Modern
### 1.2.3 Strength: Modern
Language made to take advantage of modern parallell hardware, with modern language features. A new generation of programmers expects modern features from a language. Rust makes it easier to convince young programmers to get started with low-level programming.
### 1.1.4 Strength: Young community
### 1.2.4 Strength: Young community
A new generation of programmers are developing Rust. This is also reflected in how the community communicates. In the very beginning I got a lot of help from the Rust Discord server. They have a "beginners"-channel, where no questsions are too stupid to ask :) Highly recommended: https://discord.com/invite/rust-lang-community
### 1.1.5 Strength: Endorsed by industry
### 1.2.5 Strength: Endorsed by industry
- **Linux** - has been talking lately about allowing contributions to the Linux kernel in Rust. This is a huge breakthrough for Rust, since the Linux kernel has been quite conservative in regards to supporting languages, and only supported C up until this point. See an interview with Linux Torvalds about the topic here: https://www.zdnet.com/article/linus-torvalds-on-where-rust-will-fit-into-linux/
- **Mozilla** - made a bold decision in 2017 to rewrite its core Firefox browser-engine in Rust. The engine was previously written in C++, but Mozilla thought it was worth scrapping it's C++ codebase in favor of Rust due to many of the reasons already mentioned here. See a blog post about rewriting browser-code to Rust, from a Mozilla engineer here: https://hacks.mozilla.org/2019/02/rewriting-a-browser-component-in-rust/
### 1.1.6 Strength: Strong documentation
### 1.2.6 Strength: Strong documentation
As a beginner learning Rust, the Rust Book helped me to get up the steep learning curve: https://doc.rust-lang.org/book/
### 1.1.7 Weakness: Slow compilation time
### 1.2.7 Weakness: Slow compilation time
It takes 3-4 seconds to build DID-CLI in a debug-build. DID-CLI is barely 1000 LOC project. This is a weakness because we noticed that our iteration-speed was slower than when working in higher-level languages like Javascript and Python.
### 1.1.8 Weakness: Verbose syntax
### 1.2.8 Weakness: Verbose syntax
If a developer is used to a language like javascript, the Rust syntax may feel a bit verbose. This may scare developers away from Rust.
......@@ -76,13 +82,13 @@ Extra concepts you have to learn in this example, when coming from javascript:
- `filter_map()` - Does .map() and .filter() at the same time.
### 1.1.9 Weakness: Steep learning curve
### 1.2.9 Weakness: Steep learning curve
At least from my own experience, getting into Rust was like getting hit by a brick wall. The amount of new concepts that was thrown against me, not seen before in any other language I had ventured into, was freightening at first. Borrowing, explicit mutability, etc. Nonetheless I soldiered on, knowing that most of these new concepts actually was a strength of Rust, and not some idiosyncratic bullshit withouth any benefit, some languages make you learn
Again the Rust Community Discord server helped me through the steepest part of the learning curve. Thank you https://discord.com/invite/rust-lang-community :pray:
### 1.2 How we controlled process and communication systems during development
### 1.3 How we controlled process and communication systems during development
- **Discord** - Most live discussion was conducted in Decentralized Identity Norden (DIN) Discord server.
- **Slack** - DIN also had a Slack-server, but this was never utiliized throughout the project period. DIF on the other hand, did most of their discussions through their Slack server.
......@@ -92,7 +98,7 @@ Again the Rust Community Discord server helped me through the steepest part of t
- **Email** - Before getting into DIFs Slack-channel, there was a need to get in touch with some of the DIF-guys to ask questions about which direction the project should go in. We wanted to avoid doing uninteresting things. Snorre, which was the projects product manager, had some contact information to reach these key-industry-experts via email. The conversation always started with Snorre sending an email to one of these experts, with me (Jonas) as a CC-recipient, introducing me.
### 1.3 Use of version control systems, ticket tracking, branching, tagging/versioning
### 1.4 Use of version control systems, ticket tracking, branching, tagging/versioning
<img src="./github-kanban.png" width=600>
......@@ -101,12 +107,12 @@ Again the Rust Community Discord server helped me through the steepest part of t
- **Github Branching** - As only one developer was working on this project, throughout the entire period, most issues were resolved directly on the main branch. The few times a separate branch was created, was when bigger milestones were implemented - Example: When DID CLI was first conceived, it was being worked on on a separate branch for quite a while. Also there were alot of `playground/<miniproject>` branches in the beginning, for experimentation with different SSI-technologies. It was good to keep the experimentation in a separate branch. Because this made it easy to kill experiments, if they turned out to be a dead end.
### 1.4 Programming style guide including how to comment code
### 1.5 Programming style guide including how to comment code
- We are using the Rust official style guide found here - https://doc.rust-lang.org/1.0.0/style/style/README.html
- We are following the official style guide religiously and want to avoid in-house style guides. Sticking to the offical one makes it easier and faster to onboard new developers.
### 1.5 Use of and integration of libraries, modules, and other ways for modularisation of your product
### 1.6 Use of and integration of libraries, modules, and other ways for modularisation of your product
One of the goals of the project, was to re-use as much as possible of existing libraries from the SSI community. This was the main reason Rust was chosen in the first place. The SSI community are already heavily invested into Rust, for many of the same strengths mentioned in section 1.
......@@ -117,7 +123,7 @@ One of the goals of the project, was to re-use as much as possible of existing l
### 1.6 Use of code review
### 1.7 Use of code review
- Pull Requests in Github is at the center of the code review process. Ideally there should be one pull request attached to every branch.
- When the pull request has received a code review, it could either be approved or receive a change-request.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment