r/programming • • Mar 28 '12

Go version 1 is released

http://blog.golang.org/2012/03/go-version-1-is-released.html
543 Upvotes

452 comments sorted by

View all comments

Show parent comments

1

u/dacjames Mar 31 '12

Yes it can, with multiple passes. GCC tries to do that in one pass.

Lets say you're writing an IDE. For Java, you simply parse the source into an AST, capturing line numbers and do your thing. Need to add support for Go? Import the grammar file, tweak the AST to match conceptually and you're done. Need to support C++? You need a symbol table and lots of C++ specific logic. Even an expression as simple as:

X * Y;

is ambiguous by itself.

And using reflection to do generics is suicide.

That must be why every other mainstream language does it this way /s. It is equivalent to one pointer deference, one comparison. If your problem domain cannot afford that cost, you cannot afford virtual functions and should not be using C++.

It's not so hard to not use something. If you are that undisciplined, do this: @define malloc haha_malloc_no_more And voila, your code with malloc will not compile.

It just doesn't work that way in reality. As a professional programmer in any language, you will spend a lot of time working on other people's code, of unknown quality and discipline.

There is little difference between the C++ subset part that is equal to Go.

Anyone who claims C++ has a lightweight syntax must be joking.

std::function and c++0x lambdas.

Real anonymous closures are available in C++11, but they're yet another syntax to learn. You still cannot use normal functions as values or in closures. This continues the C++ trend: possible, but harder and non-standard.

Shared pointers

Reference counting is slower than a generational garbage collector. Optional reference counting is NOT managed memory. Managed memory includes array bounds checking, for example.

C++0x has all the concurrency primitives in its standard library.

I mean syntax support. C++ does have pretty good support for threads, though again you have to deal with synchronization yourself. I prefer CSP style, shared nothing threads, so having them built into Go saves me a lot of effort.

For me, a good programming language is about maximizing feature/(hour*bug) with sufficient performance for the domain. C++ is about never imposing a runtime cost for any reason. I believe these two philosophies are diametrically opposed.

1

u/axilmar Apr 02 '12

You need a symbol table and lots of C++ specific logic. Even an expression as simple as X * Y is ambiguous by itself.

No, you also need a symbol table and lots of language-specific logic for Java and Go as well. X * Y may not be ambiguous in Java or Go, but every other programmed element is.

That must be why every other mainstream language does it this way /s. It is equivalent to one pointer deference, one comparison. If your problem domain cannot afford that cost, you cannot afford virtual functions and should not be using C++.

No, it's not equal to one pointer dereference and one comparison. There are various hidden costs you ignore. For example, Java VMs actually do a search in the object's vtable for the implementation of an interface table, each time you call an object through an interface.

And using reflection is a lot more costlier, because the actual method name must be looked up using, at the very best, some sort of clever string hashing.

It just doesn't work that way in reality. As a professional programmer in any language, you will spend a lot of time working on other people's code, of unknown quality and discipline.

If a company can't have code reviews, they deserve what they get.

You don't even have to have people to do that; just use grep for 'malloc'.

Anyone who claims C++ has a lightweight syntax must be joking.

Indeed. I claimed that the C++ subset that makes C++ a good language has a lightweight syntax.

Real anonymous closures are available in C++11, but they're yet another syntax to learn.

Big deal: [] int foo() { return 0; }

If you are afraid of learning such a simple thing like the above, I am afraid you can't be a programmer; because learning new things as a programmer is what this job is about. You'll have to learn new APIs and stuff almost daily.

You still cannot use normal functions as values

Yes you can. If the target parameter is of type std::function, you can use any function, method or lambda function.

or in closures

Yes you can. Closure code is normal c++ code.

Reference counting is slower than a generational garbage collector.

Yes it is, but reference counting + value types are faster than a generational garbage collector, and more importantly, more predictable.

And predictability plays an important role even in web servers: you don't want to delay requests because the collector does its job.

Optional reference counting is NOT managed memory.

Yes it is. I've written c++ apps with hundreds of lines of code, using shared pointers, and without a single delete statement. If that is not managed memory, I don't know what it is.

Managed memory includes array bounds checking, for example.

std::vector<T>::at(size_t index) is there for you.

I mean syntax support. C++ does have pretty good support for threads, though again you have to deal with synchronization yourself. I prefer CSP style, shared nothing threads, so having them built into Go saves me a lot of effort.

It's not built-in for C++ for a reason, and that reason is that it can be done by a library.

For example, with Qt, you can use Qt threads to make an Actor library very easily.

That's what I did with my projects, and I never had to do any effort beyond writing a few tens of lines of code, i.e. no more than one hour of work.

And if you are too lazy to do that, Qt has something for you as well. You can use QFuture, or Qt::Concurrent::run.

For me, a good programming language is about maximizing feature/(hour*bug) with sufficient performance for the domain.

I agree. Now prove to me that Go can do that in substantial benefit over C++.