20 ms·
Twelve Years of Go
- Zababa 5y agoCongratulations on those 12 years! Generics and supply-chain security seem like a very nice focus for the next year. That's one point where JavaScript seems to be stagnating a lot, so I'm glad other people are taking it seriously.
- abdulwajid31 5y agosuperb
- princevegeta89 5y agoWould you say Go is suitable for web services and apps? I was trying to compare it with a rapid development framework like Rails but felt Go Web Frameworks aren't as mature and ready like Rails. Any insight would be appreciated, thanks!
- pphysch 5y agoDefinitely suitable. Depends if you want to work within a framework or not. If you want a framework, use Rails/Django/Node as they are very mature. Huge plugin ecosystems, great for prototyping non-trivial features like authn, because a plugin certainly exists for it. If you want more control (fewer dependencies), roll everything yourself with Go. The built-in libraries are fantastic, you can spin up a CRUD app without any external libraries. There are also great third-party libraries, but I would stay away from framework-y stuff like GORM.
- princevegeta89 5y agoThanks. How about a framework which has all these things stitched together already? For example, a good templating engine and an ORM that supports DB migrations out of the box? Do we have one for Go?
- pphysch 5y agoGORM (https://gorm.io/index.html https://gorm.io/index.html) has auto migrations. But it is still a framework, which means it is making a lot of decisions for you and forcing you to learn its own way of doing things. Ultimately it is a relatively thin layer over builtin Go libraries like `html/template`, `net/http`, `database/sql`; generally speaking, the Go philosophy is to build systems yourself from these components and therefore keep the architecture simple, focused, and maintainable. Unless you are stuck with Go for a good reason, if you want a framework use one of the industry standard ones mentioned previously.
- petepete 5y agoI'd say that's not where its strength lies, but it's certainly possible. Building an API backend for a single page app though, absolutely.
- handrous 5y agoAFAIK nothing has the plug-n-play library availability of Rails, as far as things that are highly relevant to stitching together "web apps". Not even Django, which may be its closest competitor. That single aspect of it is so good that even though I hate Rails (but I think Ruby's alright—go figure) it's hard to recommend against it for some projects.
- nkozyra 5y agoTrue, but that's comparing a (light) framework to a language itself. Go is great for web services, it's the first thing I reach for.
- grey-area 5y agoYes. I've used Rails extensively before writing some larger sites in Go. Quick comparison of Go vs Rails: Pros: More performance, multi-threaded extremely capable web server built-in, culture of simplicity and low-dependencies, no breaking changes, goroutines, ideal for small services, static binaries (all deps included) so no need for rbenv, docker etc etc, no included JS, great stdlib (far better than Ruby's IMO), NO INHERITANCE. Cons: No standard structure others are familiar with, you'll need to find/write code for things like migrations, auth, rendering views, skeleton code generation. For things you need to find/write this may seem intimidating but it's an opportunity to explore the bits you liked about rails and jettison the bits you didn't like or need, and the stdlib includes a lot of what you need at a low level (e.g. html templating, crypto libs). I cannot emphasise the importance of no breaking changes, it's so refreshing compared to other language ecosystems like Ruby or JS. Overall I'm really happy with Go for web apps and would choose it again in a heartbeat, particularly over Ruby and Rails (which I also like, but has performance issues and cultural issues IMO).
- copperx 5y agoIs there a canonical ORM to use in Go, or would raw SQL be preferred?
- korginator 5y agoThere are ORMs available for Golang, but my experience has been better with packages like sqlx [1] or dat [2]. We've since been using SQLX for pretty much all DBMS related work, and regret nothing. In my experience SQLX gave us the right balance between abstraction and control. [1] http://jmoiron.github.io/sqlx/ http://jmoiron.github.io/sqlx/ [2] https://github.com/mgutz/dat https://github.com/mgutz/dat
- grey-area 5y agoNot really no, the lack of generics has hampered this as you can't easily return slices of arbitrary objects from an ORM so existing ORMs are pretty ugly. One way round this at present is code generation. From your comment I think you're talking about a query builder/executor though, which is a specific part of an ORM, they're pretty simple to build if that is your thing or there are a few examples of that out there. You're really just building up an sql string, storing params, adding a few helpers for things like joins and then executing. I personally use a query generator to generate consistent queries, and generated code per resource to create models from results.
- machiaweliczny 5y agoI suggest going Rails/Next.js/Django and then extracting Go microservices if you ever need it.
- princevegeta89 5y agoThis seems to be a really valid point
- dhagz 5y agoI only use Go for two things: CLIs and web services. There are a lot of frameworks out there to help you develop web services in Go, but what really impresses me is that you don't really need them - you can get surprisingly far just using the standard library.
- lawn 5y agoYou should also consider Elixir with Phoenix, as it's a comparable experience with Rails (although not as many libraries) while giving you much better performance. And Phoenix LiveView is just an incredible productivity boost, there's nothing quite like it.
- princevegeta89 5y agoHave been working a lot with Elixir lately. It's just that I wanted to see where Go stands
- behnamoh 5y agoYou mean, it all started twelve years a-go :)
- crecker 5y ago-.-
- Shadonototra 5y agoKeeping things simple, fast while maintaining super high iteration time is the way to go for success A lot to learn from this success story
- geodel 5y agoPlenty of great initiatives listed here. Integrated Supply chain security tooling is going to be increasingly important. For Java we use third party tools to identify vulnerabilities in libraries.
- zabil 5y agoCongrats for turning 12! Starting using golang 6 years ago and it's been so easy maintaining our projects and upgrading to the latest versions. Cheers to the team.
- jstx1 5y agoI’ve only picked up Go recently and I must say that the beginner experience is superb. Way easier to get started, learn new concepts and put them in use compared to some other languages.
- 0x008 5y agocan you recommend any video lectures?
- squegles 5y agoI suggest running through each example at https://gobyexample.com https://gobyexample.com This personally helped me build a good foundation on Golang.
- JimiofEden 5y agoSo it's not a video lecture on Go specifically, but I first started learning itbecause I saw how it looked and how fast it ran while watching a Dynamic Programming series that happened to use Go for its implementations. https://www.youtube.com/watch?v=jTjRGe0wRvI&list=PLVrpF4r7WIhTT1hJqZmjP10nxsmrbRvlf https://www.youtube.com/watch?v=jTjRGe0wRvI&list=PLVrpF4r7WI... From there, I started reading about it more seriously here: https://golangbot.com/learn-golang-series/ https://golangbot.com/learn-golang-series/ And I've been using it and loving it ever since. There are one or two things that trip me up (slice manipulation can sometimes get me if I'm not paying close attention to my capacity and just pointing around, rather than copying) But for the most part, it's a fairly elegant language, and amazingly fast! For me, it's also been incredibly intuitive start working on asynchronous features. The new inclusion of Generics is just icing on the cake.
- AtNightWeCode 5y ago12 years and still no proper error handling. World stars. ;) Seriously, the error handling is a big problem with Go. Not the way it works, the way it effects how people do control flow in general.
- mountainriver 5y agoIt’s never actually been a problem for me, I prefer Go errors over most languages
- AtNightWeCode 5y agoI can live with the error handling. But as I wrote. The problem is that it encourages if-programming. Something that is a problem in the Go community.
- handrous 5y agoIf it's helping keep the "'if' considered harmful" crowd away, I say keep it. There are plenty of other languages.
- mountainriver 5y agoYeah exactly, conditionals around errors are fine. Nothing like being pedantic for no reason
- mseepgood 5y agosince when is if-programming a bad thing
- skybrian 5y agoIt depends on what kind. I didn’t find maintaining codebases littered with platform-specific ifdefs all that fun. If statements used for error checking are a bit verbose but basically fine.
- quadcore 5y agoI cant believe they are moving forward with "generics". Programmers on average already tend to make things more complicated than they should be. Now every single module in the ecosystem is gonna use more abstractions, generics to fit their social environment. Its well known that abstractions are the devil. How many modules are gonna use generics when they should not? Most? Programmers are bad at programming and they are social herdy beast - they are human. Their code must follow the social norm. The consequences of that could be terrible for the language. I dont understand why they move forward with this. Go is absolutely awesome, it's a gem, adding generics is too risky. This is such a bad news for me (i didnt know). I'm trully affected.
- brokencode 5y agoGenerics are not that complicated or hard to understand, and most of the time developers don’t even need to interact with them, except to say what type of data will be used in a collection.
- ohCh6zos 5y agoProgramming is always going to be complicated as long as the domain is complex. Go as is has traded having no learning curve for having nothing to offer.
- convolvatron 5y agoI think a dumb language for dumb programs is a really valuable contribution - hardly nothing to offer. is it less suitable for hard programs than other environments - almost certainly
- ohCh6zos 5y agoThank you, that’s an excellent point.
- handrous 5y agoWhat it offers is that code you didn't write is significantly easier to read & understand than in most languages.
- nedsma 5y agoGo is great! Looking forward to another 12. Hear hear!
- jrockway 5y agoA good twelve years. Go really changed the way I think about programming. I used to be excited by programming language features instead of what problem I was actually trying to solve with programming. I'd spend hours condensing 10 lines of perfectly working code into 1 line of the most concise text possible; huffman encoded better than even gzip could imagine. And I'd feel great about it. I'd imagine people reading it and thinking "wow, there's no way I'll ever be as smart as jrockway, I should nominate him for Extreme Excellence And Awesomeness award!" Sadly, there is no such thing. Go taught me that it's just structs, for loops, and if statements, and if you want someone to be impressed, they should be impressed by what the program does for them, not what language features you used to implement it. It has also ruined other programming languages for me. "go get" doesn't print 30 lines of text telling me that a new minor version of "go get" is available, and that I should stop what I'm doing, rm -rf node_modules, upgrade it, and then resume what I'm doing. It just pauses for a bit, and then I have the library. (I also love reading about the node community's push to make installing libraries not run arbitrary code on your machine. Yeah, I've been doing that for years with Go. It's great. I can use a library and it can't print a "hire me!!!" ad at install time. What an innovation!) I also remember struggling for years with not being able to run other people's software. There was an RPM package, but not a Debian package, so I have to build it from source. ./configure; make; oh no, the c compiler I have can't compile this code. With Go, you can just emit a binary for every supported platform dump the binary somewhere, and everyone in the world can download it and run it. No installing packages, no finding the right version of Go (that doesn't exist in your Linux distribution because they never ship up to date versions of programming languages). Just software, running, forever. It's really good stuff. Go is the tool that lets me make software, and not worry about bullshit. And that's revolutionary, even 12 years later.
- leoc 5y agoIf you think there's some virtue in writing verbose and inexpressive imperative code, what does Go provide in that department that you couldn't have got from Java 1.44?
- ignoramous 5y ago
- qqumut 5y agoI prefer Rust.
- philosopher1234 5y agoImpressive. This sums up Hacker News in 3 words.
- askonomm 5y agoThen why are you commenting on a thread about Go? Just to be dick?
- steeve 5y agoUnfortunately this situation happens way too often.
- kryptonomist 5y agoTo me, the greatest advantage of Go is the build time, which is almost instant. So you get the joy of programming like in Python/Js, being able to test very quickly your code, without having to deal with stupid errors coming from type mismatch or function parameters. Plus, you get the performance of a compiled language, with a simple syntax. Sure, you get just slightly better results with C/C++/Rust, but then you deal with complicated OS level calls, memory and library deployment issues (problems fixed by Go). Yes, a few benchmarks show C#/Java almost as fast, but at the price of a highly optimized syntax not seen in any average programmer. An average guy get superb performance with Go without complications from day 1. And absent object oriented features are quickly forgotten.
- maleldil 5y ago> C/C++/Rust, but then you deal with complicated OS level calls What OS-level calls are you doing in C++/Rust that you aren't in Go? > library deployment issues (problems fixed by Go) How is Go's library tooling better than Cargo? I believe Go's is strictly worse, with its URL-based imports and how it deals with major versions.
- Thaxll 5y agoI think OP is talking about single binary with no dependencies here. As for go mod, yes it's not perfect but it's as powerful as Cargo. https://golang.org/ref/mod https://golang.org/ref/mod
- throwaway894345 5y ago> So you get the joy of programming like in Python/Js, being able to test very quickly your code Ironically the canonical Python type checker, code formatter, etc take ages to run on even small code bases.
- bobbylarrybobby 5y agoI think a lot of that is that Python doesn't launch a server that handles code analysis/formatting requests, so every time you want to do another round of things-to-do-on-save, they all have to do be done more or less from scratch (some info can be cached between runs, but if you're launching a Python process that's like 100ms right there...). I imagine if there were a Python code server that handled formatting and type checking without ever shutting down, it would be quite speedy.
- grey-area 5y agoComing from other languages, the most interesting thing about Go for me (in my limited experience of a few other languages) was all those things they left out: No inheritance - no more digging through the massive world-tree of objects to find the code that actually does things. No churn - I have not seen a Go update break my code in about 8 years of use. No complexity - I like the culture of simplicity and eschewing dependencies in favour of writing the minimum code required. No dynamic libraries - deployment is easier and apps more stable No declared interfaces - they are defined at the point of use, not declared elsewhere No header files - why C++, why? No implicit type conversion - of the kind that plagues JS (see WAT), this rarely makes it more verbose. There are of course a few gnarly corners - nils, errors, panics, struct tags are not very satisfactory IMO at the moment. There are also lots of great positive things about it – the GC, tooling, fast compiler, stdlib and docs are a great example for other languages IMO. I'll be really interested to see where they take it next, while hopefully keeping the culture that has made it so pleasant to use. Thanks to everyone working on Go from me, and here's to another 12 years of Go.
- throwaway894345 5y agoI'll add: * No DSLs for declaring dependencies or otherwise scripting the build system. * Excellent standard library * Incredible ecosystem
- grey-area 5y agoThey do have a few little DSLs, which I dislike: struct tags (optional, I prefer to avoid), magic comments which provide build directives (this seems icky to me, but avoids breaking Go1 promises I guess). https://dave.cheney.net/2018/01/08/gos-hidden-pragmas https://dave.cheney.net/2018/01/08/gos-hidden-pragmas
- throwaway894345 5y agoI don't want to be too contrarian, but I'm not aware of any library which uses struct tags to encode anything that anyone might call a DSL. At most, they're used for key-value pairs (e.g., `foo:bar`), which is pretty easy to get one's head around. I don't use build directives and ideally we wouldn't need them, but most (all?) mainstream compiled languages have them. Maybe the complaint is that they don't get their own dedicated syntax, in which case I don't see the issue beyond "in $MY_PREFERED_LANG, build directives have their own syntax, and that's how I like it!". In all cases, these issues seem positively trivial compared to "you can't parse JSON or send an HTTP request until you learn some DSL or cargo-cult someone else's build file".
- shaan7 5y agoI can attest to the fact that programming in Go taught me a lot of good engineering. I certainly find myself better trained at handling errors, for example. However, I always feel exhausted when implementing real-world systems with Go given the lack of $things (that everyone feels is a virtue). Over time I realized that a lot of people just aren't as lazy (or scared of breaking things) as I am - they find it easier to copy code dozens of times and then fixing them all in one go using their ninja refactoring skills. Just a different kind of tradeoff, at the end. So given how laborious it is to make anything more than simple programs (because of the amount of copy-paste-driven-development required), I generally avoid Go unless I'm writing a webservice. For me Go's virtues are static typing and wide variety of community packages to do things. The whole "oh not having features is a feature" thing is just an opinion for the sake of having an opinion. otoh, I damn excited to have generics support soon finally :)
- jerf 5y agoIf you are or your coworkers are constantly copying and pasting code, stop, and think a bit more. I do a lot of Go development and almost never copy and paste anything anywhere. (And even in those cases it's usually justified. I just a few minutes ago copied and pasted a big struct... but it's because the first struct was defining a JSON message, and the second struct was defining a very similar, but not quite identical, JSON message in another file. This doesn't seem like a big deal to me, because it's defining a separate external data format and while they are superficially similar they are not the same and really shouldn't share code.) Either you're not using the tools Go has to their full effect, or, possibly, you shouldn't have chosen Go. But I make that last concession not because it probably fits your case, but because it is technically true. (In particular, don't take Go for heavy math code where you need a type system that is ready for lots of mathematics.) But it's probably not applicable. You should not be copying and pasting all the time. There are several communities; I happen to hang out on the reddit /r/golang. If you've got something that you'd like to see how to refactor to not be copy and paste, consider posting a question there (ideally with a running version in the playground of whatever you're asking about). It is true that not everything can be improved, but most things can.
- 5y ago
- ianopolous 5y agoThings I love about Go: 1) ridiculously easy built-in cross-compilation 2) structs (compact memory layout and usage) 3) easily having millions of cheap threads aka go-routines 4) modern standard library for things like cryptography Things I hate about Go: 1) plugins (very painful to get working and not even cross platform - e.g. Windows) 2) duck typing make refactoring and understanding new codebases error prone 3) no ternary operators (the verbosity!) 4) missing basic collections (like set, various queues etc.) 5) lack of built-in memory use limits 6) errors and error handling (just give me a stack trace for pete's sake)
- wtf_is_up 5y agoThe thing about Go that pulled me in around 10 years ago was that I could inspect the source code of an open source Go project on GitHub and actually tell what was going on. And on top of that I could easily cross-compile and deploy binaries in a way that blew automake/CMake away. And of course the goroutines... no more pthreads. It's a real case study in opinionated language design.
- drumhead 5y agoWhats the flagship application thats written in Go? Or the application that we're most likely to have used?
- mdaniel 5y agoI'd guess some of the contenders for that crown are docker/containerd or kubernetes but (obviously) the answer will depend a lot on the "we" in that sentence 1Password is also a heavy golang user, as a more silent entry into that race
- copperx 5y agoKubernetes.
- princetman 5y agoDocker and Kubernetes comes to mind.
- FR10 5y agoGo is my go-to language when I can get away with it. (otherwise its RoR for me). The only thing I dont grok besides the aforementioned filter/map/reduce (probably coming soon) is the name itself. It is really hard to Google by itself, now I always default to "golang".