I am stating a new course about TypeScript programming language, and I am feeling that I’m enjoying with Javascript, maybe becuase my skills improve. In today’s entrance, let’s read about what’s TypeScript and how to start with CATS, an IDE for TypeScript (also, it’s portable, a feature I like a lot!). Let’s start!
What is TypeScript
TypeScript is a programming language for developing large web applications. It’s not about hundreds of lines but thousands, and once you get to that dimensions, TypeScript can help you to skip this inconvinience, because Javascript is not the best option to program large apps.
TypeScript syntax is a superset of Ecmascript 5 (ES5) syntax, and the code is always compiled to Javascript code, that it can run on distinct browsers independant on the operating system. One advantage that can be used with this language is if you use also Javascript for the server, for example, using node.js.
The most important features for starting with TypeScript are:
- ECMAScript 6 is the new Javascript version, and TypeScript is design for it, that is the engine used by the most important browsers such us Firefox or Chrome.
- You can run old Javascript code in Javascript, written for previous Javascript versions
- It’s modular, what makes easy to maintain and code reuse
- Scalable app structure
- Good for working in group
- It’s a strongly typed language, that is, every variable has a type and it cann’t be changed (in Javascript, it can)
- It is supported by several tools, such as Sublime Text or Notepad++ (although I have decided to try CATS, an specific IDE tool for TypeScript), Visual Studio, WebStorm, Brackets, …
- Easy to work with other frameworks, such us AngularJS, EmberJS, NodeJs, Bootstrap, jQuery, …
TypeScript features
The main features are:
- Strongly typed language for variables, functions and parameters
- Classes, with constructors, functions, fields and properties. This way you can program the same way you do in other languages
- Interfaces
- Generics
- Modules, what allow the developer to have well organized code and avoid name conflicts
And the result is compiled to Javascript, always.
CATS, Code Assistant for TypeScript
CATS is an IDE for TypeScript and Web developers. CATS is open source software released under the Apache 2.0 license and runs on Linux, Windows and OS X. CATS itself is also written in TypeScript, so you can easily customize it if required. I’ve installed it on a Windows XP machine, but you can do it also on Linux or Mac, 32 or 64 bits . Also, I like it because it’s portable and for Windows XP. The steps are:
- Download NW.js from here: http://nwjs.io/, and uncompress on a directory
- Download the software CATS, from here: https://github.com/jbaron/cats/releases/. In my case, I downloaded version 1.4.344 (you can download now version 1.6.362 and try TypeScript 1.6), and I put the nw file on the same directory as the uncompress NW.js, having all in the same path.
- Using a MS-DOS console, go to the dir where you have all ready, and write the command nw cats-x-y-z.nw:
In few seconds, CATS will be running with all prepared fr you to start:
Once you verify that every thing works, it’s time to automatiza the opening of CATS, by telling Windows which program to use with nw files:
You mark Select a program on the list, a go to the path where you have nw.exe, the right program to run that type of files:
And you got it. Next time you’ll open a nw file, it will be open with CATS.
Node-WebKit
The first fo the program downloaded is Node-WebKit, and you can execute it. It’s a kind of browser:
How TypeScript works
Typescript works with .ts files that are compiled to ECMAScript 3, ECMAScript 5, o ECMScript 6, to create Javascript files, .js.
The best part of using TypeScript is that from a source code, it can be compiled to be running on different Javascript engines, with no problems, although Javascript is a language that has suffer a few changed until now.
First lines of TypeScript
Well, you have every thing ready to start, now that you now what language to use, and the IDE.
Have fun and happy coding!