News for hackers. Stuff that matters.
Re:Writing a website in Rust by kybernetyk on Saturday May 30, 2015 @01:34PM (#9630919)
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.

Re:Writing a website in Rust by viraptor on Saturday May 30, 2015 @02:07PM (#9631099)
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 by neverminder on Saturday May 30, 2015 @02:11PM (#9631129)
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 by ghayes on Saturday May 30, 2015 @07:11PM (#9632204)
This may miss your point, but I would easily argue that Scala is a "web language," just as Java is and was before it. Scala's focus on concurrency helps drive this point, as it's not response time so much as throughout given IO constraints that make a good environment for web applications.
Re:Writing a website in Rust by cgag on Saturday May 30, 2015 @08:55PM (#9632519)
Yeah, I don't really think people would argue scala doesn't make sense for web dev. I think the main is that webdev can generally tolerate GC and it's not worth giving it up.
Re:Writing a website in Rust by mangeletti on Saturday May 30, 2015 @01:45PM (#9630978)
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)?
Re:Writing a website in Rust by OneMoreIdol on Saturday May 30, 2015 @02:35PM (#9631227)
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 by justincormack on Saturday May 30, 2015 @02:43PM (#9631258)
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 by OneMoreIdol on Saturday May 30, 2015 @02:51PM (#9631306)
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 by justincormack on Saturday May 30, 2015 @04:04PM (#9631567)
Yes you can call mmap with the ffi in LuaJIT just fine. It is not very complicated, it just asks the kernel to do it. Implementing what the kernel does, well that does need some assembly.
Re:Writing a website in Rust by OneMoreIdol on Sunday May 31, 2015 @09:12PM (#9636320)
Indeed we agree. Using any ffi for that matter.
Re:Writing a website in Rust by bbrazil on Saturday May 30, 2015 @02:04PM (#9631080)
For Prometheus's console templates (basically offering a html templating engine to end users to create monitoring consoles with), I used Go's own templating language as nothing else seemed mature at the time.

Go is strongly typed, and so is it's templating language. This means that you need to take a much more rigorous approach to using them, as a single unhandled edge case value can break the entire page. Contrast this with something like Jinja2 where if you mess up it'll only break a small bit of the page.

I managed to produce a usable template system, but it's still a tad more verbose than I'd like. It'd have been nice if a more scripting-language style templating language had been an option.

Re:Writing a website in Rust by S4M on Saturday May 30, 2015 @07:59PM (#9632382)
> Contrast this with something like Jinja2 where if you mess up it'll only break a small bit of the page.

Do you have some examples of error that are easy to make with Jinja2? I personally find it to be a thing of beauty, but it's possible that I don't try to make very elaborate things with templating engines and thus might be missing out.

Re:Writing a website in Rust by kybernetyk on Saturday May 30, 2015 @02:11PM (#9631127)
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 by pjmlp on Saturday May 30, 2015 @02:07PM (#9631093)
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 by supster on Saturday May 30, 2015 @01:59PM (#9631049)
Super fast, type safe (and thread safe in Rust), compiled, low/no cost abstractions
Re:Writing a website in Rust by pecan_xt on Saturday May 30, 2015 @02:03PM (#9631073)
Re:Writing a website in Rust by Rusky on Saturday May 30, 2015 @02:48PM (#9631284)
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 by igouy on Saturday May 30, 2015 @07:09PM (#9632190)
>>not very correlated with real-world performance<<

Please share your measurements of "real-world performance" that are "not very correlated" with the benchmarks game's results.

edit: Please provide a better response than downmods.

Re:Writing a website in Rust by pcwalton on Saturday May 30, 2015 @07:28PM (#9632270)
Servo layout, painting, DOM performance. JSON serialization in serde.
Re:Writing a website in Rust by igouy on Saturday May 30, 2015 @07:58PM (#9632378)
Obviously not in any way an answer to the question asked.

edit: Please provide a better response than downmods.

Re:Writing a website in Rust by Daishiman on Saturday May 30, 2015 @10:35PM (#9632803)
Go actually check the things pcwalton mentioned instead of complaining.
Re:Writing a website in Rust by igouy on Sunday May 31, 2015 @12:48AM (#9633132)
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 by pcwalton on Sunday May 31, 2015 @12:44PM (#9634667)
Re:Writing a website in Rust by igouy on Sunday May 31, 2015 @01:52PM (#9634893)
How about some measurements made with rustc 1.0.0?

(There seem to have been plenty of breaking language changes in the last 6 months.)

Re:Writing a website in Rust by Manishearth on Monday June 01, 2015 @04:17AM (#9637302)
http://xania.org/201505/on-rust-performance

(The "faster" bit isn't important; various reasons might have made C++ slower than Rust for this, but what is important is that perf was comparable)

Re:Writing a website in Rust by igouy on Monday June 01, 2015 @12:47PM (#9640070)
Do you think a 100 line ray tracer is any more "correlated with real-world performance" than 100 line benchmarks game programs?

What I questioned was Rusky's technical-sounding but apparently unsupported claim that "the benchmarks game's results are not very correlated with real-world performance." For Rusky to know he'd need some kind-of "real-world performance" measurements and a correlation coefficient - neither of which have been shown.

Re:Writing a website in Rust by steveklabnik on Saturday May 30, 2015 @02:30PM (#9631205)
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 by jamii on Saturday May 30, 2015 @02:48PM (#9631287)
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 by burntsushi on Saturday May 30, 2015 @10:23PM (#9632771)
> only regex looks hard.

I'm working on improving the regex engine now. Hopefully I can submit some improvements soon. :-) It will be hard to get near the top, but I think there's some low hanging fruit I can tackle first.

Re:Writing a website in Rust by igouy on Saturday May 30, 2015 @07:15PM (#9632218)
Let's not make this about the benchmarks game.

A couple of weeks ago you said -- "… optimizing performance hasn't been a focus, shipping good language semantics has been."

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

edit: Please provide a better response than downmods.

Re:Writing a website in Rust by pcwalton on Saturday May 30, 2015 @07:28PM (#9632271)
Optimizing language performance has been a focus.

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

Re:Writing a website in Rust by igouy on Saturday May 30, 2015 @08:00PM (#9632385)
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.

Re:Writing a website in Rust by ben0x539 on Sunday May 31, 2015 @06:44AM (#9633775)
Please provide better manners than those in your comments. :)
Re:Writing a website in Rust by igouy on Sunday May 31, 2015 @08:53AM (#9633999)
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 by adwn on Sunday May 31, 2015 @03:11AM (#9633351)
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 by igouy on Sunday May 31, 2015 @08:55AM (#9634008)
Conclusion: "Measurement is highly specific … Measurement is not prophesy." (benchmarks game homepage.)
Re:Writing a website in Rust by supster on Saturday May 30, 2015 @02:13PM (#9631139)
> 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 by Gibbon1 on Sunday May 31, 2015 @03:31AM (#9633376)
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 by derefr on Sunday May 31, 2015 @09:31PM (#9636376)
> 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.

Erlang would argue with you. GC works fine as long as you have a bunch of really tiny heaps (attached to a bunch of really tiny processes) which can be collected in parallel. It just sucks for Unix-process-sized heaps.

Re:Writing a website in Rust by Thaxll on Saturday May 30, 2015 @01:48PM (#9630996)
Standard library, look at PHP it's all about web!
Re:Writing a website in Rust by nickpsecurity on Saturday May 30, 2015 @08:34PM (#9632471)
Plenty of people use C++ for web apps. It doesn't take a good coder a lot of time to use them. Those apps also run crazy fast compared to Python apps, even on embedded boards. Plus they support every security, speed, or reliability-enhancing tech ever developed for native code.

So, I'd rather use a higher-level language (and do) for most web-application development. I also love Python for its tradeoffs, esp productivity & readability. Yet, there are valid use-cases for native web apps esp where performance or memory-usage matters.

Re:Writing a website in Rust by agumonkey on Saturday May 30, 2015 @04:34PM (#9631651)
I think I saw an article about people using c++14 as a scripting language since infered type, closures and other syntax niceties can make simple c++ as short as python.
Re:Writing a website in Rust by rkangel on Monday June 01, 2015 @05:39AM (#9637513)
"As short as" doesn't necessarily mean "can be written as quickly as". I write a lot of C++ at work, and it's usually quicker to write a Python script to do glue type work.

There is another advantage - I mostly write python for the 'glue' scripts in large build systems. It saves some complication if your build system doesn't first have to compile chunks of itself!

Re:Writing a website in Rust by agumonkey on Monday June 01, 2015 @08:54AM (#9638145)
> "As short as" doesn't necessarily mean "can be written as quickly as".

Meaning, c++ semantics still require more care to have a running program, even a low-LoC one ?

Re:Writing a website in Rust by aswanson on Saturday May 30, 2015 @04:58PM (#9631734)
Bitfields are evil...the fact that the language designer left them out signals he/they have good taste...I have to get around to trying out Rust.
Re:Writing a website in Rust by milspec on Saturday May 30, 2015 @05:57PM (#9631900)
No, ill-defined non-portable C bitfields are evil.

If you can specify bit endianness, byte endianness, spans of bytes, and so on... bitfields are mighty nice.

Re:Writing a website in Rust by aswanson on Saturday May 30, 2015 @06:11PM (#9631953)
But the thing is...the spec is ill-defined in C, and given the fact the C runs on almost any processor, you can't specify endianess in the abstract and pandemonium ensues.