News for hackers. Stuff that matters.
Re:Show HN: We wrote a book about building business applicat... by gengstrand on Thursday May 13, 2021 @11:42AM (#27143371)
Go did rise to prominence by being the programming language behind such high profile software as Kubernetes, Docker, and Prometheus. None of those are business applications and Rob Pike (ex Bell Labs guru and co-inventor of Go) gave a presentation about Go in 2015 where he explicitly identified that Go was invented for infrastructure and not business applications.

I have encountered many engineers who are excited about Go and want to adopt it for enterprise systems. In 2019. I evaluated Go for that purpose. You can read my evaluation at http://glennengstrand.info/software/architecture/microservic...

What I discovered is that Go is not any faster than Java on a light weight framework. Here is the part that may seem controversial for the folks here. The simplicity of Go did not result in simpler systems.

I found that the lack of inheritance hampered me in expressing solutions to complex business rules and data models. Many of you may disagree with that and counter argue that inheritance is a bad thing. That is most probably one reason why there is so much interest in Go. It intentionally lacks support for inheritance. I agree that inheritance can and has been misused a lot. It is an advanced programming language feature that should be used sparingly. Removing inheritance entirely reduces the expressiveness of the programming language, especially when it comes to enterprise computing.

Re:Show HN: We wrote a book about building business applicat... by hughrr on Thursday May 13, 2021 @12:49PM (#27144351)
I’ve done a huge amount of “enterprise architecture” going back 20 years or so. I’ve designed and built horrible things that scare most people to death. Imagine monoliths with over 1000 DD and ORM mapped business domain classes, 2000 http endpoints and hundreds of database tables glued into tens of megs of Hibernate mappings.

Inheritance is the number one cause of these turning into a massive shit show. It’s not a pattern that can ever be refactored into something else down the line once the decision is made. You end up with things that can’t be fixed and escalating costs like you have never seen just to keep the plates spinning.

I always favour composition for that and very light weight service oriented architecture.

Roughly the only thing that scales is things that have fairly strict command-query type segregation. Carefully designed REST interfaces are a good example of that.

Regarding complex business rules they are mostly best evaluated through simple stacked middleware, messaging, matching, routing and workflow style applications. All of those are feasible with the simplest of languages. Hell half the world is still hanging off rancid bits of COBOL.

If you are short circuiting your evaluation on this basis I think you are making a lot of noise without a lot of experience.

Re:Show HN: We wrote a book about building business applicat... by kodah on Thursday May 13, 2021 @12:18PM (#27143909)
I've used Go on both infrastructure and web projects. "The simplicity of Go" entirely depends on architecture and code quality. Go will force you into some design patterns that are not too favorable if you're not familiar with them. When I was helping people with Go I would see it a lot when people first start using interfaces. I would never claim, as you have, that Go cannot be used on the web or that it won't be just as effective as Java + Spring. Generally I've found most tasks between Java and Go to be similar in complexity (and requiring different approaches), as it seems you found. Where there is a massive difference is tooling and dependency management. That absolutely contributes to developer ergonomics and is a fairly weighty point that is not mentioned in your analysis.

Personally speaking, choosing between languages is a non-starter conversation for me. At this point, since my childhood, I have rotated through 10+ languages. Languages are certainly tools and picking the right tool for the job is important. That said, I don't want to work at another company that mandates one language (as is commonly the case with Java) across the entire enterprise. We need solutions that bridge tooling language gaps for enterprises more than we need archaic mandates about what I'm allowed to write in for a given purpose.

Re:Show HN: We wrote a book about building business applicat... by bndw on Thursday May 13, 2021 @12:01PM (#27143653)
In my experience, I've found the lack of polymorphism to be the larger challenge in building complex business systems in Go.

Managing a bunch of polymorphic entities in Go often requires implementing a bunch of interfaces in various types. You then have to write a bunch of mapping logic for every type, driven by type assertions. Apply this in a large codebase that encapsulates transport, data access, and so on and you end up with a ton of complexity.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Thursday May 13, 2021 @12:04PM (#27143708)
> The simplicity of Go did not result in simpler systems.

I echo this 100%. I worked at an employer who heavily used golang. The resulting projects were honestly a mess, yet they pushed through.

What's ironic, is that they ended up reinventing the wheel on so many different things, including DI and an entire application framework. Millions of dollars spent writing and maintaining these libraries, where Java already had them ages ago.

As you point out, the modeling capability of golang is extremely subpar. It results in verbose code that is very sparse, lots of code to implement something that would have taken a few lines in a language like Java and C#, let alone something more dense like Scala.

The way interfaces are handled in golang makes it very annoying to try to find out which types implement said interface. It puts a lot of pressure on the IDE to search the entire code base, and you end up with types you don't even care about. It clearly shows that the golang authors did not have IDEs in mind when writing the language, which is just absurd as it's supposedly a language designed for "programming in the large". Anyone who used "goland" knows what I'm talking about. Try refactoring a type, and have the IDE scan the entire code base to look for comment strings, which it has to because golang has no notion of doc strings like Java or C#.

Add features like records, pattern matching, enums (the amount of code that had to be written to implement something to emulate enums was just absurd and frustrating to deal with, not to mention error prone).

The concurrency aspect of golang is decent (though it will be even better in Java). Other than that, the language doesn't really have anything going for it other than having a large brand name backing it.

Re:Show HN: We wrote a book about building business applicat... by konart on Thursday May 13, 2021 @12:34PM (#27144175)
>It puts a lot of pressure on the IDE to search the entire code base, and you end up with types you don't even care about. It clearly shows that the golang authors did not have IDEs in mind when writing the language, which is just absurd as it's supposedly a language designed for "programming in the large". Anyone who used "goland" knows what I'm talking about. Try refactoring a type, and have the IDE scan the entire code base to look for comment strings, which it has to because golang has no notion of doc strings like Java or C#.

Even if this was the case years ago - it is not now with an LSP.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Thursday May 13, 2021 @03:15PM (#27146124)
It still is, it's inherent to the way interfaces are designed. Did you use golang on a monorepo for example?
Re:Show HN: We wrote a book about building business applicat... by konart on Thursday May 13, 2021 @04:55PM (#27147330)
>Did you use golang on a monorepo for example?

No. I have met monorepo on my path only once (not a golang one, it was mix of java and jruby) and I hope I will never see one again.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Thursday May 13, 2021 @06:08PM (#27148100)
golang fails miserably in a monorepo setting, which is ironic because it was designed at Google, and Google are known for their monorepo.
Re:Show HN: We wrote a book about building business applicat... by konart on Friday May 14, 2021 @01:09AM (#27150929)
>which is ironic because it was designed at Google, and Google are known for their monorepo.

Google is huge. I'm fairly sure they use different approaches to code organisation in different teams\departments.

Anyhow - I'd rather thank them for that. Now chances I'll have to deal with monorepo are lower. I'm going to think of this as a feature, not a bug, lol.

Re:Show HN: We wrote a book about building business applicat... by eaa on Friday May 14, 2021 @05:58AM (#27152577)
May I ask, what do you mean and why do you say so? What is wrong with golang in monorepos?
Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Friday May 14, 2021 @07:40AM (#27153142)
Because interfaces are nominally typed, it's very simple to accidentally implement interfaces that are defined in other parts of the code base, even though they are not related to your project. This makes searching for implementors of a given interface in a project show implementors you don't care about, which makes navigation and discoverability very tedious.

Furthermore, golang does not have a proper format for docstrings like Java or C#. When refactoring, the IDE tries to be smart and parse all comment strings as they are doc strings, and when you want to rename a struct, you're going to get a huge dialog with so many entries which can be false positives, and you have to go through them manually to check whether or not they apply. Same as with the interface issue, similar struct names may appear all across the code base which makes this refactoring very tedious.

There are other issues of course, like the fact that golang has no constructors, and structs are defined adhoc, meaning adding a new field to it needs more hunting across the code base to make sure you don't miss defining and break something.

Re:Show HN: We wrote a book about building business applicat... by sagichmal on Thursday May 13, 2021 @09:30PM (#27149616)
> I worked at an employer who heavily used golang ... they ended up reinventing the wheel on so many different things, including DI and an entire application framework.

Sounds like they were trying to force the language to be something it's not. DI frameworks (I think what you mean) are basically incoherent in Go, dependency injection is naturally modeled with interfaces. In fact any inversion-of-control style "framework" is a mismatch to the language, it (intentionally) lacks the features that frameworks rely on to deliver benefits that outweigh their costs.

> The way interfaces are handled in golang makes it very annoying to try to find out which types implement said interface.

The desire to do this reflects a misunderstanding of interfaces.

Re:Show HN: We wrote a book about building business applicat... by closeparen on Thursday May 13, 2021 @09:59PM (#27149784)
Take a look at the major DI frameworks for Go, Wire [0] and FX [1]. They just plumb the gaps between methods that return types and methods that want them. Although technically they work for concrete types, 99% of the time it's going to be an interface, so that you can substitute a mock for testing.

Prior to DI frameworks we used global variables, often initialized in a package's init() method.

>The desire to do this reflects a misunderstanding of interfaces.

Generally you have a few layers: gRPC/HTTP/Kafka handler, business logic, and database or external service access. Layers are unit tested individually against mocks of the layers below. Because you're going to inject a mock, you can't depend on a concrete type, so you depend on an interface. Often when you're developing you want to know what the concrete implementation of a lower layer does, so it's useful to have "go-to-definition" see through the interface declaration to its implementations.

I think the implicit satisfaction of interfaces is very cool and I wish I had it in every language. I wouldn't give it up just to simplify the IDE's job. But the IDE having this functionality does matter.

[0] https://github.com/google/wire

[1] https://github.com/uber-go/fx

Re:Show HN: We wrote a book about building business applicat... by sagichmal on Friday May 14, 2021 @01:50AM (#27151166)
> Take a look at the major DI frameworks for Go, Wire [0] and FX [1]

I'm well aware of them. (There are several more, too, which see at least as much use as these two, unfortunately.) They also reflect a misunderstanding of the language. Wire less so than FX. (I'm also aware Wire is written by Googlers, no need to point that out.)

> Prior to DI frameworks we used global variables, often initialized in a package's init() method.

I don't understand how these things are related. DI frameworks aren't necessary for Go-idiomatic dependency injection, and global variables were never an appropriate way to manage dependencies.

> Generally you have a few layers: gRPC/HTTP/Kafka handler, business logic, and database or external service access.

Yes!

> Layers are unit tested individually against mocks of the layers below.

Yes!

> Because you're going to inject a mock, you can't depend on a concrete type, so you depend on an interface.

Yes!

> Often when you're developing you want to know what the concrete implementation of a lower layer does, so it's useful to have "go-to-definition" see through the interface declaration to its implementations.

...no?

There are basically two situations where you use an interface in this way. One, most often, in an application where the "production" code uses one implementation, which you know a priori and therefore have no need to go spelunking. Or, two, in a library where you by definition cannot know what implementation your users will provide to you. In the first case, your mock would model the implementation, which I guess is trivial. In the second case, your mock would reflect your expectations of the interface's implementations, explicitly without knowledge of any implementation.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Friday May 14, 2021 @05:12AM (#27152323)
> which you know a priori and therefore have no need to go spelunking.

Except when you're working on a codebase that's new to you, and you're trying to navigate it to make a change somewhere, so you don't have a priori knowledge about what implements which interface.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Friday May 14, 2021 @05:02AM (#27152269)
> Sounds like they were trying to force the language to be something it's not

They're getting around the lack of features in the language. Most languages that I know of have mature DI solutions, and those are needed for writing any non-trivial app.

Also, one of said frameworks I was referring to generates mocks for your app and wraps errors so you automatically get stack traces in errors that are being passed around. Something already solved in Java and C# and practically any language with exceptions.

Re:Show HN: We wrote a book about building business applicat... by sagichmal on Friday May 14, 2021 @07:33AM (#27153105)
> Most languages that I know of have mature DI solutions, and those are needed for writing any non-trivial app.

Patently false.

> Also, one of said frameworks I was referring to generates mocks for your app and wraps errors so you automatically get stack traces in errors that are being passed around. Something already solved in Java and C# and practically any language with exceptions.

You're speaking as if generating mocks and adding stack traces to errors are... features? They're not! Generating mocks almost totally defeats the purpose of using them, and stack traces have no business being attached to errors in the general case.

Sometimes I truly don't understand the context that my peers are working in. Totally incoherent...

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Friday May 14, 2021 @11:57AM (#27155650)
> You're speaking as if generating mocks and adding stack traces to errors are... features

They're working around a weakness in the language. Stack traces in exceptions are definitely a feature. golang doesn't offer it out of the box, which is why the abomination of a framework I was telling you about had to be written. Similar things had to be done to work around the lack of generics, or the lack of composability of goroutines, or even in normal functions because of lack of composability of error handling.

> Sometimes I truly don't understand the context that my peers are working in. Totally incoherent...

Exactly what I think when I see people writing large projects in golang, and all the messes they have to go through to work around its limitations.

Re:Show HN: We wrote a book about building business applicat... by sagichmal on Friday May 14, 2021 @03:46PM (#27158913)
> They're working around a weakness in the language. Stack traces in exceptions are definitely a feature.

OK, I understand this is your position. I don't share it, nor do the authors of the language. So I guess it's not a truism.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Saturday May 15, 2021 @06:26AM (#27163989)
The language authors did not work on large systems. If their position did hold any merit, we wouldn't have seen many people try to solve the shortcomings of their language.
Re:Show HN: We wrote a book about building business applicat... by sagichmal on Monday May 17, 2021 @10:46AM (#27184031)
> The language authors did not work on large systems.

Um. Alright.

Re:Show HN: We wrote a book about building business applicat... by closeparen on Friday May 14, 2021 @12:53PM (#27156504)
Sometimes these "everyone else is wrong about everything they think is obvious and only I know the truth" takes can be interesting, but usually when accompanied by some kind of reasoning or presentation of an alternative.
Re:Show HN: We wrote a book about building business applicat... by dimitrios1 on Thursday May 13, 2021 @11:45AM (#27143413)
(a pedantic correction: Pike originally describes it as a systems language, which can include infrastructure)

Thing is none of the above is going to apply when generics land. You mentioned kubernetes which use complex, maintainable abstractions and structures with only the facilities Go provides. There isn't that much difference between writing a maintainable system, whether the primary user is the business, or other software.

Re:Show HN: We wrote a book about building business applicat... by gengstrand on Thursday May 13, 2021 @12:01PM (#27143669)
https://www.youtube.com/watch?v=rFejpH_tAHM

“Go is software for the parts that we work on which is mostly infrastructure.”

Generics is a good thing and I look forward to seeing the details in how Go will support it.

Re:Show HN: We wrote a book about building business applicat... by gher-shyu3i on Thursday May 13, 2021 @12:07PM (#27143757)
You can say the same about Java and C#. These claims about golang are all baseless as far as I'm concerned, especially since they're contradicted by reality.
Re:Show HN: We wrote a book about building business applicat... by hannofcart on Thursday May 13, 2021 @11:48AM (#27143460)
Would you be able to share an example of an abstraction you wanted to create in enterprise computing where lack of inheritance stymied you?
Re:Show HN: We wrote a book about building business applicat... by segmondy on Thursday May 13, 2021 @02:58PM (#27145900)
I was going along with the comment till they mentioned inheritance too. I hope they can share such an example.
Re:Show HN: We wrote a book about building business applicat... by gengstrand on Thursday May 13, 2021 @03:25PM (#27146242)
Like I already said, inheritance is an advanced programming language feature that is easily misused. To give a specific example out of context would just leave you open to inventing context that would yield inheritance as an improper choice.

There is plenty of advice online already about how to use inheritance properly. In general, inheritance should be used to signal taxonomy. It should not be used to DRY unless there are good extenuating reasons behind that. There are lots of frameworks that require the use of inheritance which is somewhat unfortunate. You are most probably okay until you find yourself starting to form deep inheritance hierarchies. If you do have deep taxonomies, then consider modeling that in data (e.g. widgetType or widgetParent) instead of using inheritance. The decorator pattern is also used a lot when inheritance gets out of hand.

Re:Show HN: We wrote a book about building business applicat... by sagichmal on Thursday May 13, 2021 @09:16PM (#27149514)
> inheritance is an advanced programming language feature

It really isn't.

> that is easily misused.

If a tool is misused frequently enough, it really isn't the fault of the users.

Re:Show HN: We wrote a book about building business applicat... by Thaxll on Thursday May 13, 2021 @12:19PM (#27143919)
The thing with Java is that it's harder to make code fast, in Go it's easier.
Re:Show HN: We wrote a book about building business applicat... by NovaX on Thursday May 13, 2021 @05:16PM (#27147576)
My only experience with Go was to help advise a team when porting a Java cache. They struggled with performance because Go kept fighting them. This was partially due to it having a poor concurrency library, resulting in excessive use of read/write locks whereas Java's advanced capabilities made more things lock-free. The database founder noted that Golang is slow single-threaded but makes up for it via concurrency and low latency.

To my unexperienced eyes, it seemed like a real PITA mostly because the Go authors insisted on artificial limitations externally, but bypassed them internally. I certainly have not found it hard to make Java fast and the core developers have always been open minded when I've talked to them.

Re:Show HN: We wrote a book about building business applicat... by erik_seaberg on Thursday May 13, 2021 @04:30PM (#27147016)
Sun made huge investments into HotSpot to optimize reusable object-oriented code. As I understand it, GC and interface method dispatch on heap objects are relatively slower in Go so they’re mildly discouraged.
Re:Show HN: We wrote a book about building business applicat... by winrid on Thursday May 13, 2021 @12:44PM (#27144303)
Could you provide an example or citation?