News for hackers. Stuff that matters.
Re:3.5 Years, 500k Lines of Go by excepttheweasel on Friday March 24, 2017 @11:10AM (#13949394)
I think the go language has taken a position along the lines of "re usability and abstraction are overrated". I certainly think there is some truth to that, I am really enjoying working with go on smaller projects and it is this philosophy that has made understanding the code much easier.

But I wonder how it really scales on a large code base like this? Some of the best projects I've worked on leverage usability more effectively to create a sort of vocabulary. They're far more concise, there is rarely more than one source of truth, they're far easier to change and improve. Does this hold true for 540,000 lines of go code?

Re:3.5 Years, 500k Lines of Go by weberc2 on Friday March 24, 2017 @11:24AM (#13949499)
> But I wonder how it really scales on a large code base like this? Some of the best projects I've worked on leverage usability more effectively to create a sort of vocabulary. They're far more concise, there is rarely more than one source of truth, they're far easier to change and improve. Does this hold true for 540,000 lines of go code?

Doesn't this article speak to this? It mentions juju has over a million lines.

Re:3.5 Years, 500k Lines of Go by goatlover on Friday March 24, 2017 @12:57PM (#13950328)
Yeah, but there is no comparison to the same project done in Lisp, Haskell, Java, etc.

All the author is doing is relating their success using Go, which is great, but there is no comparison to how it would have fared in another language, except his previous frustrations with C#, on other projects, I guess.

Re:3.5 Years, 500k Lines of Go by weberc2 on Friday March 24, 2017 @01:49PM (#13950769)
It would be ridiculous to expect Canonical (and even moreso, the author alone) to rewrite juju in another language as a simple comparison. Even if it were feasible, the comparison would be polluted by the experience gained by building the application initially (or you could rebuild with a completely new team of developers, but then you're introducing a whole new set of variables). The best we can reasonably do is compare applications aggregating on language.
Re:3.5 Years, 500k Lines of Go by sciurus on Friday March 24, 2017 @06:15PM (#13952669)
Juju was originally written in Python. They ported it to Go 4 years ago.

https://groups.google.com/forum/?fromgroups=#!topic/golang-n...

Re:3.5 Years, 500k Lines of Go by NateDad on Friday March 24, 2017 @11:23AM (#13949487)
functions and methods are the original abstraction. Interfaces allow you to abstract implementations of sets of methods.

I fail to see how that is saying that abstraction and usability are overrated. They're not. They're important.

Re:3.5 Years, 500k Lines of Go by 2_listerine_pls on Friday March 24, 2017 @11:28AM (#13949539)
Yeah, I guess some need to review the definition of abstraction.
Re:3.5 Years, 500k Lines of Go by sbov on Friday March 24, 2017 @12:06PM (#13949858)
Sometimes I feel like the OO world has redefined abstraction to only mean an interface.
Re:3.5 Years, 500k Lines of Go by pjmlp on Friday March 24, 2017 @12:42PM (#13950176)
Re:3.5 Years, 500k Lines of Go by kuschku on Friday March 24, 2017 @12:13PM (#13949910)
And go can not write abstract functions and methods.

I can not write a function dealing with arbitrary values.

Somethind I’d do in Java with

    public static <T extends IIncrementable> T increment(T val) { val.increment(); return val; }
is impossible to do in Go.

You can not abstract over types, and write metric fucktons of duplicated code. I’ve tried porting some of my Java code, and it quickly grew to some classes being duplicated hundreds of times, once for every type. Fixing bugs became a nightmare.

Re:3.5 Years, 500k Lines of Go by jy3 on Friday March 24, 2017 @07:23PM (#13953051)
> I’ve tried porting some of my Java code, and it quickly grew to some classes being duplicated hundreds of times

Who would have thought. Maybe a rewrite would have been more appropriate.

Re:3.5 Years, 500k Lines of Go by kuschku on Friday March 24, 2017 @09:50PM (#13953635)
Porting meant rewriting here.

But I still ended up with the same classes replicated hundreds of times.

Polymorphic code is not possible in any other way in go – you always have to duplicate the code.

Re:3.5 Years, 500k Lines of Go by jy3 on Saturday March 25, 2017 @08:08AM (#13955216)
I'm sorry it went badly then.

Your example intrigues me, isn't an interface enough?

Is what bother you that the return value won't be typed T but IIncrementable in go?

Re:3.5 Years, 500k Lines of Go by kuschku on Saturday March 25, 2017 @01:31PM (#13956653)
Yes, exactly. This is an actual issue.

My system is usually designed that I provide a function that generates a value of type T, a function to filter T (T -> boolean), and a way to display Ts.

So, the library now gets these functions, and does all the filtering on other threads.

So either I have to replicate the entire async code for every type, or I can’t keep type safety.

Re:3.5 Years, 500k Lines of Go by rogpeppe1 on Saturday March 25, 2017 @05:03PM (#13957552)
Don't keep type safety then. Think of Go as half-way between Python and Haskell in that respect. Types are great when they're useful, but they're not required.
Re:3.5 Years, 500k Lines of Go by kuschku on Saturday March 25, 2017 @05:37PM (#13957689)
If you’re serious, that’s... the worst solution I’ve heard yet.

That’s the same mistake C did with void, Java did with Object and corrected with generics in 1.5, just called interface{} this time.

And while with python and Java, even if I circumvent the type system, I can still use annotations (see typed python, or JetBrains @Contract, Google’s @IntRange, etc), with Go I have nothing of that sort.

Types are useful to provide safety, if your type system has to be turnt off, then I am losing all that safety, and might as well code in PHP (although they also* saw that mistake, and are fixing it now, with 7.0 and later).

Re:3.5 Years, 500k Lines of Go by NateDad on Friday March 24, 2017 @12:15PM (#13949927)
To actually answer the question - yes it holds true, yes it scales (in my experience). There are a lot of abstractions that we built for Juju. And we absolutely tried to ensure there was only a single source of truth for everything. It would have been totally unworkable if we couldn't reuse logic etc. We may not always have chosen the best abstraction, but that's a problem in any language.
Re:3.5 Years, 500k Lines of Go by jrs95 on Friday March 24, 2017 @11:16AM (#13949437)
Well, it'd definitely be easier to change than something that had the wrong abstractions.