4 ms·
It appears to me that, in the examples shown, the advantage of Go in terms of clarity is only in the existence of the "func" keyword.
by vasco 12y ago
It appears to me that, in the examples shown, the advantage of Go in terms of clarity is only in the existence of the "func" keyword.
- signa11 12y agodont forget about ease of implementation as well...
- leaveyou 12y agoMany times I want to program in C or try to debug some open source apps but I'm always reminded why I didn't touch C/C++ since high school: macros, #include, CONSTANTS, long_identifiers, ugly castings everywhere and cryptic function pointers with the dreaded clockwise spiral rule. I still wonder how the world would look like today if instead of C++ we would have had a C v2 binary compatible with C but with type safety, interfaces and syntax similar to Go, or even this c2lang.org.
- aikah 12y agoD?
- leaveyou 12y agoD is a better C++. My feeling is that many people wanted just a better C (a portable & extensible assembler with a good standard library?).
- pjmlp 12y agoYeah, having gone through latest version of Effective C++, updated for C++14 I have not really sure if I want to step away from JVM/.NET worlds back into C++ that I left in 2005. Working alone in C++ is one thing, but having to read other people's code seems to turn into a mess if you have a mix of C++98, C++11 and C++14 code bases.
- raverbashing 12y agoC is great, but it is very limited. Mainly, it knows almost nothing about data structures (strings and arrays, with the absolute minimum support) Merely reshuffling the syntax/grammar but not going deeper is not going to change anything. C++ is, let's say, interesting. But it's always going to be a "bolt-on" addition to C, and keeping the redundancy (should I use open, fopen or a C++ object? when opening devices, open is usually used)
- bjz_ 12y agoAnd ease of tooling.
- Peaker 12y agoThe left-to-right reading is the main advantage. In C, of the 3 type operators you compose to declare the type (arrays, functions, pointers), 2 are postfix (arrays and functions) and one is prefix (pointers). This causes a mixture of directions when you read the type. Here in go they fixed this by making arrays and functions prefix like pointers, so you get a unidirectional read and you don't need parenthesis for precedence (except maybe for associativity).
- curun1r 12y agoThe problem is that functions, in C, are neither prefix nor postfix. A postfix function would look like: int (int argc, char*[] argv)main prefix is: main(argc int, argv []*char) int The C version: int main(int argc, char *argv[]) Is a horrible jumbling of both styles, with some confusion around type and name thrown in for fun. The main benefit of the Go approach, beyond whether prefix or postfix works better, is consistency. Compare to Go's: main(argc int, argv []*char) int Once you learn to read it, it's much better, though perhaps not like English. In English, we preface the noun with the adjective, "the red car," whereas other languages say the equivalent of, "the car red." When people object to the Go syntax, they're almost always native English speakers.
- Peaker 12y agoWell, in C, the type operators are: Ptr(Type) -- deref type Array(Count, Type) -- elem type Func(ParamList, Type) -- return type Since the "Type" param is always there. C declaration syntax is like a linear composition of operators where the Type flows through all the operators to form the final type. The base type on the left of the declaration is the initial parameter that goes through the composition. So C type operator grammars (in the right-hand side of the declaration, excluding the base type) are actually: Ptr *rest_of_type Array rest_of_type[count] Func rest_of_type(params) That is why I say ptrs are prefix and array/func are postfix. All 3 have the extra implicit type argument that comes from the wrapping type-expression and the base type - so I wouldn't include it and say they're both prefix and postfix.
- bjz_ 12y agoAfter spending some time in a language with left-to-right declarations, going back to spiral declarations makes you realise just how many contortions your brain has to constantly go through. left-to-right is a breath of fresh air. Edit: Of course I must add that it is a breath of rather old fresh air - Pascal and SML have had it for decades.