16 ms·
Yes. That's what Go is for. Go is for doing the things that Google does on servers, which mostly means web apps of one kind of another. It has all the parts for
by Animats 6y ago
Yes. That's what Go is for. Go is for doing the things that Google does on servers, which mostly means web apps of one kind of another. It has all the parts for that, and they're well-exercised because they're doing billions of operations per second on Google's own work. It's hard-compiled, so you don't have all the extra overhead of the interpreted languages. Also, Go has a better async story than most web-oriented systems. Goroutines, or "green threads", do both the job
of threads and "async". In async land, if anything blocks or uses much CPU time, you're stalled. Not so in Go. A goroutine can block without stalling other goroutines.
Right now, I'm writing a client for a virtual world in Rust. There's a big need for concurrency, but, unlike web stuff, it's all tightly interrelated. There's a GPU to keep busy. There's network traffic of several different kinds. There are compute-bound tasks which need to be kept out of the frame refresh loop.
Rust is good for this. The existing C++ client is too much of a mess to make concurrent; people looked at it and gave up. In Rust, it's coming along nicely.
Use the right tool for the job.
- nx7487 6y agoinb4 C++ brigade
- WClayFerguson 6y agoActually not to pick a fight, but that's what "Java" is for. The only reason we have too many languages is because every software developer wants to create his own, and inevitably some will gain traction, and get popular enough to further fragment the industry. Imagine how awesome the world would be right now if all those kiddies had just focused their energy on making JAVA better. Java would be 1000x better, and would be the ONLY language. But nope, everybody knows best, and so now we have a "Tower of Babel" for a software industry.
- damnyou 6y agoTo put it plainly, Java is a fundamentally broken language and its mistakes, starting from not having sum/option/result types from day 1, make it impossible to fix. edit to respond: calling them "bells and whistles" is a deep misunderstanding of what sum types are. They profoundly change how every single piece of code in the language is written, starting from how nulls are handled, and cannot be retrofitted into an existing ecosystem. (You can add them later, but baking in sum types from the start is very different. In particular Java would not have its terrible exception system if it had sum types.)
- mc10 6y agoI’m curious what your alternative is, given that Go famously also lacks sum types.
- damnyou 6y agoYes, Go is a fundamentally broken language too. As is C++, as is C. Sum types are the absolute bare minimum a language must have for me to not consider it broken beyond hope. Go in particular is really unfortunate for a language so new. The language's weaknesses have dropped my estimation of its creators by several notches.
- Guthur 6y ago"I'm broken and can not use a language without Sum Types" There, I fixed it for you.
- damnyou 6y agoYes, that's possible. I would rather tear my eyes out than use a language without sum types. The benefits of sum types in being able to model arbitrarily complex domains are extraordinarily massive. Every language has product types. Every programmer understands how useful product types are. Why in the world would the same not apply to sum types?
- AnimalMuppet 6y agoYou sound like you have a hammer, and so every problem looks like a nail. Sum types can be useful. Other aspects of languages can be useful, too. Why fixate on that one? And if you're going to say that it's a minimum bar, well, some of the other features are missing in most languages that have sum types. Pick the language that has the total set of features that makes it easiest to write whatever program you're trying to write. Don't get locked in to focusing on only one feature.
- 6y ago
- hansvm 6y agoIf that argument were valid wouldn't it apply to any language? Would Forth be 1000x better if nobody used anything else?
- WClayFerguson 6y agoI don't mean Java was perfect from day one and forevermore. I mean it was the language that was perfectly dominant and acceptable at the time, and could've been extended and kept backwards-compatible, rather than restarting new languages from scratch. JavaScript is particularly hideous, and was cobbled together over a weekend, and because of that misstep the industry got stuck with it and had to invent TypeScript to "fix it" and create something tolerable in the modern world.
- AnimalMuppet 6y ago> I mean it was the language that was perfectly dominant and acceptable at the time No. Java never was what you're claiming.
- WClayFerguson 6y agoIf you don't think Java was ever dominant (and frankly I think it still is), then probably we just disagree about the definition of the word "dominant".
- AnimalMuppet 6y agoIt was a dominant language. But you said "perfectly dominant", which I took to mean "the one dominant language". Java was not that - not overwhelmingly more popular than C++, for instance.
- WClayFerguson 6y agoJava was perfectly dominant in it's realm only. Obviously Java is not competing in the realm of machine code generation at all, and assembly language should always exist too. C/C++ is the perfect example of a language lasting multiple decades without each new generation trying to throw it all out and start from scratch, but simply evolving it.
- seangrogg 6y agoI can confirm that the seeming majority of application-layer code written at Google is Java (with Go being a relatively small contributor by way of comparison). That said, I shudder at the thought of Java being any larger than it is, much less ubiquitous. If I had to choose between this world and one where Java was the "one true language" (or even a more extreme version of the current situation where we have other languages all built atop the JVM) I would pick this world with fragmented languages every single time.
- WClayFerguson 6y agoWhatever people find unacceptable about Java could've been fixed. No need to burn it all down and start over. Remember, I'm talking about "source level" syntax of the language not any specific VM implementation. Every compiler and VM can be replaced eventually. It's the code syntax that needs to be "universal" not anything else.
- manigandham 6y agoThat's what Scala and Kotlin are, fixes for the original Java flavor. Then again, more alternatives are good for competition; and incubating and sharing new designs that aren't possible in a very old language.
- lumost 6y agobarring competition languages seem to stall out over time. Java fell out of favor because every java app turned into a pile of xml and factories that everyone hated and was slow to develop. The faster evolution of peer languages allowed for recognition of what people didn't like in Java (The ceremony of getting setup and invoking "app" logic). The better parts of Scala, kotlin, and the guava library are steadily making their way into the language. But if there wasn't competition the language would absolutely stagnate again as risk aversion sets in.
- WClayFerguson 6y agoRight, I think the languages that compile JVM bytecode were much more heading in a better direction than the ones who said "let's have fun and just start from scratch, and further fragment the industry"
- AnimalMuppet 6y agoSounds like you think you know best, too. No, Java would not be the "only" language in any set of circumstances, however fictional. No language will be, ever, because no language is better than all other languages at everything.
- acdha 6y agoMore accurately, imagine how much better the world would be right now if the Java community had been interested in dealing with the many usability and performance problems encouraging developers to move elsewhere. Imagine if all of those years of saying that it was just laziness causing people not to like Maven, massive object hierarchies, or repeating claims about JIT performance which statistically represented no application anyone actually used had instead translated into “There are a ton of basic gaps which give every new user a bad first impression. We should do something about that!”. Repeat for “Maybe it was a really bad idea re-inventing PHP-style typing with introspection so you have all of the inconvenience of static types but still commonly find type-confusion problems which editors and the compiler won't tell you about”, “Maybe it isn't reasonable to tell people that you normally need to edit multiple XML and properties files to run anything more than hello world”, or “Maybe we should burn with fire any codebase which thinks the right way to handle an error is to permanently stop working but still keep running so anything which doesn't do an end-to-end health-check won't know all of your users see the service as down”. It may sound a bit bitter but I'm saying that as someone who started using Java circa 1995, left to more productive shores, and recently came back to a new development team seeing that nothing seems to have changed in terms of the amount of time developers spend fighting the tools rather than doing their jobs. Yes, Java code can have competitive performance (Solr/ElasticSearch are world-class) but the code I see is more commonly slower than Python while using more memory and lines of code because it turns out that even heroic attempts at JIT optimization can be easily defeated by the average enterprise Java architecture.
- WClayFerguson 6y agoYou're conflating the monstrosity of J2EE (which admittedly was a mess, and completely unrelated to Java itself) with the "Java Language" by which I mean the syntax of the language itself. Yes the younger/newer generation took a look at all the XML files in J2EE and said "Isn't there something simpler", and so now today we ended up with JavaScript running on the server side (NodeJS). TypeScript came to the rescue over the last 5 years, but now we have a world with TS and Java. The solution should have been to make Java run in the Browser, and not JavaScript, but I understand the history, and how, when, why that occurred. I've been coding 30ish years myself, like you.
- sheeshkebab 6y agoDude, we’d writing in COBOL if anyone followed your logic.
- dec0dedab0de 6y agoAnd it would still be better than java. :-)
- inopinatus 6y agoTwenty years I predicted to various peers that Java would become the new COBOL, the lazy enterprise’s default choice of our time, and I’m very sorry to have been proved right.
- WClayFerguson 6y agolol. A generation of script kiddies too lazy to learn Java invented NodeJS, so they could run the toy version of Java on the server side. Then they have the audacity to claim the shoulders of giants upon which they stand should've been strong enough to comprehend JS rather than Java...even though those giants invented BOTH JS and Java before you were even born. Here's a newsflash for you: if the Netscape inventors of JavaScript had been capable of making Java run in the browser then all you kids would be running Java instead of JS today. The only reason JS exists at all is because early browsers had limited memory and CPU back in 1990s, so they cobbled something together over a weekend and named it JavaScript. Now that JS is running server side, these kids claim that's the way it should've been from the beginning. No, sorry JS is a train wreck compared to Java, which is why MSFT had to come to the rescue with TypeScript.
- inopinatus 6y agoOh, it’s you again.
- WClayFerguson 6y agoYep. "Java is the new COBOL" was simply irresistible. If you want to troll a Java developer, that was absolute perfection.
- necovek 6y agoMy dislike for Java aside, you fail to realise there have been hundreds of programming languages created before Java too. The same would be true if all the car companies in the world just cooperated on a single car model to rule them all, right?
- WClayFerguson 6y agoOh, you think I'm just pushing for Java. I'm not. I'm saying having one language is better than 100. People can't share code very well if there's so many languages. Languages themselves don't need to be completely reinvented like things in the real world (cars, etc). For example C/C++ has been around for decades and no one ever said "Burn it all down and start over."
- rottc0dd 6y agoI am a noob and I am happy to be corrected. Every language is designed with a specific design decisions and tradeoffs intended for hopefully wide audience. I think C and unix culture reflects this in some way. It is home grown environment by handful engineers working initially their own sake. You cannot objectively say, "Everything as file" is good concept, but if you are just handful of people tackling myriad of problems, it should have been liberating to have a too simple of an abstraction. It might be pile of hacks on pile of hacks but, it worked for the time. Whether it is good or bad, depends on what you want to achieve. I think more communities can benefit from more focus on what they are and how they want to do things than trying to be "be all, do all" thing. I might not want to solve problems the way somebody else would solve the problem and I would use a tool to best fits my way of thinking. Even if there is only one language, fragmentation is inevitable. Because, all people might not have the same way of working or thinking. Even if it is written in same language, one might not understand idioms of somebody else. It is easier to read a language with community adopted idioms, than a language that is made for all people. I have been using Java, but the erlang concurrency primitives looks great. But, it would be hell, if single code base has all possible primitives and style. Asking people to have one language to work is not different from asking people to think in one single way. Edit: added couple more rants.
- inopinatus 6y agoThere was never, and shall never be, a particular reason to anoint Java - or any other development environment - as some kind of universal panacea “one true language”, and demanding everyone’s attention for your own pet preference is beyond hubris and into the realms of absurdity. > All those kiddies You chose the wrong venue for this remark.
- WClayFerguson 6y agoLol. I'm well aware many users on HackerNews are very young and very left-wing, and they take offense at the drop of a hat, while sitting in safe spaces petting kittens. It's ok. I don't mind.
- inopinatus 6y agoPerhaps you have this forum confused with Reddit. By my estimation, everyone here is over forty, either in body or in soul, and by way of particularly cringeworthy example the correspondent you most unfortunately chose to rag on was already a computer scientist of international note twenty-five years ago. Many, if not most, of the designers of the new programming languages and paradigms under discussion are of similar breadth and depth of experience. There is no monopoly on the grumpy old fart act; there is only a difference in their willingness to continue pushing back the boundaries of ignorance. All of which is notwithstanding the necessary and essential vigour of youthful perspectives, c.f. Seymour Cray’s notable preference for working with recently graduated engineers both for their energy and their fresh ideas.
- WClayFerguson 6y agoDefinitely Reddit is much further left-wing than HackerNews. No doubt. And you're right there are quite a lot of older, respectable, experienced devs on here too, which is a demographic I'm fairly certain doesn't include yourself.
- inopinatus 6y agoI am sufficiently ancient to not require any external validation, and yet here you are.
- likortera 6y agoGo is to backend what React is to Frontend and what Kubernetes is to infra. Everyone wants to have fun. And when things get complicated enough just switch jobs.
- damnyou 6y agoLike Java, Go is a fundamentally broken language and its mistakes, starting from not having sum/option/result types from day 1, make it impossible to fix. edit to respond: as the commenter below pointed out, dynamic languages can express sum types just fine (though statically verifying e.g. null checks isn't possible without some sort of gradual typing effort). This is why they are superior to traditional statically typed languages like Java. But even better are languages which have static sum types.
- AlotOfReading 6y agoYes, person on a lisp-powered hackers forum, tell us more about how languages lacking native sum types are unusable.
- Ericson2314 6y agoWith untyped languages, essentially everything is a (shitty) sum type because of runtime tagging. Tags <-> sum type.
- zeeboo 6y agoYou can do dynamic tagged values in Go, too. It's called interface{} and everyone hates it. So this does not respond to the parent's point.
- Ericson2314 6y agoI'm not arguing untyped is good: it's most certainly not. Everything nullable is also bad, and also introduces a limited some type (Maybe). What I am saying is if you have static types (good) but don't do anything else, you loose sums (bad). You then need to add (back) sums.
- kazinator 6y agoPlease don't spread this flamewar-provoking way of speaking about type-systems. Firstly, dynamic languages are typed. The word "untyped" has a very specific meaning in a narrow branch of computer science, as in "untyped calculus", which refers to a situation in which the types of the syntax tree nodes of the program are not being taken into consideration. (Which doesn't mean they don't exist, by the way!) In sofware engineering, an untyped language is something utterly unsafe, like assembly language or BCPL, where every value is just a machine word, and the meaning/type of a machine word is just that of whatever operation is being applied to it at a given spot in the program. Dynamic languages are typed, and even to the extent that some of them do assign type to the nodes of program (type inference). Secondly, a "tag" is an implementation concept. A tag typically does not give all of the type information about an object, or not about every object kind. There may be more than one kind of tag used. For instance, a value might have a two-bit tag indicating a crude classification of a value into four categories. For an unboxed fixnum integer, that indicates the exact type (fixnum), but most heap objects might be lumped into the same category accordint to that tag, distinguished by a more comprehensive type tag that might take on, say, one of twenty values. That tag is also not complete information for all objects. For instance for an OOP object, the tag might indicate "this is an OOP object", without regard for its class: all OOP objects might share the same tag. Yet, at the language level, their type is their class. Another example is functions. All functions might have a tag indicating "this is a function". There might be a separate tag for things like compiled function, interpreted function, foreign function or whatever. But the type of a function takes into account not just that it's a function, but other properties like number of arguments. In many dynamic languages, you cannot call a two arguments function with three arguments. That check doesn't come from the tag, which doesn't have that information. The type of an object in a dynamic setting goes beyond the tag. For some objects, the word tag tells everything, and the heap tag does for others; but not for all object kinds. When the dynamic language implements a type inference system, the truths which that inference system works with cannot simply be reasoning about tags. The representation of type has to include concepts like the class of an object, or the number of arguments and types of a function and its return type.
- wyager 6y agoI think the closest thing to "Rust plus green threads" isn't Go, but Haskell. If you try to switch from Rust to Go, you're going to find yourself missing the type system, ADTs, traits, etc. I wrote this back in 2014 comparing (early) Rust, Go, and Haskell, but I think it's still more or less accurate. https://yager.io/programming/go.html https://yager.io/programming/go.html
- Ericson2314 6y agoYup! That's why Haskell is still the best language for business logic. Rust is for programmers at large companies trying to avoid the business (logic). I'm quite sympathetic, I would be doing that too at one of those. But when I need to program something a non-programmer actually cares about, Haskell is the way to go.
- nemothekid 6y agoThis misses the entire point of the article. The author's pain about Rust wasn't about wanting green threads - it was about building web APIs. Haskell doesn't succeed at that either. Haskell's Morpheus also suffers from n+1. Haskell isn't nearly as supported for the author's use cases as Python or Go, and Haskell is closer to Rust in that regard.
- wyager 6y agoI'm addressing the comment I'm responding to. If I was responding to the contents of the article, and in particular the specific thing you're focusing on (GraphQL support) I would have written a different comment and posted it elsewhere in the thread.
- high_density 6y agohm I agree on the points made you made on the GoLang -- its design seem to be a regression. (to add another: look at Go's "default-value instead of Null" instead of adding actual null-safety in the type-system like kotlin/swift/scala/typescript/etc.) Anyway, this blog-post seems to rally for a better eco-system work on Rust part. Being a new language without a rich parent (like Go's "google" or C#/Typescript's "MSFT"), the situation is somewhat understandable.
- mwcampbell 6y agoI wonder if the author of the article would agree with you on that. He made a distinction between specialized services and general web applications, which reminded me of this article about why Go isn't necessarily a good fit for the latter: https://chadaustin.me/2016/04/two-kinds-of-servers/ https://chadaustin.me/2016/04/two-kinds-of-servers/
- Philip-J-Fry 6y agoGo is amazing, probably my favourite language I've ever learned. The rate of development is insane I find, you can just bang out straight forward easy to read code and everything you'd ever need to write a web API is there in the standard library. Where I work we've shipped Go APIs using just the standard library running on like 1/10 of the hardware we were using in the .NET (not core) world and handling 10,000s requests per second. Perhaps that was just because we had really old shitty .NET code though.
- spaethnl 6y agoFor a point of reference, which other languages have you learned?
- rad_gruchalski 6y agoI share the opinion of the person you are asking this question to and I can share my list of languages I delivered production systems in: Scala, Erlang, Java, Ruby, Python. In the past life C# (.net on Windows). Now 4 years of golang. It beats all of them at development pace and ease of integration, especially since modules are working as they should. The killer features of golang: modules, http stuff, channels, ssh in stdlib, fantastic, easy to use crypto.
- PhantomBKB 6y agoI've seen my co-workers talk about similar things about Go. They especially like the verbosity. I personally like features that make code smaller, concise and at the same time readable. I'm referring to the syntactic-sugary things like the `for` comprehensions in Scala and `do` notation in Haskell which are pretty much built to do the same thing. Wish Go had a little more of those, it would have made things a little more exciting for me.
- thayne 6y agoYeah, my experience with go is there is a lot of boilerplate, and the verbosity actually makes it harder to read imo, because the core logic is cluttered with less important details.
- xwdv 6y agoDoes it have generics yet
- erik_seaberg 6y agoPeople are still trying to fix that: https://news.ycombinator.com/item?id=25750582 https://news.ycombinator.com/item?id=25750582 The last error handling fix didn’t really go anywhere, but just being able to send Either[error, T] will help quite a bit.
- echelon 6y ago> Yes. That's what Go is for. > Use the right tool for the job. Rust will be the right tool for the job when the library ecosystem evolves beyond just Actix. Give it time. FWIW, I've written half a dozen web services in Rust [1] and it's a breeze. The type system is incredibly expressive and lets you accomplish things with clarity. I already find it an appropriate tool for backend web and service development. [1] eg. https://vo.codes https://vo.codes is 100% Rust
- rmdashrfstar 6y agoIt has absolutely moved beyond just Actix. There are many web frameworks or lighter routers available to choose.
- burlesona 6y agoDo you have a recommended starting point for learning how to build web apps in Go? As a language, Go seems pretty easy (although the upper case method names really bug me), but I don’t have a ton of time to pick up new stuff on my weekends, and have not yet stumbled onto a great “start here” guide.
- randomopining 6y agoFollowing
- smnrchrds 6y agoYou are new to HN. If you click on the timestamp of a comment, you go to the permalink for that specific comment. There, there is a "favorite" button you can use to save it. You can access all the comments you have upvoted or favorited from your profile page.
- randomopining 6y agoYou da man, thanks.
- danielmg 6y agohttps://www.youtube.com/channel/UCa_MfJER8quGtCJd3MbZzCA https://www.youtube.com/channel/UCa_MfJER8quGtCJd3MbZzCA
- sebmellen 6y agoThis is the simplest "start here" guide out there: https://learnxinyminutes.com/docs/go/ https://learnxinyminutes.com/docs/go/. For more depth, check out FreeCodeCamp's course: https://youtube.com/watch?v=YS4e4q9oBaU https://youtube.com/watch?v=YS4e4q9oBaU.
- walty8 6y agoThank you! The tutorial is great.
- cromwellian 6y agoMost of Google's Web front end servers are written in Java, a lot of the backends too.
- throwaway45349 6y agoC++ still dominates in most of Google's 'big' systems, most of which are implemented as HTTP servers.
- thethethethe 6y agogoogle uses stubby (essentially gRPC), not http, for internal APIs.
- throwaway45349 6y agoStubby still uses HTTP as the transport layer. You're probably thinking of REST.
- eikenberry 6y ago> Use the right tool for the job. I think you mean to use the right medium for the project. Languages are a communications medium. Your compiler, linter, editor, debugger, those are your tools.
- soledades 6y agohttps://en.wikipedia.org/wiki/Language#Tool_for_communication https://en.wikipedia.org/wiki/Language#Tool_for_communicatio...
- eikenberry 6y agoThey are tools only in the broadest use of the term that applies to most everything we use to interact with the world. From philosophies like science to the mundane like a spoon. Why use such a general term when a more specific, much more meaningful term is available.
- soledades 6y ago"Medium" is a much more general term than "tool," the edit you suggested adds nothing to anyone's understanding of gp's point, and to suggest they actually 'meant' something that means the same thing is... strange. Also, they are tools in a much more narrow sense as well, but that is left as an exercise.
- tyingq 6y agoI have seen, though, a fair amount of Go applications with http[s] servers that are (unintentionally, I think) missing Content-length in the response, correctly handling HEAD/RANGE/etc requests, ETAGS, Expires, and so on. It seems like people aren't fully aware of what the bundled libraries do and don't do...and how that might affect end-to-end performance and load.
- Thaxll 6y agoI've never seen that in 5+ years of Go. 1) You don't have to touch Content-length since it's computed. https://golang.org/pkg/net/http/#ResponseWriter https://golang.org/pkg/net/http/#ResponseWriter 2) ETAGS, expire, ect ... are not managed by the std lib, as it should not.
- tyingq 6y agoOn 1), Looked, and yes, you're right, and it seems to have been there from the beginning. I think I may have been thinking of node.js on the Content-length having to be a deliberate action.
- sockgrant 6y agoGood to know but this is pretty small deal, easily fixed, also there's probably quite a few Go backend frameworks and I doubt all of them have this issue
- joshxyz 6y agoOn nodejs that is left on the userland. It's up to the user to provide content-type; content-encoding; provide etags, cache-control and 304; handle cross origin requests. Which looks like the right choice. ExpressJS has some helpers for it but it's a soup of unpredictability and shitty performance. You'd want something as simple as uwebsockets.js
- gher-shyu3i 6y ago> Go is for doing the things that Google does on servers, What does Google do on servers that has not already been served by Java and C++? As far as I know, the vast majority of code both existing and newly written at Google is Java and C++, not golang.
- EhhhhSql 6y agoMake it easy to ship code? C++ compilation is a nightmare & it's extremely expensive language to teach. JVM tuning is a nightmare and takes a while to setup (at which point it does run well relatively unattended, barring security fixes). With go, you practically need to work to avoid shipping an binary that can copy and run. You can learn the entire language in like two days and it can easily compile as you type with a decent latency to feedback (<1 second, in my experience). Its FFI is about as usable as JNI, maybe a little better once you get past the awkwardness of using a separate stack. Its GC is good enough with reasonable bounds. Keep in mind, I use rust and c++, primarily. I just look over the fence at go and can appreciate what it does well.
- kaba0 6y agoYou don’t really need to tune the JVM for most applications other than setting a maximum heap size. More than likely you will make things worse than the defaults.
- wtetzner 6y agoAnd I don't see how Go could be better in that respect, other than not allowing tuning. But that's really no different than not tuning the settings on the JVM.
- BobbyJo 6y agoI can't speak for present day, but, while I was still working there a few years ago, they were pushing Golang pretty hard. They weren't being hard-lined, so I'm sure a lot is still done in other languages, but I wouldn't be surprised if Go rivals at least C++ in terms of service count at this point. They realized C++ sucks for simple services and due to the Oracle litigation they were trying to get away from Java where possible. Having written backends in C++, Java, Python, Rust, and Golang myself, Golang is far and away the best tool for the job in my opinion.
- franklyt 6y agoOne of the things I really hate about golang is the idiomatic usage of single-letter variables. Other than that, and a couple of other quirks, it’s good.
- hamandcheese 6y agoI’d love to understand the rationale for preferring extremely short variable names.
- tempest_ 6y agoGotta save those bytes
- tedk-42 6y agoSingle letter variable names are throw away variables which you don't actually care about except for maybe a line or so. I think to use them when I'm trying to "show my working out" and it takes me back to algebra class days so I don't mind
- dmlerner 6y agoI like short variable names - for variables used in only a short block of code. I like long variable names - for e.g. a field on a struct used all over a file, and certainly exported ones. I think "Go uses single letter variable names" is not so true in practice. There's a balance, in every language, between when to use short and long names. Go's balance is tilted (a good bit) more towards short, but it's not a hard rule. There's significant mental overhead in reading `numberOfSubprotosOnProto`, as well as time hearing it in my head. I'd rather see `n` declared, used a few times in the next <10 lines, and then disappear. If there's two similar concepts in the same function, use slightly longer names, sure. Certainly not m and n. I think that's the same reason math tends to use single letter variables. "Taylor series are easy! Just memorize: 'f_series_degree(evaluation_point, expansion_point) = sum(derivative_order=0..series_degree, (evaluation_point - expansion_point)^derivative_order * f^{derivative_order}(expansion_point) / derivative_order!)' No thanks, I'll take f_n(x, a) = sum(i=0..n, f^n(a)(x-a)^n/n!).
- Thaxll 6y ago"The existing C++ client is too much of a mess to make concurrent; people looked at it and gave up" 99,9% of games that you describe are built in C++, it works fine. Modern engines are doing that without much troubles.
- aaron_m04 6y agoEvery C++ project is different. Maybe this one was poorly architected.
- Animats 6y agoThe original implementation is 20 years old. Some very good people designed it, but it's from the era when computers came with one CPU and GPUs didn't do much. C++ programs tend to be heavily inheritance oriented, with huge lists of includes and inheritance. Decoupling things to parallelize them is very difficult in that environment. Rust is mostly a single assignment language with move semantics, which encourages creating objects (yeah, the Rust crowd calls them structs) and passing them off to something else in a somewhat functional style. So you get programs that are less tightly coupled. That's useful if you find you want to pass an object to another thread, put it on a queue, etc. for performance reasons. Any dangling pointers or cross-thread references will be caught at compile time. That alone makes development far easier.
- pjmlp 6y agoAlthough not perfect, assuming all source code is available, clang and visual c++ checkers can do similar checks. So it is always a matter of equating the value of a full rewrite and how well the checkers are able to provide valuable feedback. Which I concede Rust will be much better, however then there is the whole loss of ecosystem to also consider.
- frankzinger 6y ago> clang and visual c++ checkers can do similar checks. > Which I concede Rust will be much better, Aren't these two statements contradicting each other?
- pansa2 6y ago> Use the right tool for the job. Do you agree with the article's recommendation of Rust for command-line tools, or do you think Go is the right tool for that job as well? Or perhaps I should stick with C++? For one thing, it's nice to be able to re-use code between command-line tools and other C++ programs, which AFAICT would be a bit harder between Rust & C++ and much harder between Go & C++.
- hamandcheese 6y agoI’m not the one you asked, but I think go is also a fine language for command-line tools, thanks to is truly breezy cross-compilation story.
- ericbarrett 6y agoThe ability to trivially cross-compile in Go, and get a single-file executable artifact, is often mentioned but still not appreciated enough. This is still a multi-hour project, minimum, for most languages, especially if you are introducing a second platform to a well-established project. In Go, it‘s a compiler flag. I think between http, encoding/json, and the io libraries, it’s also very simple and straightforward to do most of the things a typical command-line program does, in a cleaner way than shell or Python (both have their place) and with less fuss than Rust or C++.
- krferriter 6y agoThere's a relatively large difference in executable size, which might matter in some situations. And in run time. For executables that can get put to task doing a lot of heavy lifting and hammering on memory resources like grep and awk and others, it might make a real difference.
- SomaticPirate 6y agoI see a lot of people asking for resources to learn Go. I strongly recommend Thorsten Ball’s How to write a compiler in Go and How to write an interpreter in Go. It’s definitely overkill but it does more than the average language intro book. Lastly, does anyone have any resources for actually writing concurrent Go code? I have been spoiled by so many of the underlying libraries “already” doing this for me.
- nine_k 6y agoGo still has a few annoyances: error handling and casting things to/from interface{} are the most painful of them. Certainly, it's still ways better than C. But the resulting boilerplate and copy-paste programming ought to be a source of errors. (I'm happy to see the generics proposal coming closer and closer to a future feature.)
- nprateem 6y agoError handling is such a train wreck. Manually returning an error in 2021? What were they smoking?
- it 6y agoIt's actually really nice to have the good quality error messages that Go encourages when something goes wrong.
- nprateem 6y agoIf you remember to write them and propagate them...
- jamiesonbecker 6y agoExplicit is better than implicit, and you can't get much more explicit than that.
- erik_seaberg 6y agoNobody wants to write or read PUSH EBP MOV EBP, ESP SUB ESP, 12 a thousand times a day. The best you can do is avoid screwing it up. So when you write a function in any language since 1960 it just happens. Stopping a function halfway and bubbling an error up the stack should also just happen.
- _peeley 6y agoI agree, although there are IMO more optimal and explicit ways to handle errors - Rust and Haskell come to mind. When dealing with a Result/Either/Maybe or some other functor, you have to acknowledge the context of the value, i.e. that the value could possibly be an error. This way the error handling is baked into the type system in a way that's hard to replicate in languages that just return error codes or exceptions.
- likortera 6y ago> That's what Go is for. Go is for doing the things that Google does on servers Definitely not, unless you are google. Go is great for hardcore backend and systems programming, as a replacement for c/c++ or Java. For most companies over there (which are not Facebook, Amazon, Google, etc) what you need is just f**ng python/django, ruby/rails, php/symfony, etc. P.S. You probably don't need kubernetes and monorepos either.
- pjmlp 6y agoNot only Go, any language with automatic memory management and AOT/JIT capable toolchain.
- andrewwebber 6y agoAfter 8 years of writing Golang microservices one observation is comparing the compile times when optimizing for production. A typical Golang CI/CD pipeline should - compile without CGO enabled and with go build -tags netgo -a -v so that the binary can run on in a minimal docker image like alpine or scratch - should be compiled and tested using the race detector - should be linted using golanglint-ci All of these flags and linters considerably increase the build time for deployment to production The rust compiler effectively gives me the same outcome using the type system and the compiler advancements when targeting release musl. I have seen many Golang projects where the race detector was skipped because the code base was to large or it was flaky. One the other hand I do miss the code coverage tools. Code coverage for rust seems to only work on Linux
- _JB_py__ 6y agoExactly. I'd like to add that Go gets out of the way like I've never experienced before (having worked with Python, .NET, Java (Spring), C++, Rust, Javascript). Very good tooling and a standard lib that is great (e.g. networking) to mostly good enough (e.g. xml). Developer productivity is unmatched with Go. Focus is almost always on the problem to solve not on language features (I'm happy for generics to come but really don't need them), memory management / borrow checker or build tools / config (gradle et all). Rust is a formular 1 car. Use it when you need it and be aware that it has substantial costs developing and maintaining (immature ecosystem).
- lumost 6y agoI've been around go, java, and rust for a bit now (I even worked full-time on go projects for a couple years). Go really lacks a few features that are required for the numeric computing, and data processing. If you are building a web service that needs these kinds of things, it'll be a painful experience. There are a bunch of things rust has which makes it attractive over go for these types of apps, from a practical perspective it tends to be better for a team to use a minimal number of languages across their stack. The lack of generics means that each numeric type has it's own signature, if you deal with a lot of numbers with different precisions - you'll have a bunch of identical methods lying around just to support alternate precisions. The lack of function/closure serialization in Go means that "moving compute to data" ala Spark or Hadoop becomes exceptionally difficult. As native code, rust interfaces cleanly with C and can run in a few more places than Go - there are some active efforts to even support GPU kernels. Go can't really do any of the three things above today, and the community is averse to include new features into the language for both good and bad reasons. Java can do the first two, but struggles in the last category. Rust has an interesting opportunity to be a modern C which does the things java does and the things C/C++ do. But the library support and learning curves would need to improve dramatically for it to get there.