Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Precisely.

You can subset C++ and still knock out a program.

You cannot subset Rust and still create a program.





You can absolutely make a complete, featureful program in Rust without naming a single lifetime, or even without dealing with a single reference/borrow.

But Rust is a dramatically smaller language than C++. The various subsets of C++ people usually carve out tend to be focused on particular styles of programming, like “no exceptions” or “no RTTI”. Notably never things like “signed integer overflow is now defined”, or “std::launder() is now unnecessary”.


Discussions about Rust sometimes feel quite pointless because you can be several replies deep with someone before realising that actually they don't know much about the language and their strongly-held opinion is based on vibes.

Exactly. Claims like "even without dealing with a single reference/borrow."

When you have this stuff in "Hello World":

Egui Hello World:

    ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
Ratatui Hello World:

    fn render(frame: &mut Frame) {
or

  fn run(mut terminal: DefaultTerminal) -> Result<()> {
      loop {
          terminal.draw(render)?;
          if matches!(event::read()?, Event::Key(_)) {
              break Ok(());
          }
      }
  }
And I didn't even break out the function chaining, closure and associated lifetime stuff that pervades the Rust GUI libraries.

When I can contrast this to say, ImGui C++:

  ImGui::Text("Hello, world %d", 123);
  if (ImGui::Button("Save"))
      MySaveFunction();
  ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
  ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
which looks just slightly above C with classes.

This kind of blindness makes me wonder about what universe the people doing "Well Ackshually" about Rust live in.

Rust very much has an enormous learning curve and it cannot be subsetted to simplify it due to both the language and the extensive usage of libraries via Cargo.

It is what it is--and may or may not be a valid tradeoff. But failing to at least acknowledge that will simply make people wonder about the competence of the people asserting otherwise.


I don't get your examples.

The rust code you pasted doesn't show any lifetime.

The `&f` in your imgui example is equivalent to the `&mut age`.

Are you just comparing the syntax? It just take a couple of hours to learn the syntax by following a tutorial and that `&mut` in rust is the same as `&` in C, not to mention that the compiler error tell you to add the `mut` if it is missing.

Also 0..=120 is much more clear than passing to arguments 0.0f, 1.0f. it makes it obvious what it is while looking at the imgui call it isn't.


This seems like a very strange position, code written for Rust in 2015 still works, and in 2015 Rust just doesn't have const generics†, or async, or I/O safety, so... how is that not a subset of the language at it stands today ?

† As you're apparently a C++ programmer you would call these "Non-type template parameters"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: