News for hackers. Stuff that matters.
Re:A brief history of Rust at Facebook by fioawjpoifajio on Thursday April 29, 2021 @06:19PM (#26987522)
I've never thought of myself as a C++ dev (or a PHP dev, or Rust dev, or Haskell dev).

I write computer programs. I don't "invest" in a language and only take jobs that use that language.

Learning more languages is almost always good. Not because you're learning more languages, but because you're learning more modes of thinking which will apply to any future language you learn.

Re:A brief history of Rust at Facebook by howinteresting on Thursday April 29, 2021 @06:59PM (#26987891)
I agree in the abstract, but Rust is a step-function improvement compared to most other mainstream languages. It is hard to go back to writing, say, C or C++ once you have a few years of Rust experience—not because you've lost competence in them but because Rust offloads most of the complexity onto the compiler in a way that's simply not possible with older languages. You really start leaning on the affine types, the compile-time mutability xor aliasing checks, the pervasive checking of thread-safety...
Re:A brief history of Rust at Facebook by zozbot234 on Thursday April 29, 2021 @07:35PM (#26988182)
> It is hard to go back to writing, say, C or C++ once you have a few years of Rust experience ... You really start leaning on the affine types, the compile-time mutability xor aliasing checks, the pervasive checking of thread-safety...

C++ has semi-official Core Guidelines issued by prominent members of the ISO-WG21 standard committee, that describe how to express these things idiomatically. Of course Rust can actually check these things automatically and achieve something close to actual memory safety, but there are ways to at least make a meaningful effort in C++.

Re:A brief history of Rust at Facebook by imron on Thursday April 29, 2021 @08:40PM (#26988629)
The key part is "Rust offloads most of the complexity onto the compiler".

Yes you can make a meaningful effort in C++, but one of the great benefits of Rust is that effort is handled by the compiler instead.

Re:A brief history of Rust at Facebook by saagarjha on Thursday April 29, 2021 @09:43PM (#26989017)
The burden isn't all that great, as most good C++ code ends up looking like how you'd write the Rust code anyways.
Re:A brief history of Rust at Facebook by jcrites on Thursday April 29, 2021 @10:36PM (#26989327)
New C++ code that your team has written, sure. What about all the libraries that you integrate with, that all have different models for allocating/using/freeing buffers? Or system APIs? (At best for those you can build a wrapper layer, and the wrapper layer is subject to the same errors as C/C++ classically is.)

One of the things that struck me as a major advantage about Java and garbage collected languages is that you can simply combine code from different libraries without worrying about what's freeing the objects, because that's the GC's job. With Rust, the memory management model takes over this responsibility without runtime cost (or minimal cost -- perhaps freeing something from the heap, if you allocated it there, but definitely not GC).

With C++, unless the library that you're using is using the same smart point library as you, from the same language version, then aren't you stuck writing wrappers around the libs you want to use?

Types like std::async seem to have changed in every recent revision of C++ version (11, 17, 20). Can you reliably find multiple open source libraries that you could integrate into a codebase that uses futures and async/await?

(It's been a long time since I've done much C++ professionally. I'm asking skeptically but genuinely.)

Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @01:36AM (#26990117)
While true, I don't need to rewrite those libraries and can just use them rigth away, and this is why C++ keeps being my to-go language for native libraries, despite some of its flaws.

I can spend all my development budget on the problem instead sacrificing part of it to building an ecosystem.

Re:A brief history of Rust at Facebook by oblio on Friday April 30, 2021 @04:43AM (#26991114)
Yeah, but that's a losing race. Considering how much investment is happening with Rust right now (when Amazon, Facebook, Google, Microsoft, a ton of smaller companies are investing), Rust will become "good enough™" at some point.

I'd imagine that we're at most 3 years away from it having mature libraries for 99% of tasks you'd want to do as a professional developer.

Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @04:56AM (#26991187)
C++ has hardly replaced C in some domains after 40 years trying, and it is mostly compatible with C at source level, build exactly to fit into existing C toolchains.

Some of those companies, like Google, Microsoft and NVidia, are heavily invested into C++, ISO C++ and selling C++ based products.

To use a common example that one puts against any technology that Microsoft touches, when will Office use Rust on its foundation and extension APIs?

Are you aware that Apple has rather created their own safe C dialect for iBoot firmware instead of using Rust?

Re:A brief history of Rust at Facebook by oblio on Friday April 30, 2021 @06:33AM (#26991735)
A big company can push forward on many fronts in parallel :-)
Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @06:57AM (#26991881)
Indeed, as long as it makes sense in the long run.

If we can have Singularity/Midori back, with a microkernel in Rust, it would be quite nice, but yeah, I guess that is more of wishful thinking.

Re:A brief history of Rust at Facebook by imron on Thursday April 29, 2021 @11:42PM (#26989645)
Sure, they end up looking similar, but the point is that with C++ the developer carries the burden of making sure everything is correct and doesn't prevent you or other developers from breaking outside the bounds of what is "good" - either on purpose, or accidentally, e.g. when refactoring.

With Rust, the burden of checking all of that is shifted to the compiler, and that reduces cognitive load for the developer.

Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @01:37AM (#26990121)
While Rust is a big help regarding memory corruption errors, you still need to watch out for the remaining 30%.
Re:A brief history of Rust at Facebook by imron on Friday April 30, 2021 @06:23AM (#26991685)
Rust is not a panacea for all bugs, but making memory problems and data races a compile time problem rather than a runtime problem is a significant benefit.
Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @06:54AM (#26991863)
Indeed, and if that is what makes the industry rediscover Ada and Modula-2, more the better, however care need to be taken how it is sold, and also be understood this is going to take several decades.

Anyone that cares about memory safety for userspace applications has already moved on into other languages, the problem is the foundation and those that resist no matter what.

Also the data races prevented by Rust type system only apply to multihreaded code accessing in-memory data structures, there plenty of other data races in multiprocessing scenarios.

Re:A brief history of Rust at Facebook by imron on Friday April 30, 2021 @07:29AM (#26992075)
Your “only” clause captures the entire definition of data race - compared to the broader category of race conditions [0]

Safe rust prevents data races at compile time. It doesn’t prevent other race conditions.

And “only” preventing data races, is still a non-trivial achievement!

0: https://blog.regehr.org/archives/490

Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @11:01AM (#26994325)
No need for the exclamation point.

Yes it is a non-trivial achievement, just I get the feeling that the advocacy for it tends to forget about the other ones.

By the way, John Regehr's example won't work if the transferXXX functions are using SQL statements without transactions across threads each with its own connection, instead of in-memory variables.

Re:A brief history of Rust at Facebook by steveklabnik on Thursday April 29, 2021 @07:38PM (#26988201)
The Core Guidelines are great, but don’t attempt to go as far as Rust.
Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @01:52AM (#26990187)
Microsoft and Google are taking care it does.

I would watch the upcoming VC++ static analysis talk regarding its progress.

https://visualstudio.microsoft.com/de/pure-virtual-cpp-event...

Re:A brief history of Rust at Facebook by steveklabnik on Friday April 30, 2021 @10:11AM (#26993695)
I don’t know what specifically you mean by “it does” but if you mean “goes as far as Rust,” that’s simply not true. It’s never even been a goal of the project.
Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @10:57AM (#26994257)
Indeed, the goal has been to be as close as possible to Rust, given the constraints of C++ semantics.

Note I mean the work being done by Microsoft and Google on top of Core Guidelines on their syntac analysers, which on Microsoft's case are active by default as background process that validate your code as you type.

It will never be as good as Rust is able to, but in some domains a "worse is better" solution will already be better than nothing, because they aren't going to port their code to something else.

Re:A brief history of Rust at Facebook by tffgg on Friday April 30, 2021 @04:57AM (#26991193)
I have been following such efforts (esp. of MS) in C++ for years - progress is so slow. Feels like a slug that halfs it's speed regularly and thus will never arrive at the finish line
Re:A brief history of Rust at Facebook by pjmlp on Friday April 30, 2021 @05:47AM (#26991485)
Me too, however I am the opinion that I rather having something that improves the status quo than nothing at all, specially because there are millions of C and C++ lines of code that no matter what will never be rewritten.

I will consider Microsoft is fully into Rust when Azure Sphere supports Rust instead of being a C only SDK, despite its security marketing.

https://techcommunity.microsoft.com/t5/internet-of-things/de...

The first step in reducing those 70% is to actually use the tools that exist, but unfortunelly the macho attitute is still quite prevalent.

https://isocpp.org/files/papers/CppDevSurvey-2021-04-summary...

Those that are open to embrace Rust, are most likely already using static analyzers.

Re:A brief history of Rust at Facebook by Salgat on Thursday April 29, 2021 @09:40PM (#26988994)
Learning a language in depth along with its extensive standard library can buy you months or even years of expertise. This is especially true in languages like C++ (a language with massive depth, such as template metaprogramming) or C# (a language with a massive set of libraries, ASP.NET alone can take years to truly master).

This is what companies are paying big bucks for, immediate competency and productivity.

Re:A brief history of Rust at Facebook by oblio on Friday April 30, 2021 @04:39AM (#26991096)
The extensive standard library and the big libraries or frameworks that are the gold standards for their niches, in that language's ecosystem.

For example Hibernate for Java ORM, Spring as the big Java "LEGO brick bucket", Rail for Ruby web development, etc.

Re:A brief history of Rust at Facebook by jcrites on Thursday April 29, 2021 @10:31PM (#26989290)
If you ever need to work with PHP, use PHP/Hack developed by Facebook: https://hacklang.org/

It's a compiled language built partially in Rust, being rewritten entirely in Rust, JIT compiled using HHVM: https://hhvm.com/

I don't believe it's compatible with existing PHP codebases, but you could probably convert one over, catching safety issues while you did it.

Hack a modern and highly productive language that's in many ways as nearly sophisticated as Rust. (How many other languages have both opaque and transparent type aliases, for example? https://docs.hhvm.com/hack/types/type-aliases ). It has a mature async/await system, for another example. One feature it's missing is the macro system that Rust has, though.

Re:A brief history of Rust at Facebook by est31 on Thursday April 29, 2021 @06:24PM (#26987552)
I agree but many job postings contain stuff like "3+ years of professional experience in language x".
Re:A brief history of Rust at Facebook by azdle on Thursday April 29, 2021 @07:40PM (#26988221)
Honestly as someone (on the team) hiring for a job where someone else wrote the job posting, ignore the number. Just read that as "do you think you enjoy maintaining a codebase written in X".

Job postings are the fucking worst.

Re:A brief history of Rust at Facebook by abzug on Thursday April 29, 2021 @06:32PM (#26987621)
Yes but with time you gain experience in one or more languages and you can choose a job with the ones you like (or tolerate more). You don't need to pick or specialize one to apply for this kind of postings.
Re:A brief history of Rust at Facebook by void_mint on Friday April 30, 2021 @12:27AM (#26989824)
I've never actually found that to be enforced. None of my jobs have shared a tech stack, all of them have included such language. YMMV of course.
Re:A brief history of Rust at Facebook by oblio on Friday April 30, 2021 @04:41AM (#26991105)
They don't enforce the number of years, but they could ask you quite deep questions about the language.

Even if you're a senior Python/Javascript developer, with experience in C# in the past, etc., if they start grilling you about Ruby, you probably won't prove that you're as equally productive as a similarly smart dev that is an actual senior Ruby dev.

Re:A brief history of Rust at Facebook by void_mint on Friday April 30, 2021 @12:52PM (#26995969)
I think your statement implies that you and I do not agree at a very fundamental level.
Re:A brief history of Rust at Facebook by oblio on Friday April 30, 2021 @05:25PM (#26999563)
I'm saying that the world is a big place.
Re:A brief history of Rust at Facebook by gofreddygo on Thursday April 29, 2021 @07:38PM (#26988206)
> Learning more languages is almost always good

Learning for the sake of learning and betting on it for employment and professional use are very different beasts.