This is a creation in Article, where the information may have evolved or changed.
The original is here: Http://www.syntax-k.de/projekte/go-review. The author is Jörg Walter, a German.
According to Rob Pike, the article has some mistakes, but it looks worth reading.
"Why all C-like languages except one suck": http://www.syntax-k.de/projekte/go-review Some errors in there but a positive Response.
——————— – Translate split line ——————— –
Go programming language, or: Why besides it, other C language is garbage
2011-06-07
Jörg Walter writes
Brief introduction
This is a review of the Go language that Robert griesemer,rob Pike and Ken Thompson developed in Google from 2007. Now, Ian Taylor,russ Cox and Andrew Gerrand have joined the core team. This is a class C language, with some features of the dynamic scripting language, and provides some novelty (at least in the common language domain) feature about parallelism and object-oriented. Its purpose is to become a system development language, which is why this review is chosen to compare with other classes of C languages, rather than scripting languages.
In writing this review, I found that rather than evaluating Go, it had more features that were worth explaining more. Go is completely different and cannot be judged by standard OO background knowledge. Therefore, this review may be more like an introduction to Go. I am a Go novice. Writing this also helps me to understand what go is and how to do it, but it's important to remember that my first go app only developed in half. I have used many languages to encode, so I will use Go to do some comparisons with them.
Go is young. It was only identified as a stable version this year. In this review, I also expect to be able to contribute to the discussion of the future direction of Go, making it a great language. This includes pointing out some of the flaws that still exist.
About swearing in C-system language
I am always interested in the new programming language. In general, I use a handy dynamic language, such as JavaScript, Perl, or newer Python. In most cases, I prefer readable, maintainable, technic efficiency over a single performance test. Premature optimizations are usually not worth it. Security is also an aspect, and the scripting language frees you from the world of buffer overflows, string formatting flaws, and other underlying attacks (assuming the runtime environment is not available).
But these languages also have negative problems. They are not flexible enough, and I work from 8-bit MCUs and smartphones on ARM systems to standard desktop applications. I tried to use C (+ +) on it, but that made me feel very miserable. There are no handy string operators, cumbersome regular expressions that rely on external libraries, manual content management, and, of course, a security nightmare that lasts for 40 of years. In addition, it works well and provides the fastest memory efficiency that can be achieved almost.
In the underlying language, some basic things are missing. The things that are used to write the underlying tools and operating systems are quite old and forgotten by the modern system environment. This is what I want to show here. It covers only the C-lineage language, as people get used to, but you can easily add Pascal, Modula, Oberon, Smalltalk, Lisp, and any other language that has been core in a computer system.
C
I like C. That's true. Its simplicity makes it quite graceful. Unless you do something stupid, like using C as the main API to write a complex GUI development package.
A really good thing is that you can control it like a compilation, which is really important in a particular scenario. In addition to optimization, it is absolutely. The rescue is then a hard-hitting response from C's puzzling syntax, such as the inability to reclaim memory for sensitive data, or the hurdle of synchronizing between record declarations. This is unavoidable. If you have pointers and operations, you need the implicit semantics in the language to ensure that optimizations don't get worse.
But what really sucks is string, memory management, arrays and so on ... Anything that might be exploited. and difficult to use. So, C may be as lightweight as its performance, and it's not suitable for projects that exceed 10k lines of code (it's a bit extreme, isn't it?) )。
C++
C + + has improved some aspects of c. But it has brought something worse, especially the useless lengthy syntax. You can always find those shackles. However, for standard application development It is always preferred, and some good lightweight full-featured GUI development packages use these advantages well.
But when you try some modern dynamic language features (lambda functions, map/reduce, type inference ...) is usually the way "Hey, cool!" This can actually be implemented in C + +! That's all you have to do.
Dynamic_cast<mydata*> (Funky_iterator<mydata &const*> (foo::iterator_type<mydata> (obj))
All right, that's it! ”
Don't mislead me, I love templates, but using STL's C + + looks like a standard case of "If you only have a Hammer" syndrome. GCC had to make a special diagnosis and simplification, and eventually found that the 5-line error message was just a simple constant quantization error when using the Std::string method. Equally bad, they are as slow as hell. So what about waiting for Boost compilation? A good idea, a bad reality.
Objective C
Now I feel like a heretic. I should not belittle anything from NeXT. But I can't help it--the sense of bondage also exists in Objective C. It's not as verbose as C + +, but the parentheses syntax is like entering a parallel world of C, so that all of C's syntax is available.
If you're not so impressed with writing template conversions in C + + (which may be an advantage ^ ^), you still manage memory manually. The memory can be freed in C + + at least by reference counting (if you have found the correct syntax in the thousands of error template).
Objective C In response to this problem, the cross-sex official provides an optional GC. Wait--This is always optional for the C-series language. How many years has BOEHM-GC been there? But the standard is to use a memory pool, in many cases good compatibility makes it work, but compatibility is good.
Java
You don't really think I'm going to forget Java when I curse C language, do you? For now, Java is almost always a solution. Almost a little unreal.
There are binary platform capabilities, a variety of implementations, no major pitfalls of the language details of the specification, standard OO, garbage collection, some real dynamic characteristics, and ultimately even generics-and prohibit the consumption of memory and slow startup time.
There is no clear need to explain why this is the case. The enhanced JIT compiler (theoretically) can do better than any other static compiler that is pre-optimized. The GCJ compiler can handle machine code if you want it to. VMS also have an exact matching hardware implementation. But the JDK makes the base bloated, and many Java projects have Byzantine-style complexities (the Byzantine style is always gorgeous and luxurious, but it seems to be a bit flashy, isn't it?) )。
Now, it's very comfortable to write modern Java. WEB services provide some really good abstractions. Until you lift the hat and find some fuss about the mechanism. Each layer is built with the most popular abstraction layer of the previous year. You can't compromise on backwards, right?
Look at the library directory of your usual Web app. I'm not surprised to see hundreds of JAR files, for a simple database search or shopping site implemented in PHP can be within 10k lines of code. Or if you're adventurous, try compiling it yourself. The most fun thing in the world! It's easy to set up a Linux system without any step-by-step introduction. Believe me, I've done it. Before you start, make sure that you know how to spell "Dependency hell" (Hell of Dependence) in forward and reverse.
All of this is contained in the tedious grammar and object models of the old school. There's basically nothing wrong, but there's a better way. Artistic taste is another matter. Look at Perl6 and try to put all modern language designs together so that they become usable (truly valuable "usable") languages. and its first feature production available version has been more than ten years! Java is now so fast, except generics.
C#
I almost forgot about this. In fact, I did forget this until there was feedback reminding me. Frankly speaking, I don't understand C #. As a language, it looks good, C and C + + are well developed. Let me keep my distance to it is that it is not free of birth. Yes, there is Mono, but I never like to have my work built on a language that Microsoft can readily turn into a charitable license for patent litigation. We all know about this company (well, actually any big company) that implements it as a ruse of slavery.
I don't see the highlight of writing code that doesn't boast platform, so trying Mono is a danger to me and I'm always away from it. Similarly, when the strengths and weaknesses of Java VMs are widely circulated, the CLR must have gained enough credibility. I might write C # code at some time, but this day won't come soon.
Without the promotion of an open ecosystem, and the realization of a special purpose, it is not suitable as a system programming language. Only suitable for enterprise development.
Oh, and companies are looking to make money from the development of language, which is not a healthy way to develop. Business interests will impose something bad for the language. The pressure of improvement exists for a long time, otherwise it cannot be sold out. In contrast, take a look at Tex, which has a history of more than 30 years and is a bug-Free state that software can achieve. You can't really compare the two, but you can show where the end point is, and C # stands in the wrong place.
Javascript
JavaScript should not appear here because it is a completely dynamic language. It is one of the most widely used languages, however, it is also a C-series. And, more importantly, the JS engine has supported quite advanced JIT compiler optimizations for a while, so the performance is similar to the other languages mentioned here.
So, what is the nature of JS error? Not much. It's just not suitable for small systems. It is a great application of the embedded language, but also for writing Web services, but the design makes it no way to interact with the outside world. The main application defines all the interaction APIs in the implementation container and therefore determines that it cannot be used as the primary language of a system.
Further, the JIT and runtime requirements limit its embedding purpose. This is quite handy if you have a Palm Pre and use JS as the embedded language. When the 500MHZ/256MB system is the bottom line, it is available. The lowest possible use of JS (or ECMAScript) as the system's primary language device is Chumby, which plays Adobe Flash Lite movies on 450MHZ/64MB. There's no real universal language there.
Wish
Dear Santa Claus, all the underlying languages are rotten. Christmas I want a programming language that has the following characteristics (as an example of an existing language), in a number of priorities:
General design principles
1. Ability to express
I expect a language to have a high enough level to express my ideas and algorithms, rather than wasting time and screen space on tedious task management or 80% of all template code. The more important elements that embody the expressive power are listed separately. Writing a lexical parser is a good test. This is the right direction if the final result code has many similarities to the structure of the analysis. (Example: Perl 6 syntax)
2. Simple
I expect a language to be elegant and simple. Only a few concepts are needed to express all possibilities. Orthogonality is the key to this situation. Simplicity also makes language easy to learn. Reuse the syntax structure for the same purpose, and let the user code interface with these structures so that they can be augmented. Similarly, do not force users to use complex structures. There is nothing wrong with providing classes, unit test frameworks, or document comments, but don't let them get into sight if they don't want them. Ideally, let them "do what I mean".
3. Equal rights
If the built-in federated array algorithm is inefficient for a particular dataset, I expect to create an implementation that can be used as built-in instead. Language should not have privileges. Therefore, the operator should be overloaded. Oh, the magic thing that's done in Python ... Similarly, the built-in data types should be used as object syntax in the language. All these do not need to be dynamic, and most can be implemented with static syntactic sugars. (Example: Perl's prototyped Subs,python operator overloads)
4. Meta-programming
There are two aspects here. One is a template and/or generic, which is so useful that you can't have it. Although C has some evil hack to emulate this: the preprocessor. Everybody needs this. The more advanced aspect is compile-time code generation code, like Lisp macros and Perl Code filter. As an additional explanation, this allows the creation of new language structures or specific domain languages.
5. Efficient and predictable
If the language is aimed at system programming, it must be quite efficient and can be predicted completely. You must be able to visually predict what time consumption and memory allocations are brought about by the determined operation. The core language functions must be well optimized. Libraries provide a higher level of structure that makes coding more efficient and less efficient to execute. The object system does not require expensive runtime support (both time and space), and static optimizations should be possible.
Ideally, it is possible to write a useful control program with thousands of lines of code and hundreds of bytes of memory. Of course, efficiency and functionality are often the opposite and need to be chosen, so the language should provide the opportunity for me to decide.
6. Availability
Eventually, the language must be available. All ideas aside, the most important thing is that it solves practical problems. With a little pragmatism there will be no harm. Language should be close to other languages, so that you can think about it in the same way as before. If there is a serious deviation from the norm, it must be worthwhile. Be loyal to the principle and avoid surprises!
7. Modular Library and Code warehouse
I look forward to the sophistication of the scripting language built or part of the standard library that I grew up with. The common code warehouse for a package and the proper portability of package management are better. Typically, packages include network protocols, parsing of common formats, GUI, encryption, general mathematical algorithms, data processing, and so on. (Example: Perl 5 CPAN)
Special Features
8. Data structure
I want my hash! A language that is not well integrated with the language of the Union array data type is a joke. It is obvious that OO (or other convenient encapsulation) is also necessary. The Boolean type is good, but more important is the explicit interpretation of the various types in the Boolean context. Additionally, there are several advanced data structures in the standard library, such as different trees, lists, collections, and so on. If you already have a jump list, it's on track.
The string is also OO, especially if a similar operator (such as Len ()) acts on a string that should act as if it were on an array or an object that simulates an array. Additional, also depends on whether all the original data types support the same OO syntax as all other objects. No need to be like Ruby. As long as there is grammatical sugar. (Example: Python and its standard library)
9. Control structure
It sounds obvious, but allowing control to jump out of multiple nested loops at once is appropriate. Eliminate Goto, really. The last time I used it was ... All right, that's last week. I do a nostalgic program demonstration at the Commodore C64 in the Oldenburg Computer Museum. It doesn't count. So drop the Goto, but give me a foreach. There is nothing else to ask for. I've never used JavaScript with statements, but it's also a good idea, and I think it's some form of "less is more." (For example: All scripting languages are excellent in this regard.)
In fact, there are some things that have never been seen elsewhere. Before, I encountered many loops, and the entry and condition test/loop exits for Each loop were not adjacent. So if there is a way to express a loop starting from somewhere in the middle, it looks cool. Otherwise, you need to copy some parts of the loop. A bit like Duff device, not for optimization, just let the code not so verbose.
10. Expression syntax
Many people deliberately avoid it, but?: The ternary operator is a good idea if you use the correct words. Python implements Foo If bar else Baz, a bit verbose, but also OK. However, the Boolean operators of JS and Perl and and or are not used to evaluate true and false, but can be considered true for specific values. Suppose assignment value = cmdline_option | | "Default". This requires a proper boolean meaning on all data types.
11. function Properties of expressions
If I wanted to write Lisp, I would do that. I don't need a complete functional programming language. But nothing is better than map (). Closures and anonymous functions (lambda expressions) are also killer-level features. Perhaps the "super-complex" domain is the Hyper operator (which is called in Perl6) such as any () and all (the name in Python), but they are great and imply parallel meanings. Welcome to the new century, at least in the 90 's.
12. Objects
There are already several object-oriented models, but at least encapsulation and polymorphism are required. There are also methods for combining classes, such as inheritance and blending. Interface should have, or use multiple inheritance to replace the (note: multiple inheritance?) Nightmare, the absolute nightmare! Overloading is important, or at least give me the default parameters. Naming parameters is also a cool way to do it.
13. Parallel
I'm a loser for this situation. Generator and co-processes apply to this in some cases. The point is not to build multi-threading, but to make it easy for multiple code to work together. They do not need to be executed at the same time, but they should work in multiple parts of the dataset at the same time. It should be easier to construct an app as an event driver. This mechanism is great for real multicore. (Example: PERL5 's Poe,python generator)
14. String and Unicode
This is the Damned 2011, except that Unicode doesn't need anything. So be sure to include a secure string type, and all are Unicode, with no exceptions. I'm sick of the extra double-coded implicit conversions, and I don't want to see it again, or manually instead of language support. By the way, I prefer UTF-8. Who cares about the index of a constant string? In this case, use a character array. Regular expressions are used in the general case. Regular expression support is needed on the API of the original string.
15. Bottom-Level interface
There is a view that it may be necessary to manually manipulate the bit. Especially when the target is a microcontroller or embedded ARM core, there should be a way to scare off the bare device. The ideal scenario is to write the OS kernel directly in a language without any assembly (except for platform-specific boot code, which is not available in any other way).
——————— – Translate split line ——————— –
This article is really too long, split it. This is the end of today's mission.
To be continue ...