5 ms·
Here's a newbie's bit off topic question: As a C++ dev who wants to write "slightly less low-level code", should I go for RUST or GO? My intuition says Rust is
by ktpsns 8y ago
Here's a newbie's bit off topic question: As a C++ dev who wants to write "slightly less low-level code", should I go for RUST or GO? My intuition says Rust is more like a safer version of C++ while Go is more half way to Python/Julia. Do you agree with this sloppy assessment?
(Please, don't start a religious war on programming languages. We are all grown ups)
- cshenton 8y agoYeah that's about right. Go wont fit the bill if you can't trust the garbage collector (often true for scientific computing), or if you're not running your code on a full OS (like if you were writing an OS / embedded code). Since Go is easier to learn, it probably couldn't hurt to learn it, then turn to Rust if it's not powerful enough for your use case.
- _ph_ 8y agoWhy wouldn't you be able to trust the garbage collector? Especially with scientific computing, by which you probably mean numerics, your program shouldn't produce much garbage in the first place.
- cshenton 8y agoSure it will, scientific computing is rife with potentially very large intermediate matrices/tensors of data that need to be deallocated. In C++ I can explicitly free that memory, and in higher level frameworks, like tensorflow, dependency properties of the computational graph as used to figure out the earliest point in time a tensor can be deallocated.
- dbcurtis 8y agoI have not studied Go. I am learning Rust. I am not current with C++, but once was fluent. My take on Rust (as a Pythonista) is that while C++ is tedious and error-prone, Rust is merely tedious. Which IS progress. But... if you want to up-level, then I think the goal you seek depends on the state of the Rust crate ecosystem to get you out of the trenches.
- LambdaComplex 8y ago>My intuition says Rust is more like a safer version of C++ while Go is more half way to Python/Julia. Do you agree with this sloppy assessment? Yes
- _ph_ 8y agoIn my eyes, Go is rather a safe version of C. So you should be able to pick it up quickly.
- andreygrehov 8y agoAs I'm learning Go, I'd like to know why this comment is downvoted. I'd personally never compare Go to C++ as they're completely different animals to me.
- paulsutter 8y agoYes, you’re right. The Go team was originally targeting use in C++-like applications, but was surprised to see Go catching on more among Python programmers than C++ programmers. I would also suggest trying Python itself (why not go all the way?). Personally I write quick hacks in Python and real code in C++, and find Go to be an interesting middle ground. Python will do more to stretch your idea of programming. Maybe someday Go will get numpy and tensorflow.
- pietroglyph 8y agoI'm not sure if this is what you meant, but there are actually supported Tensorflow bindings for Go. They're quite usable (at least for me when I used them for inference), relatively idiomatic, and well documented. See https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go https://godoc.org/github.com/tensorflow/tensorflow/tensorflo...
- weberc2 8y agoAlso I’m not sure exactly what Numpy is but Go probably has an analog as it already has a suite of scientific computing libraries (check out gonum as a starting point).
- pletnes 8y agoAfaik Go does not have operator overloading and, hence, will never be popular for numerics, just like java never was (or will be). Python has this flexibility and allows for great numerics libs for this reason.
- _ph_ 8y agoYou are correct, Go does not have operator overloading. While that can be cute, I wonder how important that would be for numerics, as only a subset of the computations break down to + - * /. Also, for decades Fortran was the go to language for numerics, and still is. It also did not offer operator overloading.
- 8y ago
- skocznymroczny 8y agoIf no garbage collector isn't your requirement, you could try D.
- earenndil 8y agoMy understanding is that go is primarily targeted at spinning up webservices quickly, at the expense of most other purposes, so probably rust. (Or another contender for c++ replacement like d, nim, or zig.)
- lsllc 8y agoGo is great for all kinds of [web] server/systems and network programming -- if you're ok with the GC (i.e. it's a replacement for most things you'd do with Java and possibly some C/C++ stuff). Then Go is a great choice (BTW the Go standard library is fantastic and the eco system is amazing! you want to do USB, see gousb, d-bus? look at go.dbus etc). If you are building an OS, game engine, database server or doing embedded programming where the gc is a problem, or if you need a memory/type safe program (at the expense of a bit of productivity), then use Rust.
- earenndil 8y agoSo in other words 'use go for everything, unless gc is a problem, then use rust'? That seems like a bit close-minded, as if to say 'all the other languages and all they offer...is useless'.
- mhh__ 8y agoRust. Go and C++ have completely different aims, Rust is of the same ilk as C++
- Lutger 8y agoSomewhat. But I would rather characterize Go as a modernized middle ground between C and Java. Both C++ and python are rather fully featured languages, while the design of Go seems to aim for more simplicity and quality of implementation which affords a great developer UX. In this sense, Go is a step back from the complexity of both C++ and python. Go for me feels more like an updated and slightly higher-level C for application or webserver programming than any sort of alternative for C++.
- platz 8y agoI don't understand why anyone would characterize C and go. C and Java makes much more sense. It's basically Java with a clean an minimal API. That does not make it C.
- _ph_ 8y agoIn my eyes, Java and Go have very little in common beyond that they are both garbage collected languages. Go has been created by experienced C programmers and the heritage shows. Java is completely object-oriented, based on byte-code which gets JITed by a VM. All complex types have to be objects and are always handled by references - you cannot make an array of objects, you can only have an array of references. Go is statically compiled into a statically linked executable. Go has structs as complex types. They are handled by value, unless you specifically use pointers. Structs can contain other structs as values, without requiring the indirection and the overhead of references. The same applies for arrays. You can have methods on any type, including structs, but you can also just have functions.
- smittywerben 8y agoI’m a novice programmer but guessing Golang is concerned with keeping things as bytes; arguably _the_ distinguishing characteristic of C. So it has a scanner like Java or C#, but you’d get laughed at iterating bytes not objects in Java. I’d also note Golang’s API is built for enterprises so it’s familiar by design. I’d enjoy to hear other perspectives.
- wbl 8y agoSee Go vs. Brand X for a take on what Go offers.
- golangnews 8y agoIf you like C++, try rust, if you like C, try go.
- aikah 8y ago> As a C++ dev who wants to write "slightly less low-level code" If you really know C++, then you know it's easy to write safe C++ code with the latest standards so I'm not sure what's your problem here. Go and Rust brings very little to the table for an experienced C++ developer IMHO. Stick to the latest C++ features and you'll write "slightly less low-level code", although it's debatable how level C++ is to begin with.
- _ph_ 8y agoAs the initial concept of Go was made while the creators waited for their rather large C++ application to compile, I guess there are at least some things Go has to offer. One thing are the fast compile times. Not only is the Go compiler rather fast, as Go packages are compiled and stored as binaries, you usually do not have to rebuild them, only the code you are working on. Of course, there is the garbage collector, which can be of great help.
- jjnoakes 8y agoIf you really know c++, then you know it is not easy to write safe code. It is easier than it used to be, for sure, but not yet easy.
- saghm 8y agoI think your assessment is fairly accurate, although my recommendation would depend on having slightly more information. If you're looking for C++-like language but designed from scratch to be more modern (singular toolchain across platforms, better package management, compile-time guarantees about things like data races), then Rust would be a good choice for you. In my opinion, it's roughly as complex as C++ but fixes a number of the common pain points that resulted from C++ being designed to be mostly compatible with C. On the other hand, if you'd prefer something with less complexity with C++ (simpler memory model, smaller number of language features, eschewing of "magic"), then Go is probably a better choice. Ultimately, I think the right choice comes down to identifying what exactly your dissatisfaction with C++ is. Disclaimer: I'm a huge fan of Rust and not much of a fan of Go, but I do have experience writing each of them, and I tried to focus on the positives of each language as they might appeal to the parent commenter
- cogman10 8y agoI'd say rust is like C++ without the C legacy. Or maybe even a more modern C. It isn't quite as complex as C++, but has more meat to it than C.