MSDN Interview (MSDN SHOW) C # Programming
C # is a relatively refreshing and one-to-oscillating programming language that is designed to c programmers to bring fast development capabilities, and no sacrifices C and C features and control. In this issue today, we will talk to Anders Hejlsberg. He is a senior engineer in Microsoft, which has been helping design, develop, and implement the language and play its role in the future .NET platform. We also have to talk to Jeffrey Richter (a famous programming writer and consultant expert), and his work in C # has been more than a year.
Introduction
Robert Hess, Microsoft Product Manager and "SHOW" host.
Robert Hess: Let us continue to pay attention to the understanding .NET system (Architecture). We will pay attention to the new C # today (read "C Sharp" instead of "c on"!) Programming language. First look at the MSDN message update section.
MSDN message update
Hosted by Technical Editor Erica Wiechers (slightly talking to C # independent conversation)
Techno Babble
Robert Hess and senior engineers Anders Hejlsberg meet, to discuss ...???
Robert Hess: Welcome back to this section. Ok, just like any platform to develop software above, in order to make these applications can run truly, the main thing you need is a programming language. Currently, .NET already has a special language specially developed, we call C #. Today and we are Anders Hejlsberg, he is a Senior engineer in Microsoft, playing a key role in the C # language and .NET platform field, everyone has seen him in the previous "Show" program. So I invited him to come here, talk about C # together with everyone, talk about it, and how it can be obtained from it, and how it really affects the development of the application.
So, what do you engage in C #, starting from starting?
Anders Hejlsberg: In the recent two and a half years, we have been working on C # research. The design team consists of 4 people, and during this time, I put the main energy in this. To know, we have a lot of things to do for a new programming language. I think it is the ultimate goal of providing programmers to provide programmers to develop more products. Today, although it is just the scale of the product, it can be said that our goals, in a sense, not only make C # with C powerful features and excellent performance, but also make it easy Use and Rad (Rapid Application Development, fast application development) productivity productivity.
We have made some work, for example, how to use a better tool to write components. If you look at how we write an application, it should be how to write an application. If you look back, it is 5 years or 10 years ago, the application is to be created such that the iron board is created, it and the operating system The only interaction, you know, is the I / O operation of the file, and whether it is loaded into the application anyway, the user will interact, and finally exit. Look at how we now create an Internet application, compared to the average of the an. The application is no longer a piece of iron, but consists of a series of smaller components, which are perched in different environments. For example, you may have components like stored procedures and SQL Server, or you may have controls inhabit in the browser, or code existing in the ASP page. The commercial object is survived in the middle layer, and the components that call the entire collection are equal to calling the application. So in order to make ... Robert Hess: And at that time, you understand that each component is more complicated than 5 or 10 years ago.
Anders Hejlsberg: Oh, absolute, absolute. Similarly, in order to reduce the complexity of creating components, it is not like the large block program, whenever one of the components must be created, there is no need to stove, but should try to inherit some of these dedicated habitats (Hosting Environment). thing. If you want to write a control in your browser, you should inherit a base control; if you want to write a business object of the intermediate layer, you must inherit some business object classes; and want to open attributes, methods, and events, Note How they are connected to the component by linking properties to the component. Moreover, it is also possible to write a document that is published with the component for these components.
Robert Hess: All of these is just a standard object-oriented programming, and SmallTalk has this feature that seems not short, and ...
Anders Hejlsberg: Well, it is absolutely like this, it is not something like this. But if you pay attention to this programming language that has been widely used today, they don't actually support the concept of components. If you agree that we talk about the components, then they have properties, methods, and events in today's extremely common. But if you pay attention to C , it will find that it only refers to the concept of "method", no attributes, and there is no event. Now you can use naming mode to simulate them, that is, for an attribute, you can replace a Color property with a GET Color and a SET Color; to replace the event as the first class member, The interface you have for receiving events should be implemented. For this, you must deal with some trivial things ...
Robert Hess: Well, part of the reason is that C is based on C, it is just like pre-process, but because C is not supported, C does not support ...
Anders Hejlsberg: Yes, how much I think, what you see is the development process from c to c to C #. From C to C , the concept of object-oriented programming is added. If you have experienced from C to C #, then I will say that the concept for component programming has also been added, and there is really similar place between them. Just like C instead of C for object-oriented programming, you can also use C instead of C # to make a component-oriented programming, but it is more difficult. It is extremely difficult to use C to perform object-oriented programming, you must arouse the V table (virtual function table) manually, and also deal with all trivial things. Write components with C must also be feasible, but must set naming patterns for attributes, Event Syncs, must have external IDL files, in the file, Hosting Attributes Description, must have an external document file, and so on. We only adopted a reasonable step, which reflects how people write applications and integrate it into the language of Robert Hess: So what is the initial goal? From the perspective view, when you first start this project, what is the problem you want to solve and what is the direction of this new language to be determined?
Anders Hejlsberg: Well, I think that as you said, the components are just one aspect. I think another key factor is simply. Make written applications more simplistic, do not let programmers do trivial things, machines can do it. A large amount of simplification depends on the .NET Runtime itself, but also depends on the language. Basically, in the end we do, let you put more time, more energy on the algorithm, and let the system do some trivial things. I think that many other critical things are more realistic, I can't tell people to throw away their existing code. We must find the method of weighing, not just your programming skills, but also include code you have written before, already existing. So in C #, we strive to adhere to the basic grammar of C is closest to the basic grammar of C . So use C #, C programmer will immediately feel very familiar, very kind.
Robert Hess: Everything you do should be based on the C language. Is it one of the original ideas? Or if you agree, let us completely break with the past, then start design a new language?
Anders Hejlsberg: Well, I think this language should appear in a new look, but we understand that C and C programmers must be familiar with this language. Of course, it means some extent, we must transform the statement structure from the curved braces into other things. We have already made some foundations, but there are still some key rules, such as allowing to write robust software, which means the function of garbage collection, exception handling, type security, changed fundamentally Designing the language of the language is very difficult to get started, and it is not easy to expand. I mean, in C , one of the powerful features of the C language, but sometimes it is one of the difficulties, in fact, you know, there is no type of security. If you understand what you want to do, you will get huge strength from it, otherwise, just find it. In C , a dangling pointer is getting a lifting pointer. Similarly, cover the tail of an array, or have an uninited variable, etc., is also extremely easy. And we need to solve these problems. I think we can't just start from C and expand it. And really must be retired, design new solutions with C soul, and these we have almost completed. Robert Hess: What other languages? Do you notice what these languages do? Whether it is PASCAL or MODULAR 2 or FORTH, what are you lending?
Anders Hejlsberg: Absolute! Oh, we consider, um, I mean, I am born in a deep pASCAL background, so naturally to consider Pascal, Modula, Oberon, consider SmallTalk, Java, C , and all languages. You know, today they can survive and have been applied, and more or less spread.
Robert Hess: What functions do you think these languages are better than C and C ? And you can introduce these features in new languages?
Anders Hejlsberg: Well, I think there is something to explain, I always like SmallTalk, because in this language, anything is object. This makes the program greatly simplified, because no matter what kind of data sheet, you can move it as an object to the B point. In general, anything can be operated. You can use it as an object type and place it in a container. In the actual implementation of SmallTalk, if this is done, the additional burden of program performance is greatly aggravated. For example, in SmallTalk, when the float number is calculated, each generation of numbers are generated, if it is added to 1.0 and 2.0, a new object containing 3.0 values is assigned. And do this, the price is of course very expensive. Now in C #, we have conducted some innovative work, which makes you gain the same interests, but there is no additional burden. Just use the float as float, or Double as a Double as a Double, there is no price. However, if they see them as objects (also when doing this), they have to assign them (HEAP). Therefore, it has formed a relatively perfect unity, which can give you a lot of benefits, and there is no additional burden on the program performance. Robert Hess: What is the structure of the final result of C # generated? You got a text file for a C # program and compile it, then what problems exist in the compiler itself, how to design these programs to more efficiently, and this optimized other languages may have done, and even final Also generate binary executables?
Anders Hejlsberg: Well, we have made some work involving how to encode. If you are a C programmer, of course, how to do it, declaration and implementation in C is separated. So all statements are placed in the H file, followed by containing it in other modules, and then write the implementation in the CPP file. In C #, write them in the same place. In this way, it can be written there again and then immediately write the implementation code.
Robert Hess: What should I do if you have to use some of the values declared in the main file in another file?
Anders Hejlsberg: What is the situation? When compiled, actually generated code or regenerated output files contain two codes: metadata, symbol tables (Symbol Tables), or other related symbol information, not only generated only Execute the X86 machine code of the code. In a sense, these codes have become self-description. So when you want to use another code from a code, you can quote them, and these code's self-description is enough to let people know what kind, what is the membership, what method can be called, what is the property, What is the name name, and so on.
Robert Hess: So, is it like a .Obj file or .exe file, suppression or ...
Anders Hejlsberg: Well, you are right, our format we used in .NET is PE format, so you can point to additional EXE or DLL. We now call these assemblers, and basically describe these advanced DLLs in this language, which not only contains code, but also contains such information: Description What is the other compilation of other compilation? program. Robert Hess: The code you said refers to binary code or executable code.
Anders Hejlsberg: Well, in fact, we don't directly generate executable X86 machine code, but generate MSIL, which is the intermediate language, which is defined by .NET, and compiled by JIT (Real Time Compiler).
Robert Hess: OK, this seems to have an executable file, itself is associated with the intermediate language and metadata, and if I want to use it in one of the applications, I just want to point to it and say, I want to borrow these classes, borrow these objects and use it in such a program. This reminds me of a problem that many people have mentioned, involving potential vulnerabilities in the intermediate language, and some people may take this document and resemble them, and then restore the original source code. Therefore, not all intelligent properties are beneficial to developers. What is wrong with this?
Anders Hejlsberg: Well, first, you can actually use DLL now. This may be a bit difficult, but you can use a DLL containing the x86 code and then close it to the assembler. You can do the same ...
Robert Hess: On my Apple II, I have been doing this.
Anders Hejlsberg: Indeed, I feel awkward. But use .NET DLL and compile it into MSIL, you can also do the same job. They can't be directly compiled into C #, although you may be might, it is too difficult. Different places are, with a lot of symbolic information is associated with code generated by C #, as well as MSIL, sorry, is .NET assembler. For example, you can know from your code, what class is here, what are their members, and so on. This is a tricky problem that needs to be solved because the benefits of self-description (Self description), but in fact, the code is described by the description of themselves, and the code processed by the anti-compilation tool seems easy to understand. If we recognize this problem, basically we have to do, it is something called a mixer (Obfuscator), which will join and mess, so that the code is almost difficult to understand, but still keep the same Public interface.
Robert Hess: Yes, because you encounter such a problem: When using, when writing these compiler programs, you want to let the compiler understand the code (or similar procedures, etc.), but don't want people to understand at the same level. they.
Anders Hejlsberg: Indeed, this is true. I really want to point out that for a small program, I can actually make anti-compile, give enough time and resources, you can even understand what it is doing. However, for an application in the real world, this is a daunting task. In reality, you better run this app, understand what it is doing, and then writing a copy. You will quickly reach this level. Robert Hess: Maybe write a more cattle program, because you are a more cattle programmer, right? In order to determine if our viewers want to start the next C # project, what do they need to understand what questions about C #?
Anders Hejlsberg: Well, I want to first take your own basis. If you have a ready-made code body, let's assume that it is written with C , perhaps the best way to put these code to .NET Framework is to use Managed C , the C compiler will be released together with .NET. However, if you look at the new code, you are writing a new module, a larger module, join an application or a fully understate application, and you are proficient in C , then I suggest consider C #.
Robert Hess: Therefore, we don't have to say that everyone must rewrite their applications with C #. We are talking about whether people must understand the types of the project they are engaged in, whether they are ready-made projects, old code, and sometimes use C # to write some components, can you alternately use C # and C ?
Anders Hejlsberg: Oh, absolute. First, if you have ready-made code, assuming that these code is written by any language supported by the Windows platform, it is compiled into COM components or DLLs, which will get interactive operation with these codes (Interoperability ). If you want to write code specifically for .NET Framework, you are used for new code for .NET Framework, of course, use any language supported by .NET Framework. We plan to post four languages in Visual Studio .NET: C #, C , Visual Basic and JScript. However, in order to cooperate with industry and academia, I think that the latest statistics may not be very accurate, but I think about 17 different languages are now aiming to this platform, and their range has been from APL to COBOL.
Robert Hess: What about Fortran?
Anders Hejlsberg: I believe that the relevant work is in progress, but I can't know how to design the Fortran compiler. But the key is, in fact, we have done multiple demonstrations, you can write a base class in C # and inherit it in C , then use the VB program to create an entity. Interoperability operations between different languages are seamless. I want to be these performance, so that .NET Framework opens the products of other competitors in the industry. (Interested readers can go to http://www.lahey.com/net_down.htm to download Lahey / Fujitsu Fortran for .NET Technology Preview 1, Translation)
Robert Hess: And it uses and allows multilingual interoperability operations at the base hierarchy.
Anders Hejlsberg: Yes, it is very accurate. But it is located in a high level. You may argue: Now the language can be interoperable, but can only be at a very low level, such as the entry point of the DLL, has a structure in which a pointer is in it. And we are talking about higher semantic levels, is an object-oriented level, with classes and interfaces, etc. Robert Hess: C # is considered to be Microsoft's private language?
Anders Hejlsberg: It is not true. We cooperate with industrial partners, especially HP and Intel. At the beginning of this year, we submit proposals to a European Standardization Organization called ECMA (European Computer Manufacturer Association) to standardize C # and CLI. CLI represents a common language base system (Common Language Infrastructure).
Robert Hess: Is this a bit similar to c runtime and vb runtime?
Anders Hejlsberg: Well, actually CLI is a big subset of .NET Framework. In a sense, it is part of .NET can be ported to other platforms. This means, for example, it does not include any Windows special UI library because other platforms do not have much interest.
Robert Hess: Like memory management, but ...
Anders Hejlsberg: Well, absolutely this, memory management, most class libraries are included in the CLI. We submit this suggestion to ECMA in September and have been adopted at an ECMA meeting, and the work of these two standards is underway. One is the C # standard, and the other is the CLI standard.
Robert Hess: So, C # has an ECMA standard what does it mean?
Anders Hejlsberg: Well, this means that other industries can also implement the language on different platforms.
Robert Hess: If I am a company like Boeing, I have some old-fashioned PDP 11/70 computers, I want C # it's above it, may consider using ECMA standard to design a compiler to these old-cut guys, if nothing People have done similar work.
Anders Hejlsberg: It is absolutely correct. Now these two standards have actually been submitted, and the current C # itself does not specify a runtime library, but relying on .NET Framework, or when we are talking about the standard proposal, C # depends on the general language base system as It provides the Runtime base system and class library. We are currently working with standardized organizations and our industrial partners to determine the lowest threshold. Obviously, the CLI will be divided into several levels. In fact, the scheme submitted to ECMA is divided into several levels, and these levels begin to have a very low core layer, and you really have these core data types, some image arrays It is very simple, and all atomic variables there (atoms), but molecules are unnecessary. They are constructed on a higher-level stack, so that the embedding device is also the case, it can actually apply it to a very lightweight environment (Lightweight Environment), and this lightweight environment can be ported to a different platform.
Robert Hess: Thus I can run a version of the C # in my watch or in some similar devices.
Anders Hejlsberg: Yes, theoretically, or in your refrigerator, or anywhere.
Robert Hess: To some extent, this is the full goal of .NET Framework, that is, the layered system allowed programming in a variety of different types of devices, similar to the network or Bluetooth, one device can be and another Equipment communication, and borrow services, providing mutual support, Anders Hejlsberg: Yes, that is part of it. I think now, now we should be in mind, although you talk about mutual communication between distributed applications or devices, but placed in .NET Framework even in the grassroots system in the CLI, it does not require two two There are .NET existence. Moreover, the architecture we recommend does have guidance, when to use the class library to design the program based on industry standards such as XML and SOAP, and you can implement it in Linux Box (for example, Java and Apache Web Server). Then use other tools to develop the corresponding program at the other end, if you are happy.
Robert Hess: So in my C # app, if I am writing it with an external service connection, I can treat a standard C # call, and an external service running on different machines may be amazon.com, Or systems similar to other do not run Windows or running C # systems ...
Anders Hejlsberg: This is the dream of all Web services ...
Robert Hess: And all things you have to do are only achieved SOAP.
Anders Hejlsberg: Yes, Well, basically what we have to do is to use the existing Internet's grassroots system, meaning that the transfer protocol is HTTP, which is a SOAP Formatted XML, which is encapsulated in XML format. And actually in the other end of the network can be anything. When accessing XML and SOAP calls from C #, we actually have the ability to make them look like objects, but we give you all grassroots systems, all continuously in the .NET Framework Grassroots system, you can call the method to convert the method into the XML SOAP package, such a package can pass the network and return to then the package.
Robert Hess: Ok, you said that you have been working in C # has been several years since the work, and the XML life is just the same. This means that when they start, there is no understanding each other.
Anders Hejlsberg: Well, the history of XML may have a little longer. SOAP is quite new, it is in .NET Framework is a hand, and we are also very active from W3C to these standardized subjects, we have been tracking its development and append these technologies to the latest standards.
Robert Hess: Is the interconnectivity between SOAP and XML at this level? Is it a C # one aspect, or developed with the development of the language?
Anders Hejlsberg: Well, I don't think there is some distance here. Most of the base systems that need to address XML and SOAP are provided by .NET Framework instead of C #. The C # language is built on the top floor of .NET Framework and enables you to access these things, for example, through our property (attribute) in C #, you can directly express something directly from this class The entity mapping becomes the XML format crossing the Internet. So I can say, for example, for members (Field), I want this member to turn the XML element with the same name, let this class name becomes the tag (TAG) name in XML, and so on. And attributes can be integrated into the code directly, which is one of the more ways to make XML and C # more easy to use. Robert HESS: So are they really suitable?
Anders Hejlsberg: Yes, it is true.
Robert Hess: When considering an application design, in order to better use C #, I want to have a problem with the application, have any different ways? Or is it the same idea with normal development of a C application?
Anders Hejlsberg: Well, I think a key principle of it is that you are programming in a very deep object-oriented manner, even when you use C #, it is done in a component-oriented manner. So it will tend to think that your application design is a bit different. Ok, if you are using C , you may think of write objects, and more. When you use a C # write program, for example, you may think, oh, do I am writing a component? Well, this component must be able to join the Visual Studios toolbar so that I can drag it to a form or drag to a business object, or drag to a web page, then it will be displayed by the Property Inspector Come out, oh, then what the property should I have, how can I control things in the order? Can I have such editors? Now, we present all the things of the grassroots system to you, which makes you realize that your design is different from C traditional design.
Robert Hess: So many times, you are still writing applications, through the decoration application, you just have more performance to be displayed.
Anders Hejlsberg: Yes, you can say this.
Robert Hess: What is more about this class-oriented full concept? So I are writing a GUI application and running on a server and plans to attack it with a web client. The client request first reaches the server and requires responding to track the package (package). Is this fundamentally changed my thinking or still the same service direction?
Anders Hejlsberg: Well, I think in a sense, it allows you to consider the abstraction in the application. You should pay more attention to how I put the application to the business logic tier and the representation tier how to put the API in the business logic layer so that it can be represented by logic. Indicates HTML or UI-based customers, even specifying entry points (entry Points) for Web services over the Internet. Therefore, you should pay attention to the programs of those iron plates. Robert Hess: Do you imagine that this itself helps people use the components of others more easier than past? I remember that when I work in Boeing, I always encountered this key issue related to the code reuse. We must ensure that any apps written, any code is designed for code reuse, although this sounds in theory is theoretical, but in practice, it has never been well used. The life is dead, because the code of reused others is simply difficult. Do you think this can actually reuse the code easier?
Anders Hejlsberg: I think it will, and the key role here is actually .NET Framework. In fact, we have defined such a substrate, which can generate components on top of it. And how many about how to put them into classes, how to make them a component, and we give you a clear guidance, but in fact, the entire framework is as one of them, but the key is that the components must be able to be available. The language is accessed, so you have already discussed this problem, for example, if some guys write some languages or libraries with COBOL, you want to use them from C , you know that this will be particularly difficult. In fact, we provide you with Substrate to let you perform the above interactive operations. So you have a big hope to interact with the component. Because in fact, it is necessary to make people confused in different design points or in different abstract layers. They are not accustomed to this style of API, so lost in the grassroots system, I only see the trees, I don't see the forest, you should understand what I mean. Therefore, you will have a better reusability by explaining a lot of how to write components and provide a permanent effective API and a base system for write components.
Robert Hess: Well, I think explanation is just right. In order to grasp the focus of the C # language system, what do you think in the last important concept wants to understand the audience?
Anders Hejlsberg: I think the best way is that you should play with it. So I will urge people to download from my site, and I also believe you will give them the address. Download it, put on the play, write some examples, participate in our user groups or newsgroups, talk to people who have used it to see what experience they have. I think you will be very comfortable.
Robert Hess: I will definitely build a link behind this record to let them download the current version of C # runtime and our .NET material we public on the PDC, I guess we will have another version ...
Anders Hejlsberg: Our Beta version 1.0 is released ...
Robert Hess: Beta 1.0 version will soon be released, so the newsgroup you mentioned will also establish a link to Beta 1.0. So you should guarantee that I will contain these newsgroups in Email so that I can build.
Anders Hejlsberg: Ok.
Robert Hess: Thank Anders, thank you for your conversation, and I hope that the audience will thank this expert who really helps design C # language, thank him for developing applications. After a short break, we will continue to talk to a programmer, and it has been used in C # development applications. We will learn about his idea of this language, and any help we use C # development. Clues of our application. So please don't go away.