Live data from Hacker News

Writing a website in Rust

blog.viraptor.info

111–120 of 141 posts

Re: Writing a website in Rust

#111
post #97

Earlier quoted context omitted.

Obviously not in any way an answer to the question asked. edit: Please provide a better response than downmods.

Go actually check the things pcwalton mentioned instead of complaining.

Please provide comparison measurements of the things pcwalton mentioned.

Just a URL to published comparison measurements would be so much more interesting for anyone interested in Rust, than downmods.

Re: Writing a website in Rust

#112

Earlier quoted context omitted.

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.

This is the same in even many dynamic languages, though, isn't it?

Almost. In Rust to use a trait, you have to explicitly import it. That means if you want to run `.to_json()` on something, you need to import trait `ToJson`. Then again if you want to force a type of something (for example an empty hashmap) you need to import the types which are included.

So what in a dynamic language could be:

    a.to_json() if a else {}.to_json()
In rust will start with:

    use rustc_serialize::json::{ToJson,Json};
    use std::collections::BTreeMap;
    ...

Re: Writing a website in Rust

#114
post #100

Whenever someone writes bad things™ about some language, one of the language's fanboys shows up and starts nitpicking! Yes, now is the time! > Another bad part is Rust’s JSON handling. It badly needs macros which make things easier. Actually this is not the end of the world. As you mentioned, Rust's JSON library supports `ToJson` for primitive types, but also provides compile-time code generation for arbitrary `struc…

> Actually this is not the end of the world. As you mentioned, Rust's JSON library supports `ToJson` for primitive types, but also provides compile-time code generation for arbitrary `struct`s. Quoting the code from my project:[1]

Pardon my self-promotion: if you just need some one-off JSON and are willing to use the nightly compiler, I wrote a compiler plugin that expands JSON-like literals into an expression that expands to the tedious way of building up a JSON object.

https://github.com/tomjakubowski/json_macros

I find it's super handy for testing libraries or applications that emit JSON meant to go across some well-specified protocol. Some day I'll get around to expanding the library to support pattern matching with JSON literals as well (pull requests very welcome!).

Re: Writing a website in Rust

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

Okay, so I just tested the n-body benchmark [1] for Rust and C++ (program #8), and where they list runtimes of 24.62/9.4 (a factor of 2.62), I actually got a factor of 1.25 (5.45/4.35) on my machine [2]. I used the same version of Rust and nearly the same version of gcc (4.9.1 vs 4.9.2).

Conclusion: Don't draw conclusions from the benchmarks game.

[1] http://benchmarksgame.alioth.debian.org/u64q/performance.php...

[2] i5-3470 @ 3.20GHz

Re: Writing a website in Rust

#116
post #66

Earlier quoted context omitted.

I'd love something similar to be part of Cargo, maybe as an option in the manifest. Like the author, I've learned to guess when the codegen starts, but having this information displayed would be useful.

I'm actually working right now on a `cargo check` command which only runs those phases of the compiler to do with typechecking, to accommodate workflows based around tweaking types and then running the compiler to check your work. Given that the vast majority of compilation time is currently based in code generation and linking, this should drastically improve usability for this sort of rapid-iteration, dynamic-langu…

This is a great idea. I wish other compilers would offer this feature (scalac is in dire need of such an option).

Does the Rust macro system require compile-time compilation before type-checking?

Re: Writing a website in Rust

#117

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

I think seriously the intrinsic thing is that the language itself doesn't marshal (right word, not sure) anything that's particularly fat. The classic is if allocating memory require dealing with a general purpose garbage collector. If that's the case you're pretty much dead as far as systems stuff goes because now you can't predict how long anything will take to run.

And the minimal libraries usually need to be light weight as well. Or at least such that you can strip out what's not wanted. Here again garbage collection becomes an issue. If the language supports it natively then it's going to be impossible in practice to prevent the libraries from using it for something unexpected.

The last bit is escape. There are always some cases where the language doesn't have the ability to implement a critical bit of stuff and you need a way to seamlessly mess with that something. In simple you need to be able to insert a bit of arbitrary code and have it work properly.

Re: Writing a website in Rust

#118
post #99

Earlier quoted context omitted.

Optimizing language performance has been a focus. Optimizing the workloads tested on the benchmarks game has not been a focus.

You seem to have a disagreement with what steveklabnik said, so please take that up with him. https://news.ycombinator.com/item?id=9554676 edit: Please provide a better response than downmods.

Please provide better manners than those in your comments. :)

Re: Writing a website in Rust

#119
post #99

Earlier quoted context omitted.

You seem to have a disagreement with what steveklabnik said, so please take that up with him. https://news.ycombinator.com/item?id=9554676 edit: Please provide a better response than downmods.

Please provide better manners than those in your comments. :)

It isn't bad manners to ask Rusky or pcwalton to show measurements in support of their claims.

It isn't bad manners to trust that when steveklabnik answers "No, as optimizing performance hasn't been a focus, shipping good language semantics has been." that's what he means.

https://news.ycombinator.com/item?id=9554676

Re: Writing a website in Rust

#120
post #115

Earlier quoted context omitted.

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

Okay, so I just tested the n-body benchmark [1] for Rust and C++ (program #8), and where they list runtimes of 24.62/9.4 (a factor of 2.62), I actually got a factor of 1.25 (5.45/4.35) on my machine [2]. I used the same version of Rust and nearly the same version of gcc (4.9.1 vs 4.9.2). Conclusion: Don't draw conclusions from the benchmarks game. [1] http://benchmarksgame.alioth.debian.org/u64q/performance.php... [2…

Conclusion: "Measurement is highly specific … Measurement is not prophesy." (benchmarks game homepage.)
Post reply on HN