6 ms·
When Rust Makes Sense, or The State of Typed Languages
- sagichmal 11y agoReformatted to be readable: https://gist.github.com/anonymous/296f6c90dcbc9033d97c https://gist.github.com/anonymous/296f6c90dcbc9033d97c
- walrus 11y agoDo you have HTTPS Everywhere installed or JavaScript disabled? The site tries to load a Markdown-rendering JS library over HTTP, so if you visit https://m50d.github.io/ https://m50d.github.io/ instead of http://m50d.github.io/ http://m50d.github.io/, your browser won't render the Markdown.
- emn13 11y agoI think it's sort of weird how people have latched on to markdown. Minimalist html is hardly any wordier than markdown, and at least that works everywhere, and works the same everywhere (unlike xyz-flavored markdown of the month), and it allows an escape hatch into complex layout when you really need it.
- d_theorist 11y agoMarkdown is fine, but I can't understand why you would want to render it in the browser. Why get the client to do the work with every request? Just render it once on the backend and deliver the html.
- emn13 11y agoSure, it's "fine" - it's just unnecessary, less portable, less future-proof, and more complex to render (as this article demonstrates). What's the point? Why opt for that complexity when you don't need to? Just to save a very low percentage of key-strokes? That strikes me as being penny-wise & pound foolish. And much as most text is fairly bare-bones, sometimes you do want extra layout control - and then markdown is really in your way.
- d_theorist 11y agoI don't see why it's either less portable or less future proof. It's a different markup. One that many people find easier and more natural to write. Of course, different people have different opinions on that. For people who find writing and reading markdown nicer than HTML it makes sense to use markdown as the base format that you write everything in, and then convert to different formats as needed (html, pdf, whatever). For you, HTML may play that role. Personally I find HTML ugly to read and write.
- emn13 11y agoI agree that markup is easier to write - it's shorter. And typical html is much messier. But if you wrote html the way you did markdown the difference is much smaller. In fact - look at the OP's text. That article in html would be barely longer. To summarize: markup is better to read+write. But the difference is almost zero. Anything other than trivial markup is a mess; exceptional layout often impossible (and I value the ability to creatively use layout to get my point across). It doesn't support wysiwym editing (very well). It isn't trivially statically hostable - and if you try it's fragile and flashes uglily. Many flavors exist that are slightly different. I prefer flexibility, consistency and simplicity over micro-optimizing source readability.
- lmm 11y agoMy blog originally lived on fully static hosting. When I moved to github I made minimal changes. I also like the idea that the "source" is right there on the page rather than a separate "API" - the dream of XHTML+XSLT. When I originally set it up I wanted the page to be readable using Telnet - which I think it is, more so than one rendered on the server would be. I couldn't tell you now why that seemed important though.
- sagichmal 11y agoOK, that explains it. But it's crazy, in my opinion, to use JavaScript for this purpose.
- d_theorist 11y agoThanks.
- skimpycompiler 11y agoRarely do I ever manage memory in C++. As much as I adore Haskell there's a bunch of stuff you cannot do fast enough in any of the languages described above, as easily as you can do it in C++. Try writing a fast A* (without any pointers and memory management, easily done in C++), maybe a travelling salesman problem -- simple 2-opt heuristic (easily done without memory management). If you find these suitable for libraries, and not something you would write on your own, there's not a single fast matrix library implementation in Java or Haskell. If something that "simple" can't be done, then, in my case, I cannot use these languages as easily as I can use C++. A simple principle, a simple idea of copy and move semantics enabled me to write C++ code without worrying much about memory at all. When allocations become a problem, I just move the container out of that heavy loop, or change my malloc implementation with a simple flag, and it's still 10x if not 100x faster than what Haskell/Scala/Java could accomplish in the same amount of time it took me to write the C++ code.
- claudius 11y agoCame here to say this. "Modern" C++ with move semantics may still be fairly verbose in some cases, but claiming that you need to manually care about memory management (i.e. call new/delete/malloc/free) is a bit weird. It becomes especially weird when the post somehow implies that “paying client[s]” have arbitrary amounts of CPU time and memory available and that you can hence squander their resources as you please. Having said that, I can easily agree with the remainder of the post that the existing languages/ecosystems aren’t alternatives, and that statement does not change if you correct Scala’s “great performance” to “mediocre performance”.
- lucian1900 11y agoThat's precisely why I find Rust so interesting: you can get the same results as with C++, but without accidental memory unsafety.
- lmm 11y agoOn the matrix algebra side I use breeze, i.e. backed by netlib-java and ultimately by the native LAPACK (probably FORTRAN), but with a nice Scala interface on top. It reads very nicely, and performs well.
- gmjosack 11y agoI'm personally interested in Rust for a couple reasons. As an SRE/SysAdmin I struggle to believe that C or C++ can be written safely. It is very common that I see software being emergency patched because of memory unsafety from very experienced engineers in ubiquitous software. Why would I need the performance/efficiency of C in the first place? Well, I regularly write software that runs on thousands to tens of thousands of machines in production. This software runs below the service. I feel a certain sense of pride in minimizing my observer effect on the system. With Rust, compared to Python, I can write software that has more functionality with a fraction of the memory and CPU utilization. Another thing that has become more appealing to me is the strong static type system. Not having a formal background in CS I fell in love with Python for how it enabled me to move quickly, and Python is still my go-to language for most things, but after years of supporting large production sites plus running my own code in production I'm a bit tired of runtime exceptions. We have great exception logging and there are entire classes of bugs we'd just never see with Rust's type system and error handling. Essentially, Rust gives me new super powers and the borrow checker is my sidekick making sure I don't shoot myself in the foot.
- MichaelGG 11y agoBut this whole time, if efficiency was your aim, why not use, say OCaml? But good viewpoint: Rust is actually friendly enough that it is viable for the kind of things you mention.
- gmjosack 11y agoAnother thing is the lack of runtime is really compelling. I can continue to write Python and can drop into Rust for hot code. Right now this is through C which does get me a bit of unsafety but it's much smaller scope. As Rust becomes more mature I'm looking forward to the ABI stabilizing so other languages can build ffi interfaces against it directly. I'll admit that OCaml is something that I've looked at before but it didn't have the staying power for me. It's likely just because it was too different at the time compared to what I was used to.
- something123 11y ago
- diminish 11y agoIf someone writes a nice summary of what is missing/failing in each one of those typed languages, would be very fruitful. At the end why don't we see a flood of people quitting C/C++ or dynamic languages to jump to those challengers?
- conceit 11y agoinertia. Observers are waiting for a killer app to sway the masses. Obviously memory safety isn't a killer feature in many eyes, because they trust their abilities, would have to go all out using the unsafe environment or they don't see the benefit of one less class of bugs over other concerns. If they did any of that, they would at least be using e.g. java already - on another note I'm only waiting for rustc's first security relevant bugs to be reported, that are supposedly impossible. I heard the name was a play on words on a one-of-error concerning Trust.
- kibwen 11y agoNobody pretends that bugs in rustc are impossible. :P Go peruse the issue tracker if you don't believe me, though many of the soundness bugs there are so obscure that I think you'd have a hard time exploiting them in theory, let alone in practice (and they're also liable to be fixed well before Rust starts getting deployed en masse).
- rwmj 11y agoOCaml "writing a first-rate concurrency-friendly runtime would require massive investment". Except it's already being done in OCaml 4.03 [1]. I still don't think this is actually a problem, since in many cases (NUMA, distributed systems) it's better to use other approaches. If the article is serious about safety, then it wouldn't encourage people to use threads with shared memory. [1] https://sympa.inria.fr/sympa/arc/caml-list/2015-05/msg00034.html https://sympa.inria.fr/sympa/arc/caml-list/2015-05/msg00034....
- MichaelGG 11y agoIt is confusing to me, too, why a Ruby or Python user would look at Rust (for the same use cases). Unless they want it to replace C for native extension libraries: then it makes a lot of sense. But I'd expect a Python user to pick up Go before Rust, simply because Go is more like Python (managed runtime). Rust comes up a bit short, I think, when looking at some functional styles. Function composition doesn't look very easy in Rust, so a lot of the concise code you might expect in a functional language is much more work to express (no custom operators either). Not that I blame them: having no-overhead (no GC, but also no spurious code/allocations in general) yet fully safe as a core design goal is a huge constraint that no one else has had success under.
- bjz_ 11y ago> It is confusing to me, too, why a Ruby or Python user would look at Rust (for the same use cases). Perhaps it is because they are not looking at it for the same use cases, and more as something to augment their toolkit. Rust makes it possible to be a decent systems programmer without having to spend a decade of acquiring the war wounds to become a great C or C++ dev. In the past, the only real option for those devs if they wanted decent performance was Java, and it's really hard to get Java to talk to Ruby or Python, and it's also hard to understand what the JVM is doing under the hood. Rust is now a possible alternative.
- eevilspock 11y agoHere's what Armin Ronacher, the creator of Flask, thinks of Rust and how it compares with Python: http://lucumr.pocoo.org/tags/rust/ http://lucumr.pocoo.org/tags/rust/ Note the articles aren't listed in order. Rust for Python Programmers is the latest, written four months ago.
- mangecoeur 11y agoAs a Python developer interested in Rust, for me it's the logic is this: Rust allows me to learn a systems language to complement high level/scripting language without having to learn C/C++ which I find ugly and full of legacy cruft. This is important since Python encourages you to build native libraries for performance or low-level interfaces. The Rust programming style is also more familiar than "true" functional languages. Languages like Go are tricky for Python extensions because they include their own runtimes, which means you have 2 runtimes with garbage collectors to deal with. In a more "fuzzy" sense, I think there's also a philosophical appeal in the way Rust promotes human-friendliness over theoretical purity. Python promotes one correct and logical (to humans) way of doing things and I feel Rust is designed with the same ambition, even if the requirements of low-level memory management necessarily make it more complicated.
- Drup 11y agoIn all the section related to OCaml, replace "concurrency" by "parallelism". OCaml has an excellent concurrency story (through libraries like Lwt and Async) and a decent story for message-passing parallelism. The issue appears with (GC-managed) shared memory. Incidentally, the work on the GC is on its way.
- moomin 11y agoWorth mentioning that footnote [2] also applies to Haskell, but not to the same extent.
- yokohummer7 11y agoAs a Rust proponent, the reasons listed in this article match my sentiment surprisingly well, although the author seems to think Rust isn't ideal for my use cases. I'm also from Python, which I've used for more than 10 years, and chose Rust as my next weapon. - Haskell: While pervasive laziness does have its merits, I believe it is not the best choice in general, especially for performance-wise. Having to use streaming libraries to do even a simple I/O is just ridiculous. Its syntax was also a big obstacle to me, but thankfully I overcame it. But I'm not sure I can also persuade my colleagues to do the same thing. - Scala: If I have a JVM requirement, Scala would be a really good fit. (Un)fortunately I don't have such a limit, so what Scala provides are less appealing to me. It also seemed way too gigantic to me at a glance, probably to be interoperable with Java. But I've not tried it deeply. - F#: I've only heard good things about that, and it was quite a great experience learning through its great IDE. The problem is that even though MS's recent moves I'm still not completely sure if I could retrofit myself to the .NET ecosystem. But the future is bright. - OCaml: OCaml always felt a bit "obsolete" to me. AFAIK it even didn't have multi-core support until very recently (no parallelism, concurrency only), and they seem to have no resources for a decent Windows support. It has also a funny syntax. I definitely agree Rust's syntax is ugly at best, but OCaml's is... I just can't describe it. Hopefully I can get used to it someday, like I did to Haskell. And I met Rust and instantly fell in love, even though it requires me to do manual memory management. While manual memory management makes a certain data structure harder to implement, what I realized is that for my daily job, especially for "boring" works (e.g. CRUD apps), it is OK to use manual memory management. If there's a need, I can always borrow libraries from others to accomplish my job. And it is fast by default, less need to optimize the code by myself, as seen in Haskell. That said, what I have as a "best" language in my mind is, probably a strict version of Haskell. Yeah, that would be Idris, like the author suggests. I really hope that Idris will take off in the near future.
- groovy2shoes 11y agoOCaml's syntax is really not that different from F#'s. This isn't surprising, since F# was originally just "OCaml for .NET".
- moomin 11y agoI think people who've experienced the awfulness of cabal should give Haskell another try with stack.
- heinrich5991 11y agoThe text is somewhat hard to read for me. Upon a closer look it seems that the text has different font sizes in it. I tried to mark some inconsistencies: http://i.imgur.com/ECUBQA5.png http://i.imgur.com/ECUBQA5.png Is this intentional? If so, what purpose does it serve?
- lmm 11y agoNot intentional. I just wanted to defer all that to Strapdown and get on with writing. Maybe I should give up and move to medium.
- yokohummer7 11y agoThe page renders well in my browser, and lookup at the generated HTML there doesn't seem to be something suspicious... Maybe one of the fonts doesn't render in your browser?
- osullivj 11y agoThe author wonders why Rust is getting attention in 2015, despite lacking GC. The answer is concurrency, a much more difficult problem than avoiding null ptr derefs. C++ advocates are right to say that with Boost libs and C++ 11 and 14 it's much easier to avoid mem mgmt problems. Concurrency remains hard, and Rust's borrow mechanism is the biggest step forward since the late 90s IMHO.
- lmm 11y agoHow does borrowing help with concurrency? You can only borrow on the same stack, no?
- osullivj 11y agohttp://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.ht...
- steveklabnik 11y agoYou can borrow something that's on the heap as well. And you can safely share pointers into stacks across threads with the right libraries, too. See https://crates.io/crates/crossbeam https://crates.io/crates/crossbeam
- graffitici 11y agoCan somebody expand on the "social issues" with Scala?
- kod 11y agoIt's really just the blog author's subtle way of saying that a particular individual (probably Tony Morris) is an asshole.