Live data from Hacker News

Writing a website in Rust

blog.viraptor.info

41–50 of 141 posts

Re: Writing a website in Rust

#42
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...

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.

Re: Writing a website in Rust

#43
post #33

Earlier quoted context omitted.

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 uses generational gc with some kind of compacting these days. Why do you think that's legacy? What models are strictly better than that?

Nim's garbage collector is better than Spidermonkey's.

Re: Writing a website in Rust

#44

Well, IMHO, "the right hammer for the right nail". Rust is a great systems language (besides the lack of bitfields) but I wouldn't use it as a web language. Just as much as I wouldn't use C++ to develop webapps. Sure you can do it but then again there are far easier ways to achieve your goal.

Out of curiosity (I've never done systems programming), what are some of the things that make a language more suited to systems programming rather than web (other than libraries and community support - I'm more interested in the intrinsic qualities of the language)?

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 interpreters that have only userland privileges. So good luck writing a driver. And I don't know ... if your vm has heap allocated to it, are you able to address system memory out side of that to address hardware? Also, the language runtimes usually add a lot of overhead as well and employ automatic garbage collection, which is generally something you don't want in performance-critical systems.

Re: Writing a website in Rust

#45
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.

Re: Writing a website in Rust

#46
post #18

Earlier quoted context omitted.

While I agree with some of your arguments, namely that "popularity and merit are not the same thing", I think saying that Mozilla is "trapped in a pseudo-C++ mindset" and that its new browser would ideally be written in Nim is plain wrong. The fact that using Rust to write a simple website isn't very handy doesn't mean it's a bad language. Web development simply isn't its primary focus: this is a systems programming…

The idea that you can't get something good without a trade-off involving something bad is a false belief, an over-generalization that is very popular among people from all walks of life, including, unfortunately, technologists. Trade-offs do exist, but even a sword in fact has many more than two aspects.

OK, but we know precisely what the downsides of GC are (for some applications).

Re: Writing a website in Rust

#47

Earlier quoted context omitted.

Out of curiosity (I've never done systems programming), what are some of the things that make a language more suited to systems programming rather than web (other than libraries and community support - I'm more interested in the intrinsic qualities of the language)?

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).

Re: Writing a website in Rust

#48
post #43

Earlier quoted context omitted.

Spidermonkey uses generational gc with some kind of compacting these days. Why do you think that's legacy? What models are strictly better than that?

Nim's garbage collector is better than Spidermonkey's.

Irrelevant here.

For Servo we need a javascript engine. We're already using Spidermonkey. It has a GC for Javascript; we're already paying those costs. The Rust-side representation of DOM objects is also managed by the GC; that makes sense because these are tied to Javascript things.

We don't use the GC elsewhere. I think at some point we did, but the only place now in Servo where GC is used is where the data is strongly connected to data already managed by the SM GC.

Nim's GC is for general-purpose use in a language. Spidermonkey's GC is for GCing javascript, which already has an extensive runtime (which the GC ties into heavily). "Nim's GC is better than Spidermonkey's" is a statement of no value (and oversimplifies the situation) unless the context is specified. Using the SM GC to collect random Rust objects would be a bad idea. Somehow rigging up spidermonkey to use a Nim-like GC in Rust (all other things being the same) would also be a bad idea. Two different scenarios, two different GCs.

Re: Writing a website in Rust

#49

The tooling for the web written in JavaScript is excellent, so I was curious, are there any options there are for calling JavaScript from Rust code? I know there is the ffi module for NodeJS that allows you to call Rust from JavaScript, but I was wondering if there is something that works well in the other direction.

It's an interesting question. You can embed V8 in Node, so theoretically you could also embed the entirety of V8 in a Rust program just as you could embed Lua or Python in a Rust program. But just because it's possible doesn't necessarily mean that it's easy... it would be a fascinating project for someone adventurous. :)
Post reply on HN