From Go, Swift: the choice of language requires caution

Source: Internet
Author: User
Tags php language microsoft c
This is a creation in Article, where the information may have evolved or changed.

This article transferred from : http://www.csdn.net/article/2014-12-09/2823025

Summary: Whether it is open source go or closed source Swift, the new language is always the pros and cons. However, it is certain that the new language gives the programmer some useful support points. For developers, no matter how much you grow, you will be subject to the language you use, so choose to be cautious.

Google introduced the idea of go for the first time in 2009, and Facebook brought in hack last spring, and Apple released its swift language shortly thereafter.

In war, winners write history books; in technology, winning companies are writing programming languages. Interconnection is built on the development of standards and code, but social networks and cloud computing are dominated by corporate giants, and they are starting to put their own unique imprint on digital technology--which is inevitable, like William the Conqueror and his Norman, a large number of new words added to the English language. He brings many new things, such as the jury system, which affect the local laws and the way of the language.

To be sure, the new language gives the programmer some useful support points. The build of the Google go language simplifies the work of running code concurrently, and because of the parallel programming pattern, this language is also designed to solve multiprocessor tasks. For popular web scripting languages, the Swift language like PHP and Javascript,apple gives iphone programmers some simplicity and flexibility. Each language has its own logo: Swift is a stylized bird, and the go language is a ground mouse with a foot.

Ken Thompson, Rob Pike and Robert Griesemer, Google's three-bit coder, made the idea of go in a half-joking 2009. The widely used programming languages such as C + + and Java are dull, especially when it comes to large-scale project deployments like Google. Each time you add or change something, you need to wait for the compiler to convert the code into a machine-readable binary version.

Rob Pike said: "This waiting process takes 45 minutes, I think it is painful." When it takes so long to wait, you have a lot of time to think about what you need to do to be better. ”

Design programming language is a trade-off-easy for programmers, best for machines

Creating code that runs fast requires more effort from the programmer. How much time and effort does it take for people to write code that runs quickly? Another major tradeoff is the amount of memory that the language provides when accessing the machine directly. Not only here, but also elsewhere, language inventors have to choose: How much freedom do you provide to programmers when they know they might screw up? How many measures do you offer them to alleviate their mistakes?

The task of language design is solemn, formal, magnificent, full of difficulties and contradictions. There is no right answer, there are only different options to adapt to changing hardware, changing users and picky programmers.

The creator of the go language had enough experience to make these choices, and Ken Thompson created UNIX, and he and his companion Pike (Bell Labs veteran) devised a character-coded style, known as UTF-8, that most web use today. So they know that small decisions can have a huge impact. The addition of each rule now may mean that a lot of keystrokes in the future require the programmer to operate. The omission of each rule could mean a myriad of crashes.

For example, a programming language typically uses semicolons to separate statements, with parentheses to organize related statements together. Typical C-language programs such as "Hello,world":

[CPP]View Plaincopy
    1. Main ()
    2. {
    3. printf ("Hello World");
    4. }

The creator of Go believes that parentheses are essential. Some languages (especially Python) put this aside, allowing programmers to use indents (spaces) or "invisible characters" to tell people and machine code where they are. The Go team sees this as a "profound mistake", which means that the programmer can clearly and unambiguously tell the computer how to assemble the code in a large area. At a meeting with Sergey Brin, Google's founders suggested that go designers use square brackets instead of curly braces, saving developers countless trips using the "Shift" key.

In December 2009, go decided to stop asking the programmer to end the statement with a semicolon. The semicolon is used for the parser-the behind-the-scenes tool that breaks the project into chunks (a piece of related code), and the current FAQ explains: "We want to eliminate it as much as possible, and when you deliver your code to the parser, the machine injects a semicolon." ”

The go clear semicolon relieves the programmer of Eyestrain, but the programmer needs to deploy curly braces more rigorously, or the semicolon is injected into the wrong place.

These choices are not uncontroversial, one critic complained in Pike's lecture: "They have broken the language through redundant curly braces." "The language can also be designed easily, using only the whitespace to exercise the curly brace character to block different parts of the code. Andrew Gerrand of Google responded: "Every day there is a certain amount of incredible misfortune happening." It means someone will secretly put some invisible symbols into the code base, causing a subtle bug. This has happened more than once in Google's Python program. ”

But for programmers who argue about nuances in software forums, the "wayward" syntax also makes them "drunk".

Unlike the language we speak, programmers call it natural language. Programming languages are carefully crafted for special purposes and purposes. Go, as Pike explains, is designed by Google to solve Google's problems. Google has big problems ... We need a language that will make it easier for us to do our job-writing service software.

Google runs its own global supercomputer in cloud services, which makes it possible to optimize the use of go. But Google didn't get a penny from the sales software. And go is already a free, open-source project, which allows it to quickly enter the technical library of other equipment. "It's a new language for cloud infrastructure," said an analyst at RedMonk Consulting. ”

Go has become more and more popular. For example, Dropbox has shifted most of the back-end code from Python to go. Automattic, a company that operates WordPress.com, also uses go, although WordPress itself has been using the PHP scripting language. Automattic developer Demitrious Kelly said: "These days there are more than 10 new frameworks and ways to put it, and you have to ask yourself, is it better than what we have?" But this is a complex question in itself, how good is it? What can it do to make us do what we can't do before? Is it worth it? Kelly says go has performed well in many tests, partly because the language is small, saying: "The go language is easy to get started within one weeks." ”

Given that go is designed primarily for Google-specific questions, the choice of syntax, namely semicolons and braces. The question is not so simple as to pursue detail and enthusiasm. Willing to ignore the traditional programming to bring new language to the world. What might ultimately drive language adoption is that programmers pay careful attention to everyday coding-programmers call it "pain points."

The origins of Swift

Every programming regime has this pain point, but the rapid rise of iOS gives developers more than their regular share. Until the advent of the swift language this summer, if you want to write a program for iOS, you must use the Objective C language. In the 80 's, Steve Jobs had adopted objective C, and when Steve Jobs returned to Apple, the language became the main tool for Mac OSX.

Now the developer speaks a language that also reveals his age. Writing Mac OS veteran Andy Hertzfeld said: "I was very excited when I saw the swift announcement." Because I always despise objective C, I like the principle behind it, but I hate its grammar, I have never been able to really enjoy programming. ”

Apple has entrusted its next-generation product and programming language project to a computer scientist named Chris Lattner, one of the main sponsors and authors of the LLVM project. LLVM is an open source project whose core library provides compiler-related support that can be run on different platforms (including Apple and Google, which are widely used). After joining Apple in 2005, Chris Lattner continued to LLVM the project and related work, then disappeared for a few years in the public eye, and last June, at the Apple Global Developers Conference, brought Swift in front of everyone.

Swift is designed to be "the first industrial-quality system programming language!" "In other words, Swift is promising, and you will be able to write code that runs quickly without the hassle." This has won the cheers of a large number of iOS developers and bystanders. Hertzfeld says: "Well done, it relieves everyone of the great pain points." For iOS developers, it's foolish not to pursue Swift's top. ”

If you "sign up" for Swift, you're buying the entire apple sector: you need to develop and sell your programs through Apple, your programs will run on Apple machines, and if you want to run anywhere else, you need to write them again in other languages. Your destiny will be inseparable from Apple.

Hertzfeld said: "You have to submit to this" walled garden ", so he resisted the temptation to work with Swift. But if they realize open source, or have a little interest in cross-platform, I might be able to accept Swift's work. ”

The open source version of Swift means that developers can find a way to quickly migrate programs to different platforms, and this will ensure that in the future, when Apple loses the interest of Swift to continue, the language still has a future. Developers who have stayed on the periphery of "walled gardens" are often very concerned about this issue. Apple is not entirely allergic to open source, although it seems determined to seize control of iOS worldwide. Shortly after Swift's announcement, developers in the LLVM project began to dwell on the issue of Swift's "isolating nature" from Apple and Lattner,lattner in response:

friends, your speculation is just--speculation. We haven't talked about this because we have a lot of work to do to deal with a lot of feedback, and we're going to do a lot of things (like access control) before we release the 1.0 release this autumn. You can imagine that many of us want it open source and become part of the LLVM, but the discussion hasn't happened yet and it won't happen in a short time.

Swift does not have a long go time, and in any case its future is safe in the Apple field, if Apple says Swift is the future of 1 billion iOS devices, then it is. Like a Portland independent iOS developer David Wheeler, people use it because they have no choice in the long run and it makes sense. Wheeler said Swift quickly took him down and thought Apple would continue to patch objective C, "I wonder where it is now?" "Wheeler said.

Language instincts

Mainstream languages in the mainframe era had similar origins: Fortran from IBM, and COBOL was largely based on Grace Hopper's Flow-matic, which was created for Remington Rand UNICAC. In 1990, Sun created the java,2000 Microsoft C #.

In fact, most languages are the product of large institutions, businesses or schools.

"It takes a lot of resources to create a new programming language," Hertzfeld says. It's a 10-year project to make new languages completely tool-based, built and used, and small companies can't do that. ”

Despite the difficulties, it is sad that since 1960 there have been too many languages in the computer industry that have duplicated parts. Today's sorrow is useless, and programmers are less likely to stop designing new languages or agree to share them, as earlier developers Alex Payne said: Without motivation, language history is rife with standardized efforts. This is very wrong, wasting a lot of time, but does not produce a result that everyone is satisfied with.

That doesn't mean ignoring the new language hack developed by Facebook, although Hack is an open source, but essentially a variant or extension of the PHP language. are not sought after by people outside the company. There's no question that Facebook wants to see change, but it's not something that social networks are actively pushing. The response to Facebook's hack these days is "wait and see."

The developer points out that every new language begins to exist as a seed that is not lost in a person's or group's brain, which has plagued me. We can do it even higher. In any case, patience and effort are needed to learn a new language, and developers have to choose carefully. Payne said: "When I am elected to use a new language, I will follow other people's things, because these people are as dependent on libraries and documents as you are, and I think you want to know if you have entered the right town." ”

One thing we can confidently say is that the new language is good, they simplify the programmer's life, simplify the process of programming, they incorporate new promising ideas, and they win the respect of developers both inside and outside the company.

For these reasons, hegemonism may be a false historical contrast to the creation of new programming language trends. Instead, we're talking about more like the type of foreign policy called soft power: Go and swift embody the essence of their company in a specific way. Server vs personal device; Open Web vs App Store; a cross-platform world vs. a company. All differences between programming languages--compiling or interpreting? Static vs dynamic Variable type? Memory Management/garbage collection? These may all be important today.

In other words, anyone worried that the real cause of the business development programming language might not be "OMG, they want to take over the world!" Instead, the reason they worry is that no matter how big they grow up, they are always bound by the underlying language.

As for programming languages, once they occupy the programmer's "mind", you never know where they will eventually go. In the 80 's to create objective C's object-oriented programming enthusiasts, they may not know that the language in 25 will become a huge global ecosystem mobile devices necessary programming language. When Sun introduced Java in 1995, everyone thought it would be a great tool for building browser applets, but its fate went to the server side. The simultaneous release of JavaScript is widely forgotten, and today it makes a lot of Web "mobile".

For developers, choosing a language is like choosing a country's nationality, you buy not only grammar and semantics, you also buy economics and culture, and how you get the rules of livelihood and power. As they often say: To avoid a "dead" language that controls the world, buying requires caution.

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.