5 ms·
The biggest difference I see: the author immediately reached for a framework instead of checking out the standard library. In Node, the standard library is eff
by marcus_holmes 9y ago
The biggest difference I see: the author immediately reached for a framework instead of checking out the standard library.
In Node, the standard library is effectively non-existent, so Node devs get trained and acclimatised to dependencies.
In Golang, dependencies are minimised. Everyone tries to stick to the standard library as much as possible. Because the standard library is so good, for most projects this is perfectly reasonable.
I'd say the first thing every Node dev should know when learning Go is that they don't need a dependency manager. If you can't do it with the standard library then you're probably doing it wrong (at least until you've got some experience with the library).
- paulddraper 9y ago> they don't need a dependency manager. For not needing a dependency manager, Go sure has developed an amazing number of them! https://github.com/golang/go/wiki/PackageManagementTools https://github.com/golang/go/wiki/PackageManagementTools https://github.com/avelino/awesome-go/blob/master/README.md#package-management https://github.com/avelino/awesome-go/blob/master/README.md#... In fact, Go probably has the most package managers of any language I've ever seen.
- gerred 9y agoPerhaps everyone coming from other languages who can't imagine a world with a good standard library!
- seabrookmx 9y agoGood is _really_ subjective. While its definitely better than JS/Node it has some warts. For example, I find the "time" builtin package to be pretty terrible. Specifically how it does formatting[0]. This method makes the format look like a magic string rather than being an obvious template like other languages would use. I've found some legitimate bugs[1] in simple functions that don't give me a ton of confidence in it either. Personally I find the standard libraries in the likes of Python and .NET Core much more comprehensive, intuitive, and reliable. [0]: https://golang.org/pkg/time/#Time.Format https://golang.org/pkg/time/#Time.Format [1]: https://github.com/golang/go/issues/15852 https://github.com/golang/go/issues/15852
- yur83838 9y agoI often see time.Parse as a common complaint - but my code is much more readable when I can see what the date format looks like, rather than trying to interpret the cryptic syntax which differs from language to language. It's sure not perfect, and it's impossible to please everyone but I think it was worth the experiment.
- krinchan 9y agoWell that explains the fucked up nonsense of the time format function used in Packer Templates.
- autarch 9y agoI wouldn't exactly call Go's standard library _good_. It's got a lot of stuff in it, which is nice, but the API design ranges from excellent (net/http) to "how much crack?!" (time.Format and .Parse) to not-quite-sufficient (various packages). And of course, standard library APIs age with time. Perl and Python are good examples. Both ship with packages that were really good in their day, but have long since been superceded by community-created tools. But the core has to keep shipping the old thing for backwards compat and the maintainers are reluctant to add yet another package that does the same thing. Dependencies have their downsides, but being able to assemble the best of what's out there rather than relying on the best of what was available at some point in the past has a lot of advantages too. Languages with good dependency management seem like the best possible option. Go's refusal to embrace this is a huge pain point. Dep is a decent start, but without a community actually doing things like releases, changelogs, and all the other things that go into a solid ecosystem, it's a half measure at best.
- yur83838 9y ago> Go's refusal to embrace this is a huge pain point. Dep is a decent start, but without a community actually doing things like releases, changelogs, and all the other things that go into a solid ecosystem, it's a half measure at best. Go has indeed embraced it and is working on `dep` the officially sanctioned dependency manager. It's under the official golang github repository.
- autarch 9y agoYes, I know. But that doesn't help at all with the lack of releases, changelogs, etc. As I said, it's a decent start.
- ta2384428 9y agohttps://github.com/golang/dep/releases https://github.com/golang/dep/releases https://github.com/golang/dep/graphs/commit-activity https://github.com/golang/dep/graphs/commit-activity Agreed that it's a decent start, however I disagree with the lack of releases. If you look at the git history there is a lot of activity in it.
- pjmlp 9y agoGo's standard library is pretty thin compared with Java and .NET, both with quite good dependency management tools.
- outside1234 9y agoWhich is a good thing, because Go's dependency management is terrible!
- mlevental 9y ago>In Golang, dependencies are minimised. Everyone tries to stick to the standard library as much as possible. i don't understand this. yes net/http is nice but there's no router, there's no orm (yes i know that's not really possible at all because of strong typing), yes database/sql exists but you know most everyone uses at least sqlx and e.g. lib/pq. yes html/template is nice but we're all doing SPAs now anyway. okay there's logging but e.g. no websockets. so in what sense is the stl really complete? what modern web app could you write with just the stl?
- marcus_holmes 9y agoYou don't need a router (especially for an SPA with client-side routing). If you've got less than 20 or so routes, then a big switch statement is all the routing you need. Learning to write "proper" logic around routes instead of parsing them with regexes was a learning milestone for me. You don't need an ORM. Mapping database tables to objects directly is a really bad idea. Write SQL, it's easy, simple and cheap. Yes, you'll repeat yourself. Golang generally prefers some repetition to some dependency. You don't need middleware. Once you get used to handling routes as logic, then the need for middleware kinda vanishes. You can use the semi-official google websockets package [0]. It's borderline whether this could be considered part of the standard library or not (I use the google uuid package all the time for the same reason). I believe there's an intention to include these packages in the standard library at some point, probably Go v2. Try it out, it's liberating. 0: https://godoc.org/golang.org/x/net/websocket https://godoc.org/golang.org/x/net/websocket
- akmittal 9y agoI see Go community pushing for no framework everywhere. I agree Go std library is good enough but some people prefer the framework magic because they want the stuff done faster. Community should better be saying try std library if you find it verbose try framework(router+ORM)
- dithering 9y ago> some people prefer the framework magic because they want the stuff done faster. Those people should try being maintenance programmers sometime /curmudgeonly-grumble
- masklinn 9y ago> In Node, the standard library is effectively non-existent, so Node devs get trained and acclimatised to dependencies. Have you ever actually taken a look at it? https://nodejs.org/api/index.html https://nodejs.org/api/index.html > In Golang, dependencies are minimised. Everyone tries to stick to the standard library as much as possible. Because the standard library is so good, for most projects this is perfectly reasonable. Meh. The Python stdlib has been considered "good" for a long time[0], but the last few years people commonly reach out for external dependencies. It's not because the stdlib has gotten less good (the opposite), it's because the experience of publishing and using external dependencies has significantly improved. > I'd say the first thing every Node dev should know when learning Go is that they don't need a dependency manager. They do, they just don't have one. Which is why people tend not to bring in external dependencies: bringing in external dependencies in Go is a traumatic experience, much as it used to be in Python a few years back. [0] in fact this exact same argument was relatively common in the mid-to-late aughts, Java developers dipping their toes into Python would complain about the state of dependency management and get told that the stdlib is so good you don't need dependency management, the stdlib is almost all you need and there's no need for advanced dependency management for just one or two dependencies…
- oneweekwonder 9y ago> much as it used to be in Python a few years back. few years back being pre-2011, with pep 405[0] and virtualenv[1] solving most of the nostalgic py dep hell problems. venv's been a option since 2007, only getting pep'ed later? [0] https://www.python.org/dev/peps/pep-0405/ https://www.python.org/dev/peps/pep-0405/ [1] https://virtualenv.pypa.io/en/stable/changes/#id54 https://virtualenv.pypa.io/en/stable/changes/#id54
- masklinn 9y agovirtualenv solved conflicting dependencies but pip is what made installing & managing them convenient. I see many people who use pip without virtualenvs.
- 9y ago