10 ms·
Go vs. Rust? Choose Go
- njetten 9y agoTook a look at both Rust and Go to hack on, but up until today I haven't found a usecase where I _need_ C-like performance (and choose to use Rust). Even though Google/Fuchsia is using Go for it's networking[1], I wouldn't really consider Go to be a system language. [1] https://groups.google.com/forum/#!topic/golang-dev/2xuYHcP0Fdc https://groups.google.com/forum/#!topic/golang-dev/2xuYHcP0F...
- majewsky 9y agoI concur. I would really love to love Rust because it's a cool language that values efficiency and safety, but in the end of the day, I keep writing Go programs on all scales because it's just so productive.
- thinbeige 9y agoSomehow this feels like apples vs oranges.
- pgwhalen 9y agoAgreed. It's unfortunate that Go and Rust are frequently compared to each other, they're not really trying to solve the same problems, they just happened to be modern, hyped, backend languages. I don't blame this post really, it's trying to correct that belief in a way. Rust is roughly a modern C replacement, while Go is a modern Java replacement. (very roughly)
- baq 9y agoit is; it's like comparing Python to C, except it's 2017 instead of 1997.
- deleted 9y ago[deleted]
- alekratz 9y agoI think this is a good answer. If you're really not in the mood to scratch your head over confusing reasons for why your program won't compile while learning the language, Rust is not what you want. While I have used Rust, I have not used Go. Anecdotally, the consensus seems to be that it's relatively easy to pick up, and get something done. And really, if you're just doing a personal project, part of the point is to feel the Joy of Programming (TM) and being able to make or learn something.
- aaron-lebo 9y agoThis'll be a fun comment section. Maybe Go isn't so simply the answer, but the spread of "write everything in Rust" or "Rust is the salvation of software" is crazy. It's got huge advantages but it's really a very difficult language for what it does. 80% of software (nonsense percentage) that gets targeted to Rust would actually be better in another language. Rust's focus is on (for most devs and software) the wrong things. It's too bad something like a better OCaml or Nim weren't what people were going nuts rewriting stuff in but they don't have the mindshare. Rust evangelism is like using a very advanced hammer to do everything. We've got screwdrivers, chisels, and multitools, yall, use them! Is Rust actually the right tool for the job? As programmers we do tend to seek the one true language which doesn't really exist.
- webkike 9y agoWhat are some program that Rust is not always a reasonable choice to write in? Frankly, there may be some areas where another language is slightly easier to program in than Rust, but I see the value in trying to promote a lingua franca for programming. Different languages causes huge interoperability problems
- aaron-lebo 9y agoI would argue almost anything. Nim writes like Python. The average programmer never worries about lifetimes because there's a GC, which the vast majority of programmers (especially application programmers) have gotten used to over the last 40 years. Rust is a big sidestep in usability, which makes sense if you want to replace C and C++, but not much sense elsewhere. Humans are really, really good at juggling multile languages, it's why we make a new one whenever we can.
- webkike 9y agoSo you're saying that for almost everything Rust is not a reasonable choice. You then state that a reason for this is because people don't have to worry about lifetimes because it has a GC. There are applications where a garbage collector is simply unnecessary and possibly extremely detrimental. And if you get down to it you'll find an amazing truth: once you learn how writing programs is about as easy without a garbage collector than it is with one and your programs run a lot faster. Using an automatic transmission is a lot easier but manual is not hard and you save a lot of gas.
- CSDude 9y agoI code in Go for 2-3 years and tried to learn Rust for fun, but it was harder for me. While Go is very simple and it has almost no barrier of entry, it lacks much as well, Rust definetely looks more interesting and it would be another enlightning experience.
- dhbradshaw 9y agoIt seems like this could depend on what is already in your tool belt. If I want productivity, I use Python. If I want raw speed and low overhead, there's Rust. So Go ends up eclipsed on both sides.
- zellyn 9y agoHmmm. If you know Rust well already, sure. But both Go and Rust have a much better binary a distribution story than Python once you stray from the standard library...
- skybrian 9y agoThere's another dimension to this: how big is the codebase you have to maintain? This is a "pets versus cattle" thing. If you like artistically crafting small bits of code, Python may work fine. If you're building something to last and need to shovel large amounts of code around while migrating API's, a statically typed language with a fast compiler will do more to help. Python in the large is not very maintainable. I expect that a Rust codebase will eventually be pretty nice to maintain, after the tooling matures more. Currently, Go is probably easier, and quicker to write.
- deleted 9y ago[deleted]
- baq 9y agoside note: check out mypy for a powerful type system in Python; i'm a happy user in a largeish project for a year or so and it really works.
- depressedpanda 9y ago> Python in the large is not very maintainable. Could you elaborate on that? I hear this a lot, but I work on a large Python project, and I don't think it is hard to maintain. We do have some strict requirements, though: 1. Test coverage; if it's testable there must be tests for it 2. Type hinting; for large projects it's actually really nice to know at a glance what the expected type is 3. PEP8 & Pylint; how we write code should be standardized and easy for others to read
- siddhant 9y ago> Both languages seem to be competing for the same user base and they both seem to be "systems programming" languages, so there must be a winner, right? Are they competing for the same user base? As far as I can understand, Go is mostly being used in distributed software systems (like kubernetes) while Rust is being used for more "systems" software where performance is critical (like a web browser).
- webkike 9y agoIt may be true that Go is easier to use than Rust but over time I have learned to essentially love Rust and hate Go. Rust isn't perfect by any means, but when I program in Go a lot of times I wish I could avoid costly abstractions that don't have any real reason for being required, and thus I usually avoid Go for any task I wouldn't just use Python for (sans the REPL). Go doesn't let me describe data the way I want it to let me. Concurrency is not even incredibly profitable using language idioms. I like the syntax, but frankly Go is in an entirely different league than Rust is. And that is to say, when I want to write a program Go sometimes is just not an option. Rust is always available, even if you have to do a little bit of learning.
- aaron-lebo 9y agoWhat about Nim? I've found that a lot more productive than Rust even without libs.
- mlevental 9y agohow's the compile time with nim? go's compile time makes it almost as good as having a repl. i tried crystal a while ago and it has atrocious compile times.
- dom96 9y agoThe compile times are on par with Go. The Nim compiler (written in Nim and containing ~100k LOC) compiles in under 10 seconds on my MacBook Pro, and this is from a cold cache. It's even faster when making changes as the C source files generated by Nim are cached.
- merb 9y agothe question how big are the compile times on a project in the size of kubernetes, i wouldn't call that "quick compile time". even the go part of it. I mean yes the use case for many people who use go have a fast compile time, but once it goes huge, the speedup isn't as big as on other languages.
- bad_user 9y ago> Both languages seem to be competing for the same user base and they both seem to be "systems programming" languages, so there must be a winner, right? No, Go isn't a systems programming language because it has a GC. This matters in constrained environments, like when doing embedded development, or for real time systems. Sorry, but Go isn't in the same category as Rust or C/C++. Go is in the category of Java and C#. And IMO its only advantage is that it can produce lighter binaries. And while Java and .NET are evolved towards building lighter binaries, you can't evolve a GC-ed language towards one without a GC.
- Veedrac 9y agoFrom the article: > Go is not even a systems programming language.
- user5994461 9y agoGo is for distributed systems. It can be for system programming, depending on what you mean by system programming. I would personally not assimilate system programming to embedded.
- axaxs 9y agoAnd even then, it's ok. Hell how many places has Java been embedded?
- sah2ed 9y agoPlenty. https://en.wikipedia.org/wiki/Java_Card https://en.wikipedia.org/wiki/Java_Card
- deleted 9y ago[deleted]
- user5994461 9y agoOr billions of places to talk in numbers. Java is running on so many smart cards, TV and set top box nowadays. It's almost everywhere.
- yawaramin 9y agoOr choose OCaml: http://engineering.issuu.com/2015/09/17/ocaml-production.html http://engineering.issuu.com/2015/09/17/ocaml-production.htm... It's enterprise-ready. Seriously. Hate the syntax? Wait a little bit and try out ReasonML (new syntax for OCaml), e.g. the following OCaml channel |> Channel.push "new_msg" [%obj { body = "a" }] ~timeoutMs:10_000.0 |> Push.receive "ok" (Js.log2 "Created message") will become (pretty much) the following Reason channel |> Channel.push("new_msg", { "body": "a" }, timeoutMs::10_000.0) |> Push.receive("ok", Js.log2("Created message"));
- aaron-lebo 9y agoStill waiting for Duke Nukem Forever, aka multicore, until then OCaml has major limitations for such a low-level and performance-oriented language.
- yawaramin 9y agoLet's be honest. You don't really need multicore (i.e. language-level parallelism support) for most enterprise work. Hence people use NodeJS just fine. OCaml has not one but two very nice concurrency libraries so for most backend work you will be absolutely fine.
- Can_Not 9y agoSure, but for specific projects, I'd leave NodeJS faster if OCaml had multicore.
- yawaramin 9y agoYou don't even need to leave NodeJS to get all the OCaml benefits: BuckleScript compiles to readable JS. Compare the input and output of the example: https://github.com/bucklescript/bucklescript#an-http-server https://github.com/bucklescript/bucklescript#an-http-server You can get all the type safety benefits of OCaml right now, on NodeJS.
- 9y ago
- Lerc 9y agoIf you need what Rust offers, use Rust. If you don't need those things there are hundreds of languages that you could use(including Rust if you really want)
- bfrog 9y agoI chose rust after endless annoyances in a 100kloc go program due to piss poor type safety and nil pointer checks, lack of meaningful containers, and working around GC when working with C libs. I didn't think I needed any of those things until it was too late. Any project of meaningful size will eventually need everything go avoids.
- egeozcan 9y agoYou rewrote a 100K LOC project because you felt the language is lacking! It really must have been a huge battle with the management (or whatever stakeholder there is), I suppose? If you did make your case against others, could you please share how you went about that?
- rusht 9y agoOut of curiosity, what type of project was this? Did you end up rewriting the entire 100K loc in Rust? I ask because Docker and Kubernetes are large projects and as far as I know, using Go hasn't been an issue for them.
- scalatohaskell 9y agoit actually has. Try to ask around some former workers of those projects.
- rusht 9y agoAny links?
- deleted 9y ago[deleted]
- Animats 9y agoMuch as I like Rust, I have to agree. When you have to get it done, use Go. When you want to explore advanced experimental programming constructs, use Rust. The Go guys knew when to stop. Arguably they stopped too early, before generics or parameterized types, and "interface[]" is used too much. But that doesn't seem to be a big overhead item. Rust has the complexity of C++ plus additional complexity from the functional community. Plus lots of fancy template cruft. The trouble with language extensibility is that people use it without an overall plan. The end result is a Winchester Mystery House language.[1] LISP went down this rathole, and Scheme had to be developed to get out of it. C++ went that way when nobody stopped the Boost crowd before it was too late. Now it's happening to Rust. (Anyone involved in language design should see Václav Havel's "The Memorandum". Or at least read it; I've seen it performed, but it's not performed often.) [1] http://www.winchestermysteryhouse.com/ http://www.winchestermysteryhouse.com/
- wyager 9y ago> When you want to explore advanced experimental programming constructs This is a weird euphemism for "get it done correctly". It seems to come up in any discussion about languages that help you to write correct code.
- jstimpfle 9y agoNow what was wrong with that? I totally subscribe to the view that advanced experimental programming constructs are neither a guaranteed way, nor the only one, to write correct code. Doesn't a language which helps you to get code done (and makes it easy to iterate on it, and has the right psychology to let you move on instead of trying yet another way to get at the old problem) help you write correct code, as well?
- wyager 9y agoNothing in Rust is an "experimental construct", so I'm not sure why you keep using that phrase. Lightweight formal tools like those available in Rust do guarantee that your program satisfies certain correctness properties that Go cannot. To guarantee correctness in all aspects you need more heavyweight tools than Rust provides, but they do exist. No, languages that let you "iterate" and don't provide any sort of formal guarantees don't help you make correct code. They help you pump out a lot of mediocre code that probably works acceptably enough to satisfy a business with a medium-low focus on correctness.
- LambdaComplex 9y ago"Rust and Go are both systems programming languages, so we have to compare them! Go wins because it's easier. By the way, Go isn't a systems programming language and would suck for systems programming." That's basically what I got from this article.
- qyv 9y agoThe point of the article is that Go and Rust don't actually serve the same purpose. So asking "Go or Rust" 99% of the time means choose Go. For the other 1% of the time you (should) know that you actually need Rust, not Go.
- lordCarbonFiber 9y agoThe problem with performance is that "you don't need it" right up until the moment you do. It's the same argument startups use for writing their apps in python. You get your "massive dev output" right up until you realize your web app isn't going to scale and you've got to do a full rewrite and runtime errors have burnt out most of your dev team. There's a reason why the lion's share of code written today is Java or C++ and Rust compares much more favorably on the more "enterprisey" merits (stability, expandablility, performance) than the startup merits (how fast can we ship).
- red75prime 9y agoI use F# and Rust for personal projects. At work I deal with a programming language akin to Go on the simplicity side, and it is just not fun. But I am probably not typical. I'd no problems learning a language I'm interested in (but Haskell. Monad pattern recognizer somehow can't take a hold in my head for long).
- Roritharr 9y agoI always look at programming languages from the same position i use to look at guns. What kind would i want OTHERS to use around me? From that POV Go wins hands down in my opinion. Harder to get wrong. Easier to get right.
- millstone 9y agoHow is Go "harder to get wrong?" It's very easy to accidentally introduce a null pointer dereference, data race, type assertion panic, or drop an error. It's much harder to get these sort of bugs in Rust.
- baq 9y agoactually it's the other way around; once your rust code compiles, it's going to be much safer to use than go. the difference is more in that the parts you have to assemble the gun from are much smaller in rust.
- BlackjackCF 9y agoI've been using Go in production for a little over a year now. I'm also attempting to learn Rust in my spare time. This post just about sums up my feelings on Go vs Rust.
- y_u_no_rust 9y agoI've still yet to really see rust in a non just fucking around professional setting that said go's import/package management fuckery is best avoided almost everything else is better IMO it's just a side effect of the designers being overly obsessive about the failure that was plan9
- SwellJoe 9y agoI've had the same experience. I'd like to learn Rust, at some point, and I read articles about it and tutorials now and then. But, realistically, I would need to dedicate myself to it for a long period of time to be able to build something from scratch in the language. On the other hand, in a weekend of casual hacking, I was able to learn the language (sort of) and make a project from scratch in Go that actually did something useful. I'm sure the code is awful, and it'll take months of weekends of casual hacking to be able to recognize why, but Go is damned near comparable to Python or Ruby in terms of being able to go from zero to writing working code. I'll still keep learning a little rust here and there when I have some free time. I'd really like to know a good, modern, systems language. I used to work on some C projects, but C++ was just too daunting, it's just to big of a language for casual use, so I never went down that path. Rust seems to be a good compromise. It's not even a "Go is better than Rust" situation; the Rust team has made reasonable, occasionally brilliant, compromises on ease-of-use and ease-of-learning vs their other hard requirements. Go just has different requirements and they result in a language that is easier for new programmers.
- foobar20198 9y agoArticle makes a false premise: that speed of writing the first version is important. Much more time is spent maintaining software than writing the first version. Some poor sob is going to have to go and fix all those "silly" mistakes that were made and the bugs they caused (but of course, as we all know, they would have been avoided if the programmer had just been a better programmer). Save yourself (and us) the bother. Please use languages that stop you from shooting yourself in the foot. (Not that rust will avoid bugs, but it seems to catch a lot of stupid "mistakes" before compile time. We're all humans and make mistakes, please accept that fact before inflicting software on us.)
- danjoc 9y ago>Article makes a false premise: that speed of writing the first version is important. In my experience, project managers care more about how long it's going to take to build than about how maintainable it is. It's literally always the first question they ask: "How long do you think this will take you?" I don't believe I've ever heard anyone in management ask, "How maintainable will this be?" I'll ask around. I bet none of my peers have gotten that question either.
- tatterdemalion 9y agoExcept that normally a new feature does not involve creating a new system. Technical debt significantly impacts velocity of implementing new features in the future.
- onkgdlnf 9y agoAt least at my current company talking about maintenance is a huge thing given it's not happening right now.
- baq 9y agomy take at a summary: use go if you want to do something, use rust if you want to learn a lot of important and interesting stuff that's been hidden from you before doing something.
- adamnemecek 9y ago> You'll need to unlearn bad habits and learn new concepts. Ok, yeah, that's totz the way forward. Repost this if you are strong independent developer who doesn't need no good engineering practices.
- dpc_pw 9y agoProductivity comparisons are tricky. As an analogy: Being more than 10 years long Vim user, I am very productive with Vim. I have all my configs polished, I know all the tricks, etc. I can work on shell scripts, C, C++, D, Rust, Python, Go, anything... all in one editor, locally or through ssh, on any platform, etc. But if you take a person that has spent a month using Vim, and a person that has spent a month using some popular IDE, the IDE person is going to be more productive. Also, I'm sure long-term Java IDE user is going to be more productive than I am with Vim, when writing Java. Obviously. Similarly with Go and Rust, as I'm following Rust development since like 0.3, I am very productive with Rust, while I find Go noisy, verbose and constantly dragging me down with its limitations. I don't have to be "architect astronaut" to need generics or decent macros. On top of that: how do you measure productivity? Many people seem to measure it by "perceived productivity when writing new code". "I am writing this new service in Go, and I was able to do 500 lines today. I feel very productive!" Never mind that 30% of that lines are verbose error checks and other error-prone boiler-plate, reviewing it might not be pleasant, there are multiple errors that will have to be ironed out when production starts to exhibit them, everything needs refactoring because performance is not good enough under load, and that the next person might not have a such a wonderful time modifying the original code, as the first person writing it, and so on. The project might be in such a bad shape, then it will just get rewritten from scratch, so the next developer will feel "productive" again, ironically. I am NOT addressing Go and Rust particularly here - just overall. It is very hard to measure long-term productivity, while it is easy to lure yourself into believing the perceived short-term productivity matters a lot. Having said all that, Go is easy to understand, so it is easy to find people that are able to use it (huge business reason to prefer it!), has a nice ecosystem, fast compilation, nice scalability with goroutines and many things that are going for it. I find Rust's "quality", trump Go's "productivity", but that's like ... my personal opinion, man. :)
- zzzcpan 9y agoI think people who come to Go from not so productive languages might feel productive in Go. I mostly feel very unproductive with Go, like I'm wasting too much time dealing with code, when I should be thinking about the problem I'm solving. Although I almost completely stopped using Go at this point.
- didibus 9y agoWhy not Java, Kotlin, Scala, Clojure, C#, F#, OCaml, CL, Scheme, Haskell, or any other efficient GC language? Its funny to compare Rust, whose sole purpose was to enable garbage collector free semantics, designed to reimplement an efficient and small memory web browser to languages with a GC. Go is great, because compared to most other GC languages, it has small self contained binaries and comes with a great toolchain. Its AOT is better then C# and Java, and bundles its runtime with every app. It's not great, because people would really just want a more expressive language that had those same qualities. That's why there's effort for Kotlin native and Scala native. If anything, the fact that some people are thinking to pick Rust over Go is a testament to Rust. Rust should have nothing of interest over Go, except for no GC. But apparently, even with the added complexity of a borrow checker, it has enough to entice people from GC languages.
- wink 9y agoI've yet to see some Go code for typical CRUD web apps that doesn't look roughly as elegant as 10-15 year old PHP code, if you know what I mean. I'm not a real fan of ORMs and I'm surely not trying to badmouth PHP - but times have changed and Rails did bring some things that inspired tons of web frameworks in other languages to have cleaner, nicer code. Open to suggestions for projects to take inspirations from so that my future Go code will not be "quickly written AND it works AND it looks horrible" :)
- legendiriz68 9y ago"Safety against Null pointers, race conditions and all sorts of low-level threats. Predictable runtime behavior (zero cost abstractions and no garbage collector). ...yadayadayada... If you don't require any of these features, Rust might be a poor choice for your next project. That's because these guarantees come with a cost: ramp-up time. You'll need to unlearn bad habits and learn new concepts. Chances are, you will fight with the borrow checker a lot when you start out." If you don't require...seriously is there any case ever in the world of programming when you don't require those? I can't even believe this article exists. Why would anyone ever use Go for anything? It's the worst programming language ever invented. Yeah Im sure it makes things fast just like jumping down from rooftop makes you go fast but there is small side effect of dying.
- ivcha 9y agoyeah... no...
- holydude 9y agoI prefer Go's lacking to Rust's syntax and long compile times. But then again I do not write things like Servo. I also like Nim and Crystal and while Crystal's compile times are not ideal I can forgive this as i like the syntax
- kissgyorgy 9y agoBased on this article, I guess not a lot of developers need to program in Rust nowadays.
- pmm 9y ago> Predictable runtime behavior (zero cost abstractions and no garbage collector). I see a lot of people considering Rust/Go because they are looking for something much more modern than C++ and at the same time not running on JVM due to the above