• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

TypeScript, WHY?!?!

Question

Riva    1,099

Hello I am struggling to understand the purpose of TypeScript and please correct me where I might be wrong:

  • It doesnt help back-end developers write JS code; Syntax feels totally wrong and has nothing to do with most typical OOP languages, looks like a really bad version of BASIC, and I used to think that was Pascal :p
  • Bloats development skillset; you could just learn JavaScript, bigger learning curve
  • Not every JavaScript library out there is based on the new craze (TS that is).

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0
Seahorsepip    610

Main reason for TypeScript is the strict type implementation as example, a function can only accept x & y as variable which are type a & b. This makes it a lot stricter language then plain JavaScript, which is ideal for larger software projects where documentation tends to be partially made or even non existent at all, as example we know at least now exactly what we can input and get as output when using code that we didn't write ourselves but another team member.

 

JavaScript is a very open language without many restrictions like strict types, classes, interfaces which results in it being very flexible for small development teams and projects but being very unstructured for larger teams :p

 

Of course there's the new class, interface etc syntax in ES6 but that's built on top of the function/object/prototype implementation and is simply syntactic sugar. 

 

Personally I'm more excited about ES6 it's syntactic sugar implementation then TypeScript.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
agtsmith    111

"Syntax feels totally wrong and has nothing to do with most typical OOP languages"

Huh? The syntax merely adds type declarations to variables and parameters. C++ does this. Java does this. C# does this. You know, the major players. If Java, C++, C# are not typical OOP languages, then do tell, which languages would qualify as "typical OOP" in your opinion?

"looks like a really bad version of BASIC"

Ok, so which programming languages have you seen or have programmed in before posting this comment?

"Bloats development skillset"

Static typing is a *bloat* of development skills? If you feel that confining your development skillest to JavaScript only is the way to go, then perhaps I could agree. Static typing DOES help to write code as one is less likely to make a mistake by calling a function with incompatible parameters.

Share this post


Link to post
Share on other sites
  • 0
Xilo    914

If you think typing is bad, you might be a bad developer...

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
1 hour ago, Riva said:

Hello I am struggling to understand the purpose of TypeScript and please correct me where I might be wrong:

  • It doesnt help back-end developers write JS code; Syntax feels totally wrong and has nothing to do with most typical OOP languages, looks like a really bad version of BASIC, and I used to think that was Pascal :p
  • Bloats development skillset; you could just learn JavaScript, bigger learning curve
  • Not every JavaScript library out there is based on the new craze (TS that is).

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
1 hour ago, Riva said:

Hello I am struggling to understand the purpose of TypeScript and please correct me where I might be wrong:

  • It doesnt help back-end developers write JS code; Syntax feels totally wrong and has nothing to do with most typical OOP languages, looks like a really bad version of BASIC, and I used to think that was Pascal :p
  • Bloats development skillset; you could just learn JavaScript, bigger learning curve
  • Not every JavaScript library out there is based on the new craze (TS that is).

Everyone I know that uses TS already knows JS. Typescript isn’t a replacement for that. It gives structure to JS. Let’s face it, the average JS developer writes terribly structured JS. Why? Because it will let you. 

 

Thats why why I was so opposed to schools (well the school I was discussing at the time) replacing Java with JS as their first language. 

Share this post


Link to post
Share on other sites
  • 0
Riva    1,099
6 hours ago, adrynalyne said:

Everyone I know that uses TS already knows JS. Typescript isn’t a replacement for that. It gives structure to JS. Let’s face it, the average JS developer writes terribly structured JS. Why? Because it will let you. 

 

Thats why why I was so opposed to schools (well the school I was discussing at the time) replacing Java with JS as their first language. 

Thing is TS isnt that well structured either. In all fairness I prefer the old ASP.NET AJAX 3.5 JS Framework as it allowed for namespace and type declarations, identical to Java and .NET.

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
1 hour ago, Riva said:

Thing is TS isnt that well structured either. In all fairness I prefer the old ASP.NET AJAX 3.5 JS Framework as it allowed for namespace and type declarations, identical to Java and .NET.

It’s hella better structured than a language that has no structure. 

Share this post


Link to post
Share on other sites
  • 0
+Red King    2,445

Advantages of TypeScript

  1. You know exactly how many parameters and what type of parameters you need. It won't compile if types do not match. In JavaScript, on the other hand, it will blow up at run time or -better yet- when demoing your project to your clients.
  2. You know exactly what can be undefined or null. There is no need to check. In the matter of fact, with a fully TypeScript project - you can drop type checking and null checking altogether and allow TypeScript to simply prevent you from passing in stuff you don't need.
  3. It is a superset of JavaScript. So you can write ES6/ES7 JavaScript code and it will transpile it down to ES5. This allows you to write cleaner code by utilizing modern JavaScript features such as classes, string interpolation, async/await, and decorators before browsers support these features.
  4. All good JavaScript libraries have type definitions available.
  5. Powerful constrains, overloads, and things like keyof allow you to create classes, abstract classes, and functions that provide significant structure to your application
  • Like 1

Share this post


Link to post
Share on other sites
  • 0
FloatingFatMan    17,569
On 8/30/2017 at 3:03 PM, Xilo said:

If you think typing is bad, you might be a bad developer...

Every single day I'm forced to write JS, I curse the cretins who developed it in such a lazy, sloppy fashion.

 

Honestly...No typing.. What were they thinking?!

 

On 8/30/2017 at 9:53 PM, Riva said:

Thing is TS isnt that well structured either. In all fairness I prefer the old ASP.NET AJAX 3.5 JS Framework as it allowed for namespace and type declarations, identical to Java and .NET.

It's trying to put a ribbon on a pig. What do you expect? :p

 

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012

While I understand the power of types (as PHP7 has made fantastically easy to implement for the most part), I think that no matter what option you use to try and enforce types in JS it's going to feel like a bandaid for the "problem". To me, it's not a problem that's really worth solving. There are plenty of new features in ES6 that are far more useful for organizing and structuring your javascript than TypeScript will offer you. Classes, inheritance, all in a non-cringey syntax. And with this you can check type when it's truly important (dependency).

 

I think the really worrisome part of JS isn't that people can't write loosey goosey software. It's the fact that the ecosystem is basically flavor of the month.

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
5 minutes ago, Emn1ty said:

While I understand the power of types (as PHP7 has made fantastically easy to implement for the most part), I think that no matter what option you use to try and enforce types in JS it's going to feel like a bandaid for the "problem". To me, it's not a problem that's really worth solving. There are plenty of new features in ES6 that are far more useful for organizing and structuring your javascript than TypeScript will offer you. Classes, inheritance, all in a non-cringey syntax. And with this you can check type when it's truly important (dependency).

 

I think the really worrisome part of JS isn't that people can't write loosey goosey software. It's the fact that the ecosystem is basically flavor of the month.

And what happens when a browser doesn’t support es6 properly?

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012
3 minutes ago, adrynalyne said:

And what happens when a browser doesn’t support es6 properly?

You transpile it to ES5 using Babel. It's not hard to make ES6 work in older browsers that don't support it. It's just another step in the build process.

  • Like 3

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
52 minutes ago, Emn1ty said:

You transpile it to ES5 using Babel. It's not hard to make ES6 work in older browsers that don't support it. It's just another step in the build process.

Or you can use typescript which does the same thing and much more. 

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012
25 minutes ago, adrynalyne said:

Or you can use typescript which does the same thing and much more. 

It's just another dependency. ES6 brings you to the next iteration of Javascript and you don't lose anything by switching to it. TypeScript is another dependency that when compared to ES6 doesn't offer much more and isn't going to become native in the future. It's not forward compatible as far as I know. If your problem is organizing your code and structure, TypeScript isn't necessary. If you want strong typing then sure why not, but you should always look to solve the problem you need to solve rather than trying to solve every problem before it becomes one.

Strong typing is great, but it's not an absolute necessity and there's enough languages out there now which don't enforce it that are doing perfectly fine. Not everything has to be C#, C++ or Java.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
10 minutes ago, Emn1ty said:

It's just another dependency. ES6 brings you to the next iteration of Javascript and you don't lose anything by switching to it. TypeScript is another dependency that when compared to ES6 doesn't offer much more and isn't going to become native in the future. It's not forward compatible as far as I know. If your problem is organizing your code and structure, TypeScript isn't necessary. If you want strong typing then sure why not, but you should always look to solve the problem you need to solve rather than trying to solve every problem before it becomes one.

Strong typing is great, but it's not an absolute necessity and there's enough languages out there now which don't enforce it that are doing perfectly fine. Not everything has to be C#, C++ or Java.

Typescript isn’t destined nor intended to become native. There aren’t compatibility issues because it compiles down to JS.  Your issues with it are purely subjective. If you don’t like it, don’t use it. I’m not seeing a problem here; we all have different preferences. 

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012
40 minutes ago, adrynalyne said:

Typescript isn’t destined nor intended to become native. There aren’t compatibility issues because it compiles down to JS.  Your issues with it are purely subjective. If you don’t like it, don’t use it. I’m not seeing a problem here; we all have different preferences. 

I have no particular opinion on it, however I don't agree with your implication that TypeScript is a viable substitute for ES6. It's just not.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
20 minutes ago, Emn1ty said:

I have no particular opinion on it, however I don't agree with your implication that TypeScript is a viable substitute for ES6. It's just not.

It’s not meant to be a substitute for es6 and I never said it was. 

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012
6 minutes ago, adrynalyne said:

It’s not meant to be a substitute for es6 and I never said it was. 

If that's not what you were saying with the below statement then perhaps you should have worded it better.

1 hour ago, adrynalyne said:

Or you can use typescript which does the same thing and much more. 

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
12 minutes ago, Emn1ty said:

If that's not what you were saying with the below statement then perhaps you should have worded it better.

 

If reading is hard for you, improve yourself. Don’t blame me. You were talking about all the things Babel could do. Well Typescript can do those same things. I wasn’t aware I needed to hold your hand and walk you through the text. 

Share this post


Link to post
Share on other sites
  • 0
Emn1ty    4,012
Just now, adrynalyne said:

If reading is hard for you, improve yourself. Don’t blame me. You were talking about all the things Babel could do. Well Typescript can do those same things. 

Perhaps you should take a step back, because you're getting rather heated over this and starting to get petty. Again, you offered it as an alternative to ES6. I'm not sure how else to take what you said seeing as your post is "or just use TypeScript because it does the same an more". So why else would you be claiming it does the same thing if not to say that it can be an alternative?

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
astropheed    2,168

There is no reason for this to escalate. You can maintain a civil discussion about the benefits of using TS vs ES6+Babel without resorting to attacks of character or reading comprehension. In the end it'll fall on deaf ears because I'll just delete it.

 

Keep it civil. Discussions on language preferences are always subjective and personal and any discussions regarding them should be approached with this in mind.

 

As for the reason for using TypeScript, the reason is in the name, "type". Other than that it's just another way to structure JS which can mostly be accomplished now by using ES6 and Babel for any issues that arise from that. I personally have a lot more faith in ES6 than I do in TS.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201
33 minutes ago, Emn1ty said:

Perhaps you should take a step back, because you're getting rather heated over this and starting to get petty. Again, you offered it as an alternative to ES6. I'm not sure how else to take what you said seeing as your post is "or just use TypeScript because it does the same an more". So why else would you be claiming it does the same thing if not to say that it can be an alternative?

I’m not heated at all; I’m just treating you with the same contempt you showed me. I did NOT offer it as an alternative as es6. You talked about Babel transpiling es6 to ess5 and I said or I can use typescript which does the same and more.  The proof is in the text I quoted. 

 

3AE475C0-4FC3-40E6-B7F3-E4765BFC3205.png

Share this post


Link to post
Share on other sites
  • 0
adrynalyne    11,201

Regardless, I’m not interested in fighting with you @Emn1ty . Just understand that in no way do I feel TS is an es6 replacement. 

Share this post


Link to post
Share on other sites
  • 0
+DevTech    1,508
On 9/4/2017 at 10:36 PM, adrynalyne said:

Regardless, I’m not interested in fighting with you @Emn1ty . Just understand that in no way do I feel TS is an es6 replacement. 

I actually enjoy reading these "heated" discussions sometimes and often in the process people will go to extreme lengths and drag up all sorts of useful reference material so it's a balancing act.

 

Since this discussion is essentially "timeless" I would like to add that there is no reason why Typescript can't evolve and include elements of ES6 and maintain a comprehensive "Superset" status.

 

Also, Facebook uses Flow which is similar to Typescript.

 

And then there is the whole JS as "ASM of the Web" thing with transpiling from C++, Java, C# and Scala etc to JS.  I should post a bunch of links for future readers, but...

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
Matthew S.    728

I have a feeling you feel the same way about SASS and LESS...

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.