News for hackers. Stuff that matters.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by zamalek on Saturday October 24, 2020 @12:16AM (#24876891)
It's not unreasonable to expect it to replace C, but as a major Rust fan myself, I don't see it specifically taking aim at C. C++ is the monster under the bed.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by pezo1919 on Saturday October 24, 2020 @12:21AM (#24876912)
Can you please elaborate on that? Both why not C and why C++ sounds really interesting.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by edsac_xyzw on Saturday October 24, 2020 @01:10PM (#24880492)
Hardly it will fully replace C++ due to the pervasiveness of the language on many domains and also due to the C++ ecosystem that encompasses system programming; embedded systems; games and so on. For instance, the C++ ecosystem still outmatches rust regarding high performance libraries for several scientific computing domains; GUI graphical user interface libraries, such as Qt, MFC, wxWidget; Game engines and so on. In addition, Rust lacks openMP feature which allows parallelizing for-loops, which are widespread on scientific computing, for taking advantage of multi-core CPUs and from SIMD.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by swsieber on Saturday October 24, 2020 @12:45AM (#24877020)
An outsider's perspective is that c and c++ are pretty similar except c++ is a little more ... powerful? More something for being a bigger language.

Rust is a bigger language.

There are other languages aiming to be small and a better c. Zig comes to mind.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by echelon on Saturday October 24, 2020 @12:58AM (#24877064)
C++ has a ton of baggage and is a very difficult language to use. There are too many language features and they all have years of warts.

Imagine PHP, but not memory safe. Mistakes cause segfaults, memory leaks, and can enable attackers write memory they shouldn't be able to access. To top it off, a lot of libraries are still written in "PHP4 style" and you've got to make use of them. C++ is really hard.

Both C and C++ require consideration of memory semantics, and they are both "hard" in this sense. You have to allocate and free memory deliberately and be conscious about what memory you're passing around. C is much simpler in design than C++. It doesn't have as many features, so it's harder to trip over. It doesn't necessarily make it easier to program, though.

Rust targets the same domains that C and C++ do: systems programing (operating systems and drivers), real time programming (robotics and control software), graphics and games, etc. These are places where explicit memory management is important. Rust does so while being much easier to write. The language leverages new programming language theory and design to protect memory from being written incorrectly. The memory semantics are baked into the language design and checked at compile time. Bad code (in terms of memory and async) simply doesn't compile.

Rust does this while being just as fast as C and C++.

In addition, Rust has a ton of modern features that make it feel like Ruby. Functional idioms, zero-cost abstractions, a modern trait-based type system, generics, macros, and a beautiful package manager and package ecosystem that is better than Ruby and npm.

Rust is going to beat both of these languages.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by tcoff91 on Saturday October 24, 2020 @03:24AM (#24877560)
IMO C++ despite its warts is easier to avoid mismanaging memory than C. RAII and smart pointers are very useful. Fewer off by one errors leading to buffer overflows as well in my experience due to things like iterators.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by papaf on Saturday October 24, 2020 @07:36AM (#24878542)
Rust is going to beat both of these languages.

I think looking at this as a battle is not helpful to understanding the situation. In order to supplant C/C++, Rust (and Rust programmers) will need to operate in harmony with the existing ecosystem for decades.

This interoperability means that Rust programmers will need to also be good C/C++ programmers. Its not a binary OR, its more like diffusion.

Just as an example, the primary (or earliest) use of Rust is in Firefox. But Firefox is still a C++ project.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by tikej on Saturday October 24, 2020 @12:53AM (#24877046)
Rust is bigger than C++?!

I mean i can hardly imagine any language being BIGGER (as in more language features) than C++ (except C++ 2030 standard ;)

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by AlphaSite on Saturday October 24, 2020 @04:06AM (#24877701)
You’ve obviously never looked at swift.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by pjmlp on Saturday October 24, 2020 @06:49AM (#24878332)
Only because it has a npm style library.

The biggest chunck of ISO C++ is describing the standard library.

Just wait Rust to get 40 years of language improvements, while you try to link 5 different epochs on the same executable.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by swsieber on Saturday October 24, 2020 @01:21AM (#24877151)
No, not bigger. Maybe same order of magnitude though.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by skohan on Saturday October 24, 2020 @01:10AM (#24877111)
They're actually pretty different. C is a very simple language - it's probably possible to learn most of the important parts in a few days. C++ is a super-set of C, but it adds a ton of complexity. For instance, C++ templating itself is turing complete.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by jjnoakes on Saturday October 24, 2020 @01:12AM (#24877114)
Friendly nit: c++ isn't strictly a super set of c, thought it is fairly close.
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by astro-codes on Saturday October 24, 2020 @03:17AM (#24877540)
Interesting! Could you explain? What C features doesn't C++ have?
Re:Rust-GPU: Making Rust a first-class language and ecosyste... by atq2119 on Saturday October 24, 2020 @04:28AM (#24877766)
- C has its own syntax for generics

- C has broader support for designated initializers

- C allows implicitly casting void* to any other pointer type

- C has fewer keywords, e.g. you can use "friend" or "class" as identifier

- ...

Despite all this, it's true enough that one can easily write C code that also compiles as C++.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by xondono on Saturday October 24, 2020 @04:53AM (#24877871)
- C has its own syntax for generics

C has generics?

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by kzrdude on Saturday October 24, 2020 @06:09AM (#24878163)
Nothing like C++ or Rust generics. C has _Generic (type-switch macro): https://en.cppreference.com/w/c/language/generic

Go into pointer qualifiers and const with _Generic and you'll see that it's a mess to do anything serious with it. But it's handy for type-generic math (tgmath.h style) and that's seems to be about it.

Re:Rust-GPU: Making Rust a first-class language and ecosyste... by zamalek on Saturday October 24, 2020 @01:53PM (#24880782)
C++ is vastly more complex, meaning that it should tend to have more footguns, and it definitely does.

Simplicity is a feature, and one that C++ aggressively avoids.