12 ms·
The first few comments here seem to argue against the article, as do comments below the post but I am very much with the author. I strongly disagree with the R
by Barrin92 8y ago
The first few comments here seem to argue against the article, as do comments below the post but I am very much with the author.
I strongly disagree with the Rust mentality, and the general mentality of statically typed languages with extremely prohibitive compile time checks, that seem to become more common.
Underlying that model seems to be a concept of software like a sort of renaissance master's marble statue, error free and perfect at time of production.
The downside that the author points out seem to be often neglected. Constant interruption and battling with the type system during development, when mental overhead is a problem. Coupling components by types propagating through software, increasing time and effort to make changes to your software, increasing the overhead for others to contribute.
In my opinion the dominant metric to evaluate the usefulness of a language's type system should be its overall effect on cost, time spent, productivity, ease of development and capacity to change. Everything else is very subjective or just an aesthetic concern.
- sanxiyn 8y agoI disagree, because Rust compile time checks are not prohibitive. I agree on all other points: you shouldn't try to write perfect software first time, mental overhead is a serious concern, battling type system is bad (but you don't do that in Rust). Overall, Rust is a productive language, especially compared to C++.
- adamnemecek 8y ago> capacity to change Good luck making changes to a 100kloc Python codebase.
- gmueckl 8y agoYou could perhaps start by adding type annotation. They are not perfect, but they help.
- adamnemecek 8y agoToo little too late.
- ignaloidas 8y agoIf you have good manners, Python codebases can easily grow over 100kloc mark. Static type annotations, using descriptive variable and class names, type checks on user input(esp. libraries) makes growth safe and simple.
- arcticbull 8y agoThat’s a good observation, thing is, Rust just makes the manners mandatory.
- Spiritus 8y agoNo problem. I do it every day.
- adamnemecek 8y agoAlright, now dive into a new codebase and report back.
- pizza234 8y agoI do something similar daily, and it works fine, as we have a strong test suite. You can't disassociate dynamically typed languages from (strong) test suites, so one needs to qualify: > Good luck making changes to a 100kloc Python codebase without test suite versus > Good luck making changes to a 100kloc Python codebase with a good test suite In context, the first case is no different from "Good lucking making changes to a 100kloc Rust spaghetti-coded codebase", and one can't meaningfully judge a something based on a poor use of it.
- adamnemecek 8y ago> In context, the first case is no different from "Good lucking making changes to a 100kloc Rust spaghetti-coded codebase", and one can't meaningfully judge a something based on a poor use of it. It's not the same. Type system provides certain guarantees. Also it's much harder to write spaghetti code in Rust.
- baq 8y agodid that on 50k code base with the help of runtime automatic type annotators (e.g.https://github.com/Instagram/MonkeyType https://github.com/Instagram/MonkeyType) it's absolutely doable, it took a few days total.
- petre 8y agoThis was my impression as well when I tried Rust - always fighting the compiler. None of this happens with D. You just code away and keep being productive without the annoyances of C++. In fact C++11 and 17 are less and less annoying.
- isatty 8y agoI believe you’ve not been on the receiving end of a 17 page compiler error while trying to compile a template heavy app, because you forgot to put an &. The important part is to realize _why_ you’re fighting the compiler as it’s trying to make _you_ write better code and improve. If you find non issues being reported by the compiler please report it and make it better for all of us too!
- Const-me 8y ago> as it’s trying to make _you_ write better code and improve. It’s not necessarily an improvement. When an algorithm processes complex data structures organized in graph or tree, no amount of better code allows to easily implement that in Rust. It’s either slow, or unsafe and hard to implement, or both. Even without trees, consider a simple LRU cache structure. Trivial to implement in most languages by combining linked list with hash map. Rust implementation is more than 1000 lines of code, many of them are unsafe: https://docs.rs/linked-hash-map/0.4.2/src/linked_hash_map/lib.rs.html https://docs.rs/linked-hash-map/0.4.2/src/linked_hash_map/li... I never wrote production code in Rust. But based on my limited experience, the language is fine for projects that have few data structures, or they’re simple so you can stick to library containers, and a lot of code processing them. For many practical problems it’s quite the opposite.
- baq 8y ago> Even without trees, consider a simple LRU cache structure. Trivial to implement in most languages by combining linked list with hash map. Rust implementation is more than 1000 lines of code, many of them are unsafe: ... in this context, criticizing using unsafe in rust and comparing that to C++ is comparing apples to oranges. GC languages aren't even worth mentioning here. > It’s not necessarily an improvement. When an algorithm processes complex data structures organized in graph or tree, no amount of better code allows to easily implement that in Rust. It’s either slow, or unsafe and hard to implement, or both. here's the thing: all of the above are true in other languages, C/C++ included, it's just that no compiler besides rust will warn you that recursive data structures are hard - it doesn't matter if implementing them is easy, proving they're implemented correctly never is. rust tries to help you prove you did the right thing and it needs assurances (unsafe) where it just can't do that. C++ is all unsafe.
- mjburgess 8y agoStatic checking burdens the developer with thinking more, etc. -- for sure. The cost is requiring a developer with stronger cognitive abstracting skills. Those people tend to be academics (its almost a definition of a good academic) and also, perhaps, less pragmatic. The ease of programming is not merely a matter of knowledge or experience, base cognitive skills play a very significant part which are largely an at-birth and developmental factor (cf. The Neuroscience of Intelligence (Cambridge Fundamentals of Neuroscience in Psychology)). Probably languages requiring a proficiency at dealing with highly abstract relationships as part of the activity of programming are never going to be mainstream. Most people find that too difficult to do easily, and so too tasking to program. That isn't the general case however. Some people find it easy enough, and so do not see this tradeoff. For these people, the clear benefits in creating a statically "correct" program outweigh the minor difficulty in creating it. For the able, this "difficulty" is perceived as fun, and as frustrating by those who aren't. When something is beyond our basic capacity we tend to see it as "needlessly difficult" and not worthy of our time/attention (and of course, for us, it is). In otherwords: the unable are often snobs. eg. "Acting is stupid", "Rust is crap", "Painting is pointless" etc. -- all amount to, "i struggle to do that".
- TomVDB 8y ago> In otherwords: the unable are often snobs. Oh the irony.
- mjburgess 8y agoYou'll find no value judgement in my comment. There are many axes of intelligence, as well as of human value in general. I only said that comfort-with-abstraction is one axis on which people vary -- and I'd say that's exactly what the previous comment relies upon. All it says is "this is needlessly hard", the only reply can really be: yes, for you. I was offering an explanation of why that is; or else are we really saying that this "hardness" is universal? One of the more important characteristics of a developer is pragmatism which has zero covariance with comfort-with-abstraction. And so, why not value those who have that more? That is, to be better at abstraction isnt to be a better developer. It is only to be better at one sort of development. Equally, to have more pragmatism is to be better at a different sort. There's no snobbishness in my comment, only in a person who reads into it a value judgement about this specific form of intelligence. Why read that into it?
- edflsafoiewq 8y agoI feel the opposite. Strong compile-time checks make it easier to modify a system, and especially make it easier for people unfamiliar with a codebase to contribute. Being explicit what the static properties of a system are makes them easier, not harder, to modify. Types serve as explicit documentation for facts about the system that would otherwise have to be reconstructed by every reader. Type checking ensures that any change to one part of a system still interfaces consistently with all the other parts. Writing in a dynamic language can be faster, since you can skip writing down information that you would have to be explicit about in a static language, but once that information has been purged from your mental cache, IMO that's when the system acquires the immutability of marble. (The other nice thing about dynamic languages is certain patterns are often syntactically much cleaner.)
- sanxiyn 8y agoHot reloading is the critical feature, and dynamic languages usually have better support for it. (Lisp is a good example.)
- adamnemecek 8y agoHot reloading doesn’t provide safety guarantees.
- sanxiyn 8y agoMaybe, but hot reloading is very very useful. It is mostly a development time only feature anyway.
- loup-vaillant 8y agoI believe we have seen Casey Muratory doing hot code reloading in C++, in his Handmade Hero stream. Compile the dll, reload & test the dll, without exiting the game runtime he's developing. The Yi editor, written in Haskel, I believe does hot code reloading as well. The XMonad window manager can be recompiled and reload while keeping your windows up (the configuration file is actually Haskell code). --- Yes, hot code reloading is bloody useful. It is also perfectly compatible with static typing. I see no good reason for statically typed languages to have worse support for it.
- flukus 8y ago> I strongly disagree with the Rust mentality, and the general mentality of statically typed languages with extremely prohibitive compile time checks, that seem to become more common. I think this is more post-hoc justification than anything else. There seem to be an awful lot of developers concerned about memory safety since rust started becoming trendy and I don't think many of them were coding in ada before rust existed.
- Jach 8y agoRust's contribution is memory safety without a GC, so as a new approach it's somewhat exciting. But for most programmers before Rust and today, memory safety has been a solved problem not worth thinking about because most programmers use a GC language.
- geezerjay 8y ago> The downside that the author points out seem to be often neglected. Constant interruption and battling with the type system during development, when mental overhead is a problem. This assertion is just wrong. The author makes it quite clear that he doesn't know the language and is still taking his first steps ( "I am still a Rust learner, not a veteran" ), he implies that has problems with correct memory management and best practices while using other languages (core dumps heart attacks), and claims that one of the most important aspects of Rust is that "it's memory safe". Of course, memory safety is achieved through compiler checks. However, the author is still someone who does not know how to use a programming language and is still bound to not only the mental model of another programming language but also bad practices that lead to problems. If someone tries to write broken C or C++ using Rust and Rust's compiler starts to throw error messages pointing out the errors the programmer is making by trying to write broken C or C++ in Rust then obviously Rust is not the problem. It is im fact the solution, and a solution that's being ignored. Heck, the author praises Rust and it's memory safety, but then proceeds to criticise Rust's compiler because, as he puts it, the compiler will stop you from doing unsafe stuff again and again. Isn't that the whole point? Or is anyone expecting that your memory corruption problems will magically cease because you write your same old memory allocation and access bugs in Rust instead of C or C++?
- tsimionescu 8y ago> Heck, the author praises Rust and it's memory safety, but then proceeds to criticise Rust compiler because, as he puts it, the compiler will stop you from doing unsafe studf again and again. Isn't that the whole point? Or is anyone expecting that your memory corruption problems will magically cease because you write your same old memory allocation and access bugs in Rust instead of C or C++? I think the biggest problem with advanced type systems and complex compiler checks is that they are only desirable when you know the code you're writing is the the right one. A lot of the time, you're exploring a solution and don't care about edge cases, since you're not sure you've even found the right happy path. At this stage, you don't really care if your code is handling all required inputs, if it doesn't have leaks etc. - you just want to run it and see whether it at least sometimes produces the right output. At this stage, you're often fighting the compiler. Once you know that you're on a good path, then you start caring about safety and all the other bits, and the compiler starts becoming a trusted friend. It would be really interesting to have a system that supported both modes, e.g. starting from Rust but setting a flag to turn borrow checker errors into warnings or something similar. I'd bet that would change many people's perspectives, like the author of this article.
- jayd16 8y agoIts just temporary pain. Once you learn to use types properly, you stop having to constantly think about typing. I assume Rust pointer ownership is much the same way. The author was doing unsafe stuff and the compiler complaining. Once he gets in the swing of things, doing it right will become his natural flow. Verbosity of a language is a valid complaint that never goes away no matter how idiomatic your code writing gets but as written I'm not sure this was the author's complaint.
- atoav 8y agoI am probably more of a beginner when it comes to compiled languages. What surprised me most about Rust was that after understanding it, I liked it more than Python. I intended to learn it as a speedier more controlled alternative. A sharp tool to throw at slow code to make it go away. But once I got the hang of it progtamming Python became less and less attractive. The most interesting thing about rust is, how fast you can get up to speed with understanding what somebody elses code does. The thing however is: if you try to write Rust like Python or C, you’re not in for a good time. It took me 3 months to stop using ingrained OOP patterns I really thought I needed because this was the way how I did things back in Python. The moment I started to become interested into how to structure code in Rust, was the moment it made click for me. Seems it is much easier to program WITH the compiler than against it — who would have known!
- xvilka 8y agoYou can try to use Elixir for scripting instead. It feels "right", after the experience with OCaml, Rust, and similar languages.
- stunt 8y agoThat’s not necessarily a fair point to compare. Perhaps it just feels like that because C++ has been around for a long time. If you write production code without being a C++ master, you also have different struggles before getting it right.
- devwastaken 8y agoRust doesn't make much sense for this kind of project in the first place. You use it for things that need to be memory correct, and proveably so. Very useful for handling uncontrolled data.
- hawski 8y agoThere could be a --i-am-a-stuntman-and-i-spit-in-the-face-of-danger flag, that would disable some checks for compilation to be fast enough. It could be used when building known good packages or during design iteration. It would be an escape hatch. Of course the problem is: would people just add the flag to their configuration and never disable it? I think they would not. Because people mostly use defaults. That's why instead of -Wall -Wextra -pedantic with possible -Wereor for development, most places I worked in ignore most default warnings and just occasionally run some kind of static analysis. Even though many times the analysis often results with things that would be detected with additional warning flags. And yeah I hate it and I wish that warnings would mostly be treated as errors or silenced when applicable. Then there are always separate efforts to "clean the warnings". But afterwards new code just introduces new warnings, because people are trained to ignore them. I assume that Rust developers don't want my scenario to happen at all, but I feel that with defaults reversed it wouldn't. But maybe it's to great a risk? Of course as always it's a game of trade offs.
- Retra 8y agoYou're assuming those checks are a real bottleneck for compile times. Rust only does borrow checking at the function level, so it's easy to parallelize and not all that slow. Most of the compile time is spent on code gen, if I recall correctly.
- yoklov 8y agoIIUC, for typical programs, most of Rust compilation time is spent waiting for LLVM to spit out results. There's a plan to use https://github.com/CraneStation/cranelift https://github.com/CraneStation/cranelift for debug builds instead of LLVM, which would make them faster at the cost of supporting fewer targets, and producing worse code.
- p0nce 8y agoI'm 100% with you. There is often a debate in the D community how the defaults could have been better: pure, @safe, const by default, no GC by default etc. But not every bit of code need to be perfect. Code must prove its usefulness first and foremost, before the need to be reliable, safe, fast and beautiful even enter the picture. I'd go as far as to say, thinking of a nascent project as something perfect and beautiful likely leads to over-idealization and will delay the time to completion many-folds. Ability to write ugly code is - for me - a feature.
- yoklov 8y agoYou can still write hacky temp code in Rust, although it does take some experience to get familiar with the ways you can do this without hitting borrow checker errors and etc (well, short of reaching for unsafe, which is generally not a good way to do this). That said, for getting code written fast, Rust for me has been better than C++ for a while now, even though for most of that I was better at C++ than Rust. The reason for this was largely Cargo, which eliminates the pain points of dependency and build management that plague C++.
- sametmax 8y agoI agree, but let's remember how young rust is, how little experience people have with it and its paradigms and how much they are used to code with c/c++. How course it's hard for them right now. Guess what, it was harder when they started c/c++ decades ago. There was less tooling, best practices were even less clear, all code bases looked different and the language ergonomics were way worse than today. Give it some time. Some time for the language to mature of course. But more than that, some time for the dev to actually reach fluency, not only it the language and ecosystem, but on the general philosophy of this way of producing software. It's even harder given many have to unlearn years of experience and patterns that made them productive, and adopt, discover, or even even new ones to replace them. We have hugely high expectations towards rust because of the amazing work the core team has already made in so little time. I see the same reaction toward the last 2 flight crashes. People are shocked this can happen. I'm just amazed it doesn't happen more often. The institutions have generally done a fantastic job. Now to say we should not fix what's broken in both cases. But let's be fair to the incredible result we already got.
- clanrebornx 8y agoPeople are downvoting not because Rust is better choice for this project with the cons you mentioned but because Go is far better choice if you want less mental overhead and total cost
- loup-vaillant 8y ago> The downside that the author points out seem to be often neglected. Constant interruption and battling with the type system during development, when mental overhead is a problem. Dunno about Rust specifically, but I have written a little Haskell, and a significant amount of OCaml. I found that the type system reduces my cognitive overhead, compared to looser languages like Python or Lua. The compiler is disciplined, so I don't have to be. In practice, with few exceptions, when the type system is refusing to compile something I just screwed up, and I'd better fix my mistake right away. I'd wager that with few exceptions, when Rust is refusing to compile something, you are making a mistake that in C++ would have bitten you down the line. What you call "fighting the type system", I call "fixing bugs".
- blattimwind 8y ago> you are making a mistake that in C++ would have bitten you down the line. Taking some C++ code from an explorative phase that "usually works kinda ok" to something seaworthy requires, in my experience, a huge amount of work (which usually neglects a few issues that will bite you later regardless). I'm not so sure the (probably) faster exploration in C++ compensates for this compared to more "strict" languages like Rust. Of course, if the functional requirement is only "usually works kinda ok", then you don't really need something like Rust.
- loup-vaillant 8y agoI found that strict compile time checks speed up my exploratory phase. That's because the type system provide an even tighter feedback loop than a REPL, and effectively cuts down the search space. Other people seem to have experienced the opposite, though. I have no idea why.
- milesvp 8y agoIt might depend on the problem space. I dunno. But I suspect it depends a lot on the type system and type inferencer of the language you use. It is easier to write a true statement than it is to prove the statement is true, and getting a compiler to agree to compile quite literally requires proving a statement is true. This can be more or less difficult based on the language. I’ve read a lot of war stories, particularly in java, about having to do a lot of crazy convoluted code to get the compiler to realize that yes actually these 2 objects are interchangeable from an API/Interface point of view. I don’t know, but I suspect this may be a lot less common in languanges using hindley-milner type system, since that lends itself to very good type inferencing.
- dahfizz 8y agoI have started to see a worrying trend were developers focus more on how easy it is to develop X rather than how good of a finished product is X. It makes sense for developers to want development to be easier and for businesses to want it to be faster but it feels lazy and cheap to actively avoid tools that would help us produce better programs with much stronger guarantees in the name of ease of development. It's not like rust's checks are arbitrary. If you wanted Rust's safety and guarantees in C++, then you would still have to do all the things the rust compiler is doing for you.
- edflsafoiewq 8y agoThere are plenty of ways to write a program where, eg. a mutable and immutable reference exist at the same time and there is no memory unsafety. You have to learn to write programs in the way that rustc can prove is safe.
- raphlinus 8y agoThis. I believe the value proposition of Rust is that it decreases the cost of developing high quality software, much as the value proposition of PHP is that it decreases the cost of medium-quality software. It is not a magic bullet, but requires a nontrivial learning curve. If the goal is safe, performant code, then I think there's a good argument it's worth it. If that's not the goal, then other languages might be better choices.
- vbezhenar 8y agoThat's true. Different projects require different quality. The projects I'm working on are tolerable to bugs. I just need to know that bug happened (from logs or user complaints) and I need to fix a bug in a timely manner. I don't need to produce bug-free code. I don't need to produce fastest possible code either, servers are seriously underutilized and there's a lot of CPU and memory. I'm using Java because that's what I know well. I like Rust idea, I'm tinkering with it because I'm kind of perfectionist and I like Rust approach, but I won't apply it to my current work in foreseeable future. Even switching to Kotlin from Java was a hard call, because so many people don't want to learn anything new and I can't really blame them.
- Retra 8y agoIf you want to build the best code, you want it to be fast, correct, and maintainable. If you want to build the best company, you might not care so much about these. But then, not all of us are running businesses. And building your company on top of the best code isn't even a bad idea.
- ilovecaching 8y agoI’ve had the opposite experience. Type driven development makes writing code easier, with less errors, and also makes refactoring significantly easier. For those of us where C++ is the optimal choice Rust is a major step forward in terms of better abstraction, safety, and yet maintains the efficiency requirements we need.
- woah 8y agoDo you use a text editor that highlights errors inline or do you depend on errors in the terminal? Maybe your frustration stems from a lack of tooling.
- 75dvtwin 8y ago> I strongly disagree with the Rust mentality, and the general mentality of statically typed languages with extremely prohibitive compile time checks, that seem to become more common. > In my opinion the dominant metric to evaluate the usefulness of a language's type system should be its overall effect on cost, time spent, productivity, ease of development and capacity to change. Everything else is very subjective or just an aesthetic concern. I agree with your overall dominant metric. But I come to a different conclusion of what language/libraries bring me there. To me a type safe language, is a refuge, a comfort zone -- away from the wilderness, unpredictableness and punishing complexity of troubleshooting -- associated with untyped languages.
- kurtisc 8y agoI think the assumption that static typing means things take more time requires justification. Usually I see the assertion given from people who naturally take longer getting things to pass compilation just because they're not used to using it. When I use dynamically typed languages I find footguns in undefineds and empty strings where others wouldn't. I also have to write tests - which themselves may have bugs - for things that static analysis could do on its own. Why use expensive dev time for this instead of cheap CPU time? >Underlying that model seems to be a concept of software like a sort of renaissance master's marble statue, error free and perfect at time of production. Most of the time I'm writing code isn't for the first implementation of a green-field feature and, really, most programming problems aren't that hard in terms of logic flow. If I refactor and the type system and static checking don't complain, I can be reasonably sure it's going to work. And I've seen too many 'temporary hacks' that became forgotten and leaked to review or production.