7 ms·
Rust for Clojurists
- edem 9y agoThey are called __clojurians__.
- idobai 9y agoThey are called __trolls__.
- rcarmo 9y agoAside from the emphasis on mutability, I got nothing from this except bias. .jar files are an _advantage_, and the author comes across as a card-carrying member of the Rust Evangelism Strikeforce aiming to bring into the fold a small (but opinionated, and borderline influential) community :)
- badpenny 9y agoIt's not a competition.
- madez 9y agoWhy are you so negative about Rust and people who advertise it?
- rcarmo 9y agoBecause they _advertise_ it. The piece would be a lot better if it did positive comparisons.
- sanderjd 9y agoI think you may have missed the sense of humor. For instance the thing about jars is absolutely a joke. I thought it came across very much as someone very reasonably discussing tradeoffs and cracking some pretty good jokes along the way. As an aside, you have to be kind of careful when saying things appear to be advertisements - if it doesn't seem to be true (as in this case it doesn't), then you come away looking like the one with an agenda.
- hacker_9 9y agoGood article. He missed out the main pro though (and literally the only reason I ever use any Lisp): hot swapping. The ability to change code on the fly as the program is running. For this to actually work you need 2 things: 1. No explicit types: Everything in Clojure is just a list or hash map, so I can add extra members to anything at runtime no problem. The amount of static checks Rust does at compile time makes this non viable. 2. Fully immutable data structures: If my changes cause exceptions, then the program can just rewind and throw away the new state it was building, let me fix the error I made, and then continue on as if I never committed the broken code. In Rust an exception would mean I've potentially mutated state in a bunch of places, and now can't get back to the previous working state at all.
- MichaelGG 9y agoIn which scenarios do you use hot swapping?
- hacker_9 9y agoJust about every scenario? Any algorithm I am working on, any function, any config variable I want to tweak in real time, any GUI I am developing, and so on.
- MichaelGG 9y agoSo for interactive work? Versus updating long running server jobs? I'm used to using the REPL in F#, but you can't redefine data types and have old code pick up on it - only new code. Such an approach is theoretically possible in Rust. Debuggers can do this for C++ to some extent.
- stingraycharles 9y agoClojure has a very REPL-driven workflow, where you connect your editor to a REPL (usually emacs+cider) and get instant feedback about anything, reload code on the fly, and inspect your program's state. This is a fundamental concept of pretty much any LISP, and is lacking in rust.
- 9y ago
- 1_player 9y ago> Rust chose to call its [package] format "crates". This reflects the language's industrial roots and the humble, blue collar town of its sponsor: Mountain View, California. Nice :)
- delegate 9y agoSome funny gems: > You will remain a replaceable silhouette with no discernible identity. > This isn't C or C++, where you just include files like a caveman. >The upside is, you will curse it at compile-time instead of at runtime. The downside is, "exploratory programming" means exploring how to convince the compiler to let you try an idea. After that it gets a bit more serious, but still a very good Saturday afternoon read.
- charlieflowers 9y ago+1 for this gem right here. Well done! "Many people try to compare Rust to Go, but this is flawed. Go is an ancient board game that emphasizes strategy. Rust is more appropriately compared to Chess, a board game focused on low-level tactics. Clojure, with its high-level purview, is a better analogy to the enduring game of stones."
- actuallyalys 9y agoYeah, the wry humor throughout is great. Another good bit: "While the Rust project doesn't start off with any equivalent to Clojure's namespace declaration, once you move beyond a single source file you'll need to use it. This isn't C or C++, where you just include files like a caveman. Rust separates code into modules, and each source file is automatically given one based on the file name."
- zcdziura 9y ago> You're in an industry reaping disproportionate benefit from loose money policies, leading to a trend-chasing culture of overpaid nerds making web apps. You feel guilty about this, but there is nothing you can do about it because you have no other talents that a rational person would pay you for. /r/2meirl4meirl But in all seriousness, this was a great article and an exceptionally fun read!
- StreamBright 9y agoNice. My biggest problem with Rust is the poor performance and lack of complete & sane libraries, especially for HTTP. I was running into serious issues with the following code: https://gist.github.com/l1x/5678c0fdfc2c1a6034b8bcc3800de93c https://gist.github.com/l1x/5678c0fdfc2c1a6034b8bcc3800de93c Its performance is saturated around 60K req/s on a 32 core box with 10G networking while wrk was more than happy to do 3M req/s. I was trying to dig further into why it is slow and it seems that hyper is the culprit. However, I was not able to come by this issue and just used wrk2 for testing. Let me know if anybody has insight into how to go beyond this perfroamance or what are the issues with my code.
- erickt 9y agoHello! It's been a bit since I dug into hyper, but that's surprisingly low. Just to check, did you compile this with optimizations enabled, like `cargo build --release`?
- StreamBright 9y agoYes I did compile like that, even had optimization on. [package] name = "hammer" version = "0.1.0" authors = ["me"] [dependencies] hyper = "0.10" [profile.release] opt-level = 3 debug = false rpath = false lto = false debug-assertions = false codegen-units = 1 panic = 'unwind'
- kaoD 9y agoI'm not sure about performance vs wrk (don't kwow wrk), but just to give an idea: I noticed you're not using Tokio Hyper. Try Hyper's master branch, which fully embraces Tokio's async. EDIT: From wrk's README: > wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue. Your example is multithreaded but IIRC release Hyper isn't using event notification async, which Tokio Hyper does. It might help.
- StreamBright 9y ago
- coldtea 9y agoWhile I understand this kind of guide (showing how things are done in one language/ecosystem vs another), is there such a thing as a Clojurist that would have benefited from it? I'm not asking whether there are Clojurists. Of course there are. I'm asking whether there are people that primarily and only know Clojure, and thus would benefit from a translation guide between Clojure and Rust, instead of say between C or Java or Python or Ruby etc and Rust. I'd think that anybody who uses Clojure was already familiar and/or proficient in some other language before, much more major than Clojure.
- actuallyalys 9y agoI'm better at Python than Clojure, but I appreciated this article anyway. Clojure and Python take different approaches, so a comparison of Python and Rust and one of Python and Clojure highlight different parts of Rust.
- nbardy 9y agoYes. Me. I've been programming for about ten years, but mostly jumped from language to language until I found clojure. Clojure is the only language I really "know".
- AlexCoventry 9y agoI think it's satire?
- coldtea 9y agoNo, it's written in a funny way, but it's a legit guide.
- akhilcacharya 9y agoNot even a clojurist, but this is the best Rust intro I've seen so far.
- deleted 9y ago[deleted]
- y_u_no_rust 9y agoIs the world so boring that all we have are posts about rust?