Hacker News new | ask | show | jobs
by catnaroek 3596 days ago
C++, otherwise a deeply flawed language, gives you more abstraction than Go and allows you to optimize and micromanage things more.
2 comments

Not only C++, there are plenty of options.

The only thing good about Go, is being an evolution path for C coders willing to embrace a GC and some type safety.

One thing I can credit Go for is leading me from the untyped world to the typed one. I soon found the holes in the Go type system, and went looking for a stronger type system.

I now generally prefer Haskell.

If Go is from typed world, then Perl too.

Some magical built-in types (scalar, array, hash, typeglob, regexp, io handle) you cannot confuse, interface{} is scalar holding a reference, and built-in datatypes (arrays and hashes) are magical and you cannot construct something similar. Well, at least there's 'tie' mechanics in Perl after all that makes types extensible.

Go is more from the typed world than Python where I came from. It will tell you at compile time you are using a string rather than an int (unless you use interface{}).
The only difference is a selection of basic types. There's just no such types as string or int in Perl, Perl is a contextually polymorphic language whose scalars can be strings, numbers, or references (which includes objects). Although strings and numbers are considered pretty much the same thing for nearly all purposes, references are strongly-typed, uncastable pointers with builtin reference-counting and destructor invocation.
For me the compile time and runtime distinctions are more important.
>The only thing good about Go, is being an evolution path for C coders willing to embrace a GC and some type safety.

You say that like it's a small thing, but what proportion of bugs in C code does that cover? Im guessing you'd hit over 50%.

It is a small thing because there are other languages that offer the same safety with more features and lets face it, if a C coder is willing to embrace a GC enabled language there are lots to chose from, with AOT compilation to native code.

I just expected more from Google, specially if one compares to the other company sponsored languages.

Comparing apples to apples, the first compiler sponsored by 'other company' was PHP, so Go looks not that bad in comparison. Reason is second, and maybe Google's second language would be 1ML.
Actually I was thinking in all languages that had commercial compilers, which goes way back than just PHP.
I love how C++ has had simple features like default arguments / function overloading for decades, while modern languages like Go and Rust require awkward workarounds.

Swift 3 looks good, though. They've learned the right lessons.

C++'s problem was never 'not enough features' it was precisely the opposite.
Default arguments, at least as done in C++, complicate the language's semantics (e.g., template specialization selection) far more than they raise the level abstraction. Definitely not a well-designed feature.

And Rust's traits are a far more principled (and thus better!) approach to overloading than anything C++ has (Boost's concept checks?). Traits turn concepts into language entities that are directly expressible in Rust syntax, rather than in awkward English documentation.

I certainly wouldn't say these are "simple features" in C++. Overload resolution in particular is one of the most complicated parts of the language. Default arguments can get weird since the right hand side of the default, more or less, just gets inlined at the call site; I do recall there were a couple bugs in the last year at work because of C++ default arguments, though I don't remember their details.

It's also fun when you don't realize a particular function has a default argument until you make a function pointer to it and assign/pass it to something that you mistakenly think is compatible. Depending on how nasty your codebase's use of templates and overloaded functions is, this can be a nightmare to debug.

There are also features that Rust has that C++ doesn't. So what?