Live data from Hacker News

Writing a website in Rust

blog.viraptor.info

31–40 of 141 posts

Re: Writing a website in Rust

#31

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

Some form of controlling the memory management. In GC enabled systems programming languages like e.g. Oberon and Modula-3, there there will be APIs to have control about memory.

Ability to convert between language types and raw addresses, in the form of pointers.

Toolchain should also provide the ability for aot compilation both to static and dynamic executables/libraries.

Re: Writing a website in Rust

#32

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.

Sure, that wasn't rust's main goal. I did the app in rust simply because I had time to do that and wanted to get more comfortable with lifetimes. (they're in my nightmares now)

But honestly, I came away surprised how good the experience was. I wouldn't start a big team project in it (at least not until more common middleware is available and some higher level frameworks), but when rust 1.1, or 1.2 lands I'll definitely consider it for http microservices or RPC endpoints.

Re: Writing a website in Rust

#33

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.

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?

Re: Writing a website in Rust

#34

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

For me it's strong static typing, control about memory layout of you data, memory locality (arrays are arrays and not linked lists in disguise, you know what goes on the stack and what's on the heap, etc), support for bit based operations (which Rust lacks a little as there's not bitfields), deterministic memory management and a few things I didn't think of.

Re: Writing a website in Rust

#35

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.

Some would say Scala is not a "web language" either, but I think Play Framework developers would disagree. The rules of the game are not as clear as they used to be. For instance - web frontend is being dominated by JS frameworks and all the backend does is handling REST calls. I would argue that when you need scalability/performance/reliability, when milliseconds start to count - static languages make very much sense and when Rust can offer a comparable performance with C - it looks a very appealing option.

Re: Writing a website in Rust

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

> what are some of the things that make a language more suited to systems programming rather than web

the answer was to what qualities make a lang suited for systems programming not just specific to Rust

Re: Writing a website in Rust

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

Re: Writing a website in Rust

#38
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?

Because rewriting Spidermonkey is both tedious and doesn't benefit from Rust safety guarantees.
Post reply on HN