News for hackers. Stuff that matters.
Re:Rust: Enable WebAssembly backend by default by bluejekyll on Sunday November 26, 2017 @09:06AM (#15780930)
This makes me so excited! Great job to Alex and the entire team getting this done.

I know Rust is not the most perfect language for some. For me, it’s really exciting that there is finally a high level language which can scale for every potential use case.

Rust is great for kernels and the embedded space; Excels in the systems space; Is gaining traction in the native application space; Has great tooling for web backends; and, now, with WASM, it’s capable of targeting the web (Yes, without DOM access this is limited, but my understanding is that is coming at some point in the future).

Are there any other runtime free, memory safe languages that can target all of those use cases?

Re:Rust: Enable WebAssembly backend by default by verletx64 on Sunday November 26, 2017 @12:00PM (#15781755)
> Rust is great for the embedded space

Honestly, I would disagree here, unless we're talking in terms of potential, rather than actual ability right now. There's certainly some level of support, but I really did not get the feeling that Rust was 'great' for embedded, rather that it could be.

Re:Rust: Enable WebAssembly backend by default by bluejekyll on Sunday November 26, 2017 @12:03PM (#15781773)
> but I really did not get the feeling that Rust was 'great' for embedded, rather that it could be.

My experience is very limited here, but I have used TockOS on one of their dev boards. That was very pleasant, no stdlib makes it a little harder than std Rust, but still felt more deterministic than writing in C.

Re:Rust: Enable WebAssembly backend by default by verletx64 on Sunday November 26, 2017 @12:07PM (#15781804)
I was thinking a lot in terms of device support too, I guess. That's important to me; I know with C that I don't have to think too hard about which device, at least in terms of "Does this board support my language well".

It's probably even more important for professional embedded engineers, where the hardware decisions may not even be made by the software developers, for various reasons.

Re:Rust: Enable WebAssembly backend by default by bluejekyll on Sunday November 26, 2017 @12:21PM (#15781872)
Again, not speaking from experience here, but it should be easy enough using tools like https://docs.rs/bindgen/0.31.3/bindgen/ to generate FFI interfaces to C libs where that is needed.

So, I wouldn't necessarily say that's a blocker. Obviously everyone should make the best choice given their business requirements, etc.

Re:Rust: Enable WebAssembly backend by default by vvanders on Sunday November 26, 2017 @12:39PM (#15781989)
Yup, bindgen works great. It has a little problem with c macros but they're easy enough to redefine into a static constant to make them work.
Re:Rust: Enable WebAssembly backend by default by stmw on Sunday November 26, 2017 @12:19PM (#15781858)
Good point, although one advantage with Rust is that it plays well with C -- so you could keep some C drivers or libraries, and do the rest of the work in Rust. That reduces attack surface area while providing a smoother on-ramp to full device support.
Re:Rust: Enable WebAssembly backend by default by Const-me on Sunday November 26, 2017 @01:24PM (#15782227)
> one advantage with Rust is that it plays well with C

Advantage over what? This can be said about the majority of programming languages

For example, I’ve recently done an embedded ARM Linux project where I used C# and .NET Core for higher level parts, C++ for lower level, [DllImport] and C API between the two.

Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @01:29PM (#15782243)
You're considering the "call into C" case, which is only half the story. "C calls into you" will always be easier in C++ and Rust, or any other language with "no" runtime, than heavier languages that rely on them. Yes, it can work, but it's a disadvantage.
Re:Rust: Enable WebAssembly backend by default by Const-me on Sunday November 26, 2017 @01:56PM (#15782359)
In C# I use callbacks where I find appropriate (logging, also some rare events). Under the hood, the runtime marshals delegates (most languages would call them lambdas) into unmanaged C function pointers.

Ease of use is the same when I consuming the C API from e.g. C++. No disadvantage for C#.

Re:Rust: Enable WebAssembly backend by default by sinhpham on Sunday November 26, 2017 @02:16PM (#15782465)
"C calls into you" means you already have a C code base and now need to call your C# functions.
Re:Rust: Enable WebAssembly backend by default by Const-me on Sunday November 26, 2017 @02:35PM (#15782549)
Right, C# is OK when C code calls into it.

https://stackoverflow.com/a/5235549/126995

Re:Rust: Enable WebAssembly backend by default by int_19h on Monday November 27, 2017 @12:00AM (#15784960)
One neat trick with .NET on Windows, is that you can actually export static methods in assemblies as unmanaged entry points. In other words, things can LoadLibrary/GetProcAddress them, and invoke them as native.

C# doesn't support this out of the box, but it can be easily done by post-processing the generated assembly. There's a NuGet package for that.

https://www.nuget.org/packages/UnmanagedExports

I'm not sure if any of that works on other platforms, or with .NET Core. Probably not.

Re:Rust: Enable WebAssembly backend by default by Const-me on Monday November 27, 2017 @08:09AM (#15786978)
I once tried to use that trick, for nVidia optimus integration.

Didn’t work because that recompilation step broke debugger, and invalidated .PDB debug symbols.

Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @05:01PM (#15783278)
To be clear, I’m not saying it’s not possible. I’m saying that one less runtime is an advantage.
Re:Rust: Enable WebAssembly backend by default by stmw on Sunday November 26, 2017 @05:54PM (#15783562)
I actually think .Net runtime does a well above-average job with this - including clear declarations of managed and unmanaged code - so your ARM project sounds great & what I would expect. I just don't think it's true of "majority" of programming languages, at least if you count by number of users or HN popularity. We're both right.
Re:Rust: Enable WebAssembly backend by default by Const-me on Sunday November 26, 2017 @10:06PM (#15784529)
Besides C, C++ and .NET, I have some experience with Python, Perl, VB6 and VBA. All of them have some form of C interop reasonably easy to use.

I also have some experience with Java, JavaScript and PHP. They don’t.

Re:Rust: Enable WebAssembly backend by default by stmw on Sunday November 26, 2017 @11:48PM (#15784918)
You have seem Python, Perl or VB6/VBA being called from C code, in a seamless, high-performance way? I suppose it's all a matter of degree, rather than black-and-whites, and perhaps things have improved - but I'm just surprised.
Re:Rust: Enable WebAssembly backend by default by Const-me on Monday November 27, 2017 @08:06AM (#15786965)
A bit more complex than .NET, but only a bit.

Python: https://stackoverflow.com/a/33485103/126995

Basic: http://codingdomain.com/visualbasic/win32api/callback/

About the performance… Neither of these languages are particularly fast in the first place :-) But I don't see a reason why these callbacks might be too slow.

Re:Rust: Enable WebAssembly backend by default by koffiezet on Monday November 27, 2017 @08:48AM (#15787243)
Same, I have a number of devices here on my desk that will never get a Rust compiler targeting them. With C, it's simple, the "only" thing you have to worry about is what bugs or quirks the C compiler will have on that specific platform, not if there's a compiler at all.

Now I've left embedded development behind me for a while now, things are mostly Linux on relatively modern ARM in the field where I used to do stuff, so Rust would probably be an option there, but I still have a hard time considering them to be "embedded".

Re:Rust: Enable WebAssembly backend by default by ChickeNES on Monday November 27, 2017 @12:02AM (#15784967)
Agreed, I've been waiting 3+ years for first-class support for bit fields
Re:Rust: Enable WebAssembly backend by default by justincormack on Sunday November 26, 2017 @11:57AM (#15781736)
I think another contender here would be OCaml/Reason, which has both JavaScript and WebAsm targeting, is used in systems space (eg Mirage). Its a bit different in technical choices (functional, GC, for example). Facebook is using Reason for Messenger for example, on mobile.
Re:Rust: Enable WebAssembly backend by default by d215 on Sunday November 26, 2017 @12:16PM (#15781847)
Honest question, Is reason really targeting wasm right now? Do you know a resource describing this? I cannot find anything about this.
Re:Rust: Enable WebAssembly backend by default by k__ on Sunday November 26, 2017 @05:58PM (#15783578)
Re:Rust: Enable WebAssembly backend by default by stewbrew on Monday November 27, 2017 @12:47AM (#15785139)
Yes, but a byte code interpreter ported to wasm via emscripten != a compiler with a WASM backend.
Re:Rust: Enable WebAssembly backend by default by k__ on Monday November 27, 2017 @07:34AM (#15786822)
Isn't the stuff that comes out of the OCaml compiler byte code?

As far as I can tell, OCaml has a GC and WASM (at the moment) doesn't so this seems like the only viable solution to me.

Re:Rust: Enable WebAssembly backend by default by colanderman on Monday November 27, 2017 @11:29AM (#15788508)
OCaml also has a native x86 backend, which produces quite efficient code.
Re:Rust: Enable WebAssembly backend by default by rlp on Sunday November 26, 2017 @03:54PM (#15782934)
I couldn't find anything on this either. The assembly emitters in their repo don't suggest a WASM backend: https://github.com/ocaml/ocaml/tree/trunk/asmcomp
Re:Rust: Enable WebAssembly backend by default by bad_user on Sunday November 26, 2017 @12:40PM (#15781998)
AFAIK Reason is a frontend for OCaml and can target whatever OCaml can target. Note that for targeting JavaScript they are using BuckleScript, an OCaml backend that's not built by Facebook.
Re:Rust: Enable WebAssembly backend by default by smt88 on Sunday November 26, 2017 @04:36PM (#15783138)
I consider Rust to be functional, although people would dispute that, I'm sure. GC is a huge difference though.
Re:Rust: Enable WebAssembly backend by default by yen223 on Sunday November 26, 2017 @07:15PM (#15783879)
Rust doesn't have great support for function composition or partial application, both of which I think are essential to be considered a "functional" language.

Others will have different opinions for sure, and that's fine.

Re:Rust: Enable WebAssembly backend by default by idibidiart on Sunday November 26, 2017 @12:22PM (#15781881)
Any links to instructions for Reason WASM targeting?
Re:Rust: Enable WebAssembly backend by default by k__ on Sunday November 26, 2017 @05:58PM (#15783586)
Re:Rust: Enable WebAssembly backend by default by shams93 on Sunday November 26, 2017 @04:58PM (#15783262)
There is a project TrueBit is working on for ocaml and wasm integration.
Re:Rust: Enable WebAssembly backend by default by tyingq on Sunday November 26, 2017 @09:51AM (#15781093)
"Rust is great for kernels and the embedded space"

I'm no expert, but from a layperson's perspective, the rust usage in these areas depends on a lot of "unsafe" blocks, fighting the borrow checker, etc.

Does that ratchet it down from "great" for this space to something like "ok" or "usable"?

Or is this just the best we can do in terms of a memory safe language for kernel and/or bare metal embedded?

Re:Rust: Enable WebAssembly backend by default by geofft on Sunday November 26, 2017 @10:01AM (#15781130)
The point of unsafe blocks is to contain unsafety. In a language like C, the natural pattern is to expose raw pointers through the entire codebase and document how to use them correctly, when they can be mutated, who's responsible for freeing them, etc. In Rust, the natural pattern is to implement wrapper types and other abstractions that themselves make heavy use of unsafe blocks but whose APIs are safe.

This isn't unique to kernels. The standard heap-allocated vector type in Rust (on which the standard string type is based) is full of unsafe blocks: https://doc.rust-lang.org/src/alloc/vec.rs.html The problem of implementing a heap-allocated vector, with some elements uninitialized but available for use and with the ability to reallocate the entire vector and copy the members, is not a problem that lends itself well to the borrow checker's view of the world, so raw pointers are a fine way to solve it. Use of vectors themselves, their iterators, references to items in the vectors, etc. does match the borrow checker's view of the world, so the average Rust program running in userspace doesn't have to care that the standard library itself isn't implemented in safe Rust.

So copious usage of the "unsafe" keyword in a codebase can be a sign that the code as a whole is more safe: instead of having large portions of the code be unsafe (or instead of having the code pretend it's containing unsafety when it's not), only the parts that need raw memory access use it, and they maintain invariants used by the rest of the code.

It is certainly possible to do better - there are no machine-checked proofs that unsafe code does what it claims and upholds the invariants it claims to uphold. There could be, and I'm really interested to see what people do with languages that lend themselves better to proofs (usually dependently-typed, Turing-incomplete-but-very-powerful languages). But right now the state of the art is that such languages are a pain to use and writing proofs is even more of a pain. I think that's where the compromise is right now. The borrow checker is, arguably, a system for proving things about your code; it just only knows how to prove specific things. (Way more than C's type system proves, but way less than you'd prove in a perfect world.)

Re:Rust: Enable WebAssembly backend by default by kzrdude on Sunday November 26, 2017 @11:09AM (#15781494)
This is a teaser / preview and not necessarily what is going to come. But Rust could evolve to providing checks like this:

https://i.imgur.com/oqtEDoV.png

From miri, page 27 in their slide deck. The miri project has changed a lot since the slides were written — and it is now close to being merged into rustc.

miri: https://github.com/solson/miri

Re:Rust: Enable WebAssembly backend by default by Animats on Sunday November 26, 2017 @02:07PM (#15782420)
The usual problem in C is ambiguity over "how big is it", the cause of most buffer overflows. Rust tries to contain that, but doesn't solve the problem at the language level. Part of the trouble is that there's no way to talk about uninitialized memory in Rust. If you implement something like a growable array (rust calls this a "Vector", a poorly chosen name), it has space in use and space that's uninitialized and unused. There's no way to express that concept within the language. If you had a way in Rust to say that only elements 0..N are initialized, and only they can be accessed, you could express that situation. Initializing another slot means more elements are now initialized. This is run-time checkable with some overhead.

Once you can say that, you can prove it. The proof techniques are well known. The first step is to be able to talk about it within the language. A predicate like

    initialized(A,i,j)
meaning that array A is initialized from elements i to j inclusive is all that's needed. Then, when you write

    assert(initialized(A,i,j));
    A[j+1] = 0;
    assert(initialized(A,i,j+1);
you've expressed how much of the array is now initialized. Then automatic theorem proving takes over and proves that if the first assert is true, so is the second.

This eliminates the need for "unsafe" in many places. A fancier type system is not needed.

It only takes one wrong piece of unsafe code to enable a buffer overflow attack.

Re:Rust: Enable WebAssembly backend by default by Jweb_Guru on Monday November 27, 2017 @01:14AM (#15785251)
I work on proving things about unsafe Rust for my day job, and you really don't know what you're talking about if you think what you're proposing would be remotely sufficient to guarantee safety in a modern systems language. I'm not saying a way to deal with uninitialized data would not help, but that is not the primary source of potential unsafety in Rust, and it's completely infeasible for the language to include all the features that would be required to prove all unsafe Rust code safe (at least, given what we know now--if you have ideas about weak memory that I'm not aware of, feel free to ping me!). However, it is possible to do machine-checked proofs about unsafe Rust, and once those proofs are done, they remain valid forever, so I'd prefer the current approach (which is to verify the standard library and some major third party ones, and make the tooling for proving correctness of other Rust libraries as easy as possible).
Re:Rust: Enable WebAssembly backend by default by Animats on Monday November 27, 2017 @07:58PM (#15793321)
Of course it's not sufficient. It does make possible to talk about partially initialized arrays, which is a necessary step to checking their access, either at run time or by formal methods.

The "Weak" problem is mostly a back-pointer problem. If you had some way to talk about a back pointer locked in an invariant relationship with a forward pointer, that would deal with back pointers for trees and such. I sketched out a solution for this on YC earlier this year.[1] This doesn't deal with true circular lists, but those are relatively rare; people tend to use arrays for that today.

It's good to hear this criticized from someone who does program proving. I used to do that, a long time ago. What I usually get from the Rust crowd is macho assertion that they don't need checking of their unsafe code. History and the CERT archives indicate they do.

[1] https://news.ycombinator.com/item?id=14302823

Re:Rust: Enable WebAssembly backend by default by Jweb_Guru on Tuesday November 28, 2017 @03:39PM (#15801278)
Weak memory isn't related to weak pointers. What you're referring to is actually pretty easy to deal with (well, not easy, it's pretty tedious to prove in most of the individual cases, but it's not conceptually difficult). Weak memory refers to atomic operations with weak consistency (like relaxed, release-acquire, and perhaps most confoundingly consume). Modeling them along with lifetimes and ownership tracking requires a fairly sophisticated language model with lots of intermediate tokens and ghost state, which would be a tremendous burden to include in a programming language. Fortunately, it looks like most features of safe Rust extend straightforwardly to weak memory models, but that isn't always the case for unsafe Rust.
Re:Rust: Enable WebAssembly backend by default by viraptor on Sunday November 26, 2017 @03:45PM (#15782882)
> Part of the trouble is that there's no way to talk about uninitialized memory in Rust.

You mentioned Vec right after that. Which is interesting, because Vec deals with uninitialized memory just fine. https://doc.rust-lang.org/std/vec/struct.Vec.html#method.res... allocates more space, but doesn't allow you to read it unless you explicitly add elements.

> It only takes one wrong piece of unsafe code to enable a buffer overflow attack.

Isn't that the case for every language? Here, you can limit the unsafe bit to the underlying datastructure if any unsafe actions are required. Maybe Vec uses some unsafe bits, maybe not - but the usage of it is all safe code.

Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Sunday November 26, 2017 @04:52PM (#15783238)
In many other languages `unsafe` taints the block of code it is in, which propagates upwards. Rust is the other way around, where `unsafe` means "I'm doing something unsafe here, but let's not tell anyone who doesn't look". It can be a lot harder in Rust (than other languages I've used) to know whose code you have to trust: language implementors (probably ok) or random crates (urk).
Re:Rust: Enable WebAssembly backend by default by ben-schaaf on Sunday November 26, 2017 @05:04PM (#15783301)
Could you give some examples of these other languages? My only exposure to a similar feature is D's @safe/@trusted, where if you're writing @safe code, you'll always wrap unsafe code with @trusted stopping any propagation.
Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Sunday November 26, 2017 @05:32PM (#15783459)
C#
Re:Rust: Enable WebAssembly backend by default by viraptor on Sunday November 26, 2017 @06:42PM (#15783747)
C# has both unsafe blocks and unsafe methods. The behaviour is the same as in Rust. (Unsafe function can be called only from unsafe scope and safe functions can contain unsafe blocks)
Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Sunday November 26, 2017 @08:40PM (#15784215)
I don't think you are correct, unless the language has changed substantially.

https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...

Among other things, you need to opt in to unsafe with the `/unsafe` compiler flag. I'm pretty much 100% certain that the `unsafe` keyword applied to scopes does not mean "treat the contained scope as if it were safe, but permit the use of unsafe operators" which is how it works in Rust.

Edit: to put some more words here, I think what you may be saying is "the unsafe fragment of C# behaves like Rust", which sounds sane to me: `unsafe` decorates regions and the compiler will complain at you if you use unsafe things outside such scopes. When I said "C#" I meant the larger language in which programs are either "safe" (verifiable) or not, and for which `unsafe { .. }` forces you into the unsafe fragment.

Rust doesn't have safe and unsafe language fragments; there is one language which follows rules similar to (as you say) unsafe C#, but which advertises itself as safe. In that language, `unsafe` moves you back in to "safe" code (or we could agree that it was never safe in the same sense that languages like C# are).

Re:Rust: Enable WebAssembly backend by default by int_19h on Monday November 27, 2017 @12:04AM (#15784979)
You're wrong, and that's exactly what "unsafe" block does in C# - it does not affect the outer blocks. So, for example, if you wrap your pointer arithmetic inside "unsafe", you don't need the "unsafe" modifier on the method. If you put the modifier on the method, then you don't need the modifier on the class. And the code that uses your "unsafe" classes and methods doesn't need to be in "unsafe" context.

If it were otherwise, no C# program would compile without "unsafe", because large parts of the standard library core (stuff in System) is unsafe. The only reason why "unsafe" is useful is precisely because it lets you isolate unsafe operations in a way that lets safe code invoke into them (assuming that you uphold your safety guarantees).

The /unsafe switch is a different thing - it needs to be turned out for the C# compiler to allow "unsafe" anywhere in its input, and is basically a project-level declaration that "this has some unsafe code somewhere in it".

Re:Rust: Enable WebAssembly backend by default by pjmlp on Monday November 27, 2017 @02:22AM (#15785469)
Sure it does, Assemblies with unsafe code are tainted and fail verification.

There are deployment scenarios, like IIS, where admins can disable the execution/loading of Assemblies with unsafe code.

Re:Rust: Enable WebAssembly backend by default by int_19h on Monday November 27, 2017 @03:06AM (#15785618)
"unsafe" is a C# feature. Verification is a CLR feature. And they are only related in a sense that things that you can do inside "unsafe" blogs generally produce unverifiable assemblies. But the reverse is not true, you don't have to use an "unsafe" block to consume an unverifiable assembly.

Nor does "unsafe" breaks verification by itself - it's only the specific features that you might use inside (like pointer arithmetic) that would do so, and even then not all of them. For example, C# requires "unsafe" for any use of sizeof() that is not known at compile-time, and for which it needs to emit the sizeof IL opcode. So e.g. sizeof(int) is okay, but sizeof(IntPtr) is unsafe; also, sizeof all structs are considered unsafe. However, the IL opcode for sizeof is not unverifiable, and so such an assembly would pass verification, despite requiring "unsafe" in C#.

Re:Rust: Enable WebAssembly backend by default by pjmlp on Monday November 27, 2017 @03:58AM (#15785827)
I know that, but unless one wants to become a MSIL and verification engine expert, the simplest explanation is that unsafe taints Assemblies.
Re:Rust: Enable WebAssembly backend by default by int_19h on Monday November 27, 2017 @03:19PM (#15790829)
Yes, but that's not what OP was talking about. Within an assembly, an unsafe block still doesn't taint any code that calls into it. And between assemblies, an unsafe assembly doesn't taint a safe one that depends on it. So it doesn't "propagate outwards".
Re:Rust: Enable WebAssembly backend by default by TheDong on Sunday November 26, 2017 @02:56PM (#15782655)
> The usual problem in C is ambiguity over "how big is it", the cause of most buffer overflows

Buffer overflows in C are caused by accessing uninitialized memory, regardless of why the program does it (how big is it vs null pointer derefs vs various other ways).

Rust does solve that problem at the language level. There's no such thing as an uninitialized pointer, which is the only right solution I'd argue. If you do access out-of-bounds in a safe block, you panic, not cause a vulnerability. How is the problem not solved by this, combined with iterators?

What you're talking about, tracking uninitialized/initialized at runtime, can totally be done in rust too, e.g. with a [Option<T>] or such... but then you'll obviously pay the runtime price of doing such checking.

The more common case though is someone wishes to have a mutable vector which has a capacity and an accessible subset of data, which Vec implements.

What you're claiming can be proven easily is not so trivial to prove for the common case; it may be `j+n` where `n` may derive from user input.

It would be cool if blocks of rust now could be "theorem-proved-unsafe", but I think realistically it's a huge amount of work for a small win.

Writing and proving theorems about code is typically much more time-consuming than exhaustively testing or informally verifying a block of code via review, and when the unsafe code is small and simple enough, the results we get are already "good enough".

> It only takes one wrong piece of unsafe code to enable a buffer overflow attack.

Yup, though for many programs you can entirely avoid unsafe code (outside of the well-reviewed and well-tested stdlib), and you can pay special attention to unsafe code in review and testing.

That's a damn sight better than other low level non-gc'd languages like C++/C where the default is unsafe and all code is suspect.

Re:Rust: Enable WebAssembly backend by default by andrewflnr on Sunday November 26, 2017 @04:23PM (#15783066)
Ah, no, buffer overflows are caused by failure to check bounds. Practically, this is usually only a serious problem when the buffer overflows into an area that has been initialized with something like a return address.
Re:Rust: Enable WebAssembly backend by default by Tade0 on Sunday November 26, 2017 @02:52PM (#15782629)
> (rust calls this a "Vector", a poorly chosen name),

What exactly makes it "poorly chosen"?

Re:Rust: Enable WebAssembly backend by default by jacobolus on Sunday November 26, 2017 @04:18PM (#15783037)
I think it’s based on the C++ name? (a name which Stepanov supposedly now regrets, https://stackoverflow.com/questions/581426/why-is-a-c-vector...)

But it disagrees with all past use of the name “vector” in mathematics and numerical computing, which is reasonably consistent and well defined and dates from the mid-19th century.

Re:Rust: Enable WebAssembly backend by default by gpm on Sunday November 26, 2017 @04:53PM (#15783245)
I think it agrees pretty well with the mathematical definition, it's just a slight generalization.

A Rust (C++, etc) Vec<T> of length n where T implements addition and multiplication in a way that satisfies field laws is the "reasonable" representation of a n length "mathematical" vector over the field T. It just generalizes that storage type to situations where T is not a field.

It doesn't support addition of two vectors and multiplication by a element of T using the normal mathematical syntax, but that's a fairly reasonable choice given how we regularly use vectors as a sequence of independent numbers and the different priorities for math syntax and programming language syntax.

Re:Rust: Enable WebAssembly backend by default by jholman on Sunday November 26, 2017 @08:47PM (#15784244)
What makes a C++/Rust/etc vector distinct from an array is that it's resizable. That is its defining property.

On the other hand, a mathematical vector is not a resizable thing: a vector in R² is of a fundamentally different type from a vector in R³.

A type named "vector" should be more like Vec<T, n> for some type T and some integer n. Failing that, the reasonable representation of an n-length mathematical vector, in C++/whatever, is an array.

Re:Rust: Enable WebAssembly backend by default by gpm on Monday November 27, 2017 @08:50AM (#15787257)
The whole idea of mutation is not common in mathematics, so of course mathematical vectors don't commonly resize.

The idea of appending an element to make a new vector is however extremely common, particularly in induction like proofs.

Vec<T, n> is in a sense already what we have, it's just that we are not capable of storing the n in the type information^0 so we store it at runtime.

^0 For a number of reasons. n can change with mutation while types can't. We don't necessarily know n ahead of time when building a vector (which happens in math too) but we have to know types at compile time. And we just don't have a great way of storing numbers in types in Rust anyways.

Re:Rust: Enable WebAssembly backend by default by kccqzy on Sunday November 26, 2017 @05:58PM (#15783584)
Just to clarify, a vector space is defined over a field but vectors themselves do not form a field.

Also more importantly in mathematics vectors aren’t really growable. When you change the number of elements you change the dimension (and thus the “type” for that vector). It is then ill-defined to add two vectors of different dimensions.

Re:Rust: Enable WebAssembly backend by default by azernik on Sunday November 26, 2017 @05:15PM (#15783368)
This is quite standard in the functional programming world; Common LISP, Scala, and Haskell all use "vector" to refer to (usually growable) contiguous-memory arrays with efficient random access, as opposed to "lists" with efficient append and prepend but inefficient random access.
Re:Rust: Enable WebAssembly backend by default by kccqzy on Sunday November 26, 2017 @06:03PM (#15783607)
I might be nitpicking but in Haskell and typical lisps “lists” don’t have efficient append. They are basically singly linked lists. A structure with efficient append and prepend (sometimes called a deque) is implemented as a finger tree in Haskell (with logarithmic random access), and as a vector of arrays in C++ (constant random access).
Re:Rust: Enable WebAssembly backend by default by azernik on Monday November 27, 2017 @08:08AM (#15786970)
Good point. Sometimes efficient append, but usually just efficient prepend ^_^
Re:Rust: Enable WebAssembly backend by default by jeffdavis on Sunday November 26, 2017 @03:05PM (#15782700)
I think it's wrong to say that unsafe blocks "contain" the unsafety. Unsafety can't really be contained once it's there -- that's what makes it unsafe.

The advantage is that you should be able to write application code without unsafe blocks; they should be in a library. And the library has a contract: if unsafe behavior does leak outside the library, it is clearly the fault of the library, and can't be blamed on the (safe) caller.

Re:Rust: Enable WebAssembly backend by default by TheDong on Sunday November 26, 2017 @03:08PM (#15782715)
Unsafe blocks "contain the possible sources of unsafety" may be a more correct way to phrase it.

It is better to know that only a specific subset of the codebase could be responsible for memory unsafety even if that behavior may leak. If nothing else, it helps focus reviewing and testing effort.

Re:Rust: Enable WebAssembly backend by default by burntsushi on Sunday November 26, 2017 @03:20PM (#15782768)
I'm pretty sure y'all are saying the same thing. :-) my favorite way of describing it is "Rust lets you build safe abstractions, even if its core uses unsafe."
Re:Rust: Enable WebAssembly backend by default by tyingq on Sunday November 26, 2017 @10:38AM (#15781315)
Terrific, in-depth, answer...and I appreciate it.
Re:Rust: Enable WebAssembly backend by default by javajosh on Sunday November 26, 2017 @10:48AM (#15781365)
A really nice answer. It's too bad, I suppose, that the same abstraction can't be used "all the way down". I suppose then we'd be stuck with some high-level encoding of the chip's ISA, perhaps generalized to allow the programmer the ability to define new instructions, and an increased number of registers, etc.
Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @10:04AM (#15781141)
You'd be surprised at how little unsafe you need. Consider https://os.phil-opp.com/page-tables/ for example, it uses the type system effectively to eliminate some issues, in the end, it only has two calls to unsafe.

On some level, yes, it's the best we can do. Unless you want to add hardware semantics into your language. Unless you do, writing two bytes to 0xB8000 is going to be an arbitrary memory access. At least, that's my take.

Re:Rust: Enable WebAssembly backend by default by zaarn on Monday November 27, 2017 @03:36AM (#15785746)
As someone who was worked with this page and develops a rust kernel, I have to disagree.

The two places of unsafe are barely just the minimum.

When interacting with UEFI you have to include a bunch more unsafe clauses since you'll be FFI'ing to PE-calling convention C code to wrap the UEFI methods. You'll have to allocate memory without being able to malloc which means passing a raw memory block, allocate in C, to rust and tell the frame allocator to use that.

Setting up a syscall is unsafe, you have to use a naked function with internal unsafeness and the entire construct is unsafe because a syscall can easily crash the system if it doesn't return properly.

You will have to dereference null pointers because on kernel level a null pointer is a valid address (my UEFI places a memory region at 0x00 for about 30 pages which is a great starting region) unless you waste a buffer region. But Rust and LLVM don't allow that safely at all.

The very nature of a kernel is unsafe. It has to do very unsafe things in an unsafe way to enable software running in Ring 3 to make safe assumptions about it's environment as long as it gets scheduled.

Of course, Rust is somewhat better than C since it's type system allows one to express things without the entire construct blowing up every 2 minutes unless you're developing a kernel for years.

Re:Rust: Enable WebAssembly backend by default by steveklabnik on Monday November 27, 2017 @07:17AM (#15786742)
> The two places of unsafe are barely just the minimum.

Yes, this is only one subsystem. Obviously, as you say, there are more than that in a realer kernel. But even larger ones have still shown that the vast majority of their stuff works in safe code.

> Setting up a syscall is unsafe

Fun detail, this isn't unsafe anymore on x86! You don't need naked functions; you can

  extern "x86-interrupt" fn some_handler()
and LLVM knows how to properly do the codegen! This is kinda emblematic of what I mean: you can do more with safe code than you'd think.
Re:Rust: Enable WebAssembly backend by default by zaarn on Monday November 27, 2017 @07:51AM (#15786892)
>Fun detail, this isn't unsafe anymore on x86!

On x86, not x86-64, which has the syscall instruction, replacing interrupts for syscalls (technically x86 had sysenter)

The syscall instruction requires writing the address of the syscall function into the LSTAR MSR. Additionally, the syscall entry is purely naked, only the EIP and Segments are preserved and in a way that requires the caller to handle it.

Sysret is also particularly nasty in being unsafe in various ways, including being buggy on all Intel CPUs.

Atleast it's faster than interrupts and you don't technically need the -mno-redzone for it if it's not part of your interrupt handling code.

Re:Rust: Enable WebAssembly backend by default by cwzwarich on Sunday November 26, 2017 @01:24PM (#15782223)
> Consider https://os.phil-opp.com/page-tables/ for example, it uses the type system effectively to eliminate some issues, in the end, it only has two calls to unsafe.

However, those two calls to unsafe rely on an invariant maintained by the rest of the code that is not marked unsafe. Effectively, the entire module has to be treated as unsafe code by the programmer.

Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @01:27PM (#15782238)
Yes, absolutely. It's still a far cry from what many people assume, which is that the whole shebang must be.
Re:Rust: Enable WebAssembly backend by default by andrewflnr on Sunday November 26, 2017 @04:29PM (#15783101)
No, that's sort of the problem, isn't it? Safety actually does depend on the whole shebang, or rather, the correctness of all the code that supplies inputs to the "unsafe" block. I think safety has to be thought about at level of the unit of code that can enforce its own invariants, rather than the specific syntax that does the dirty work.
Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @04:38PM (#15783147)
Safety depends on any module containing unsafe code upholding the invariants that are required. But once you've done that, it's safe.

The question is, how much code is in this state, vs being purely safe? My experience and that of others shows that it's generally a smaller amount than many people not experienced with Rust assume.

Basically, I find the "there's always unsafe code somewhere at the bottom and therefore it's the same as 100% unsafe" to be overly reductive.

Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Sunday November 26, 2017 @05:12PM (#15783349)
> Basically, I find the "there's always unsafe code somewhere at the bottom and therefore it's the same as 100% unsafe" to be overly reductive.

I totally agree; it's not the same. However, I think there is disagreement about whether saying only "there's always unsafe code somewhere at the bottom" is better or worse than saying "it's 100% unsafe".

I tend to write some sketchy unsafe code, and the only thing I can say with a straight face is "please don't use this if you care about safety", i.e. treat it as if "it's 100% unsafe". I'm slightly weirded out that Rust has a keyword that amounts to "I understand UB really well; tell others to trust me on it transitively".

I'll be less weirded out when the UB story gets shaken out more, or if cargo gets an "audit-unsafe" option that shows you all unsafe blocks you transitively depend on (does that exist yet?). Still like Rust, but letting randoms write unsafe code is scary.

Re:Rust: Enable WebAssembly backend by default by pcwalton on Sunday November 26, 2017 @08:41PM (#15784218)
> However, I think there is disagreement about whether saying only "there's always unsafe code somewhere at the bottom" is better or worse than saying "it's 100% unsafe".

Are you saying that Rust doesn't have a better memory safety story than C++? In practice, that hasn't been our experience.

Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Sunday November 26, 2017 @09:50PM (#15784477)
I would say that Rust has a different memory safety story from say C#, which distinguishes between "is safe" and "contains unsafe code outside the CLR itself". I find that very-binary distinction more helpful than Rust's memory safety story.

I don't use C++ anymore, but I am not clear on how Rust has better memory safety guarantees than C++. I do like its story more, for sure, and I could see how they might turn in to guarantees (but I could also believe that someone could identify a similarly safe fragment of modern C++, and don't want to start that).

Edit: will rust-lang.org take a PR changing "guaranteed memory safety" to "memory safety story"? ;)

Re:Rust: Enable WebAssembly backend by default by burntsushi on Monday November 27, 2017 @08:14AM (#15787011)
> Edit: will rust-lang.org take a PR changing "guaranteed memory safety" to "memory safety story"? ;)

I hope not. The value proposition of Rust is that if you stick to writing code without unsafe, then you have a guarantee that you will not fall victim to memory unsafety unless there is a bug in the language or in some unsafe block in a dependency you're using.

Personally, I find your quibbling in this thread pretty strange. Rust very clearly provides more memory safety guarantees than C++. For starters, you could not take the guarantee I just stated above and apply it to C++ because there is no such thing as "C++ without unsafe blocks."

Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Monday November 27, 2017 @09:22AM (#15787506)
I really don't have a position on C++; I don't use it, and don't really want to make supportive or limiting statements.

I have used other memory safe languages, and I find their guarantees qualitatively different from Rust. I would say of them "you will not fall victim to memory unsafety unless there is a bug in the language or in the standard library" with no mention of other dependencies. The standard library is then fairly thoroughly audited.

By comparison, you have e.g. the `memmap` crate, which I like and use, written by serious people known to you, where `unsafe` is used in construction of the memory map. It is then on the user to ensure that there are no concurrent writes to the backing file for the lifetime of the map, at the risk of (as I understand it) UB. Would you describe such a program as "safe"? Or at least, can you understand why I might not? If a concurrent modification happens, is the bug to be found in the `unsafe { MmapMut::map_mut(&file)? }` block, or perhaps farther away where you safely open and modify the file before dropping the map?

I'm sorry if this comes off as quibbling; I do actually care about getting these things right, as I want to rely on them and do more interesting things (e.g. de-abomonate mapped memory).

Re:Rust: Enable WebAssembly backend by default by pcwalton on Monday November 27, 2017 @12:04PM (#15788865)
C# has unsafe blocks just like Rust does. Likewise, Java has sun.misc.Unsafe. Python has ctypes. How is that different from Rust?
Re:Rust: Enable WebAssembly backend by default by frankmcsherry on Monday November 27, 2017 @01:01PM (#15789429)
HN wants me to stop posting, so this will be the last one. You two know how to find me elsewhere.

What I should have written is: "you will not fall victim to memory unsafety unless there is a bug in the language or in the standard library, or you explicitly opt out of safety". Using `unsafe` in C# is opting out of its safety guarantees (and requires the `/unsafe` flag); I'm pretty sure none of the C# team would say "guaranteed memory safety" of unsafe C#. I expect the same is true of Java, and have no clue about Python.

To the extent that we are talking about unsafe C#, I think you are right; it's mostly the same as Rust. But, no one would claim that unsafe C# has "guaranteed memory safety" where the guarantee is "as long as your code and all the code you bring in don't have memory safety bugs". At least, I hope not.

My original point was just meant to be that there is the risk of harm when you try and quantify a language as "more safe" because there are fewer regions where unsafe operations are permitted. People might read "guaranteed memory safety" and misunderstand what it means, as evidenced by me not actually knowing what it means.

Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @06:18PM (#15783657)
There is some tooling but not a ton. Check out the Miri link elsewhere in the thred; eventually I expect us to have amazing tools here. It’s gonna take some time though.
Re:Rust: Enable WebAssembly backend by default by andrewflnr on Sunday November 26, 2017 @07:19PM (#15783892)
Woops, I think I misunderstood the context and repeated what you were already saying. I have become that which I hate. :(
Re:Rust: Enable WebAssembly backend by default by cwzwarich on Sunday November 26, 2017 @01:34PM (#15782263)
For kernel-level programming, I think Rust is basically the same as C or C++ in this regard. I haven't seen a kernel written in Rust where I am convinced there is a submodule that can be treated as if its correctness doesn't impact the safety of the entire kernel.
Re:Rust: Enable WebAssembly backend by default by TheDong on Sunday November 26, 2017 @03:17PM (#15782759)
I don't understand this argument at all.

"Rust is not perfect, so it's basically the same as C"

The fact that "american fuzzy lop" and "syzkaller" have gone through the kernel and found dozens of use-after-free's (see https://github.com/google/syzkaller/blob/4bd70f/docs/linux/f...), shows that even incredibly carefully programmed C messes up in totally rote ways.

The basic cleanup code which is able to be exploited here would not be in an unsafe block if this were rust. In fact, because rust abstracts memory management out better, most of the cleanup code wouldn't exist at all.

Rust also allows better abstractions. For example, Rc<T> in rust is much easier to use without screwing up than the manually handled reference counters littered throughout the kernel. It seems obvious to me that numerous deadlocks in the kernel could be avoided by not hand-rolling refcounting everywhere.

You're right that there's still the potential with rust for some code to compromise the safety of the entire kernel.

But with rust that's a subset of code, not practically every single line of the whole thing.

It seems to me like memory corruption/use-after-free/etc only being able to happen in a small fraction of code is better than it being able to happen anywhere.

Re:Rust: Enable WebAssembly backend by default by zaarn on Monday November 27, 2017 @03:47AM (#15785792)
> Rc<T>

Rc requires memory allocation. When you boot a kernel you don't have that. Until you set it up, you can't use anything that requires a heap, only stack values.

The best solution I found is to use C code to allocate raw memory and then go through the elaborate process of setting up kernel address space, after which you setup a frame allocator, after which you can setup interrupts and finally use pagefaults to normally use kernel heap.

But wait there is more! During a pagefault interrupt you can't use the kernel heap in a writeful manner that is not inplace. Since a page fault during a page fault is a double fault and thusly your only option is to crash the kernel. You can only read from the kernel heap, modify in place in the heap and write to pagetables.

Same goes for some other interrupts. Which btw, violate a lot of ways Rust code likes to work. An interrupt is like a coroutine but you don't have a nice runtime that abstracts it for you, instead the IRQ just smashes into the active execution and let's hope you haven't held any locks to important kernel stuff at that moment because you will have to crack that lock open.

Re:Rust: Enable WebAssembly backend by default by TheDong on Monday November 27, 2017 @03:27PM (#15790905)
My point is really that rust allows you to build those abstractions, regardless of that specific one.

Sure, the kernel has reusable things like its embedded linked list etc, but they're not type-safe, and they can't represent ownership.

With rust's type-system, a generic rc-like thing could be created which is suitable for the world of the kernel, even if it's not the stdlib Rc.

Re:Rust: Enable WebAssembly backend by default by zaarn on Tuesday November 28, 2017 @02:42AM (#15795210)
You can't have RC until you have setup a heap. The stack is not a safe place to put these things.

Without any memory management, things get hard fast, especially considering you still need to parse the memory layout to find out which parts of memory are even usable.

Re:Rust: Enable WebAssembly backend by default by Dylan16807 on Wednesday November 29, 2017 @12:55PM (#15809085)
The original comment was "Rc<T> in rust is much easier to use without screwing up than the manually handled reference counters littered throughout the kernel."

That's heap vs. heap. It comes after the very brief stage you're mentioning.

Re:Rust: Enable WebAssembly backend by default by pcwalton on Sunday November 26, 2017 @08:39PM (#15784207)
Why is kernel programming any different from user-level programming here?

I tend to think that the driver and network level, which is where most problems in the real world tend to lie, is similar to userland in how often unsafe code gets used and the impact of unsafe code on the correctness of the kernel. In fact, the fact that you can write some drivers in userland on certain OS's--and they can crash without bringing down the whole OS--is strong evidence of this.

Re:Rust: Enable WebAssembly backend by default by zaarn on Monday November 27, 2017 @03:39AM (#15785756)
x86 is unsafe. Period. A lot of devices are unsafe. Period.

You can write some device drivers in userspace. But you can't handle page faults in userspace. Those need to be handled by the kernel and will be 100% unsafe because any mistake will lead to a certain and quick double or triple fault.

Kernel Level Programming is very very different to normal user-level programming. There is no malloc. There is no segmentation. Nothing prevents you from dereferencing a null pointer. In fact, in kernel-land a null pointer is valid memory. You don't have any of the forgiving properties of Ring3 assembly code in kernel-land.

Re:Rust: Enable WebAssembly backend by default by rcxdude on Monday November 27, 2017 @02:34PM (#15790415)
What you are describing is <10% of, say, the linux kernel. The rest of it reads very much like user-land code (and dereferencing a null pointer will often earn you a nice warning message if not a panic).
Re:Rust: Enable WebAssembly backend by default by zaarn on Tuesday November 28, 2017 @02:43AM (#15795213)
Those are usually the important 10% of a kernel that build the foundation of everything else.

Once you have VMM and Paging setup, preventing a null pointer deref is not hard (simply unpage 0x0)

Re:Rust: Enable WebAssembly backend by default by Rusky on Sunday November 26, 2017 @02:25PM (#15782505)
> a submodule that can be treated as if its correctness doesn't impact the safety of the entire kernel.

You don't have to go all that way to be better than C or C++. Rust can give you a submodule A whose correctness doesn't impact the safety of any uses of submodule B.

Re:Rust: Enable WebAssembly backend by default by cwzwarich on Sunday November 26, 2017 @02:59PM (#15782665)
If the correctness of submodule A impacts the safety of the entire kernel, then it impacts the safety of the uses of any other submodule, because you can't really contain the consequences of the unsafe behavior.
Re:Rust: Enable WebAssembly backend by default by Rusky on Sunday November 26, 2017 @04:25PM (#15783076)
> you can't really contain the consequences of the unsafe behavior.

That's true, but the property I described can still help you track down the root cause and limit the number of places that interact with it.

Re:Rust: Enable WebAssembly backend by default by 013a on Sunday November 26, 2017 @10:33AM (#15781284)
Even if you wrote your entire program in unsafe, you're still enjoying an experience at least as good as C++; you just don't get the compile time memory safety. And its unlikely your entire program would ever have to be in unsafe.
Re:Rust: Enable WebAssembly backend by default by traverseda on Sunday November 26, 2017 @10:08AM (#15781169)
Having never used rust and having barely used C, here are some uninformed opinions.

A memory safe language for the kernel doesn't seem possible using "traditional" safety tools. I'd expect a "safer" language would look a lot like formal verification. If you can make a safer language that doesn't look a lot like formal verification, you can probably automate a lot of formal verification.

There are still some big advantages to rust. By explicitly marking unsafe code, you've made it a lot easier to figure out what needs to be focused on. I imagine you can even formally verify just the unsafe parts of your ecosystem.

Also, rusts tooling just seems more pleasant.

Re:Rust: Enable WebAssembly backend by default by pjmlp on Sunday November 26, 2017 @11:07AM (#15781479)
ESPOL for Burroughs B55000 in 1961 already allowed for some kind of safety.

It was a systems programming language based on Algol and already had the notion of unsafe code for low level code.

Those modules had to be marked as UNSAFE and could only be executed if allowed to do so by the sysadmin.

Similar exemples could be provided about PL/S, PL/8, Mesa, Modula-2, Modula-3 and many others.

One big contribution that Rust brings into the table is to educate a whole generation that belives the myth that C was the very first systems programming language, that there are actually safer alternatives.

Re:Rust: Enable WebAssembly backend by default by catnaroek on Sunday November 26, 2017 @04:00PM (#15782959)
> Those modules had to be marked as UNSAFE and could only be executed if allowed to do so by the sysadmin.

Safety vs. authorization are completely orthogonal. The former is an objective property of a program, to be established or refuted with formal proof. The latter depends on the subjective whims of one specific human being, in this case, the sysadmin. And, in my experience, the typical sysadmin is not a good enough semanticist to determine whether a program is safe or not.

Re:Rust: Enable WebAssembly backend by default by pjmlp on Sunday November 26, 2017 @05:23PM (#15783414)
The point being that unsafe code had to be marked as such to be compilable and that tainted the binary, which was only allowed to execute after given permission.

Formal proofs can also contain logic errors.

Any kind of safety improvement is better than what C offers.

Re:Rust: Enable WebAssembly backend by default by catnaroek on Sunday November 26, 2017 @05:26PM (#15783426)
> The point being that unsafe code had to be marked as such to be compilable and that tainted the binary, which was only allowed to execute after given permission.

And my point is that this is useless in the absence of someone or something capable of reliably determining whether the code is safe to run.

> Formal proofs can also contain logic errors.

So you have competent people write them.

Re:Rust: Enable WebAssembly backend by default by pjmlp on Sunday November 26, 2017 @05:38PM (#15783495)
Regarding formal proof systems, not only can they contain logic errors, they are still very far from being usable for the common programmer to do regular programming.

As for competent programmer, we all know how many corporations search who they hire.

Re:Rust: Enable WebAssembly backend by default by rapind on Sunday November 26, 2017 @05:06PM (#15783309)
Nim comes to mind. https://nim-lang.org/
Re:Rust: Enable WebAssembly backend by default by dom96 on Sunday November 26, 2017 @05:17PM (#15783374)
Thank you for mentioning Nim here. :)

To expand a bit, Nim features its own JS backend with a high proportion of the stdlib supporting it. You can access the DOM via the `dom` module[1] and build some pretty cool stuff[2][3]. It doesn't target WebAssembly (yet) however.

On the systems side, Nim compiles to C/C++/ObjC and manages memory via a soft real-time GC (or via a choice of other GCs including boehm).

1 - https://nim-lang.org/docs/dom.html

2 - https://nim-lang.org/araq/karax.html

3 - https://picheta.me/snake/ (source available here: https://github.com/dom96/snake)

Re:Rust: Enable WebAssembly backend by default by santaclaus on Sunday November 26, 2017 @07:26PM (#15783931)
> Is gaining traction in the native application space

Are there any Rust-first UI frameworks rivaling something like Qt, yet?

Re:Rust: Enable WebAssembly backend by default by executesorder66 on Monday November 27, 2017 @05:13AM (#15786225)
Re:Rust: Enable WebAssembly backend by default by Thaxll on Sunday November 26, 2017 @11:48AM (#15781677)
Rust is not really good for web backends, it has no library for talking to popular service, the construct for networking are still uncertain / unstable / hard to use.
Re:Rust: Enable WebAssembly backend by default by bluejekyll on Sunday November 26, 2017 @12:16PM (#15781845)
For reference, what I have used that makes me claim this without being misleading (not necessarily all at the same time):

https://rocket.rs/, https://rusoto.github.io/rusoto/rusoto_core/index.html, https://docs.rs/postgres/0.15.1/postgres/, https://docs.rs/kafka/0.7.0/kafka/, https://docs.rs/reqwest/0.8.1/reqwest/, as well as many other supporting libraries. I've not run into many things where there isn't already support.

Also, in terms of networking, if your doing blocking IO, the stdlib is fine. Otherwise, from my experience, I really like https://tokio.rs/ for non-blocking (I know people are torn on this one) and have used it in my DNS impl, https://github.com/bluejekyll/trust-dns

For more info on web and Rust, this is a great page: http://www.arewewebyet.org/

Re:Rust: Enable WebAssembly backend by default by stochastic_monk on Monday November 27, 2017 @07:45AM (#15786873)
Modern C++ with RAII checks all of your boxes except for web backends. (Though I've heard good things about WT.)

Disclosure: I only write software for scientific computing and have no interest or experience in web development.

Re:Rust: Enable WebAssembly backend by default by FrappucinoFill on Sunday November 26, 2017 @01:11PM (#15782166)
>which can scale for every potential use case

For a certain type of lowish-level programming, yes. But there's a reason that many projects include something like Lua for the majority of the actual application-level work.