←back to thread

175 points nateb2022 | 7 comments | | HN request time: 1.509s | source | bottom
Show context
Xeoncross ◴[] No.41521050[source]
> Zero dependencies

This is something seldom attempted, but I congratulate you. Go is one of a few languages that really is batteries-included. Just about anything you could need is included in the stdlib.

replies(4): >>41521157 #>>41521657 #>>41521695 #>>41521859 #
pjmlp ◴[] No.41521695[source]
Still doesn't have half of batteries that Python, Java and .NET include.
replies(4): >>41521882 #>>41521931 #>>41522719 #>>41531371 #
philosopher1234 ◴[] No.41521882[source]
No doubt that is true, but are there particular batteries you’re thinking of?
replies(1): >>41522679 #
pjmlp ◴[] No.41522679[source]
GUI, dependency injection, huge collection libraries, dynamic runtime Interoperability, distributed objects, compiler plugins, custom runtime schedulers,... for example.

Some of the above will never be in Go due to how the community and language designers are philosophically against them.

replies(1): >>41523824 #
1. limit499karma ◴[] No.41523824[source]
> dependency injection

It's been a while since I played with the furry thing but is that even possible in Golang?

replies(1): >>41524462 #
2. pjmlp ◴[] No.41524462[source]
I was speaking about Python, Java and .NET standard libraries.

In Go you can naturally do it, by using the manual constructor approach, however there is no magic auto wiring like you can do with attributes and compiler plugins, plus standard libraries infrastructure for locating services, from those three ecosystems above.

replies(1): >>41525199 #
3. limit499karma ◴[] No.41525199[source]
Well, in my head DI at this point requires the magic bits. Otherwise it is (as you say) just constructor args.
replies(1): >>41528758 #
4. pjmlp ◴[] No.41528758{3}[source]
Except that there are many ways to do DI, magic is not necessarly required, other than much welcomed development experience.

However Go doesn't like magic, thus that isn't something that will ever happen on the standard library, like on Python, Java, .NET.

replies(1): >>41529749 #
5. limit499karma ◴[] No.41529749{4}[source]
I guess we have to disagree here. The key word here is "injection". Dependency initialization, setting, passing, etc. none of these are 'injection'. But yes, Go lacks the necessary metadata mechanisms and per what you are saying it still does.
replies(1): >>41530896 #
6. pjmlp ◴[] No.41530896{5}[source]
Injection doesn't mean automatic, or magic.

And if one goes back 20 years, constructor based injection was the norm, the magic only came later thanks to Aspect Oriented Programming, yet another tool that Go will never adopt.

replies(1): >>41531612 #
7. limit499karma ◴[] No.41531612{6}[source]
Sure, but I don't recall it being called "injection". Obviously we are in agreement that dependency references are introduced via some mechanism. Also AOP came [after] Java J2EE and Spring. However I will concede that there is a distinction between 'inversion of control' and general DI.