9 ms·
From Python to Go to Rust: an opinionated journey (2018)
- danielecook 7y agoI went from python to go to nim. Actually I still like go - but nim is an easy transition from python. I think nim is the best thing out there for building tiny CLI utilities. It’s a fun language to code in.
- lcnmrn 7y agoI wonder if there's any performance difference between Cython and Nim.
- TylerE 7y agoNim is generally considered to be faster. Being statically typed allows more optimization. Nim is usually quite competitive with even pure C, especially if the C is non-trivial (e.g. has to do actual memory management)
- coffeescripter 7y agoNim is very nicel Not that it matters much in most cases, but the compiled binary sizes are also quite low compared to Rust.
- AlchemistCamp 7y agoDo you ever regret choosing "coffeescripter" as your handle? I loved CS and contributed to the CoffeeScript Redux compiler but the language is definitely pretty hated these days...
- trpc 7y agoI love Rust. Rust can be frustrating for those who didn't do enough c/c++ but once your brain and eyes get used to it, it becomes a joy to develop with. I never felt so excited writing code unless with Rust nowadays and back when I learned C++ for the first time more than 10 years ago when I was still a teenager. Rust is the closest thing to a perfect language ever existed imho. EDIT: for some reason I get mass downvoted for whatever I say on this retarded website. Thank you this was my last one. Never seen so much insecure retards who want to feel in control for once in their pathetic lives in any other social website. You should rename this website to "Insecure Hacker News".
- dev_dull 7y agoWould you still use rust for your CRUD apps? I think of it as a specialized, safe, performant system language. I wouldn’t think of turning to it for the random rest services we constantly churn out.
- staticassertion 7y agoI don't write REST services, but I use rust on AWS Lambda, and it works great. I can interact with AWS resources easily through Rusoto, I use Dynamo and S3, etc.
- asdkhadsj 7y agoI would. I feel more performant (as a dev I mean, I'm not referring to code) with Rust after a year than with Go after 6 years. Which to me indicates that at least for myself, Rust is a language that allows me to get things done more quickly. Iterators especially. With that said, I definitely wouldn't throw Rust at the Python/Go devs in my shop expecting them to be better/faster at it. It can have significant spin up time and, most importantly, if you're used to doing things unsafely by using bad patterns Rust will be hell for you. I commented recently that I think Rust can be far more simple than people give it credit for. Namely, that you can write Rust in the same manner as Go, pretending Rust was Go. However going far beyond that too quickly is a world of hurt, from personal experience at least.
- joseluisq 7y agoI enjoy coding in Rust as well, I don't understand why some people try a forced comparison with C++ arguing that Rust is younger in contrast with C++. Sure, but Rust is very promise language and it's not restricted only at system programming scope. It goes a bit more further. In few years I see Rust taking a place on top and sharing it that place with C++.
- dang 7y agoI took a look at your comment history and it seems clear that the downvoted comments were the ones that broke the site guidelines, while your thoughtful and substantive comments have positive scores. It's true that a fine comment sometimes gets an errant downvote (if nothing else, remember that people misclick). But most of those get corrected by other users who will notice the unfairness and give a corrective upvote. They won't do that, though, if you get upset by downvotes and lash out like this—because then you've broken the guidelines, and that will result in downvotes and flags. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- dev_dull 7y ago> I compiled the code and … no error message. Everything went fine. But?! I just added a field to a struct, the compiler should say that my code is not good anymore because I’m not initializing the value where it should be! This is your big hangup with Go? You added a new field, didn’t use that field anywhere, and the compiler didn’t complain? I’ve heard a lot of valid criticisms of the language but this is a new one for me.
- whateveracct 7y agoIt's a pretty big annoyance with Go though. I hate that all struct fields are optional.
- mdanger007 7y agothere are times when a nil struct field is useful, like for trees and json. very easy to require struct fields by using a constructor
- Nullabillity 7y agoAbsolutely, and Option<T>s are great for modelling that. It just shouldn't be the default.
- whateveracct 7y agoIf it's useful, then the person creating the struct can explicitly set it to nil.
- arendtio 7y agoFWIW, I never had that problem, but I also tend to use constructors for my structs.
- whateveracct 7y agoWhen you use constructors you lose named arguments though. One use-case where this is really painful: I like to encode sum types in Go using an interface with a private dummy method + structs that implement that. I then have a function "match" that takes one function per struct. It's nice to be able to pass these functions as a record since it gets ugly, but due to Go allowing omitted functions to be nil, if I add a case to the sum, I open myself up to NPEs everywhere. If Go had a warning for missing struct fields, it would tell me all the places I'd need to handle a new case.
- Townley 7y agoAs a Python dev getting into more Rust development, I'm surprised whenever I hear of this as a progression towards better tools, rather than a way of adding new tools into my belt. Django/Flask are great tools for spinning up a CRUD application with authentication/authorization, API endpoints, and a template language if I don't want to build out a React or Vue SPA. Rust is a great language that's opened me to new domains of programming, and also gives me the ability to write more performant, hardened API endpoints at the expense of productivity in hours (this gap will definitely shrink as I get better and as rust frameworks mature, but I'd be surprised if it went away entirely) If a developer views a suite of tools they know very well as "something they used to use", they're more likely to make future architectural decisions based on incorrectly viewing framework-powered python as a relic of the past, rather than a viable (and often preferred, if hours of work are factored in) alternative.
- atoav 7y agoI get the fascination people have with Rust and I love to use Rust myself. Part of the fascination certainly is it’s tooling and that Rust nearly seems to force you to make the right decisions. I’ve never wrote in a language were I were so focused on the structure of my program rather than hammering in what I felt. And when you hit compile and it works, it usually does so flawlessly. However I use Python very often still, just not for every task. Just like you said: Rust is another tool in the tool box and it isn’t that single purpose machine that you buy and use once for a single project, it is that japanese handsaw that is incredible useful and powerful in the hands of the right person. But sometimes you just need to make many cuts fast and then the handsaw (no pun intended) doesn’t cut it. Python certainly has it’s place for me, but so does have Rust..
- cdelsolar 7y agoThat's a bizarre reason to stop using Go. I can't really think of many realistic instances where that would bite you.
- ddss 7y agopython
- kahlonel 7y ago> but at some point, it didn’t feel right anymore. That's not how engineering works. > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes That's not how engineers work. > a compiler that should not rely on the fact that I know how to code I don't even know what to say anymore.
- elnygren 7y agoMaybe you should try the dev experience of Elm or ReasonML before shooting down the author’s comments. I get what you are saying and I also get what the author is saying it might be that you are missing something truly great in our engineering field.
- kahlonel 7y agoIf the author had explained a real reason for abandoning Python in favor of Go, it would've made a lot more sense to write this article. "Not feeling it right" isn't how engineers choose their tools. He could've said that he wanted to try something other than Python, and I would have respected that. On top of it, his reason to switch from Go to Rust is laughable at best.
- jdefr89 7y agoI also can’t believe no one mentioned one of the things Go does best... Concurrency. When it comes to its concurrency and parallelism model. Go is just awesome.
- deleted 7y ago[deleted]
- rhinoceraptor 7y agoMaking concurrency/parallelism easy is not necessarily a good thing. You need guard rails in place to reduce the risk of bugs. Node.js does that by only having concurrency, not parallelism. Rust does that by having very robust memory safety checking.
- bibyte 7y agoI went through the same path as OP. But instead of discarding them I am still using all three of them. And at least for me Python and Rust don't even compete with each other.
- ngngngng 7y agoI've yet to try Rust. But Go is the best and worst thing to happen in my career. Best because it's amazing, worst because now I don't like working in other languages. I'm trying elixir currently, and it makes me want to rip my hair out. No for loops, no typed parameters, implied returns. Who in the world though any of this was a good idea? IO.puts() refuses to print certain objects (list of ints) and just prints a newline, making it useless for debugging. I'm very very excited to try Rust, and I'm glad I've been able to choose the languages I work with up to this point in my career.
- quaunaut 7y agoJust wanted to correct some things, as a fan of both Elixir and Rust. > No for loops But we do have for loops? That's what comprehensions are: https://elixir-lang.org/getting-started/comprehensions.html https://elixir-lang.org/getting-started/comprehensions.html > no typed parameters But if you need types on your parameters, you have Guards, which... check for type? Sure, you don't type every last parameter, but if you want that you can upgrade to Dializer and get that feature too. It's just not as useful as you likely treat it. > implied returns I understand that some may not like this, but it comes out of the idea that generally, you want to avoid "side effects"- ie, things in code that happen without anyone but the original function causing them being able to tell. Elixir doesn't completely lack them, as that would be pretty unreasonable, but it does at least ask that you're clear about the purpose of functions by having them always return something. > IO.puts() refuses to print certain objects (list of ints) and just prints a newline, making it useless for debugging. This seems like something must be going wrong. `IO.puts` certainly prints lists of ints, however, it might also be mistaking them for a charlist, which is definitely a concern. That's why generally, you want to use `puts` for text, and `IO.inspect` for data structures. As an added convenience, if you want to annotate your data structure with text, you can modify `IO.puts` like so: `IO.puts "List: #{inspect(list_of_numbers)}"`. That will parse the list to the inspect version and insert it into your `puts` line. For the record, I'm not saying any of these necessarily shouldn't be a reason to not like Elixir- we all have our preferences, but the reason behind many of these choices is philosophical, and I'd be happy to explain anything else that has puzzled you, if you're still interested in learning more about Elixir.
- 7y ago
- Evidlo 7y agoI was working on a simple Rust CLI program to parse JSON from the Github API, but I got turned off by some of the unfriendliness of the available http libs. One http library pulled in dozens of other crates and turned my 10 line program into a 50MB binary [0], while another had an unpleasant api [1]. [0] https://docs.rs/reqwest/0.9.18/reqwest/ https://docs.rs/reqwest/0.9.18/reqwest/ [1] https://docs.rs/hyper/0.12.29/hyper/client/index.html https://docs.rs/hyper/0.12.29/hyper/client/index.html Maybe I have too much desire for instant gratification, but it sucked the fun out of the project.
- iBelieve 7y agoYes, unfortunately reqwest pulls in lots of dependencies, but I think you should be able to get a binary under 10MB if you compile in release mode using the --release flag.
- 0815test 7y ago"Crates" are just compilation units. Do you feel "turned off" if a C/C++ library includes "dozens" of source code files, some of which might come from outside projects? (A sibling comment mentioned --release already, which is obviously something that one should be familiar with when discussing Rust's performance.)
- tptacek 7y agoThe “zero value of a type should be useful” concept is pretty fundamental to Go’s design. You can imagine compiler tooling that didn’t alter the language allowing you to catch unintended uninitialized values, but a language that changed the underlying default would no longer be Go.
- lymitshn 7y agoI would suggest F# to the op. Even though I have limited practical experience with it, from what I've read and see it checks op's checkboxes.
- stcredzero 7y ago> This was the show stopper for me. I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes. No! One shouldn't mindlessly rely on the compiler "to get your back." Instead, one should code (or alter code) so that you've manipulated the situation, such that the compiler will flag any errors. With a language like golang, this means that you should make sure that the "zero values" are always copacetic. (Analogous to crash-only software.)
- deleted 7y ago[deleted]
- slx26 7y agorust is great if you have enough experience to pick it up without dying trying. and you need to start reading the book. the enforced safety helps even experienced devs with a formal background to reinforce and see some concepts more clearly. all that said, when you have to do advanced things and go unsafe, it can feel really annoying (fighting the compiler) and limiting. most common problems can be modeled in rust without issue, but if you have a clear idea of something that you want to do that's more advanced... the language will actively work against you, that's its goal. that has both a good and a bad side. maybe it will get better in the future. still an awesome language today.
- hansdieter1337 7y agoBiggest issue for me is the compile time. Especially in comparison to Go it's a huge difference. At work we have a huge codebase with over 1M LOC. I guess for bigger projects you need proper interfaces so you can split up your code into multiple libraries.