News for hackers. Stuff that matters.
Re:Why we’re writing machine learning infrastructure in Go, ... by toolslive on Friday January 17, 2020 @11:37AM (#22076150)
"in the land of the blind, the one-eyed man is king"

Golang is probably a step up from Python, but it's just that. There are a lot of issues with Golang. From the top of my head, lack of decent error handling (if err !=nil { return nil,err} ) or lack of decent polymorphism are the most annoying. There's a github repo dedicated to what's bugging people:

  https://github.com/ksimka/go-is-not-good
Re:Why we’re writing machine learning infrastructure in Go, ... by vardump on Friday January 17, 2020 @12:49PM (#22077134)
Well... there's also other side of the coin. There's value in visibility and lack of magic.

> lack of decent error handling (if err !=nil { return nil,err} )

Errors are in your face, instead of having exceptions performing invisible gotos to somewhere far up in call tree. Implicit error handling is more code, but your error handling is going to be much more robust.

> or lack of decent polymorphism...

Lack of polymorphism also means you don't have to guess about concrete types when reading code. When troubleshooting, you can see what's going on without going through whole inheritance tree.

Go encourages composition instead of inheritance. That's something I wish more C++ codebases would do as well. Composition makes code inherently more maintainable and easier to refactor.

Go tends to be easy to read and maintain. It does come with some cost. It's just a matter where your priorities lie. Software projects spend majority of their life as legacy, something that needs to be maintained.

Re:Why we’re writing machine learning infrastructure in Go, ... by mrbrowning on Friday January 17, 2020 @01:28PM (#22077561)
> Errors are on your face, instead of having exceptions performing invisible gotos to somewhere far up in call tree. Implicit error handling is more code, but your error handling is going to be much more robust.

Errors as values is a great idea. Errors as values without sum types or pattern matching, though, gives you twice the tedium and a tenth of the benefit, so once again Golang's slavish adherence to "worse is better" really just makes things...worse. The real problem here, though, is that those invisible gotos still exist: because of how limited Go's type system is, it's very easy to cause a panic with e.g. a nil pointer. Of course, the answer is to rigorously check the cases where a pointer could be nillable, but that trivially contradicts the idea that, when reading Go code, you can feel confident reasoning locally about its resilience if it handles all potential error values appropriately. IMO, this false sense of safety is even worse than just making exceptions first class citizens of the language, and it belies the notion that Go is especially maintainable.

Re:Why we’re writing machine learning infrastructure in Go, ... by loopz on Friday January 17, 2020 @05:08PM (#22079988)
Accessing nil would be a programming error, not normal errorhandling and code logic should inherently avoid the scenario, not hide or do coverup silently. If it breaks, let the process die.

The cost of simpler tools is you need to target better, simpler designs and refactor. This requires more from programmers but produces better code.

Re:Why we’re writing machine learning infrastructure in Go, ... by allovernow on Friday January 17, 2020 @12:55PM (#22077201)
>Composition makes code inherently more maintainable and easier to refactor.

My understanding of composition comes from interfaces in C#. In my experience composition is actually more difficult to code and refactor, because it leads to bloat from repeated code as you cannot simply inherit. Refactoring then can become tedious as you may need to manually edit every repeated code block. Whereas with inheritance I define a function once and override it where necessary.

Am I misunderstanding something?

Re:Why we’re writing machine learning infrastructure in Go, ... by vardump on Friday January 17, 2020 @01:00PM (#22077275)
Composition tends to lead to more code reuse. And to more code that's still usable in unpredictable future.

Over time your whole inheritance model often turns out to be no longer viable, when the basic assumptions made years ago are no longer valid.

Worse, because of all of the accumulated cruft, you might not even be able to change the shape of the monster.

Re:Why we’re writing machine learning infrastructure in Go, ... by sseth on Friday January 17, 2020 @10:27PM (#22082046)
In go, composition has a special feature where if you include another type anonymously in a struct, the methods of that type are automatically available for the struct as well. It is also possible to "override" these methods at the struct level and call the anonymous member directly.

So you can get some of the conveniences of inheritance. The behaviour is of course different, because the composed member has no way of knowing the identity of the including struct.

Re:Why we’re writing machine learning infrastructure in Go, ... by loopz on Friday January 17, 2020 @05:22PM (#22080129)
Composition should lead to clean components for reuse. You might need some extra references, but it is more explicit, static and flexible. Inheritance sounds great in theory, but is a hierarchical blind-alley, though usable for static designs that never change much.
Re:Why we’re writing machine learning infrastructure in Go, ... by arwhatever on Friday January 17, 2020 @02:46PM (#22078430)
I don't see that composition should be cause for repeated code blocks.
Re:Why we’re writing machine learning infrastructure in Go, ... by whateveracct on Friday January 17, 2020 @05:31PM (#22080230)
> Lack of polymorphism also means you don't have to guess about concrete types when reading code. When troubleshooting, you can see what's going on without going through whole inheritance tree.

Parametric polymorphism would mean you never have to even consider the type of the code. It's a freeing abstraction with plenty of very simple reference implementations. And it lends itself to composition over inheritance.

And sadly I doubt Go will ever manage to get it.

Re:Why we’re writing machine learning infrastructure in Go, ... by shrimpx on Friday January 17, 2020 @02:07PM (#22078004)
Try/catch vs explicitly checking error values is like implementing sandboxing with os-level isolation versus with programming discipline. Why one would prefer offering guarantees like "will never crash/panic" using the latter technique instead of a guaranteed catch-all is incomprehensible to me.
Re:Why we’re writing machine learning infrastructure in Go, ... by loopz on Friday January 17, 2020 @05:14PM (#22080058)
Performance and making logic explicit.
Re:Why we’re writing machine learning infrastructure in Go, ... by dewey on Friday January 17, 2020 @12:11PM (#22076622)
These two issues are usually brought up by people who haven't written a lot of Go.

In day to day work it's really not an issue.

Re:Why we’re writing machine learning infrastructure in Go, ... by apta on Friday January 17, 2020 @12:36PM (#22076961)
I write a lot of code in golang, and if anything, my views before using the language were even further cemented by even more flaws I found while using it.
Re:Why we’re writing machine learning infrastructure in Go, ... by loicd on Friday January 17, 2020 @03:25PM (#22078832)
Out of curiosity, would you share those flaws you have found?
Re:Why we’re writing machine learning infrastructure in Go, ... by apta on Saturday January 18, 2020 @10:12AM (#22084815)
This is by no means a comprehensive list:

* no generics

* null pointers

* no compile time checked enums or sum types

* The golang time package is garbage

* golang interfaces are garbage, can't tag types with an interface without implementing a dummy method and hope that no other type implements it. Can't find what interfaces a type implements without an IDE

* profiling and debugging tools are nothing in front of JVM and .NET tools

* no const/immutablility

* no ternary operator, need to write 6 lines instead of a single line if it existed

* error handling is error prone and verbose

* no default method implementation in interfaces

* unit testing frameworks are sucky and rely on code gen, can't mock arbitrary types, but only by defining an interface

* that unnused variables and imports are compile time errors, makes it very annoying and time consuming to prototype or when debugging

* no private/public/etc modifier. if you want to change the visibility of a type, you need to rename it in all files it's listed in

* no incremental compilation (yes Java compiles faster in large projects where I only modify a handful of files, or even more)

* pervasive use of single letter identifiers in golang code bases

* pervasive use of int, which has a platform dependent size

* pervasive instantiation of structs by calling them structFoo { Field1: field1, Field2: field2, ... FieldN: fieldN }, which makes it easy to miss when a new field gets added. Rust and Zig solve this by making it required to specify all fields and values.

* defer works on the function scope, not the current scope

* defer doesn't handle functions that return errors, meaning many errors are missed

* no struct or file private, only package private

* the global scope is polluted with special functions like len, copy, delete, make, new, append, for no good reason

* golang imports don't support cyclic imports

* golang doesn't allow you to import a a specific function or struct from a package. You have you always qualify anything with the package name, which makes things verbose and awkward.

Re:Why we’re writing machine learning infrastructure in Go, ... by loicd on Saturday January 18, 2020 @12:29PM (#22085657)
Thanks for the writing. I had noticed some of the things you wrote but not all (I am not a Go programmer though I keep track of what is happening there). Your post made me look a bit more into 'defer'. I did not expect it to be a source of errors.
Re:Why we’re writing machine learning infrastructure in Go, ... by apta on Saturday January 18, 2020 @01:02PM (#22085870)
No problem. As a side note, the Zig language does a much better job here, especially with defer. It works at the scope level (how it's supposed to be), and they have an `errdefer` construct used to call functions that return errors.
Re:Why we’re writing machine learning infrastructure in Go, ... by sagichmal on Sunday January 19, 2020 @03:41PM (#22093904)
> no incremental compilation

Not true, unless you're using an esoteric definition of "incremental".

> imports don't support cyclic imports

Why on earth would you consider this bad?

Re:Why we’re writing machine learning infrastructure in Go, ... by qtplatypus on Sunday January 19, 2020 @11:29PM (#22096306)
The problem that I've ran into with the lack of cyclic imports is that I like to arrange the contents of packages logically. However sometimes in order to do this it would result in a circular dependency between two packages. So rather then getting a logical arrangement we have to refactor it into an artificial package to resolve this depenancy.
Re:Why we’re writing machine learning infrastructure in Go, ... by sagichmal on Monday January 20, 2020 @04:16AM (#22097546)
Circular imports are always a design error, no "logical" to it.
Re:Why we’re writing machine learning infrastructure in Go, ... by apta on Friday January 17, 2020 @04:38PM (#22079661)
I will hopefully later today, not able to type much now.
Re:Why we’re writing machine learning infrastructure in Go, ... by jrimbault on Friday January 17, 2020 @12:13PM (#22076653)
>These two issues are usually brought up by people who haven't written a lot of C.

>In day to day work it's really not an issue.

Polymorphism and error handling, these are issues, address them. Go's a fine language, but don't dismiss actual real issues that have been addressed in other languages for 40+? years.

Re:Why we’re writing machine learning infrastructure in Go, ... by cle on Friday January 17, 2020 @12:32PM (#22076915)
I have written a lot of Go (hundreds of thousands of LOC), and appreciate Go's approach to both of these. I disagree that these are major issues.

A bigger issue, IMO, is that people coming to Go from other languages expect it to have similar features to what they're used to. Go is small and conceptually simple, but its ideas and philosophy are pretty different from most mainstream languages.

Re:Why we’re writing machine learning infrastructure in Go, ... by flavio81 on Saturday January 18, 2020 @09:04AM (#22084479)
>Go is small and conceptually simple, but its ideas and philosophy are pretty different from most mainstream languages.

No, they aren't. They are the same as languages from 40 years ago: We have had channels, coroutines, and good garbage collectors from long, long ago. Plus the syntax is directly borrowed from Algol 68 (from 1968).

Go looks nice because it fills a niche (a high performance garbage collected language that is easier to learn than Java and provides faster compilation times than C++), but there's absolutely nothing different here.

For "pretty different from mainstream" see Forth, Prolog, Erlang, etc.

Re:Why we’re writing machine learning infrastructure in Go, ... by RandyRanderson on Friday January 17, 2020 @11:10PM (#22082204)
"I have written a lot of Go (hundreds of thousands of LOC)..."

Go only appeared about 10 years ago. The industry standard is 50 lines of production code a day. 50/day * 250 working days a year = 12.5k loc/year. So it would take you how many continuous years to write 200k LOC?

Re:Why we’re writing machine learning infrastructure in Go, ... by dewey on Saturday January 18, 2020 @07:16AM (#22084004)
There's probably a very big difference between "industry standard" and working with a new language at a startup where a lot of things are written from scratch in a short amount of time. 50 lines of code on average for a year won't get you very far if you work on greenfield project.

The industry standard is probably very heavily biased by big corporate code bases where refactoring / architecture takes a lot more time than implementing the actual changes afterwards. Doesn't seem like a very useful calculation you are trying to do there to proof the previous poster wrong.

Re:Why we’re writing machine learning infrastructure in Go, ... by RandyRanderson on Saturday January 18, 2020 @04:28PM (#22087366)
"There's probably a very big difference between" - that is precisely my point.

I have a lot of time playing ms flight sim and so obviously I know how to design airplanes is his argument.

Writing "greenfield" applications that no one (comparatively) is using is relatively easy. Creating systems that have four+ 9's availability, integrate with various disparate APIs, don't lose data, and,and etc is where, IMO, the learning is.

Once one has this experience, watching this micro services "movement" is, in my mind, related to global warming - like watching someone jump out of a plane with no parachute, smiling.

Re:Why we’re writing machine learning infrastructure in Go, ... by whateveracct on Friday January 17, 2020 @05:36PM (#22080286)
Go necessitates so much handrolling. Loops, concurrency patterns, resource management. You can't abstract over much, so you end up doing these things by hand constantly. Therefore you rely on brainpower, ad hoc linters (if one exists), and tests to not blow things up.

Go has its benefits and reasons to use it (especially the network effects around it). But when it comes to the three things I mention, Go is truly pathetic compared to a language like Haskell. It's amazing how much effort is wasted on those activities. I can see why a corporation would not care, but as an engineer I can do better with my time and effort for my personally-owned endeavors.

Re:Why we’re writing machine learning infrastructure in Go, ... by cle on Friday January 17, 2020 @08:01PM (#22081381)
As an individual, many of Go's benefits aren't as useful. It's optimized for team settings, emphasizing consistency, readability, explictness, and low cognitive overhead, which are all major weaknesses of Haskell, and major reasons it's not widely used in industry.
Re:Why we’re writing machine learning infrastructure in Go, ... by whateveracct on Friday January 17, 2020 @08:54PM (#22081630)
For many applications, Go has higher cognitive overhead than Haskell. Modulo learning Haskell of course, but still.

Go is made to treat people as Resources. Full stop. That explains everything about it's benefits.

Re:Why we’re writing machine learning infrastructure in Go, ... by icandoit on Friday January 17, 2020 @12:47PM (#22077108)
In some circles C has a better reputation than C++.

Surely you see that other people value other things than you do?

If you value simplicity check out the programming language zig.

https://ziglang.org/

Re:Why we’re writing machine learning infrastructure in Go, ... by flavio81 on Saturday January 18, 2020 @09:01AM (#22084468)
>If you value simplicity check out the programming language zig.

I value simplicity, that's what i use Brainfuck. Far simpler than Go and Zig.

https://fatiherikli.github.io/brainfuck-visualizer/

Re:Why we’re writing machine learning infrastructure in Go, ... by jrimbault on Friday January 17, 2020 @12:58PM (#22077250)
I love C, loathe C++, but it is still valid issue that polymorphism in C is hard and error handling rely on convention ? (I know of Zig, Nim et al, I'm more oriented towards Rust this last year)
Re:Why we’re writing machine learning infrastructure in Go, ... by carteloupe on Friday January 17, 2020 @12:29PM (#22076872)
Status quo is good because it's status quo, sure.
Re:Why we’re writing machine learning infrastructure in Go, ... by icandoit on Friday January 17, 2020 @12:41PM (#22077020)
I like my code to look simple and behave as expected. Stability and "one right way to do it" are great language features.

I think this was why Python was able to overtake Perl, for example.