Most active commenters
  • gf000(3)

←back to thread

257 points pmig | 16 comments | | HN request time: 0.424s | source | bottom
Show context
bryancoxwell ◴[] No.43096481[source]
> But there are obviously work around solutions in the Go ecosystem. It uses the Context ctx, which we pass around functions in order to juggle data around in the application.

Man. This works. The context API allows/enables it. But I’d really recommend against passing data to functions via context. The biggest selling point of Go to me is that I can usually just look at anyone’s code and know what it’s doing, but this breaks down when data is hidden inside a context. Dependency injection is entirely possible without using the context package at all, interfaces are great for it.

replies(8): >>43096604 #>>43096796 #>>43096956 #>>43097757 #>>43098179 #>>43098205 #>>43099616 #>>43099625 #
1. throwaway2037 ◴[] No.43098179[source]

    > The biggest selling point of Go to me is that I can usually just look at anyone’s code and know what it’s doing
This is not possible in Java or C#? Both of those languages are so simple to grasp.
replies(4): >>43098215 #>>43099187 #>>43099570 #>>43100840 #
2. zdragnar ◴[] No.43098215[source]
The languages aren't, strictly speaking, so much the problem as are the massive frameworks configured via distant files with lots of DI and reflection magic involved.

Go has some large frameworks, but the community frequently suggests they aren't needed and that the standard library is enough.

replies(2): >>43098856 #>>43101802 #
3. demi56 ◴[] No.43098856[source]
So the community influences the language, not the language that influence the community that explains everything
replies(1): >>43099710 #
4. lelanthran ◴[] No.43099187[source]
> This is not possible in Java or C#? Both of those languages are so simple to grasp.

Not really, no.

Apart from the cognitive burden of knowing the test framework in use, the DI tooling in use, the Mocking framework in use, plus all the annotations that each framework may want/need, almost none of which applies to the Go projects I've seen, the languages themselves have drifted away from simplicity.

I used to program in C# but left it for a long time and only recently looked at it again. C# is approaching C++ levels of syntax indecipherability.

replies(4): >>43099933 #>>43100780 #>>43101322 #>>43101876 #
5. rapsey ◴[] No.43099570[source]
Programs written in those languages tend to have many layers of abstractions, on top of abstraction heavy frameworks.
6. rob74 ◴[] No.43099710{3}[source]
Well, it's a bit of both. Java is of course very influential, and because it uses a framework for web applications, many languages/communities started imitating that (Ruby/Rails, PHP/Laravel, JS/[Framework_of_the_day] etc.). Then Go came along with its back-to-basics approach and its standard library which is "batteries included" but definitely not a framework, and for some this is a breath of fresh air, while for others it's apparently unbearably alien and backwards...
replies(2): >>43100819 #>>43101703 #
7. zigzag312 ◴[] No.43099933[source]
> C# is approaching C++ levels of syntax indecipherability.

Can you post an example of such new syntax? In my experience C#'s syntax is getting cleaner.

8. gf000 ◴[] No.43100780[source]
C# tends to accumulate a lot of new features, but Java has a bog-standard syntax and even new features are very carefully added and easily guessable even if you haven't seen them before (e.g. switch expressions vs statements).

There is absolutely nothing more readable in Go than in Java, it's just classis familiarity (referencing the simple vs easy talk), I would even wager that too little expressivity will actively hinder code understanding.

(It's much easier to understand the intent of a complex stream API "pipe" than 4 nested for loops with ifs, with a bunch of dumb if errs pretending to be error handling).

Also, you are comparing a complex framework that solves 70% of your problem domain (at the price of a bit of a learning curve) with a vanilla Go project that only calls libraries. The exact same is more than possible with Java, it just doesn't make much sense in case of CRUD apps because better ways exist.

9. gf000 ◴[] No.43100819{4}[source]
I'm fairly sure that most of these frameworks are not direct imitations of what Java did, and there was a back-and-fort co-evolution where standard CRUD web applications can be written in a very very productive way (for the small price of learning a framework).

Sure, reinventing the wheel is fun, but if I can finish a whole project while the equivalent go code can finally return "Hello world", then I'm not sure it's a worthwhile tradeoff. Java is not anemic when it comes to its standard library, people moved to frameworks because a good deal of CRUD apps have to solve some of the same problems. Don't forget, the only silver bullet is reusing existing code.

10. nprateem ◴[] No.43100840[source]
Try understanding what spring boot is doing. Annotation soup. It's practically impossible for a beginner to Spring to debug.
replies(2): >>43101149 #>>43101788 #
11. gf000 ◴[] No.43101149[source]
I mean, would you be able to pilot an airplane at first try? Does it mean that it is badly designed?

Frameworks reverse who calls who, it is your code that will be called at certain points, not the other way around. Obviously, one has to learn a bit about the framework before touching one, blindly copy-pasting from stackoverflow/chatgpt is not software develolment.

12. CharlieDigital ◴[] No.43101322[source]
Kinda disagree on C#

It's actually converging with JS and TS

Small repo: https://github.com/CharlieDigital/js-ts-csharp

Edit: but I don't want to dismiss either because C# does cover a large gamut of use cases (desktop, 3D/gaming, COM interop, etc.) and it is true that in some use cases, you may see a wider range of keyword soup compared to just building web APIs (where I think it really shines; this is a .NET web API in 4 lines: https://imgur.com/a/simple-net-api-with-route-param-validati...).

13. demi56 ◴[] No.43101703{4}[source]
I would say the leaders(could be the creators) of the language plays the most important role in its infancy the decisions they make defines what decisions the community are gonna make and the was what Go made right, Java been a business oriented decisions made by the community will also be business oriented
14. mattgreenrocks ◴[] No.43101788[source]
IntelliJ seems able to locate all potential implementations at injection points just fine.
15. Cthulhu_ ◴[] No.43101802[source]
Exactly; if you ask about for example a test assertion or mocking library like in Java, you get told to not use it. These libraries often add a DSL of sorts, meaning you have to relearn them.

Granted, Go's testing library / setup is also a bit of a jump from regular Go code (especially things like table tests). But the assertions are just `if`s.

16. spicyusername ◴[] No.43101876[source]
Gotta disagree for C#.

It definitely has more language features than Go, but by no means is indecipherable.

I find C# syntax to be quite crisp.