6 ms·
After years of working with web frameworks in Python and Java, and then picking up Go along the way, I've come to appreciate Go's approach much more. That is, w
by imiric 2y ago
After years of working with web frameworks in Python and Java, and then picking up Go along the way, I've come to appreciate Go's approach much more. That is, with a rich and capable standard library, you really don't need traditional frameworks. Need an HTTP server, router, etc.? Use stdlib. Need templates? Use stdlib. Need an ORM? You don't, but you may want to consider a small 3rd party query builder library of your choice. And so on.
This avoids depending on a complex framework that may or may not exist in a few years, improves security by minimizing the amount of 3rd party dependencies, keeps the learning curve low for any new developers joining the project, and is more flexible and easier to maintain. I don't have experience with Rust, and judging by the comments here, web frameworks might still be useful for it. Which is a shame, since the batteries included stdlib approach is far superior IME.
Anyway, I don't want to shoot down your efforts. Congrats on the launch and good luck!
- qudat 2y agoAgreed on all fronts. Go has nailed the stdlib and every other language is in its shadow
- t-writescode 2y agoThis is a major component of what drew me to love C# so much for a while. It's also one of those Perfect StdLib(tm) languages. Many of the components do need to be downloaded through nuget; but they are a part of the stdlib!
- celdon25 2y agoWould it be a fair comparison? C# didn't have good support for JSON in the standard libraries for almost 20 years[1]. ADO.NET seemed like a failure to me as well, but maybe I just didn't understand it. The System.Drawing namespace at least as of .NET Framework 4.5 required virtually all of its operations to be done through a System.Drawing.Bitmap, which meant that no matter how your image data was represented, it needed to get rasterized. This wasn't a big deal for most desktop/local use cases, but it's very inefficient, so if you had any servers relying on this, and had a reasonably decent amount of traffic to those servers, you could be getting CPU usages way too high. As an example, I remember one time we were hosting 30 kb TIFF images (high res, 1 bit per pixel) for download, and generating the thumbnails was done in real time, which caused literally gigabytes in memory churn per request due to the rasterizations... IIRC I fixed it by using emscripten (this was 2015-2016) to do resizing and rendering in the frontend with a small C module using LibTIFF, then the server only needed to send the 30 kb files as is. Unfortunately I've had a hard time finding people to work with these days that give me that kind of room to execute. Does Go's standard library have these rough edges or is it actually pain-free? I'm on the fence about whether I should learn Go or Rust while I am on a short employment break. 1. https://github.com/dotnet/runtime/issues/27761 https://github.com/dotnet/runtime/issues/27761
- t-writescode 2y agoI think every kitchen sink standard library has some rough edges. Java is also a kitchen sink language and it, too, has rough edges around certain areas. I don't know Go well enough to have an opinion on where its weaknesses are. As for this question, > I'm on the fence about whether I should learn Go or Rust while I am on a short employment break. What are you learning the new language for? If for fun, then this question is longer. If for employment, I would bet that there are more devops, devops adjacent and "systems developer" roles in the Go language.
- egeozcan 2y agoDeclaring a stdlib free of rough edges would be like declaring a complex piece of software bug-free.
- metadaemon 2y agoNot needing an ORM made me laugh
- sunrunner 2y agoWhy is that?
- stickfigure 2y agoYour programming language has objects. Your database has relational tables. By definition, you need to map between the two. You can write your own or you can use someone else's. Those are the two choices.
- BlarfMcFlarf 2y agoYou can map objects to db updates, and map query results to objects. Neither of those objects needs to have a mapping to actual relations, like how ORMs insist on.
- threeseed 2y agoOnly for basic objects. The minute you add relationships your approach becomes unusable. There is a reason ORMs have persisted for over 30 years.
- wtetzner 2y agoNo it doesn't. Why would relationships matter? You handle the relationships in SQL queries, and just copy query results to structs.
- stickfigure 2y ago> copy query results to structs Congratulations, you've invented an ORM.
- victorbjorklund 2y agohonestly sucks trying to build a large web app with just the go stdlib. The stdlib is amazing but it is not all you need for a good dx experience.
- int_19h 2y agoA rich stdlib establishes patterns and provides standard types for other libraries and frameworks, making the whole thing generally more consistent as opposed to something like the Node.js ecosystem, which looks and feels more like a bunch of random parts crudely fitted together through copious use of duck tape and glue.
- klabb3 2y agoConcretely, Go has eg context.Context, net.Conn, http.Handler and of course io.Writer/Reader/Closer. All 3p libs will use the standard types. This means you can compose many 3p building blocks together, without any prior knowledge or coordination on their end. When you have an insufficient stdlib, you often get compatibility issues, where things don’t compose. So you get these kind of pseudo-std mega frameworks like Tokio instead. It was a while ago I was deep in JS but I remember similar things there.
- dvektor 2y agoReally? What do you feel that it's missing? I write Go for a living but I have also used Laravel (and vanilla php back in the day),and both actix + axum and I think Go really does hit that sweet spot of abstraction level for backends/web services. I will say that I do prefer Gorm only to be used to scan the table -> model, I'd still rather write the sql by hand but I also don't want to scan the rows every time. But other than that I really cannot think of what it's missing.
- wild_egg 2y agoHave you given sqlx a try? Manual query writing like database/SQL but convenience wrapper functions that handle the row scanning part for you. I haven't felt the need to use anything else for years now.
- zarzavat 2y agoRemember the PHP 4 era. The average developer is incapable of implementing everything from scratch securely. Django and similar big frameworks perform a vital public service, by providing sensible defaults to people who need them. I do agree that personally I don't like using big frameworks. My personal favourite is the express architecture: a thin substrate that allows for middleware plugins to be installed and not much else beyond that.
- bilekas 2y ago> I've come to appreciate Go's approach much more I've also come to really appreciate a good standard library. I used to POC things in node because it's so simple, but the dependency tree is hard to justify. I do like Rust's stdlib too, but its a different tool for a different project. My issue with Rust is the refactor cost when it needs to change.
- mixmastamyk 2y agoInteresting that Python has actively said no to recent web-based modules in the stdlib. Because that stuff moves too fast, and putting in the stdlib would hold it back. The most famous is requests, but I've heard the argument elsewhere. Not sure who to believe. :-D
- littlestymaar 2y agoI've not done a lot of Go, but a former employer used it for all the back-end stuff, and they weren't using the standard modules for web stuff either (and it was at a time who didn't have a proper dependency management tooling so it was very tedious compares to modern languages).
- bilekas 2y ago> a former employer used it for all the back-end stuff, and they weren't using the standard modules for web stuff either This might have been a long time ago but I can't think of much that you cant do. I've seen this behavior though on some project, but it was usually not about the stdlib's deficiencies but more so the developers lack of understanding what they're supposed to do and so revert to another lib.
- littlestymaar 2y agoIt's never about stdlib “deficiency”, it's just that there are alternative ways of doing things in third party libraries and sometimes these alternatives are better than the original implementation which cannot evolve since it's in the standard library.
- Eduard 2y agowhich Java version is the one you used last?
- threeseed 2y agoI develop in Go every day and it's by far the worst language I've ever used. Having to explicitly handle every type of error immediately without any support for deferring, encapsulating, chaining, manipulating, transforming etc is antiquated and tiresome. Rust has Option and Result types and all of the niceties along with it.
- pluto_modadic 2y agohear me out. golang quality stdlib, with Option & Result types from haskell or rust.
- threeseed 2y agoSounds like Scala Native: https://scala-native.org/en/stable https://scala-native.org/en/stable
- hackerbrother 2y agoThe dream. Someone posted this, which is designed along these lines, here not long ago. https://github.com/borgo-lang/borgo https://github.com/borgo-lang/borgo
- shepherdjerred 2y agoNative Option/Result types + algebraic data types would solve quite a few complaints I have about Go
- egeozcan 2y agoIt would solve many of my complaints as well. But, to be honest to myself, I don't think anything will be too different in my day-to-day programming, nor that I would produce better code with less bugs.
- shepherdjerred 2y agoAdts eliminate certain kinds of bugs like nil pointer dereferencing, and, if you model your types correctly, makes invalid states unrepresentable
- giancarlostoro 2y agoEvery time this subject comes up for any language I praise Go for making it very straightforward to start a web server.
- okasaki 2y agoDo you also praise Python for having http.server?
- giancarlostoro 2y agoActually, I do for a different reason. I can go into any directory and type python -m http.server and now I have an improtu web server for a folder, so I can download files over my LAN.
- solatic 2y agoI've come to the conclusion that Professionally Pretty Products should use the JS ecosystem and Internal Web Dashboards should use Go. When your company is employing dedicated professionals for Product and UX, trying to sync their work to server-rendered Go HTML templates is just much, much harder compared to working with them in Storybook and the like. Yeah the dependency tree explosion is basically someone's full-time job to stay on top of, but when the company is already paying for Product and UX and iteration speed is key, it's a small price to pay. But yeah, when you're building some kind of internal service with a classless CSS library that's just meant to provide some kind of dashboard to illustrate the state of your service, Go's stdlib is more than good enough and helps keep down long-term maintenance, everything will Just Keep Working. I struggle to see where Rust fits in for web frameworks. You get the dependency tree explosion, the long compile times, difficulty collaborating with Frontend/UX. The benefit is, what, better performance? Is it really worth it?
- Oras 2y agoGo for web development is like PHP for machine learning. Go is a perfect language when dealing with files or network. Once you add database layer, calling external APIs, then you face the same latency of other languages due to 3rd party integration.
- deleted 2y ago[deleted]
- xpe 2y agoThere are lots of Rust web-related libraries that are modular.
- WhereIsTheTruth 2y agoAnd Go compiles very fast, very few understand how important this is Not only it is important for fast iteration, but it also contributes to the fun, waiting for compiler to finish is not fun To me there shouldn't be any new language made without hotreload and incremental compilation It's 2024, with the HW we have, we shouldn't have to wait more than 1 second to compile code Fun fact, my game written in D (30k LOC), fully recompiles in 0.4 seconds (Intel i3 10400f), if i can do it, you can too