Coffeescript? TypeScript? or JavaScript?

Source: Internet
Author: User

Please note that this article is just my prejudice, and I am trying to understand the rationale for writing JavaScript code with compilers such as Coffeescript or typescript. Statically compiled, strongly typed languages and frameworks, I have these popular, rich backgrounds. My last job was to use typescript because I had to use it. It was a time of unhappiness, and I would leave for it.

I am fortunate to have freed myself from this dilemma and burden, and I am extremely pleased to be using JavaScript to write code completely! If my enthusiasm for this change is not obvious enough, please let me assure you that I am happier now. It is important that I do not imply any errors in static compilation or strongly typed languages, because it is certainly true. It's just not my dish anymore.

Given the dynamic nature of JavaScript and the lack of static type checking, I might write low-quality code that is riddled with bugs but not found at compile time, right? The answer is unambiguous, no! I can never be so motivated, productive, expressive and efficient. I have not written a high-quality code with the fewest bugs, nor can I fix it quickly after a bug is found. Perhaps you want to know if I'm writing unified JavaScript that follows best practices and styles without a compiler? The answer is, yes! I didn't mean to preach myself here, but to point out that the lack of static compilation does not necessarily lead to more bugs and lower-quality code.

Indeed, there are many ways to ensure that JavaScript code is written correctly, follows recommended styles, and best practices. Not to mention that writing high-quality JavaScript becomes second nature, and naturally, you tend to follow the same good patterns you've learned. You should also always write appropriate unit tests, which is a best practice and another defense against bugs that helps ensure the expected functionality. Let's not forget that the right code review is also a best practice and should be used.

So why use these compilers, and what are the benefits? The answer is, I don't know. Should there be rubyscript and pythonscript that can be compiled into Ruby and python? In my opinion, if you don't like or want to write JavaScript code, you probably shouldn't be a JavaScript developer. Is it a strange, imperfect language? It's definitely, but it's been getting better. Most of the quirks and omissions in ECMAScript Harmony "Note 1" are presented, such as: Es.next.

I think there's only one reason for using some kind of compiler: if you're a high-level expert, JavaScript danale, and don't like native JavaScript, just want to do something quickly and easily. If you're not the expert you just mentioned, then I really believe you're just hurting yourself and escaping native JavaScript. Why do you ask? The answer is that JavaScript is becoming ubiquitous and becoming a solemn and amazing language. It has been integrated into all web and mobile environments, servers using node. js, databases such as MongoDB, and even recent hardware-level processing (such as Arduino).

I've read a lot of things like blogs, newsletter, books, articles, papers, documents, MDN, etc. that are related to JavaScript. They all contain code written in native JavaScript, and I rarely see the code that the author renders in Coffeescript or similar languages, and I stop reading as soon as I encounter them in very few cases, because I'm only interested in JavaScript, not other versions of it.

If you've ever planned or are interested in working with JavaScript-based databases such as MongoDB, then you need to know how to write JavaScript. You can't use Coffeescript to query MongoDB, nor can you use Coffeescript to write server-based JavaScript for node. js without precompiling, even if you have the ability to do so.

What about GitHub, a tidal flood of millions of of JavaScript libraries and frameworks on the surface? Large-scale have jquery, AngularJS, underscore and so on. I highly recommend learning JavaScript in depth so that you can not only read and understand the source code, but also debug it. Yes, when it comes to debugging, whether you're in the browser or using Webstorm to debug JavaScript for node. js, native JavaScript will be involved.

The last point I want to take is to collaborate with others (like GitHub) or get a job with a JavaScript studio. If it goes well, the benefits of mastering native JavaScript should be more obvious. When you enter the first day of your career and go into a serious JavaScript studio and ask the Coffeescript compiler questions, can you imagine what this scenario is?

Reiterate that if you are a senior expert in JavaScript Danale, then the compiler may be good? Still, I doubt you will become such a danale if you avoid learning and writing native JavaScript because you favor some kind of compiler. If you're worried about static checking and styling, you can try some build tools (such as Grunt, Gulp, Node, NPM, etc.). Many plugins run very well. For the established code, use Coffeescript or typescript to see the compiled JavaScript and then emulate the output of the native code. In any case, do yourself a favor by prioritizing JavaScript.

Note 1:ecmascript Harmony will be released as "ECMAScript 6". Http://zh.wikipedia.org/wiki/ECMAScript

Original: http://innoarchitech.com/coffeescript-typescript-javascript/translation: Labazhou

Coffeescript? TypeScript? or JavaScript?

Related Article

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.