Typescript First Experience

Source: Internet
Author: User

Why?

Why use typescript, what are the benefits and when do I need it?

Well, Typescript introduction on-line search is a big pile, various explanations, certainly more than I said the details, you can Google yourself. So, let's talk about my personal opinion!

1, out of curiosity about a new language, "black technology" what the total use of the meaning (like bridge.net is the C # version of JavaScript), not to mention that it is not considered "black technology", and is the father of C # written.

2. For programmers who are "poisoned" by C #, they hate JavaScript and other weakly typed languages, but they have to use it in their work.

3, in the construction of large-scale JS project framework, with the project more and more, redundant code is very much, its own JS Foundation dare not boast, feel that some places can fall into JS pit inside.

4, for Angular, jQuery, knockout and other front-end framework is also the perfect support, and with the corresponding declaration file directly, and can be directly compatible with the existing project code.

Start

1. Tools

Visual Studio CODE,TSC Compiler

2. Development environment

Window7

Look first.

Typescript generates native JavaScript code for compilation

Left column: [Ctrl+b] equivalent to the solution bar, Vscode supports folder as a working directory

Middle column: Typescript code Edit Area

Right column: Compile the generated target JS code, generated by default in the TS sibling directory

Look at the effect is good, with similar C # code, compile and generate the corresponding JS code.

Grammar what really nothing can be tangled, the complete object-oriented, the students have the basis of programming, I believe that learning on the Internet, in less than half an hour, basically done, with vscode powerful smart hints, greatly improved the encoding speed. In addition, Vscode's support experience with JS is excellent.

However, it seems that the speed of compiling this single file is not very fast (PS: I use the console directly compiled, of course, after the configuration of Vscode, [ctrl+shift+b] can also be compiled), this file also almost spent 5 seconds, for a large number of files to compile the compilation performance to be verified;

Summarize:

In general, TS is very good, with Vscode more embodies its strong place. Of course, there will be a lot of people to scoff at it, the purpose of a language is to eventually compile into another language, what is the meaning (I thought before), but back to think, C # is actually compiled generated Il,il runtime and become machine code it? Does Java also generate bytecode? Do you write an IL or a compilation, of course, does not rule out Daniel or special requirements, but the same function in high-level language implementation is definitely faster and easier to maintain. And I think for our front-end understanding of the fur of back-end programmers, is really a benefit, greatly reducing the risk of the bug, improve the coding experience, and strong type of inspection, classes, interfaces, namespaces, inheritance and the implementation of polymorphism is also very good wedge object-oriented programming.

As mentioned earlier, Typescript compiled into JS, so we are better use it's premise is that we have to have the basis of JS, corresponding if the use of some front-end JS Framework, we also need to have the corresponding knowledge points, to reflect the advantages of TS.

For the reasons why the front-end encoding is not directly done in Visual Studio, the personal insight is that the Web project adheres to the idea of MVC at the code level, and in the actual operation and the choice of tools, the individual also prefers this pattern, which is used by the backend code vs this IDE, encoding, Compilation is quick and easy, and front-end code has better user experience and performance in some editors such as Vscode, Sublimetext.

Well, the above is the first experience and feelings of the typescript, if there are inappropriate, please correct me, common progress.

Typescript First Experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.