[英]Nicholas C. Zakas:愛工作、愛技術才能成長(圖靈訪談)

李鬆峰發表於2012-05-16

圖靈訪談之二十三:對話《JavaScript高階程式設計》作者 Nicholas C. Zakas

enter image description here

注:以下是Nicholas C. Zakas回覆圖靈社群訪談郵件的原文。

Zakas:I'm very glad to meet you, and happy that the book has been so well-received. Here are the answers to your questions.

Q1:There has always been much debate about the pros and cons of various JavaScript libraries. In your opinion, how should a developer choose to use one or another?

Zakas:There are a couple of important things to decide when choosing a JavaScript library. First, how quickly do you need to get something working? If you need to get something working in a short amount of time, then it makes the most sense to go with the JavaScript library that you're most familiar with. If you have a little more time, then you might want to do some research. You want to ask several questions. Who else is using the JavaScript library? Is the library being actively developed? Does the library have good documentation? Is there a community around the library, and a way to access that community if you run into problems? How easy is it to find new engineers with experience using that library? Does the libraries solve all of your problems, or only part of them? All of these are important considerations when choosing a JavaScript library.

Q2:What are your thoughts on the future of HTML5? Is there too much hype now?

Zakas:HTML5 is a good thing for the web. The bad thing is that non-technical people have used the term "HTML5" can mean so many different things that it seems like just another buzzword. This is very similar to what happened with "Ajax" a few years ago. There is way too much hype, as if HTML5 completely changes everyone's business. It doesn't. All it does is give developers more tools in their toolbox to build compelling user experiences.

Q3:It seems Mobile Web Development will be the next big thing, what do you think?

Zakas:Mobile web development is already a big thing. Anyone who isn't paying attention to their mobile users is already behind the times. Mobile isn't a fad, it's not going to go away anytime soon. If you're serious about developing a web application, then you must consider the mobile experience now or else someone else will beat you to it.

Q4:Recently, several JavaScript-based languages emerged, such as Dart, CoffeeScript, just mention a few. Does this mean that JavaScript will become a JVM-like middle layer, or it will go strong into a more powerful and flexible language? On the other hand, for an front-end programmer who focuses on JavaScript, should he pay great attention to CoffeeScript, and not bothering the maybe complicated solutions on pure JavaScript?

Zakas:I don't see a day when JavaScript is just considered a middle layer. Things like the Dart and CoffeeScript are interesting because they show that developers would like more flexibility in JavaScript. Ultimately, I think you'll see JavaScript adopting the lot of the more popular paradigms from other languages to make the core language more complete. I don't think we'll see a day when web developers are exclusively writing in Dart or CoffeeScript or any other language that compiles to JavaScript.

Q5:How about Node.js? Will it play an important role in the server-side development? In the future, can the front- and back-end development be done in one language?

Zakas:I think that Node.js will be incredibly important to the future web applications. Developers have long been looking for an alternative to PHP that lets them get up and running on the server quickly and easily. The ability to write JavaScript on the server provides that alternative, and Node.js not only provides a server side JavaScript engine, but also a highly performant, highly scalable solution for web applications. I think this will turn many more JavaScript enthusiasts into backend engineers and that will allow front-end and backend engineers to communicate more clearly, both in the real world, and through code.

Q6:Is it feasible to implement an utility algorithm in JavaScript, say a compression program like ZIP?

Zakas:It's not only feasible, it's already been done! Stuart Knightley has already created a project called JSZip (http://stuartk.com/jszip/) that allows you to ZIP files using JavaScript. I think in the future, we will see a lot more of these utility algorithm implemented in JavaScript. You may not always want to use JavaScript, especially when dealing with complex arithmetic, but I think that the option is always there.

Q7:Is it necessary to emphasis the consistency in coding style of JavaScript? When building a big B/S system, how to best divide the duty between HTML, CSS and JavaScript staff?

Zakas:I think it's important to emphasize consistency in coding style with all languages. Whenever you're working on a team, it's important that everyone is writing code in the same way so that you can easily work on each other's code. HTML, CSS, and JavaScript, all should be written consistently within a single team. That's part of why I wrote my new book, Maintainable JavaScript, to explain how to write JavaScript as a member of a team, but the same basic principles apply to any language.

Q8:Asynchronous programming, callback functions are adopted widely, but they also bring us complicated code. Although some "deferred" and "promise" patterns can be used, it is still a big challenge for developers. Will some language structures be added to solve this problem in the future?

Zakas:There always proposals for different language constructs to make asynchronous programming easier. Whether or not we will end up seeing this as part of JavaScript in the future, only time will tell. In the meantime, there are a lot of developers who think callbacks and asynchronous programming is okay the way that it currently is. I'm not one of those people. When almost every method requires a callback, it leads to code that's hard to debug and maintain. I do hope that the solution appears in the JavaScript core language sometime soon.

Q9:You have been involved in Web development more than 15 years now, but what got you started originally? Could you please give some career advices to Chinese developers, so that they can be more successful? To be an expert like you maybe.

Zakas:I really stumbled into the web by accident. I was studying computer science in college, taking all of the normal courses with languages like Pascal and C, and was just really bored. I hated sitting in front of a black screen looking at white text all day. I wanted a way to keep in touch with my high school friends when I heard about this thing called the web. I set up my first webpage on AOL in 1996 and sent it to my friends so we can keep in touch. I would get feedback from my friends about other things they would like to see on the page, and it became a constant side project for me. I started researching and trying things out, and ended up teaching myself JavaScript in the process. By the time I graduated from college, I knew I wanted to work on the web full-time.

The best advice I can give to web developers is to love what you do. Love the challenges that cross browser development brings, love the strange quirks of Internet technology, love the people in the community around the tools that you use. The Internet evolves so fast that unless you love it, you'll never be able to keep up. That's because you need to do a lot of reading and tinkering on your own just to keep your skills up to date. Give yourself side projects. Get involved with open source software. Read books and blogs. Attend conferences to learn what others are doing. Anything you can do to keep growing as a web developer will serve you well.

Q10:To date, you have written 4 JavaScript books by yourself. How did you decide to write these books, and what new books are in your schedule?

Zakas:It was never really my plan to write books. I got laid off from my first job eight months in (the company shut down). So there I was, eight months out of college and unemployed, and I felt like I was just starting to learn. So I gave myself some side projects, and just documented what I did. I posted that documentation on my website, http://nczonline.net, and sent it out to some of my former colleagues to show them what I had been doing. one friend wrote back and said, "Hey, you're pretty good writer. Why don't you try to write an article for a magazine?" So I looked for some online magazines that were accepting submissions. I wrote one article for DevX and then several for WebReference. The articles were pretty well received and I was happy with that. Then one day there was an article on WebReference about one of the other authors who had compiled all of her writing into a book. I thought to myself, "wait a minute, you mean a book is just a collection of articles? I can do that!" And I made it my mission to publish a single book. That book turned into Professional JavaScript for Web Developers.

The other books just kind of followed a long after that. Professional Ajax was actually thought up by my editor at Wrox, and because I had had success with the first book, he offered it to me. Initially I turned it down, thinking that there wasn't enough to write about. But he persisted and I eventually said okay. I'm very glad that I did, because it turned out to be a very popular book. High Performance JavaScript came about through Yahoo, as someone internally contacted me about writing the book. Apparently, someone else had thought about putting together this book, but then was unavailable for actually writing it. So I took what they are ready had, change did so that I was comfortable with it, got a few co-authors, and finish the book.

Maintainable JavaScript, my latest one, is based on a talk I gave nearly 6 years ago. I always thought that the content was interesting enough that a book might be possible, I just didn't know where to start. Then one Saturday last December I woke up and my mind was just filled with ideas for the book, so I got up and spent the entire day at the computer just writing down everything that was in my head. I wrote about 45 pages that day. I spent the rest of December writing the rest of the book and pretty much had it all complete within a month.

At the moment, I don't have any other books planned. I'm planning on taking some time off from writing because I've been writing straight for more than a year. There are couple of topics that seem like good topics for books, but I need to wait for that moment of inspiration.

Q11:Could you please talk about your company, Nicholas C. Zakas Consulting? Could you share some experience with Chinese programmers who have the dream to create their startup?

Zakas:My consulting company is literally just me. I use my experience to help Internet companies with front end technologies. That might be performance evaluation, architecture design and review, establishing best practices, anything that a professional web development company needs. It's been a great experience, getting to go into various companies, meeting their teams, and seeing the incredible work that they're doing.

The best advice I can give to anyone who wants to start their own company is to make sure that you know yourself very well. You have to know your tolerance for things like not having a salary and potentially not getting paid for several months. There is a lot of risk with starting your own company, and if you have a family to support, you might not be able to take that risk. The timing for me was right, because I don't yet have a family or other financial responsibilities, so I could afford to take a risk knowing that if it didn't work out I could always go back and get a regular job. But that's not the case for everyone. If you have a love for what you're doing, a belief it will be successful, and feel confident taking the risk, then you should definitely go for it.

Q12:What are your favorite online communities? Please recommend some interesting online resourcs to Chinese readers.

Zakas:These days I don't spend a lot of time in online communities. I'm on Twitter constantly, following people who I know will give me a good overview of what's going on in web technology. I try to spend as much time as possible talking to real people at companies and conferences to keep up with the latest developments.

I spend a lot of time on GitHub, both looking at other people's projects, and working on my own. I find that there are a lot of great conversations about code going on and a lot can be learned by looking at other people's code. I've even ended up contributing to some projects I stumbled upon one I thought that I could make a difference.


更多精彩,加入圖靈訪談微信!

相關文章