11 ms·
Is Rust web yet? Not really
- levosmetalo 12y agoCan'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 12y agoSince 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?
- eudox 12y agoThe type system?
- nkozyra 12y agoThe type system doesn't preclude any of the requirements he listed (other than it simply not being Go)
- twic 12y agoDo 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 12y agoBoth 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.
- deleted 12y ago[deleted]
- VeejayRampay 12y agoOut of curiosity, why is it that you wouldn't want Go for such a task? Is it the lack of maturity, dislike for the language itself?
- Ygg2 12y agoProbably the GC. Rust once finished and proved should be safe for concurrent usage AND without GC cleanup. That's a major feat of engineering.
- matthewmacleod 12y agoThat's a major feat of engineering Absolutely, but it's not a reason to not use Go. The web is probably the platform with the least possible damage caused by GC. It's OK if people like the language and want to use it for web development, though. I'm personally pretty excited about it, because I'm not a huge fan of Go and Rust looks pretty neat.
- nkozyra 12y ago"On the topic of performance, keep in mind that Go gives the programmer considerable control over memory layout and allocation, much more than is typical in garbage-collected languages. A careful programmer can reduce the garbage collection overhead dramatically by using the language well; see the article about profiling Go programs for a worked example, including a demonstration of Go's profiling tools." And "The current implementation is a parallel mark-and-sweep collector but a future version might take a different approach." (which I'm certain it will) http://golang.org/doc/faq#garbage_collection http://golang.org/doc/faq#garbage_collection
- pcwalton 12y ago> On the topic of performance, keep in mind that Go gives the programmer considerable control over memory layout and allocation, much more than is typical in garbage-collected languages. That's true (although I would question the use of "allocation" there—I think Java has as much control over when you allocate as Go does), but "some control" is not always enough control.
- Ygg2 12y agoIf I remember Rust binaries, due to default static linking end up rather large. There is work to remove all unnecessary things from libstd into other libraries. That said, I can't wait for rust teepee server to land, it shapes up to be a rather interesting project.
- chrismorgan 12y agoThe binary is large, but the memory footprint small. And the startup time is small, too… servers that start up in under five milliseconds—delightful for me, with my Django background.
- jff 12y agoCompare the footprint of your single static binary to a python program + the appropriate python 2.7.whatever & specific library versions which must be shipped with the program since odds are the user doesn't have the right version installed...
- eridius 12y agoDynamic linking cuts the binary size down considerably, but of course it requires the Rust libraries to be installed on the machine. You can also turn on LTO for even more savings.
- b0b_d0e 12y agoFor some reason, no one has mentioned that there is a very usable rust REST framework right now that you can try out https://github.com/Ogeon/rustful https://github.com/Ogeon/rustful I'm not the author of this, so I can't tell you what features are missing, but the features that are there work very well from what I can tell. When it comes to web frameworks in Rust, there aren't many options yet (as stated in are we web yet) but the few that are out there are in active development.
- steveklabnik 12y ago> For some reason Discovery of Rust projects is super hard right now. I'm quite into both REST and Rust and didn't know about your framework :/
- b0b_d0e 12y ago> Discovery of Rust projects is super hard right now. Good point! But I'm not sure of any other way to get projects noticed besides word of mouth and posting about them on sites like Hacker news and such. In fact that is where I first heard about rustful. > didn't know about your framework My framework is actually at https://github.com/jroweboy/oxidize/tree/incoming https://github.com/jroweboy/oxidize/tree/incoming (master branch is sorely out of date) and I feel I still have a long way to go before I get that finished :)
- drbawb 12y agoI'm happily using the ZeroMQ bindings to serve an HTTP and WebSocket service w/ Mongrel2 servicing requests and Rust providing the handlers. Not a pure Rust stack, but it does a very admirable job serving responses for such a young language. (I also love have fallen in love w/ how mongrel2 handles websockets. I find it fits very well w/ Rust's message passing between tasks.) So it's not like writing a webservice in Rust is completely impossible. I will admit that "we aren't web yet," but I'm glad to see the community working on it.
- idlewan 12y agoThat's the exact path I've taken in another language (Nimrod). Mongrel2 is a really good way to have all the nitty-gritty of http handled while you worry exclusively about two ZeroMQ sockets (from and to Mongrel2). It makes it a whole lot easier and safer.
- tptacek 12y agoSo 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 12y agoGo 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-that-can-still-be https://thestrangeloop.com/sessions/fast-secure-safe-the-web....
- pdeuchler 12y agoI think you mean Go can't do a fancy ORM because of it's strong type system?
- apendleton 12y agoNo, as compared to Rust's type system, Go's is pretty unsophisticated.
- chrismorgan 12y agoNo, I don’t. While a strongly-typed language, Go’s type system is very weak compared with one like Rust’s.
- pdeuchler 12y agoWhile I'm naively familiar with Go's type system I'm not at all familiar with Rust's, so i'll defer to you on this... That said, could you explain how Go's type system is weaker than Rust's?
- scriptdevil 12y agoRust CI (rust-ci.org) is a good list of active Rust projects. (Link currently down)
- chrismorgan 12y agoJust got in contact with the maintainer of the site (hansjorg), he plans on fixing it up today or tomorrow.
- bryanlarsen 12y agoHave the servo developers endorsed TeePee yet? If not, that's a major sign that "Are We Web Yet" isn't close.
- chrismorgan 12y agoServo 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 12y agoTransport Protocol and the indian tent-thing?
- chrismorgan 12y agoI mean the spelling TeePee rather than how I have always spelled it, Teepee.
- tormeh 12y agoBig P for protocol, I guess. A hybrid of TP and teepee. Or just how "TP" is pronounced.
- hendzen 12y agoNot 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.
- chrismorgan 12y agoRust is certainly not ready yet, but I think you’ll be surprised how great Rust can end up; I believe it will end up superior to the options available, though its systems focus will certainly have certain cognitive burdens; it is not going to be superior in every way. People typically associate web servers with dynamic languages. I am ready to challenge that notion; there are various things that people don’t think of that a language like Rust makes possible, and those sorts of things are the focus of my talk at Strange Loop this year, in September: https://thestrangeloop.com/sessions/fast-secure-safe-the-web-that-can-still-be https://thestrangeloop.com/sessions/fast-secure-safe-the-web...
- mwcampbell 12y agoYour Strange Loop talk description presents some good reasons for using statically typed languages, but why Rust specifically? Why not the JVM, using Scala or even Java 8? Sure, a Rust program compiled to native code can start faster, and be fast right away without any JIT warm-up. But is it worthwhile to optimize for those things? Especially since the JVM already has a much larger set of libraries and tools. And while Rust's lack of GC would probably yield impressively low memory usage figures, I wonder if that matters in server applications. The idea of a server that starts up fast, is fast from the start, and has minimal memory usage is appealing to me, but I suspect that it's irrational to optimize for these things except in niche applications like web interfaces in routers.
- ackdesha 12y agoFTC just released a related report: http://www.ftc.gov/system/files/documents/reports/data-brokers-call-transparency-accountability-report-federal-trade-commission-may-2014/140527databrokerreport.pdf http://www.ftc.gov/system/files/documents/reports/data-broke...
- orthecreedence 12y agoThis 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_ 12y agoYou can define functions as `#[no_mangle] extern "C" fn foo() {}`
- steveklabnik 12y agoOne of the three existing Rust deployments is a Ruby gem written in Rust. Technically, it's a Ruby gem written in C, which calls out to Rust. So yes, it's very possible, today.