News for hackers. Stuff that matters.
Re:Just tell me how to use Go Modules by weberc2 on Tuesday December 11, 2018 @12:25AM (#18653431)
> How you structure your code beyond the src/git/path/your-code/ is completely up to you and every repo you visit could be different.

This is an unusual criticism. Typically Go is faulted for being too opinionated, and it’s projects too predictable. In fact, this is why I took to the language—no need to see past every maintainer’s personal flourishes just to build the code or run the tests. No ceremoniously nested directory structure. No figuring out how to point the build tool to the source files or how to convince the build tool to output or run a test target. Everything is right there, rather plainly and consistently across all projects. This does mean I have less room for creativity which is an okay tradeoff for me because I have just enough creativity to spend on the application and its architecture and the rest should just work, but I recognize that some may disagree and that’s okay too.

Re:Just tell me how to use Go Modules by Felz on Tuesday December 11, 2018 @01:15AM (#18653544)
This sounds like tooling and formatting consistency versus abstraction consistency. Go isn't great for building powerful abstractions, so at a higher level implementations will trend towards inconsistency, however consistent the low level syntax.
Re:Just tell me how to use Go Modules by weberc2 on Tuesday December 11, 2018 @10:32AM (#18655924)
A few thoughts:

1. I don't think powerful abstractions are often that useful. I use Python in my day job, and we mostly don't use many high level abstractions. We never use monads, for example, and while we do use async futures, these are strictly worse than Go's concurrency features.

2. Pretty sure abstraction power drives _less_ consistency, not more. Effectually, it means there are more ways to do the same thing (and more ways to screw it up and make a mess), and consistency depends on organization discipline and less on the rails of the language. I don't mean to say abstraction is bad--only that consistency is one of the costs, not an advantage.

I'm interested to hear your thoughts.

Re:Just tell me how to use Go Modules by zeugmasyllepsis on Tuesday December 11, 2018 @12:09PM (#18656756)
> Pretty sure abstraction power drives _less_ consistency, not more.

It depends, I think. Abstractions allow users to specify part of a program's behavior independently from others. This is not intended to start a flamewar or pick on Go, but for better or worse Go does not support user defined generic functions. One consequence is that certain kinds of methods are difficult to write in a generic, performant, and type-safe way. If users want performance and type safety, they need multiple implementations of those methods for each desired type. This leads to multiple copies of very similar code (which can evolve independently, lowering consistency) or the use of on of the community-driven code generators (which all have their own differences, again lowering consistency).

Adding generics could largely make all of this inconsistency go away, but as you point out would enable a whole slew of other programming patterns more ways to make a mess.

I prefer to think of abstraction techniques as shifting consistency. Ideally, they provide an obvious way to factor out one piece of a program's behavior, allowing developers to focus on the rest of the behavior independently.

Re:Just tell me how to use Go Modules by weberc2 on Tuesday December 11, 2018 @02:36PM (#18658136)
I largely agree, but I think people generally underestimate the abstractive power of (typesafe) Go and overestimate the cost of its abstractions.

Generally Go's abstractions are based on dynamic dispatch (virtual function calls) which are quite cheap and are the basis for most other languages' abstractions. There are languages like Rust and C++ which offer zero-cost abstractions and generally beat Go in performance and abstraction power, but lose in other ways. If you're comparing Go to Java, C#, Haskell, OCaml, Python, JS, and Ruby, Go performs on par or better.

As far as abstractive power, Go does quite well, although there is still some _boilerplate_ (for loops and closures); however, this is generally not where your bugs come from (certainly not your troublesome bugs) and boilerplate is consistent by definition. I think the biggest reason Go's lack of generics irks people is because they want _terse_ code, because terseness is the most obvious (but least useful) kind of DRYness. The next biggest reason is more legitimate--getting a lot of typesafe abstractive power out of Go requires a different bag of tricks (and a different way of thinking about abstraction) than languages with generics.

Re:Just tell me how to use Go Modules by bpicolo on Tuesday December 11, 2018 @01:06PM (#18657277)
> never use monads

I think "powerful abstractions" fall into other categories, e.g. ORMs. While gORM kinda-sorta works in the context of golang limitations, it's missing a lot of stuff that doesn't currently fit into the go model.

Re:Just tell me how to use Go Modules by weberc2 on Tuesday December 11, 2018 @02:03PM (#18657845)
Can you elaborate? I can't think of anything in Go that would preclude ORMs. I'm not familiar with gORM, however.
Re:Just tell me how to use Go Modules by gcb0 on Tuesday December 11, 2018 @02:06AM (#18653655)
in other words, it's consistent if you only look at it for a few minutes. use it for anything and it become an inconsistent mess.
Re:Just tell me how to use Go Modules by kerng on Tuesday December 11, 2018 @10:01AM (#18655700)
Been trying it out and agree. I like it a lot for simple, stand alone tools. For more complex ones it appears strangely ill-suited and "messy".
Re:Just tell me how to use Go Modules by jonathanstrange on Tuesday December 11, 2018 @04:27AM (#18654122)
As if powerful abstractions lead to more consistency...
Re:Just tell me how to use Go Modules by the_clarence on Tuesday December 11, 2018 @12:22PM (#18656871)
You mean 50 layers of abstraction?
Re:Just tell me how to use Go Modules by kodablah on Tuesday December 11, 2018 @05:47AM (#18654440)
>> Not in the fundamental "this is how you should indent" bit but in the "this is how you should unpack dynamic json content" sense

> Typically Go is faulted for being too opinionated, and it’s projects too predictable

The parent addressed this. You are confusing inflexibility of language with inconsistency of ecosystem. Devs can want both more flexibility in the language, syntax, and type system and more commonly accepted project-level structures/approaches at the same time. I definitely don't see projects being too predictable at a general level as each lib has its own way of doing many things.

Re:Just tell me how to use Go Modules by calgoo on Tuesday December 11, 2018 @12:31PM (#18656961)
I agree, I love it even more for making small tools where i can just skip the whole folder structure and just have a .go file in a directory and compile it to a bin without all the fuzz of build tools, special folder structures etc. Of course for bigger, shared projects i know these tools help, but sometimes when you just want to make something small, or test something, i find these tools just get in my way.
Re:Just tell me how to use Go Modules by jjtheblunt on Tuesday December 11, 2018 @05:29PM (#18659598)
go build -o whatever.exe whatever.go works just fine.
Re:Just tell me how to use Go Modules by fouc on Tuesday December 11, 2018 @03:20AM (#18653905)
When I hear "opinionated" I think of Ruby on Rails. Would be nice if Go had more opinions on structure and conventions perhaps.
Re:Just tell me how to use Go Modules by Someone on Tuesday December 11, 2018 @03:32AM (#18653951)
Frameworks provide structure; Ruby on Rails is a framework, Go is not.
Re:Just tell me how to use Go Modules by fouc on Tuesday December 11, 2018 @06:02AM (#18654513)
Go is already halfway there ;)
Re:Just tell me how to use Go Modules by randomdata on Tuesday December 11, 2018 @09:07AM (#18655348)
Even Rails only manages to be opinionated for a small set of aspects about building CRUD web applications. If you can stay within those boundaries, it is useful. But as soon as your application needs to deviate from that, it seems that every project goes off and does its own thing again.
Re:Just tell me how to use Go Modules by anonfunction on Tuesday December 11, 2018 @02:22AM (#18653703)
If you frequent reddit/r/golang you'll see this question pops up quite frequently and the comments have many differing suggestions.
Re:Just tell me how to use Go Modules by andy_ppp on Tuesday December 11, 2018 @02:42AM (#18653770)
Great! What are they?
Re:Just tell me how to use Go Modules by skolsuper on Tuesday December 11, 2018 @06:49AM (#18654691)
Comments are snippets of text, typically short, written by consumers of content in order to share their opinion of or reaction to that content with other consumers.