
Rust as the New C Part 1: Building and Combining Native Libs into C API - adamnemecek
http://hotforknowledge.com/2019/07/14/6-rust-the-new-c/
======
ChrisSD
> So despite the fact that many consider Go to be the main Rust competitor for
> writing complete programs...

Really? That seems odd to me. I guess there's some overlap between the two
languages but they mostly exists in different spheres.

C++ would be the more obvious comparison.

~~~
buybackoff
Author here. I have read somewhere (and have two links in the post) that the
FFI transition between native code and Go has huge overhead because of Go
runtime and bookkeeping Go has to do for making such call safe. But calling
Rust e.g. from C# P/Invoke has the same cost as calling C library. So the
point is that writing a complete program in Go is probably better or equal,
e.g. some network utility. But if I write a shared library that I call __a lot
__from C# via P /Invoke, Go will have much higher overhead. This may be wrong
for the latest Go versions, I researched that around a year ago.

~~~
gameswithgo
The higher overhead of talking to C from Go (as compared to C#/Java) has not
changed, and likely won't.

And of course, C# and Java also have overhead.

~~~
buybackoff
I mean talking to Go from C or any other language as if Go was replacing a C
library. Could not find low-level detail on this, but I remember it used to be
very slow. E.g. PInvoke has an overhead of between 10 and 30 x86 instructions
per call, which is quite small.

Actually I'm not sure if that is possible now to call Go from C via some C
ABI/ABI. I looked into CGO in the past.

~~~
proyb2
Alternative to Go, the ease of talking to C could get simple, V language which
transpile into C code with minimal overhead, still infancy at this stage, the
end goals is to translate C source to readable V code.

[https://vlang.io](https://vlang.io)

------
joshbaptiste
hmm I actually see Zig as more of the "new C" and Rust, Go, Nim as more of C++
displacements.

~~~
gameswithgo
Zig is a new C Rust is a new C++ Go is C with garbage collection Nim
is....just something totally else.

~~~
jhoechtl
Wow, Nim has some gery interesting concepts, is it backed by a heavyweight
like Go and Rust are?

~~~
joshbaptiste
Corporate heavyweights no.. but super smart people on the forums
[https://forum.nim-lang.org/](https://forum.nim-lang.org/) and its creator
[https://github.com/Araq](https://github.com/Araq)

------
pankajdoharey
IMHO, Rust is not the new C, perhaps D or Zig could be the new C. Rust is the
hardest language i failed to learn and eventually gave up. C is one of the
easiest language to learn but difficult to master.

Edit: Rust libs can be used to interface with C, but so could other languages.
Porting the huge amounts of system software is near impossible task.

~~~
cyphar
With C it might be easy to get a program to compile, with Rust it's easy to be
sure that a compiled program is actually correct from a memory safety PoV.
Rust is harder to learn, but much easier to master. I guarantee the vast
majority of systems programmers writing C code are not masters in the sense
that they will write memory-unsafe code regularly.

Personally I think Rust is competing with C (and C++ as well as Go) in the
"systems programming" sphere. It isn't a competitor to C's "portable assembly"
history. It's a far more FP-esque approach to systems programming.

