Monday, July 18, 2016

Typescript is what JavaScript should have been

When Brendan Eich added JavaScript to the Netscape browser some 20 years ago, he had roughly a month to do it and, context-wise, JavaScript was added to the Netscape browser as a reaction to the popularity of Java - applets - at that time.

JavaScript was something you could use to interact with the browser via small programs and scripts - think sub 1k lines of code. Unfortunately, that's no longer the situation. It has become common to see 1 million lines JavaScript projects. Projects of this size are unmanageable:

1. Tooling is bad - barely there intellisense, unsafe or no refactoring

2. Development flow sucks - you can't check for common errors until you refresh the page

3. JS Code bases of these sizes are hard to reason about for many reasons like duck typing especially if you got code with bad or lazy naming conventions

This is where Typescript comes in.

1. TypeScript's static typing and annotations are great for catching errors on the tool rather than waiting for a page refresh

2. Code is easier to reason about; example, function params are known if you're using interfaces

3. TypeScript allows safe refactoring and good intellisense support

4. Although from Microsoft, TypeScript is open source with a clear roadmap with rapid releases - typically 3-4 months

But Typescript is not without faults.

1. TypeScript is superset of JavaScript. So any valid JavaScript is also valid TypeScript. In that case, if you write crappy JavaScript, you still get crappy TypeScript. Somewhat fixed if you read and apply Douglas Crockford's advice in his seminal book, JavaScript: The Good Parts

2. Typings. Sort of an edge case problem because some javascript libraries don't have typings thus we don't have intellisense for that library

The good stuff out-weights the bad parts for me. Typescript is what JavaScript should have been.

Wednesday, July 6, 2016

2 very useful super nerd tricks with terminals

In Unix land and yes that includes the mac fangays, they are called terminals. In Windows land, they are called the command line and it makes Windows users cry.

Anyhow, too often I find myself traversing a long file path on a terminal. You know what I mean by where you're doing several CD commands and when you do a pwd it will show something like "/etc/var/someRandomAssAppFolder/config/local/" or "C:\Users\Jay L. Ginete\.android\avd\IonicDevice.avd\hardware-qemu.ini.lock\". You're just in too deep and then suddenly you need to open a damn window for whatever reason. If  you don't know the trick then you'll have to navigate to said path. Shit. Nobody got time for that.

So next time what you'll do is:


C:\Users\killertilapia\Documents\WebstormProjects\Katrina>start .

On Macs

$ open .

And there you go, it opens a Explorer window if on Windows and a Finder if on a Mac (or *nix equivalent) on the same path your terminal is on.