Earlier quoted context omitted.
Exceptions are bad outside the "your computer just started burning" cases, but Go has replaced them with something even worse, "multiple return values". So instead of some imagined return of "int or throw Exception" you now have "(int, error)", which basically means that the result of a function call can be any of these four options: - ( value, no error) - (no value, error) - ( value, error) - (no value, no error) An…
Feels like Javascript callback error handling. Which was not much fun.
Eight years of Go
261–270 of 291 posts
Re: Eight years of Go
#262Re: Eight years of Go
#263Earlier quoted context omitted.
go, a language which comes with many built in concurrency primitives, has chosen to leave its core datatypes thread unsafe (the magic ones with generic powers) and gives no sensible tools to remedy this with. this is one of the many ways in which it is a language hostile to its users.
Often, you don’t need concurrent types and their overhead. The sync package makes it easy to bolt on if you truly do. It’s not as if every block is sending out each line to run in a separate goroutine. Go encourages users to share data by communicating, not communicating by sharing data [0]. On phone, sorry for syntax struct CMap { sync.RWMutex i int } func (m *CMap) Inc() { m.RWLock() defer m.Unlock() m.i++ } [0]: h…
for instance, in a for loop ranging over a slice:
for _, i := range some_slice {
go func() {
something(i)
}()
}
i is re-used for every iteration of the loop, so the asynchronous function does not close over i as a particular value, but rather i as whatever value the loop has iterated to by the time it is referenced. i see experienced go programmers make this mistake sometimes, even when they've run into it before. my take is that the golang designers chose to implement this behaviour to either simplify their work or in the name of efficiency. if it's the former, it's indefensible. if it's the latter, why not offer user-friendly semantics (let closing over i as in the example capture the iterated value) and simplify the generated code at compile time when possible?for your example, you can look to the newly added sync/map which uses interface{} everywhere as an example of how the lack of generics have left users with no _sensible_ tools to remedy these kinds of language problems. how wonderful would an efficient thread-safe and type-safe concurrent map be? it's possible in many other modern and not so modern programming languages, but it is intentionally not possible in go.
Re: Eight years of Go
#264Earlier quoted context omitted.
The standard godoc documentation browser does this too when started with the -analysis option. They all use the same source code oracle functionality available from the x/tools repo.
No, Goland actually doesn't use that, they're rolling their own for everything.
OTOH, they (Jetbrains) probably have shared infrastructure (between languages) within their IDE code base, too, and are more comfortable using their existing tooling.
Re: Eight years of Go
#265Earlier quoted context omitted.
I'm not sure who you're quoting or why. > Issues are representative as a sampling, not absolute numbers. My point was that issues are not a reliable sample of the Go community as a whole. They're a self-selected population of Go developers who cared enough about generics to click on a Github proposal on the subject and react to it. I'll say it again: >> The majority may not spend their time reading or reacting to pro…
> I'm not sure who you're quoting or why. I accidentally re-pasted the same quote from nine_k I've answered to higher up the thread. Meant to quote this from you: "1734 people reacted to the generics issue, most in favor, but there are many more Go developers than that". >* My point was that issues are not a reliable sample of the Go community as a whole. They're a self-selected population of Go developers who cared…
Re: Eight years of Go
#266Earlier quoted context omitted.
I hear people praise the Java ecosystem so often, but when I use it I cannot replicate that. There is nothing like Django in Java land? Instead you are sent into a confusing mess of interface standards like JPA and implementations (hibernate, ebeans, ...) and little guidance how to choose.
Equivalent of Django would be something like Spring Boot, Play Framework etc. It's quite common that some of these frameworks rely on community infrastructure that has several competing implementations, like JPA, but the point of a tool like Boot is that they picked all the implementations for you and documented it all centrally.
For example, one thing which seems to be worse across the board is database evolutions. Django will autogenerate an evolution in Python for you [0] and if necessary you can adapt the code. In Java land you have to write SQL by hand [1] afaik? If SQL is not enough, I don't know what to do at all.
[0] https://docs.djangoproject.com/en/1.11/topics/migrations/ [1] https://www.playframework.com/documentation/2.6.x/Evolutions...
Re: Eight years of Go
#267Earlier quoted context omitted.
> If Go had ADTs In the process of hacking on my PureScript2Golang "transcompiler", I've realized that under the hood ADTs, also known as "tagged unions", will likely more often than not be represented exactly as just that: a "tag flag" and a data pointer. (Of course if all of an ADT's ctors are nullary, an enumish int will do the trick just as well --- I doubt this gains anything over interface{}-boxed 0-size struct…
Can you link to your project?
Earlier first approach, won't currently compile due to deps: http://github.com/metaleap/gonad-coreimp
Auxiliary stuff currently dumped in: http://github.com/golamb
For a fun ps2go comparison, side-by-side:
https://github.com/golamb/test-pscorefn-src/tree/master/src/... https://github.com/golamb/test-pscorefn2go/tree/master/Mini --- lots to-do still =)
Re: Eight years of Go
#268Earlier quoted context omitted.
Really? I've recently been recruited to pitch in on a Java project, they're using maven, and the compiles sure aren't incremental. What should we be using instead?
Eclipse or IntelliJ IDEs will compile while you code (like C#). Depends on the project setup and dependencies. But I've found that this works for most development until I need to produce an artifact. Then I run maven which does a lot more than just compile code and usually is longer than 40s.
Re: Eight years of Go
#269Earlier quoted context omitted.
Often, you don’t need concurrent types and their overhead. The sync package makes it easy to bolt on if you truly do. It’s not as if every block is sending out each line to run in a separate goroutine. Go encourages users to share data by communicating, not communicating by sharing data [0]. On phone, sorry for syntax struct CMap { sync.RWMutex i int } func (m *CMap) Inc() { m.RWLock() defer m.Unlock() m.i++ } [0]: h…
i understand the patterns and design intentions of the language, despite not having written very much of it. (i just checked my work stats and i'm surprised to find that i've written/changed nearly 40k lines of go - of course that counts for less given how verbose the language is). one of my complaints is that a language designed to be simple has made (to me) incomprehensible design choices in the name of efficiency.…
for (int i : someCollection) {
pool.execute(() -> something(i));
}
Because "i" is effectively final, each Runnable closes over the correct value for that iteration. If "i" were being reassigned, the closure wouldn't be allowed to use it, you'd have to decide whether to close over a final copy or a reference to a mutable object that holds the latest value over time (a one-element array is the idiom).Re: Eight years of Go
#270Earlier quoted context omitted.
No, Goland actually doesn't use that, they're rolling their own for everything.
Thanks for the correction. I think that's somewhat unfortunate, though. The powerful shared tooling is one of the strengths of the Go ecosystem and if there are issues with it that prevent the use in Goland I'd rather see those get fixed. OTOH, they (Jetbrains) probably have shared infrastructure (between languages) within their IDE code base, too, and are more comfortable using their existing tooling.