
Is Rust web yet? Not really - chrismorgan
http://arewewebyet.com/
======
hendzen
Not to be a curmudgeon but why would one want to use Rust for web development
for a non-toy project?

I am a big fan of Rust, but as it aims to be a better C++, it is probably a
better fit for OS development, game engines, embedded systems, databases,
complex desktop applications (Photoshop/Word/Chrome), etc. While Rust is quite
expressive for a systems programming language, its banner features are the
borrow checker (+ lifetimes, etc) and powerful static type system. Rust
emphasizes zero-cost abstractions with compiler-enforced memory & thread
safety. The popular web development languages are dynamically typed and
interpreted, with an emphasis on rapid development, which is a very different
niche than Rust claims to fill.

Perhaps Rust could be used to build a highly optimized server for a large
site, but at that point it would probably better to write the application to
run on the JVM. Although the JVM may be slower (within a constant factor, and
assuming Rust is eventually as fast as C++) and more memory-intensive than the
optimized native code produced by Rust's LLVM based compiler, the JVM's
extensive tooling and run-time profiling tools make it a natural choice for
high performance web servers.

~~~
jerf
"Not to be a curmudgeon but why would one want to use Rust for web development
for a non-toy project?"

Web development is horrifically, unbelievably bent around two facts:

1\. There has been no convenient, highly popular and supported language for
development that also has best-of-breed performance. You can have one or the
other. (Yes, I've probably heard of your obscure fast-as-C language that has a
great web stack... to a first approximation, nobody else has.)

2\. Web development languages have been profoundly, deeply single-threaded, to
the point that the web world began to take it as an unmitigated virtue that a
page started with a request, generated a response, and dropped everything in
the world that it knew at the end of the request. State is something that must
be managed carefully, but especially in this era of people writing web
applications that may literally have _gigabytes_ available per concurrent user
(obviously, not _everybody_ , but this is a non-trivial use case!), the
statelessness dogma has seriously broken people's mental models vs. what the
hardware is actually capable of.

With Rust, you should be able to write fast, concurrent web applications that
actually _do_ something concurrently and aren't constantly marshaling across
requests for the client to re-initiate AJAX calls or other such silliness,
it'll be fast, and with its emphasis on memory safety, statically safe as well
(something that you're not going to get very easily out of Java, and certainly
not from a programmer just sitting down and pounding out some Java). It isn't
going to be the solution to every problem, but it's going to be the solution
to more problems than people realize right now, because we've so deeply
internalized our essentially-PHP models of how the web works that we can't
hardly even see how things ought to actually be working.

Rust isn't the only language biting at this apple. Go is obviously another
one. But Rust has a pretty decent shot at taking a big chunk, if it plays its
cards right.

You say the popular web development platforms are all dynamically typed... I'm
increasingly coming around to the position that was an accident of history,
rather than an immutable fact.

~~~
MrBuddyCasino
So I guess I'm gonna be that guy.

According to
[http://www.techempower.com/benchmarks/](http://www.techempower.com/benchmarks/),
the 2nd position is held by a Java framework, losing only 13,5% to the C++
overall winner. Granted, you need a 3rd party library to have something
similar like goroutines / fibers / actor concurrency / whatever, but its all
there if you want it.

~~~
jerf
Java is not regarded as convenient for web development. Fast when built, yes,
but not convenient. And C++ is borderline _unsuitable_. (A well-chosen and
carefully used subset, sure, but the exact things that Rust is fixing about
C++ is also why you should think about a dozen times before using it to build
web apps.)

And neither are as safe as Rust is/will be with multithreading. Doing really
pervasive concurrency is possible, but not particularly easy with those
languages.

~~~
discreteevent
Will Rust really be that much more "convenient" than Java with all its
tooling, libraries stack overflow examples etc? It seems to me it would be in
the same class as Java at best when it comes to convenience with the likes of
python and ruby being in a different class.

~~~
steveklabnik
This is 100% speculation, but in a few years, I can see Rust as a language in
which _those who code in it_ find it to be way more convenient, but those who
don't find it more difficult.

Basically, the borrow checker double checks your work. As you get better at
not screwing up, it'll become less and less of an issue. When you're just
starting out, it can seem way harder, because you're not used to having those
restrictions checked.

------
tptacek
So far as I can tell, if you want a fancy ORM, you're using a mainstream web
language like Ruby or Python. Golang is obviously more mature on the HTTP
serverside than Rust, but it is nowhere close to Rails, and is particularly
weak on persistence. My understanding is that the same is true of Clojure,
too.

~~~
chrismorgan
Go can’t do a fancy ORM because of its weak type system. Rust’s type system
and compiler plugin support (still being polished, but entirely usable) allow
for some _really_ nifty things. An ORM like Django’s is absolutely possible in
Rust— _and_ with strong typing and serious error checking into the bargain.

We can also end up with things like HTML templates compiled into your binary
and the HTML validated at compile time. Even things as precise as type
checking on something like <time datetime="{{ time }}"> can be managed with
Rust. And I intend to.

I’ll be talking about how some of these sorts of things can work out at
Strange Loop this year: [https://thestrangeloop.com/sessions/fast-secure-safe-
the-web...](https://thestrangeloop.com/sessions/fast-secure-safe-the-web-that-
can-still-be).

~~~
tptacek
The most popular current ORM is written in Ruby. I find your argument hard to
buy.

~~~
pcwalton
I think what he means is static type system _expressiveness_ , rather than
type system "strength" (which is a term I don't like, since it's so overloaded
as to be practically meaningless). Since it's dynamically typed, Ruby's static
type system is maximally expressive. Go's type system (as with Rust's, or
Java's, or any statically typed language) is less expressive by comparison.

I'm not ready to say that Rust's type system lends itself perfectly well to
ORM's, as I haven't really seen an ORM as convenient as ActiveRecord in any
statically typed language. (This is one of the reasons I like both statically
and dynamically typed languages.) But I'm happy to see people try, of course,
and I'd love to be surprised.

------
levosmetalo
Can't wait to try out Rust on sever though. I'd like to have compiled,
performant, small footprint and simple http REST server written in language
that is not Go or Haskel.

EDIT: I said not Go, because I don't like its type system, and whenever I have
to cast something to interface I have a strong flashback from the old Java 1.3
days. On the other hand. It's purely personal opinion.

~~~
nkozyra
Since Go will gladly handle said requirements, is this last point simply
arbitrary?

As Go and Rust share a lot of similarities, what is it about Go that's so
unappealing for this use case?

~~~
twic
Do Go and Rust share a lot of similarities? Apart from compiling into native
code and being relatively new, what?

It seems to me that Go and Rust are much more different than alike. Go has GC,
Rust has lifetimes. Go has a simplistic type system, Rust has a sophisticated
one. Go allows shared mutable state, Rust does not. These are pretty deep
differences.

~~~
1ris
Both implement the the CSP concurrency model, for example. Both have a C-like
syntax. They are both object-oriented, but very different in that from
java/c++/.net.

------
orthecreedence
This is more of a general question, but is rust going to have a C-compatible
ABI? In other words, if I define a function in Rust, can I export it into a
.so/.dll and load it up in MyFavoriteLanguage and call that function like I
can with C? Or would it require some kind of C wrapper around Rust that
interfaces with my language?

~~~
bjz_
You can define functions as `#[no_mangle] extern "C" fn foo() {}`

------
bryanlarsen
Have the servo developers endorsed TeePee yet? If not, that's a major sign
that "Are We Web Yet" isn't close.

~~~
chrismorgan
Servo uses rust-http, which I wrote; Teepee is not yet to the stage where it
can be used, but I expect that once it is Servo will switch to it as is
convenient.

(BTW, I’m curious: where did the spelling TeePee come from?)

~~~
tormeh
Transport Protocol and the indian tent-thing?

~~~
chrismorgan
I mean the spelling TeePee rather than how I have always spelled it, Teepee.

~~~
tormeh
Big P for protocol, I guess. A hybrid of TP and teepee. Or just how "TP" is
pronounced.

------
scriptdevil
Rust CI (rust-ci.org) is a good list of active Rust projects.

(Link currently down)

~~~
chrismorgan
Just got in contact with the maintainer of the site (hansjorg), he plans on
fixing it up today or tomorrow.

------
ackdesha
FTC just released a related report:
[http://www.ftc.gov/system/files/documents/reports/data-
broke...](http://www.ftc.gov/system/files/documents/reports/data-brokers-call-
transparency-accountability-report-federal-trade-commission-
may-2014/140527databrokerreport.pdf)

