News for hackers. Stuff that matters.
Re:The struggle with Rust by rubber_duck on Tuesday January 24, 2017 @09:17AM (#13471432)
Yea that's what I see as an issue as well, I was hoping it wouldn't be but the deeper I go in to Rust the more it shows up. On one hand a really simple solution would be to make unsafe a first class citizen when it makes sense, this would let you avoid "pushing square pegs in to round holes" solutions when the borrow checker doesn't capture your problem nicely, and it would be trivial for C++ devs to get on board.

On the other hand this defeats the goal of the language - being as safe as possible - because their domain is very sensitive to memory safety issues (browser) - promoting an ecosystem of unsafe libraries wrapped in safe facades would be against their goals.

So I guess right now, because of it's design decisions, Rust isn't simply an upgrade to C++ which I want but more of a language that took different trade-offs to solve specific problems. It remains to be seen if it's worth taking those trade-offs to be rid of C++ legacy garbage.

Re:The struggle with Rust by pcwalton on Tuesday January 24, 2017 @11:33AM (#13472802)
> On one hand a really simple solution would be to make unsafe a first class citizen when it makes sense

I have pushed this several times in the past, but there's always been a lot of resistance to the idea. Though I've always phrased it as "let's allow the safety checks to be turned off", which isn't necessarily the best phrasing...

I wonder if it'd be better to just push to make unsafe easier to use: add sugar for ptr::offset, add a -> operator, relax the restrictions on casts, and so on. When I do OpenGL programming in Rust I drop into unsafe quite regularly, and it feels just like C, except for some annoying papercuts. It'd be nice to get rid of those papercuts.

Re:The struggle with Rust by AstralStorm on Wednesday January 25, 2017 @03:39AM (#13479783)
Or better extend the language to allow making code partially safe in many ways. This would make the wrappers much better.

Make it easy to reason about useful kinds of partial safety. Make it easier to define properties of external systems that Rust does not control.

Re:The struggle with Rust by pcwalton on Wednesday January 25, 2017 @04:26AM (#13479992)
Can you elaborate this into a concrete proposal?
Re:The struggle with Rust by zzzcpan on Tuesday January 24, 2017 @09:45AM (#13471642)
There might be an easy solution, they could provide more flexibility on using safety features, kind of like Perl did it, i.e. let anyone disable/enable a particular strict feature for a particular scope, for example "no borrowcheck;" or something. This will make it easier and more flexible for everyone, newcomers will be able to gradually learn more about the language and still get things done in the meantime, and power users will understand where satisfying the compiler is not worth it and will be more productive as a result without worrying about overly broad unsafe.
Re:The struggle with Rust by rubber_duck on Tuesday January 24, 2017 @10:00AM (#13471782)
They have that with the "unsafe" blocks but like I said promoting it as something you should use when things don't fit borrow-checker goes against their primary goal of making things safe. I guess there are two camps, one that wants compile time safety guarantees - those people made Rust, and the other wants a C++ replacement with modern tooling and no legacy garbage - those are looking at Rust and getting discouraged by safety trade offs they are paying but not really caring for - and every Rust tutorial I've seen focuses on hammering this aspect instead of going "OK here is the equivalent of this C++ code with unsafe code - you now get a sane build system, package manager, modules, fancy syntax. Now if you want here's how to make it safe."
Re:The struggle with Rust by vertex-four on Tuesday January 24, 2017 @10:11AM (#13471882)
You're almost certainly not looking for Rust if you don't want your language to prevent a vast variety of bugs, and instead want something that allows and encourages you to design systems which make it easy to shoot yourself in the foot (which all C++ codebases I've ever seen have grown). I don't think language developers are interested in making such a language in general, as it's not interesting - you'd just be rehashing ideas from multiple decades ago with new syntax, and not making anything particularly easier to do.
Re:The struggle with Rust by rubber_duck on Tuesday January 24, 2017 @10:35AM (#13472127)
>and not making anything particularly easier to do

Have you used C++ in the real world ? Dealt with it's insane build systems, build times, obscure semantics, etc. ? Not to mention there's nothing close to a sane package manager.

There's plenty of value of just rehashing the lessons learned in last 20 years of language design to a systems language.

Re:The struggle with Rust by shadowmint on Tuesday January 24, 2017 @11:03AM (#13472417)

    I don't think language developers are interested in making
    such a language in general...
https://inductive.no/jai/

:P

I'd argue go came from a desire to have a language that was completely uninteresting in terms of 'interesting ideas', and really just exists to Get Stuff Done.

I think more people are interested in that sort of thing than you imagine. Clearly.

Re:The struggle with Rust by AsyncAwait on Tuesday January 24, 2017 @12:28PM (#13473433)
Jai is designed on a bunch of false assumptions, which makes it hard to get excited about.

Or more precisely, the designer of Jai uses C++ as "C with classes" and then goes from that, which isn't fair. He also misrepresented a few things in regards to Rust, which he doesn't even know, but comments on etc. etc.

Re:The struggle with Rust by zzzcpan on Tuesday January 24, 2017 @10:12AM (#13471891)
As I understand it, you can't disable just borrow checker somewhere where you don't need it.
Re:The struggle with Rust by steveklabnik on Tuesday January 24, 2017 @12:03PM (#13473139)
It's subtle. Unsafe Rust is a superset of safe Rust; that is, all valid safe Rust code is valid unsafe Rust code.

  fn foo() {
      unsafe {
          let x = &5; // this is still going to get borrow checked
      }
  }
Since it's a superset, it gives you access to new tools, that don't interact with the borrow checker, rather than "turning the borrow checker off".

  fn foo() {
      unsafe {
          let x = *const 5; // this is not going to get borrow checked
      }
  }
Re:The struggle with Rust by dbaupp on Tuesday January 24, 2017 @02:52PM (#13474840)
(*const is not valid syntax: the way to not-borrow something is to coerce/cast it to an unsafe pointer within the statement, so that the borrow ends at the ;, e.g. give x an explicit raw pointer type in the first example.)
Re:The struggle with Rust by steveklabnik on Tuesday January 24, 2017 @03:09PM (#13474994)
gah, i always mess this up, haha