-
Notifications
You must be signed in to change notification settings - Fork 130
docs(cn): translate why-create-typescript into Chinese #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! This section of the codebase is owned by @Kingwl - if they write a comment saying "LGTM" then it will be merged. |
Translation of Why Create Typescript.mdtitle: Why create TypeScript translatable: trueTypeScript is a JavaScript-based language created by MicroSoft. This post is a non-technical overview of what JavaScript is, how TypeScript extends JavaScript, and what problems TypeScript solves. What is JavaScript?Because TypeScript extends JavaScript, this is a good place to start. JavaScript is often used to create websites. When you create a website, it's written in three languages: HTML, CSS, and JavaScript (JS). In general, HTML defines what the page displays, CSS defines the style of the page, and JS defines the interactive behavior of the page. We call people with these skills "front-end" developers. You can use these three languages to create pages in a browser (such as Safari, Firefox, Edge, or Chrome), and since the web is very popular in business and information sharing, there is a large demand for developers who are good at using these three languages. Related to the "front-end" development role is a set of skills of the "back-end" developer who create a computer back-end service that communicates with a Web browser (by passing HTML/CSS/JS) or to another computer service (by sending data more directly). You don't need to use HTML, CSS, or JS to write this type of code, but it's usually the end result of your work because it happens to be displayed in a web browser. What does a programming language do?Programming languages are a way of communication between humans and computers. People spend a lot more time reading code than writing it—so developers create programming languages that excel at solving specific problems with small amounts of code. Here is an example using JavaScript: var name = "Danger"
console.log("Hello, " + name) The first line creates a variable (which is actually a container that can store other data), and then the second line outputs the text to the console (e.g. in DOS or a terminal window) JavaScript is designed to work as a scripting language, which means that the code starts at the head of the file and runs it line by line. To provide some comparison, the same behavior is implemented in Java below, which is built with different language constraints: class Main {
public static void main(String[] args) {
String name = "Danger";
System.out.println("Hello, " + name);
}
} The two code examples do the same thing, but the Java example comes with a lot of ambiguity that tells the computer what to do, for example To understand the key points, we can focus on this highlighted line: // JavaScript
var name = "Danger"
// Java
String name = "Danger"; Both lines of code declare a file named In JavaScript, you use abbreviations Both variables contain a string type data, but the difference is that in Java the variable can only contain a string because this is what we defined when we created the variable. In JS, variables can be changed to any value, such as a number or a list of dates. Please see: // Before in JS
var name = "Danger"
// Also OK
var name = 1
var name = false
var name = ["2018-02-03", "2019-01-12"]
// Before in Java
String name = "Danger";
// Not OK, the code wouldn't be accepted by Java
String name = 1;
String name = false
String name = new String[]{"2018-02-03", "2019-01-12"}; These trade-offs make sense in the context of when these languages were created in 1995. JavaScript was originally designed as a lightweight programming language for handling simple interactions within websites. Java was created specifically for developing complex applications that can run on any computer. They are used to build codebases of different sizes, so programmers are required to write different types of code. Java requires programmers to be more explicit about their variable values because they want to build more complex programs. JavaScript, on the other hand, opts for legibility improvements by omitting details, and expects a much smaller codebase. What is TypeScript?TypeScript is a programming language — it includes all JavaScript and has more syntax features. Use our example above to compare the "Hello, Danger" script in JavaScript and TypeScript: // JavaScript
var name = "Danger"
console.log("Hello, " + name)
// TypeScript
var name = "Danger"
console.log("Hello, " + name)
// 是的,你没有错过任何东西,他们之间没有差异 Since TypeScript's goal is to extend JavaScript only, we see that current JavaScript code can also run in TypeScript. TypeScript is an extension to JavaScript designed to help you know more clearly what type of data is used in your code, a bit like Java. This is the same example, but uses TypeScript to more explicitly define what type a variable is: var name: string = "Danger"
console.log("Hello, " + name) This extra In simple terms, we call these annotations a "type system". Hence the name Type Script。 One of TypeScript's slogans is "Extensible JavaScript," which states that these additional type annotations can help you develop larger projects. This is because you can verify the correctness of the code beforehand. This means you can focus less on whether each change to your code will affect the rest of your code. In the 90s, maybe until 5-10 years ago, it was fine to have no type system in JavaScript applications, because the current creation of applications is limited to the front-end part of the website in terms of size and complexity. Today, however, JavaScript is used almost everywhere and can be built into almost any application that runs on a computer. A large number of mobile and desktop applications use JavaScript and web technologies. These projects are quite complex to create and understand, and adding a type system greatly reduces the complexity of modifying these applications. What problem does TypeScript solve?Typically, you can make sure there are no errors in your code by writing automated tests, then manually verify that the code works as you expect, and finally have another person verify that it is correct. There aren't many companies the size of Microsoft, but many of the problems with writing JavaScript in a large codebase are the same. Many JavaScript applications consist of hundreds or thousands of files. Changes to a single file can affect the code of many other files, just as throwing a pebble into a pond causes ripples to spread to the shore. Verifying relationships between each part of a project is time-consuming, and using a type-checking language like TypeScript can be automated and provide immediate feedback during development. These features of TypeScript help developers feel more confident in their code and save a lot of time verifying that they don't accidentally affect the project. |
The path seems wrong... |
The source file is https://github.com/microsoft/TypeScript-Website/blob/v2/packages/typescriptlang-org/src/templates/pages/why-create-typescript.tsx Not .md file I don't know how to support translations. cc: @orta |
Co-authored-by: Steven Ding <1139274654@qq.com>
@hexiaokang please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Co-authored-by: Steven Ding <1139274654@qq.com>
@hexiaokang the command you issued was incorrect. Please try again. Examples are:
and
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@hexiaokang the command you issued was incorrect. Please try again. Examples are:
and
|
|
No description provided.