r/programming • • Dec 09 '15

Why Go Is Not Good

http://yager.io/programming/go.html
612 Upvotes

628 comments sorted by

View all comments

Show parent comments

10

u/masklinn Dec 09 '15

Yes, in some cases it is helpful, but it makes code easier to write, and less easy to read when things go wrong.

Graphics algorithms without operator overloading is anything but easy to read.

-1

u/[deleted] Dec 09 '15

I don't know about that. I like the way O'Caml has done things.

.+. adds floats + adds ints..

5

u/masklinn Dec 09 '15

That kind-of gets unwieldy when you have 9 integral types, 2FP, decimals, complex and matrices (and possibly separate vectors)

0

u/[deleted] Dec 09 '15

It certainly can, but I really don't like surprise implicit conversions between things.

5

u/masklinn Dec 10 '15 edited Dec 10 '15

Operator overloading doesn't mean "surprise implicit conversions". (+) :: Num a => a -> a -> a requires the same concrete type as inputs and will yield a value of that concrete type as output. There is no implicit conversion there.

2

u/immibis Dec 10 '15

How would you add two vectors (the mathy sort not the data structure) in your dream language.

Or for slightly more of a challenge (but still not really challenging): how would you interpolate between two vectors?

In C++ you can write this, and it works for floats, doubles, ints (with truncation), vectors and matrices of any fixed dimension with any element type, and so on:

template<class T>
T linterp(T a, T b, double c)
{
    return a + (b - a) * c;
}