"Silicon Valley asks" Chris Lattner interview (next)

Source: Internet
Author: User
Tags ruby on rails
This is a creation in Article, where the information may have evolved or changed.

An interview with Chris Lattner (next)

Topic

    • What is Swift's ambition in terms of Server and operating systems?
    • Swift and objective-c love and hate?
    • What are the original ideas of Swift's father for RxSwift and ARC?
    • Will the language continue to run with Swift's father?

Interview Transcript

Swift's development in the system, server and Web

Swift can be said to work well on servers, or Linux. Are you planning to run Swift on the server or on the system at the outset, or do you want Swift to focus on IOS development instead of competing with Python or Rails?

If you look at Apple's official Swift book, there is a sentence in it: "Swift's goal is to write the application on the ability to write the operating system (Swift is designed to the scale from the Hello world to an entire operating System) ". So we started by creating it as a Eminence language .

It may be a bit of a dream, but wait a few years before you know it. Whether it's me or anyone else in Apple, I think of Swift as the mainstream language of the future world, and it will go beyond Python and even one day replace C. So how do we achieve this?

Open source is an important link. You do not open source, other platforms do not want to use this language. Swift Eminence's goal is becoming more and more realistic when all kinds of development are implemented with Swift. Now many schools are teaching Swift in computer basic education, which is becoming more and more popular.

So, the first step is to make the language popular and let everyone use it. My definition of "pop" is that Swift has to have a killer product so everyone will know how good Swift is and everyone will use it. The IOS platform and Mac OS platform now have a lot of great Swift applications. So we start the second step, open source. The third step, we have to go farther.

What do you mean to go farther? I think what we have to do now is to apply Swift to the server side. In fact, the server and mobile application development is quite similar, such as architecture design and function library call. But the only trouble is that we have to allow Swift to run smoothly on the LUnix. Build a large number of server-side library functions at the same time. Now there is a special section on the swift.org to discuss the development of the server side, we feel very good brainstorming.

Next, Swift willreplace Java, whether it is the scripting language or the underlying system design, and Swift should eventually be able to cope.

scripting language, the open source community and our Apple are trying to incorporate the features of scripting languages like regular expressions, multi-line strings into Swift, but I think they will eventually become part of Swift, albeit with a lot of work.

System development, I think the most important thing to replace Java is that Swift must have its own characteristics. I think Rust is a good language, although not many people use it now. Swift is significantly superior to Rust in some top-level development. After a few more years, Swift is not far from eminence when Swift is really popular in system development.


17. For Swift's development on the server, do you think it is enough to give it to the open source community? Will Apple itself roll out the Swift function library for the server side?

First of all I think to become a server-side popular language, these parts of Swift must have: encoding and decoding, network transport protocol, HTTP. These parts I think to become the standard function library, because they are the most basic things, Apple internal to do perhaps better, because can ensure quality. For the specific Network application function library, I think there is no need in the short term. This is because there is a lot of controversy within the industry, as the framework for a king like Ruby on Rails has not yet emerged.

I think the most important thing for the open source community is two jobs. First, the package manager for Swift. This allows us to work collaboratively across multiple platforms and libraries, significantly improving compatibility and efficiency, and second, concurrency models (Concurrency model). The reason why the Go language is so popular in server and cloud development is because the concurrency model is doing well. The concurrency model should be integrated in Swift 5.

18. Now Swift is not yet mature on the server side. Some say Swift is just a language for writing apps. Now that it's 3.0, everyone seems to be just using Swift to write IOS apps. What do you think?

I'm not worried at the moment that Swift will not succeed on the server side at all. Many people wrote for several years Swift and thought they knew the language well. When Swift has server-side features, Apple will say to you that Swift can do this, and it will be much more troublesome for you to write in other languages.

The biggest problem now is that Swift is just what Apple is doing. They think Swift is just Apple's own toy and can only be used on Apple's own IOS and Mac OS systems. So we should increase the strength of open source and community building. Now the layman's attitude towards Swift is acceptable, and Swift is slowly catching up in the field of system development.

19. We all seem to be looking forward to Swift's achievements in web development. Now Web page or network program development, is generally mixed with multiple languages, front-end and back-end may be completely different language logic, how do you think about it?

This can take a long time, and if you can replace Javascript, that's it. Now Dart is doing a good job on web development. I personally look at Asm.js and WebAssembly, both compiled by LLVM, just like Swift. If these two do well enough in the future, there may be no Swift thing. It's hard to say what's in the future.

And I now find that Javascript has become a basic language. I think a lot of scripting languages are now compiled directly into Javascript,javascript as a bit of a basic expression. I think after five years, it is very likely that Asm.js will unified the Web side. Although people say Javascript is not good debug, but in fact, even if you write C so mature language, debug still very headache. That's why we don't add a macro definition to Swift because that adds to the difficulty of compiling and debugging.

Swift language Design

Swift seems to have been designed at the outset to be easy to understand, while at the same time having many high-order complex operations. Experienced programmers can write beautiful grammatical sugars, and children who have no knowledge of programming can play Playground. Do you think Swift is a complex and easy-to-integrate language?

Swift has done a good job at this point. But I worry that a lot of new features will be added after open source, so Swift is no longer easy. I have always been committed to making Swift a simple and easy-to-learn language, yet powerful enough. Why do you think we don't support inline assembler (inline assembly supports) that only a handful of geeks would like. We must also uphold this principle in the future.

A man who can't write Swift. Open the Playground and hit "Print" ("Hello World") and it will appear next to Python, and you don't have to hit the line-break symbol like "\ n". That is to say, Swift is very friendly to beginners, and we can start from Hello world and slowly transition from simple to complex.

For system development, Swift is better at controlling memory allocations than Rust, as we can learn from the experience of developing ARC. You want to allocate this underlying stuff to memory, and only a handful of Daniel can master it. So why not introduce ARC to the bottom to simplify development? I think this is another direction for Swift development.

21. It is said that Swift is a hodgepodge, part of the reference C #, part of the reference to Javascript, part of the reference objective-c, what do you think?

Swift is indeed a hodgepodge. But it is not simply imitating other languages, but learning from them, and then creating a great language. We did refer to a lot of other language designs. For example, many concepts of Haskell are introduced into Swift. The Protocol in Swift is inspired by the construct of Haskell.

There are other parts that look like Dart, as well as a reference to Go and C #. There is another benefit to this, as developers have a sense of déjà vu when they get swift, so they are more willing to develop with Swift.

Swift vs. Objective-c


22. Give me a reason to learn Swift now?

It doesn't really matter. Personally, I don't think objective-c will be replaced in the short term, Apple still supports C and C + +, and giving up objective-c is a bad thing for Apple. You don't have to learn swift,swift is just a better language.

Speaking of Swift, we give it a name that means we want the language to be very efficient. It is designed not to allow you to write a lot of code in a short time, but rather to do the work with the least amount of time and the most concise code.

Programming actually includes everything, not just code, but debugging, adapting to various systems, and a variety of other things. In fact, the development of a short time, the time to find a bug is generally very long. In Objective-c, for example, you spend a lot of time fixing unrecognized-selector error, but Swift excludes such bugs from the top-level design.

There are some other benefits to Swift. For example, you can use switch...case for strings ... statement; You can use functional programming; enum and protocol can be used. Swift is an all-encompassing language, and the rookie and the old handwritten swift can be completely different, depending on experience.

I recently discovered that many IOS developers would write Swift as Objective-c , the logical structure is exactly the same, just a different syntax. In fact, that means they are unaware of the value of Swift-that Swift is nothing more than a objective-c alternative. When developers delve into Swift's grammar, they realize how efficient it is.

23. Will the future Swift add some dynamic features like objective-c?

Swift does not currently have a plan to add dynamic features. Many people ask why Swift cannot respond, reflection these features. Someone even wrote a blog saying, "Sooner or later, Apple will rewrite all of Swift's architecture", and every time I see these blogs in front of WWDC, I will. Many people do not understand what is dynamic, and do not care about our release of the Swift schedule, just keep blogging, predicting the spit groove that.

Personally, I can make it clear that Swift has not included a dynamic feature plan in the near future. Priorities, we have to deal with other things first, such as concurrency models, such as optimizations on the system side, such as the adaptation of scripts. However, if there is time in the future, Swift will add dynamic features, as long as we have done everything in our planning table.

24. You are not worried about the lack of dynamic features, many OBJECTIVE-C programmers will not adapt to Swift, and then abandon the use of Swift?

I'm not worried. Swift itself supports all the features on objective-c, and you just need that part of the code to be compatible with objective-c and then add them to runtime.

Although a lot of people say, I just want to write pure Swift code, but in fact I do not think this is a kind of retrogression. You can use the reflection model, to use this function you use is, your own design of the code structure of their own responsibility. In writing the code, there's never been a black-and-Bai Yi saying that we're going to do the most important thing, not having a hearing on Twitter every day. The Swift Core Group is doing the work of developing swift and directing the language to the right direction.

Swift Programming Specification

Swift now has a lot of grammatical sugars. How to avoid writing strange and inefficient Swift code? Do you think Swift can be called mature now?

Now is the time for Swift to mature. Swift 1 and Swift 2, it was true that the language had changed so much that everyone was having a headache. But the Swift 3.0 is a stable and mature version, it's really good. The next task is to add new function libraries or functions on the basis of Swift 3.0, rather than modifying the existing schema.

In fact, Swift developers are also struggling with the problem of too much grammatical sugar. I hear some people have some Swift books, which is good. In fact, when we were designing Swift, we took into account the problem of grammatical sugars. For example, if you write code and use var for all variables, the compiler will remind you to use let for constants. This suggests that Swift is encouraging the immutable data type, and Xcode will automatically urge you to write more canonical code. But for now, "is it a class or a struct?" "This kind of difficult problem, the compiler is not smart enough to automatically detect and correct."

26. Some languages begin with a set of grammatical sugars and specifications. Why does Swift not, but let the open source community to discuss? Do you personally have some programming specifications for Swift?

As a programmer, I have a programmed blood flow in my bones. But in the course of Swift's development, I have changed some of the concepts that are inherent. For example, I think all code snippets should be a local input and a local output. But I later found that the design language is difficult to maintain and readability is poor. For example, the guard else statement we designed, you must write the end of the return. This leads to a function having multiple places to output: You return in guard else and return elsewhere, not in line with my original idea. But this design will improve security, because we have to deal with some special cases ahead of time.

For whitespace This format problem, I personally tend to empty 2 squares. I know some people like to empty 4, and others like 3 (because they think there should be no tab in the file). This is completely radish green vegetables each their own, everybody to this debate, which kind all have certain reason. So we didn't have a fixed format requirement for Swift, so let's write your favorite code. But it also creates a degree of confusion--The code format you write will be completely different from your colleague's. But I don't think it will affect the diversity of languages.

Go was forced to promote a set of programming specifications, the results are still controversial. Our current job is not to do grammar above the norm, and we do not want to launch a set of norms after everyone is not buy. Another benefit of open source is that you can decide for yourself what a good grammar specification is. Even if I had time, I personally or Apple would not write the Swift Style guide. I would rather answer the questions of theory and language design than the norm.

There's one interesting thing I want to share, and I've always feared that people would ask, why is Swift's function called Func? Rather than function or FN? This is actually quite controversial. But now it's Swift 3.0, and we're not going to change it, so it's pointless to argue about it.

RxSwift and responsive programming

27. Many developers use RxSwift or other responsive programming. Have you studied reactive programming carefully during the development of Swift?

I have begun to pay attention to the RxSwift. But I did not use responsive programming to develop products, so my understanding of them came from blogs. RxSwift looks great, you can write a lot less code, and you seem to be developing more efficiently. But I heard that maintenance and testing is also very difficult, there are advantages and shortcomings.

If I have time to write an App, I'm sure I'll go back and try RxSwift, and then come over and make my point. I don't dare to say "highly recommended" or "strongly recommend it".

Garbage Collection vs. ARC

28. We all know that garbage Collection and ARC are the same. Objective-c had garbage Collection and later joined the ARC mechanism. Swift is the complete ARC. Can you tell me why you're so bullish on ARC?

Objective-c was first developed based on the Libauto system, and Libauto itself had many limitations, so we used the garbage Collection. I personally think that ARC is definitely better than garbage Collection because the latter often recycles the variables we don't want to recycle in memory. So we used the reference count and ARC on the objective-c.

One of the most important advantages of ARC is that it handles the final parameters very well. If you use garbage Collection, such as Java, the final parameter is those things that are not recycled and running, so the problem is a lot. As a simple example, when a final variable runs on the wrong thread, it will run multiple times, causing the instance to be created endlessly. ARC solves this problem fundamentally.

There are currently two reasons to oppose arc, one is that people think that arc introduces additional overhead because you have to maintain the reference count. The other is that ARC easily causes circular references.

I would like to emphasize that these problems are garbage Collection. In addition garbage Collection cannot terminate all threads, or terminate a thread at a specific point in time. This is because garbage Collection introduces a security pointer (SafePoint), which is also an additional overhead.

The overhead of reference counting in ARC has little effect in actual development. And we have control over the entire life process of the object, which garbage Collection does not have. In fact, I think some of the extra overhead in ARC is necessary, and those that are not required will be improved gradually.

As to the issue of circular references. Rather than you have to explain in a specific line, retain/malloc this variable, and then in a later line to explain, release/free this variable this kind of trouble, you just need to use strong or weak to express your ownership of the object, Isn't it a huge improvement that you save a lot of worrying about memory allocation and how to do it?

The things Behind


29. Would you be relieved to give Swift to Ted?

Don't worry at all.

Ted is a very powerful man. Stanford PhD graduate, Apple ten years of work experience, has done with a self-Clang static analyzer. Ted is also very good at management. I sometimes have a whim to have a person or group of people do what I think is meaningful. Ted is a very solid manager, he always leads the team to do the most important things, this is the difference between me and him.

In addition our team is also very strong, the core team of several people: Doug Gregor, John McCall, Joe Groff, Dave Abrahams. These people are extremely good geeks. Engineers from other Swift teams are also very strong. There is no reason for them to be successful in Swift.

30. Why do you make electric cars?

First of all, I personally like cars very much. But I am too lazy to always go to refuel ah, drive, I prefer a more reliable way, the best I do not have to do anything, the car can send me to the destination. I don't have to worry about maintenance or anything. I was actually Tesla's first batch of customers, and I felt it was a pleasure to drive.

But I never thought I would go to a car company because I thought I was a programmer, what does this have to do with cars? But Tesla asked me to do the autopilot system, which is very good for my appetite. Because it's also a world-class problem, I want to try a challenge.

Add

The language mentioned by Chris Lattner

    • Go

Home: http://golang.org/

The open source language that Google publishes. Compile speed is comparable to C, more security. The learning curve is similar to Java and is relatively simple. Currently mainly used in network servers, storage systems, and databases.

    • Dart

Home: https://www.dartlang.org/

Languages developed by Google. Class-based, only single inheritance, style bias C. The goal is to become the next generation of web development languages. Google is currently trying to develop Android apps with Dart to achieve the goal of de-Java.

    • Haskell

Home: https://www.haskell.org/

Functional programming languages that support lazy evaluation, pattern matching, list-in-Package, type-class, and type polymorphism. Very few users, generally considered difficult to learn difficult to use. Mainly used in the financial system and the security and performance requirements of high-quality products.

Reference links

Audio: Accidental TECH PODCAST 205

Original: People DON ' T use the WEIRD PARTS

Swift 3 will not contain stable ABI

Reprint why industry rarely makes With Haskell?

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.