4 ms·
For an example with Go generation and using iota see stringer[0] and Rob Pike's related blog post[1] [0] https://pkg.go.dev/golang.org/x/tools/cmd/stringer htt
by leetrout 6y ago
For an example with Go generation and using iota see stringer[0] and Rob Pike's related blog post[1]
[0] https://pkg.go.dev/golang.org/x/tools/cmd/stringer https://pkg.go.dev/golang.org/x/tools/cmd/stringer
[1] https://blog.golang.org/generate https://blog.golang.org/generate
- dmitriid 6y agoGo has so many `go generate` tools to overcome its shortcomings, it's ridiculous.
- pjmlp 6y agoYeah, remember macro based generators before C++ got templates, or Eclipse EMF before Java got annotations? Although we did survive with them and delivered code into production, it doesn't mean we keep using them 20-30 years later.
- throwaway894345 6y agoThis is true, but I'll take these shortcomings over deficiencies in tooling, ecosystem, performance, learning curve, etc any day. In other words, I can ship software pretty easily with a suboptimal type system, but much less easily if I have to select for candidates with a decade of experience in a particular VM runtime or if the performant runtimes are incompatible with important parts of the ecosystem or if there is no sane package management tooling or if the ecosystem itself is lacking important high quality packages. I'm of the opinion that in-language features are overrated.
- tsimionescu 6y agoTo be fair, Go's package management is far from sane (though better than nothing, of course). The tooling is also sub-par for modern languages, especially in terms of free development environments, though go-pls is slowly improving.
- throwaway894345 6y ago> To be fair, Go's package management is far from sane (though better than nothing, of course) It's not perfect, but it's among the best. It's far better than the popular offerings for Python, C, C++, and Java. NPM was also pretty terrible last I used it (needed to regularly blow away node_modules and reinstall things, random ENOENT errors, etc) and I think the .net world almost adopted a sane project file structure before reverting back to MSBUILD but I might be wrong there. OCaml was also pretty terrible last I used it, but people swear to me that Dune has fixed everything (though those guys have been telling me for the decade that no one needs shared memory parallelism and also it's right around the corner, so maybe take that with a grain of salt). > The tooling is also sub-par for modern languages, especially in terms of free development environments, though go-pls is slowly improving. Go doesn't have great IDEs because it's always been more of a text-editor language, and few languages have editor plugins of comparable quality. It also doesn't have a great debugging story (there is Delve, but I've heard that it's not a great debugging experience). These don't really chafe me because I don't like IDEs and I'm the unpopular guy who hates debuggers. Those are the biggest "gaps". For other things though, Go is great. Testing? Built in. Benchmarking? Built in. Profiling? Built in. Cross compilation? Built in. Static linkage? It's the default. Formatting? Built in. Documentation generation? Built in. Code and documentation packaging and publishing? Built in (to git). Not only are all of these things built in, but they're standard across the ecosystem so developers can onboard with minimal learning curve.
- pjmlp 6y agoMakes sense, after all it is catching up with Mac OS, OS/2 and Windows 95 IDEs.
- throwaway894345 6y agoYeah, I imagine it's a real problem for the people who don't know their way around a shell.
- pjmlp 6y ago
- ViViDboarder 6y agoThis is cool and something about Go that I hadn’t researched much yet. It does make me wonder, however, why not just include some higher level structure for this? Or even some method built into the compiler? It feels odd to have to install a dependency like `stringer` just to build. Do I had it to my go.mod file? Also, the comment structure, while flexible, could be greatly simplified for common cases like this if there was, for instance, an enum type. I really do enjoy Go, but there are several examples of things like enums that are left out because there is some way of doing it otherwise to only the theoretical advantage of “elegance” at the cost of developer productivity.
- everybodyknows 6y agoPerhaps the Golang managers would do well to elevate stringer into their suite of supported commands: https://golang.org/cmd/ https://golang.org/cmd/