I Chose TypeScript For the Nostalgia
Tags: javascript, typescript, syntax
Published: 2017-06-21 13:46:40

---
title: I Chose TypeScript For the Nostalgia
published: true
description: And Why I Feel Comfort in Doing So
tags: javascript, typescript, syntax
cover_image: https://cdn-images-1.medium.com/max/1600/1*CypkuNgU_yQ6RMDFMTFWTQ.png
---

Back when I was 13 years old and beginning my freshman year of high school, I wasn’t sure what programming language I wanted to learn first. After browsing a lot of fora and viewing a few old YouTube videos, people almost always recommended Java as a practical and profitable first language. So, that’s what learned.  

Fast forward to Junior year and I’ve had my fair share of class files, NullPointerExceptions, and a gamut of compilation errors. I’m breezing through my AP Computer Science course (which, as you guessed, teaches Java), and I’m starting to look into open sourcing my work and building more practical projects.  

I decided to write a web server with Java EE and Apache Tomcat, and, since I grew tired of what felt like writing more syntax than semantics, let’s just say I got much too frustrated with Java at this point, so I ventured into a different ecosystem.  

After some Google searches, I discovered Node.js and [Express](https://expressjs.com). After seeing an example Hello World server, I fell in love with the conciseness and abstraction that these technologies provided.

```js
var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
```

And so, I kind of became a JavaScript developer. I starting learning about callbacks, prototypes, and other cool stuff JS provides new developers. I started using Javascript for projects of all kinds: front end, back end, desktop, command line, etc. I fell in love with JavaScript’s ubiquity and simplicity (dynamic typing and not having to use semicolons seemed so awesome…at first).  

But, now I graduated high school and I’ve written thousands of lines of JavaScript. The things that originally brought me over to the language are now reasons for me to dislike it. I’m starting to see the flaws in dynamic typing, non-strict syntax, and other facets of the language. I’m starting to look for a compile-to-JS language to keep my faith before I (maybe) leave the ecosystem. Java’s syntax and typing never looked so attractive…  

And, that’s when I found [TypeScript](https://typescriptlang.org), a *typed* superset of JavaScript. Coming from ES5, I liked that TypeScript automatically included ES6 and beyond features (like that sweet, sweet `class` syntax) without needing complicated Babel configurations. At this point, I was happy to see some syntax that somewhat reminded me of my Java days.  

But, ES6 doesn’t natively provide great typing functionality: that’s where TypeScript’s true advantages come out. In the same way that Java’s types are enforcements, TypeScript’s types are suggestions. So, you have the opportunity to see how types semantically flow throughout your application similar to compiled languages like Java and C#, but you don’t necessarily have to abide by type inconsistencies, because it’s still JavaScript under the hood. *And that’s good enough for me.*  

The syntax is essentially JavaScript as you know it, except for [type declaration files](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html). Take a look at the example code below. Borrowed from [this page](https://tutorialzine.com/2016/07/learn-typescript-in-30-minutes).  

```js
var burger: string = 'hamburger',     // String 
    calories: number = 300,           // Numeric
    tasty: boolean = true;            // Boolean

// Alternatively, you can omit the type declaration:
// var burger = 'hamburger';

// The function expects a string and an integer.
// It doesn't return anything so the type of the function itself is void.

function speak(food: string, energy: number): void {
  console.log("Our " + food + " has " + energy + " calories.");
}

speak(burger, calories);
```

Like I said before, it looks just like normal JS, except you optionally define the types of each variable and function return with colon syntax. No trouble!😉  


Although TypeScript’s typing is more of a recommendation, it’s close enough to remind me of a more strictly typed language like my starting point, Java. It helps provide a bit of needed structure when building large scale projects and applications by adding typing, which is what keeps languages like C#, Java, and C++ in use.  


Although I grew tired of the forced verbosity that compiled languages require of their developers, it turns out that I may have taken it for granted. When given the freedom of dynamic typing, optional semicolons, and the rest of the works, it seems that it gets noticeably harder to build and debug large applications because of the lenience. TypeScript’s illusion of static typing provides that bit of structure that one might need to keep code clean and readable. As you can see, I chose TypeScript for the nostalgia. What might you choose it for?  

![Thank you](https://media.giphy.com/media/3otPoUkg3hBxQKRJ7y/giphy.gif)

Thanks for reading this! Feel free to give me some feedback on how it was and whether or not you would ever use TypeScript, and why.  

[Twitter](https://twitter.com/aunyks), [Github](https://github.com/aunyks), [Snapchat](https://snapchat.com/add/aunyks), [Medium](https://medium.com/@aunyks), [Instagram](https://instagram.com/aunyks)