The RISE of TypeScript

A couple of weeks ago we announced the rewrite of RISE core in TypeScript.

TypeScript is a free and open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.

What we achieved so far

Before we dive deeply into the current status of the TypeScript rewrite, I’d like to briefly recap what RISE has achieved so far.

Since Aug 2017 three new developers joined RISE: Alessio (carbonara), Jose (jguidos) and Matteo (mcanever).

Tests are truly crucial in the world of crypto code; these last few months our developers were mainly focused on writing unit tests for the current RISE codebase reaching a nice 68% code coverage (starting from almost zero).

Code coverage ramp up.

In the meanwhile I set up Travis and coveralls integration + slack integration to really streamline the development process.

In the public Github repository we can now count more than 90 commits and 38 closed pull requests.

The needs

When I first joined the RISE development team I immediately expressed my thoughts about the current status of the Core code which was entirely written in JavaScript. While I personally like JavaScript there is a very strong reason why most big web projects are written in TypeScript and not in JS: TypeScript lets you write much more robust and readable code that will also speed up development and future code refactoring.

Without flooding you with too many development details you should also know that code written in TypeScript usually benefits a 15% bug reduction compared to the same codebase written in plain EcmaScript (or Javascript). I’m sure you can imagine how crucial it is that bugs are eliminated in the blockchain world and why that 15% really matters (among all the other wonders of TypeScript).

The current status

The current RISE core code is already 100% TypeScript; one month ahead of my predicted deadline.

But, when porting the code from JS to TS I personally noticed some bad coding practices inherited by previous developers of the RISE core.

Dependency graph of each module

As you can see from the graph above the current modules “wiring” is totally a mess; filled with direct and indirect circular dependencies which are a known bad-coding practice.

As mentioned previously TypeScript allows easy refactoring of your code without worrying too much, so I decided to pursue another challenge and I’m personally abstracting all code implementation to use interfaces and streamline/unfold all the requirements/dependencies for each piece of code; once done, we will be able to benefit from another best coding practice: Dependency Injection and IoC.

Ok, so after creating a solid and stable core what’s next?

Immediately after TypeScript and IoC are implemented the following short-term goals will be accomplished:

  • Ensure that we have almost 100% code coverage by re-wiring the tests for TypeScript and adding more;
  • Fix current implementation glitches which I’ve been diligently noting;
  • Release the TypeScript codebase in testnet and test it live.
  • Integrate it with Travis to produce a downloadable package to ensure all delegates have the core version (dependencies included).

In the meanwhile I would like to commit and post status updates regularly here.

Stay tuned :)