News for hackers. Stuff that matters.
Re:Trying Rust for web services by jerf on Thursday October 01, 2015 @11:28AM (#10311804)
"A web server does not fall into that category, so why did you pick it?"

That's too categorical a statement. It depends on a lot of things. Sure, there's a place in the world for PHP pages that take two or three full seconds to render, but it doesn't matter because they're doing something useful and don't get hit a thousand times per second. There's also a place for things that render in under a millisecond because they're getting hit at an incredible rate, and if they also have some sort of interdependencies then Rust can make a lot of sense.

Plus as I've said before, the whole "you're stuck in IO anyhow so who cares how fast the render code runs" dogma has sometimes gone too far. (I know you didn't say anything about that, but I'm guessing based on experience it's what lies behind your point.) My experience in switching from slow languages to fast languages, even doing the same IO, is that you do tend to see real performance gains unless your page was absolutely trivial. Slow languages really are slow in practice.

Re:Trying Rust for web services by Touche on Thursday October 01, 2015 @01:34PM (#10312915)
> That's too categorical a statement. It depends on a lot of things.

I didn't mean it to be. Of course there are extreme cases where GC pauses are unacceptable on a web server, but those are relatively rare. Even Google mostly uses Java (although they are heavy C++ users, is it for their web servers?).

There are always extreme cases, which is why I asked the question.

> My experience in switching from slow languages to fast languages, even doing the same IO, is that you do tend to see real performance gains unless your page was absolutely trivial. Slow languages really are slow in practice.

Slow vs. fast is not black and white. Is Go slow? Is Lua slow? I Java (on a warmed up JVM) slow?

We're talking about GC vs. non-GC languages here. Do you really see a difference in performance gains?

Re:Trying Rust for web services by acconsta on Thursday October 01, 2015 @02:30PM (#10313454)
>Even Google mostly uses Java

I'm not so sure about that. The core services (e.g. Search, Maps, Earth, Big table, Map reduce) seem to be C++. Ads is possibly an exception.

Re:Trying Rust for web services by Touche on Thursday October 01, 2015 @02:40PM (#10313547)
We're talking specifically about the web application servers here. I wouldn't be surprised that something like Search is C++, it's one of the most visited pages in the world. But I haven't heard specifically that it is.

I don't think it's any secret that Java is huge Java users. If not web servers, then for what?

Re:Trying Rust for web services by acconsta on Thursday October 01, 2015 @03:07PM (#10313773)
50% C++, 25% Java

http://qr.ae/RP7wXh

At Google's scale, the performance difference between Java and C++ can means millions of dollars in electricity alone.

Re:Trying Rust for web services by Touche on Thursday October 01, 2015 @03:24PM (#10313955)
That's the amount of code in their repo which covers a lot more than web application servers.

This is an unnecessary tangent though, as I've said throughout this discussions, there's extreme cases and no doubt Google is likely one of them. But we're talking about common use case, to which I still haven't seen any evidences that GC pauses are a deliberating factor.

Re:Trying Rust for web services by portmanteaufu on Friday October 02, 2015 @02:02PM (#10320165)
You may already be familiar with this and are specifically concerned with GC. However, for what it's worth, it's not just the absence of garbage collection that makes languages like Rust and C faster. A huge piece of their performance is the level of control that they offer over types' layout in memory and where things get stored. Rust's preference for stack allocations and the absence of a mandatory per-Object size overhead (a la Java) really allow it to shine.
Re:Trying Rust for web services by jurre on Thursday October 01, 2015 @12:04PM (#10312141)
> PHP pages that take two or three full seconds to render

I don't use php personally, but most of my rails apps render full pages in under 100ms. I'd imagine php performance to be at least on-par with a full rails app.

Re:Trying Rust for web services by mtberatwork on Thursday October 01, 2015 @12:56PM (#10312601)
Once you start seeing hundreds or thousands of requests coming in per second and you see your cpu utilization sky rocket, then the "slowness" of the interpreted languages really comes into full play. Most apps/websites will never achieve this kind of load or scale though.
Re:Trying Rust for web services by Touche on Thursday October 01, 2015 @01:35PM (#10312920)
> interpreted languages really comes into full play.

There are plenty of non-interpreted languages that don't require GC though. When you pick Rust you are picking manual memory management. Does even Google opt for non-GCed languages for their web servers?

Re:Trying Rust for web services by steveklabnik on Thursday October 01, 2015 @01:41PM (#10312969)
We've been having a debate lately, within Rust, if "manual" is really the right term here.

  {
      let x = Box::new(5); // malloc

  } // free
Is this really _manual_? In a sense it is, but it's very different than what most people think about. "Automatic" is kind of a good word, but Objective-C/Swift's "ARC" already covers that, and we don't do refcounting, so that could be misleading too.

Maybe "deterministic"?

Re:Trying Rust for web services by gmfawcett on Thursday October 01, 2015 @02:26PM (#10313414)
"RAII" seems to cover it nicely, and extends beyond memory management to other resources. Admittedly it's not a very friendly term for non-C++ programmers.

What's this non-lexical borrowing idea you mentioned in your other comment? (I can't reply there for some reason.) Is there an RFC for that?

Re:Trying Rust for web services by steveklabnik on Thursday October 01, 2015 @02:40PM (#10313546)
The relevant search terms are "SEME regions" and "non-lexical borrows". The tracking issue is here: https://github.com/rust-lang/rfcs/issues/811 and https://github.com/rust-lang/rust/issues/6393 is the older issue it superseded, with examples.

There hasn't been an RFC yet, because we're in the middle of a large amount of compiler internals work (HIR/MIR), which will make overall analysis easier, including these two features.

> (I can't reply there for some reason.)

HN limits responses based on the depth of the comment tree and the length of time since the comment was posted, to discourage flamewars, you can always click on a comment link directly to kind of bypass that though.

Re:Trying Rust for web services by gmfawcett on Thursday October 01, 2015 @03:17PM (#10313871)
Thanks for the issue link (and for the comment-tree depth hint!).
Re:Trying Rust for web services by acconsta on Thursday October 01, 2015 @03:29PM (#10314000)
Scope-bound resource management (SBRM) is clearer than RAII, I think.
Re:Trying Rust for web services by kibwen on Thursday October 01, 2015 @01:51PM (#10313042)
Memory management in C is also "deterministic", just forget to ever free. :P
Re:Trying Rust for web services by DasIch on Thursday October 01, 2015 @02:02PM (#10313161)
How about lexical memory management as a nod to dynamic vs. lexical scoping?
Re:Trying Rust for web services by steveklabnik on Thursday October 01, 2015 @02:09PM (#10313235)
That might work for now, but something we're working on for the future is making borrows non-lexical, so....
Re:Trying Rust for web services by kibwen on Thursday October 01, 2015 @02:34PM (#10313485)
Borrows may be non-lexical in the future, but deallocation via ownership will always be at the end of a lexical scope. Not only would eager deallocation be bad for performance, it's also a backcompat hazard at this point.
Re:Trying Rust for web services by yazaddaruvala on Thursday October 01, 2015 @02:32PM (#10313472)
I personally like:

Rust: "statically memory managed" Java, Go: "dynamically memory managed"

Similar to: "statically typed" or "dynamically typed"

Re:Trying Rust for web services by Tuna-Fish on Thursday October 01, 2015 @03:07PM (#10313771)
Statically memory managed already has a meaning. It means that there is no malloc during runtime, all memory addresses are decided (usually manually) beforehand and written into the executable.
Re:Trying Rust for web services by wyldfire on Thursday October 01, 2015 @02:36PM (#10313504)
I wouldn't call it manual at all. It looks remarkably like automatic storage duration IMO.
Re:Trying Rust for web services by phaylon on Thursday October 01, 2015 @07:04PM (#10315433)
Google suggests "affine memory management" is not yet used as a term.
Re:Trying Rust for web services by jerf on Thursday October 01, 2015 @12:12PM (#10312196)
I'm thinking Wordpress, or bespoke status pages for internal apps. Of course you can get a PHP page out in under a millisecond if you try hard enough, but it's often not used in that sort of place. (And it often is, but that still doesn't mean it often isn't.)

Rails, for that matter, is known for being easy to produce multi-second pages too.

Slow languages are slow in practice, too.

Re:Trying Rust for web services by jerf on Friday October 02, 2015 @09:33AM (#10318371)
It actually amazes me that people find the statement that slow languages are actually slow offensive and worthy of downvoting. As I said, it is my experience that simply switching from slow to fast languages even on "IO dominated" workloads has real, visible effects.

If you haven't tried it, consider trying it before becoming offended at the idea that your tool may not be appropriate for all use cases. Yes, it can matter when your language is 50 times slower than another.