[英]C++ API設計大師Martin Reddy:選擇最合適的語言(圖靈訪談)

盼盼姐發表於2013-10-22

Martin Reddy博士是軟體行業的一名老兵,有著15年以上的從業經驗,早年,他曾在SRI International供職5年,他成功建立了在Web上描述3D地球空間資訊模型的ISO標準,並且還連續兩年被選為Web3D協會的會長。他曾在Pixar動畫工作室工作過6年,擔任內部動畫系統的首席工程師,這些API在一些奧斯卡獲獎及提名影片的製作中都發揮了關鍵作用,這些影片包括《海底總動員》、《超人總動員》、《賽車總動員》、《料理鼠王》,以及《機器人總動員》等。據說《超人總動員》中的超人爸爸的頭部原型就是借用自Martin Reddy。  

他還開辦了一家諮詢公司Code Reddy,為各家軟體公司提供技術諮詢,為大型線上3D虛擬世界《第二人生》設計了API並改善了其基本架構。現在Martin Reddy擔任ToyTalk公司的技術長。我們聯絡他的時候,他正在為公司即將釋出的第一個產品忙得不可開交。

訪談中文版

iTuring: Congratulations on the successful launch of your company’s new product, do you believe speech recognition and artificial intelligence would be a major trend in the future?

Martin: Thank you! Yes, with the introduction of Siri a couple of years ago, we are starting to see a lot more apps and devices that use speech as an input mechanism. From controlling your phone, to your television, to your game console. I think it makes a lot of sense that we want to communicate with our computers in the same way that we communicate with each other. So I predict that we will see many more advances in speech recognition technology to enable this, as well as the related fields of natural language processing and artificial intelligence in order to better understand what we say and to respond appropriately.

iTuring: You have worked for Pixar Animation Studio, which is a world leading animation making team. Will you attribute its success mostly to its creativity or its strength in technology?

Martin: At a very basic level, Pixar's success can be attributed to the creative story telling. It's the complex story arcs, the endearing characters, and the intelligent script that makes you really love a movie; not ray traced reflections or new subsurface scattering algorithms. However, one of the unique things about Pixar is the combination of great storytelling with amazing 3D graphics. As John Lasseter is often quoted as saying: "The art challenges the technology, and the technology inspires the art."

iTuring: What language do you like except for C++? And what tools do you prefer?

Martin: I'm a fan of using the right tool for the right job. C++ is a great language for developing portable and performance-critical code. However, other languages are more appropriate for other jobs, and indeed someone languages are dictated for particular environments, such as Objective-C for iOS or JavaScript for web pages. When I have a choice, I find myself using Python a lot these days. For times when I would use perl or shell scripting in the past, I now turn to Python. Even for a lot of GUI tools, I will turn to Python, PyQt, and PyInstaller as an environment where I can develop code really quickly that can run as a standalone binary on Windows, Mac OS X, and Linux platforms. The biggest drawback with Python for me is the fact that run-time type checking means that you can easily ship code to your users that will cause an exception at run time due to a type mismatch or undefined name. To compensate for this, I'll often use a source code checker on my Python code, such as PyFlakes or PyChecker.

iTuring: The application area for C++ is getting smaller, what do you see its development in the future? What areas are C++’s strong suit? How would you expect C++ to evolve?

Martin: Great question! I continue to see C/C++ at the top of the most popular programming languages, but other languages are also becoming popular. We still use C++ at my company as a way to have efficient code that can work across many platforms, and also to access performance-critical libraries for 3D graphics and speech recognition. However, new devices and environments are making other languages more prominent. For example, mobile, tablet, and web development are hugely popular right now and it seems likely that this will only continue in the future. I think that C++ remains good at the things I just outlined above, but these newer programming environments that are appearing have different demands where C++ may not be appropriate. I think that's a good thing.

iTuring: How do you see C++’s new standards? How would it affect API designs? How do existing libraries stay updated?

Martin: C++11 makes some great improvements to C++. In terms of API design, there are a lot of new features that you could decide to take advantage of in your APIs, including things like tuples, lambda functions, threading primitives, smart pointers, and the new override and final keywords. Of course, if your API must be used by clients who are unable to use a C++11 compiler, then you will need to stick with the C++03 syntax, or provide a wrapper API for your C++11 clients.

iTuring: The Adaptive Communication Environment (ACE) had been the best distributed framework for C++. Nowadays, there are a lot of technologies we can choose from, is there still space for complicated distributed application for C++? Is there any easy to use network framework for C++?

Martin: I don't know ACE very well, though some alternative low-level network frameworks include Boost Asio, cpp-netlib, and also Qt's network access API.

iTuring: Newly designed systematic APIs always have the tendency to be overloaded with features (ports, parameters, applications). When it comes to the stable period, these ‘features’ will become obstacles for updating. Sometimes, even earlier bugs will be forced to become a “feature” that has to be continuously supported. So what is the trick to balance between expressiveness, accessibility and compatibility for the first version of APIs?

Martin: This is one of the most critical parts of API design: keeping things simple. I think you make a great point that all the features you add to an early version of an API must be supported throughout the life of the API (unless you break backward compatibility). I'm a big fan of not adding anything to your interface until there is a real reason to add it. Don't add something that you suspect might be useful in the future but you don't need right now. Stay focused on solving the core problem.

iTuring: The programming language Go is getting more and more popular, what is your opinion towards this language which intends to replace C/C++?

Martin: I love Go! It's a great language. In fact, we use Go for all of our server-side infrastructure at my company. I love that it's a compiled statically-typed language language like C and C++, but it's designed to be much simpler than C++ with great network support and builtin concurrency primitives. And the designers of Go include Ken Thompson, who co-developed the original C programming language, so they really know what they're doing.

iTuring: ‘Executable pseudo code’ such as Python is welcomed by more and more people, what do you think future programming language will be like, would it be for everyone or only for the professional?

Martin: As I've mentioned above, I like Python. I agree that its interpreted and dynamic-typing nature makes it more accessible and easier to learn. Combine this with a massive standard library and garbage-collected memory management, I think it's a great first language to learn. And I also agree that it can be used by non computer scientists to help with calculations and automation, for example Python is becoming quite popular in the bioinformatics field. However, I think we will always have different languages for different purposes. Some of those languages will be more accessible to a general audience, but I believe we will continue to need more performance-oriented, compiled, and statically typed languages for areas where efficiency and correctness are more critical.

iTuring: How to learn as a programmer? Does it take a decade to become a programming expert? Is there any shortcut? Are there any particular advices for computer science students at school?

Martin: I don't think it needs to take a decade to become a programming expert. However, I think it requires a passion to really understand the depth and details of your programming language, and to understand the details of what your compiler or interpreter is doing underneath the covers for you. In terms of C++, do you understand code generation for templates, or how a vtable works, or the pitfalls of multiple inheritance? For Python, do you understand how reference counting works and do you know if variables are passed by value or reference? Don't be content with a superficial knowledge of the most important tool you need for your job. The deeper you understand your tools, the better programmer you will become.

However, I personally differentiate between a good programmer and a good engineer. A good programmer knows how to write code, a good engineer knows how to architect and build complex systems that many other engineers have to work on. Becoming a good engineer is a lot more difficult and the best teacher is experience. So I would recommend doing internships at companies that have large software products and learning the processes and skills of working on complex production software as part of an engineering team.

iTuring: In China, most people are eager to move to the management board. How do you see programmer as a lifelong career?

Martin: That's very interesting, because I most commonly see senior engineers wanting to keep writing code rather than going into management. If you're good at what you do, you often find yourself being promoted, and traditionally that has meant management. However, I'm seeing a lot more "dual track" careers at technology companies these days, where you can be promoted but still keep doing hands-on development work. For example, at Pixar we differentiated a "technical lead", as someone who would define the technical direction of several other engineers, from a "management lead", as someone who had people reporting to them and would have to mentor and write reviews for those people. Certainly, positions like tech lead, software architect, and principal engineer are all tracks where you can advance in your career today without having to take on the burden people management.

相關文章