Live data from Hacker News

Writing a website in Rust

blog.viraptor.info

51–60 of 141 posts

Re: Writing a website in Rust

#51
post #28

Earlier quoted context omitted.

Super fast, type safe (and thread safe in Rust), compiled, low/no cost abstractions

Super fast? More like Java ballpark: http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

The benchmarks game's results are not very correlated with real-world performance.

In this context, Rust's semantics do allow C-level performance- they make it straightforward to describe the same machine code that C would. In some cases, they even enable more compiler optimizations than C does.

Java, on the other hand, makes it hard or impossible to do that (straightforwardly at least). A more mature compiler will make a lot of difference- compare early Java performance to where it is now, for example.

Re: Writing a website in Rust

#52
post #33

Earlier quoted context omitted.

You can use full GC in Rust--we use the SpiderMonkey GC to collect Rust DOM objects, for example. It's not the most easy-to-use thing, however. Most systems software gets by fine with a combination of thread-safe and thread-local RC. Reference counting is a form of garbage collection that works really well when it's used only for the subset of data that needs GC--which is the style that Rust encourages anyhow.

Hmm.. Rust was created to support the new browser, browsers mainly manage DOM objects.. I wonder why you are using a legacy garbage collector in order to handle primary tasks rather than having that part of your core design?

SpiderMonkey's GC is very modern, it's not legacy at all. Furthermore, while Servo influences the design of Rust, it does not dictate the design of Rust (or else, for example, Rust would have had struct inheritance years ago).

Re: Writing a website in Rust

#53

Earlier quoted context omitted.

Super fast? More like Java ballpark: http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

We've been focused more on language semantics than the Benchmarks Game for a while now. A few months ago, iirc, we were faster than C on some of them.

It looks like the worst offenders (vs C) are regex-dna (which is a young regex + unicode vs pcre + ascii) and fasta (where the rust version is still single-core). The others are at 1-2x cpu and on par for memory. I suspect most of them could be on par or better with a little effort - only regex looks hard.

Re: Writing a website in Rust

#54

Earlier quoted context omitted.

Outside of userland tasks like file manipulation, it is impractical to use the popular web application languages like Java or scripting languages such as Javascript or PHP or Python for systems programming without employing interfaces or hooks to libraries or programs written in languages that are compiled to machine code, simply because programs in those languages are commonly deployed using virtual machines or inte…

That is not strictly true. Look at Snabb switch, written almost entirely in LuaJIT for example https://github.com/SnabbCo/snabbswitch - you need some kind of ffi to mmap device memory, but it is quite possible. (LuaJIT is fast of course which helps for 10Gb ethernet).

That's kinda what I was thinking when I commented, and there are sure to be exceptions. But I don't see anything different with your Snabb switch example. You can probably use Java and JNI for that matter to call mmap, but would you be able to write an implementation of mmap in LuaJIT ?

Re: Writing a website in Rust

#55

Regarding compile time, you can track the passes with `-Z time-passes` and wait for borrowck/lints to get over (or just typeck if you're only worried about types). There also was [this plugin]( http://www.reddit.com/r/rust/comments/2krdbu/rest_easy_a_lin... ), but it's outdated at the moment (I can upgrade it later). Regarding imports, `use foo::bar::*` works.

For use, I meant that there are so many packages you just take space just listing them. For basic iron you need: iron::prelude::*, iron::status, staticfile, logger, router, handlebars_iron, and more. And these are all from different crates.

Re: Writing a website in Rust

#58
post #39

Very nice write up. As a Go programmer, Rust is really interesting. Can't wait until you can build web APIs with it.

Crates.io is built this way: Rust serving JSON on the back end, Ember consuming it on the front end.

What kind of database does crates.io use?

Re: Writing a website in Rust

#59

63 dependency crates? That's insane.

Cargo makes it trivial to add dependencies to a project (which themselves may have their own dependencies), and Rust has been designed with versioning in mind from the start so that even incompatible versions of the same dependencies can exist in your dependency tree without any problems whatsoever. 63 dependency crates isn't insanity when your tools take 100% care of them for you. To me, a large collection of dependencies represents a proper and fine-grained separation of concerns.

Re: Writing a website in Rust

#60

Earlier quoted context omitted.

Rc and Arc aren't exactly GC types... they are just reference-counted pointers, Rc being akin to C++'s shared_ptr. I get that in a sense, this is garbage collection, but certainly not full-featured like the ones you find in other languages.

Refcounting and tracing are two different forms of GC, but you're right in the sense that most people mean tracing. At the same time, we're putting a lot of thought into how to properly add an optional tracing GC. It's important that it doesn't impact the no-GC case, which is still, of course, primary.

I'm glad to know there is ongoing work on a tracing GC. Rust has many strengths aside from lifetimes and ownership (algebraic data types, sane generics, strong module support, very strong type system), so a few features to make it more usable for use in contexts where performance isn't as important as expressivity would be very nice to have.
Post reply on HN