8 ms·
> Rust will force you to be a good programmer, > [if] you like it or not. This is probably the best in-a-nutshell statement that describes what a good program
by vaylian 8y ago
> Rust will force you to be a good programmer,
> [if] you like it or not.
This is probably the best in-a-nutshell statement that describes what a good programming language is for me.
I had similar moments in the past. Before Python I cared about indention to some degree. But once I got used to the way Python forces you to indent your code, I came to the realization that this is pretty much the way I should format my code anyway and it influenced my coding style in all other block-based languages for the better.
Clojure was another language that showed me how functional programming should be done. My code in all languages changed and I used a lot less variables and a lot more constants and parameters. My code and the systems I created became a lot simpler and much more robust as a consequence. I had used Haskell before but it never really transformed my mind the way Clojure did. I also got a really good grasp on destructuring and list comprehension.
Rust offered me several relevations. I finally understood test-driven-development because the language has excellent support for it. I also understood RAII more deeply. Traits became clear to me (Clojure protocols and Haskell type classes felt strange to me). I finally understood why the Maybe monad in Haskell/ML is one of the simplest and yet bests ideas in programming.
And there is the borrow checker. I already had a functional programming mindset when I picked up Rust. But having a clear owner of data takes the mindset of functional programming even further[1], even when mutability is involved. It is a lot easier to reason about your code when you know exactly which operations can (and should) change a variable.
An aspect that the Python, Clojure and Rust communities have in common is that they emphasize idiomatic code a lot. Therefore it is much easier for newcomers to find examples of professional-level code and learn things the right way. And it is much easier to dive into a new codebase. Clojure is actually a very extreme case of this, because Clojure code tends to use a lot of 1-letter parameter names. In most programming languages you are allowed to have the variable "i" for looping over numbers. But not much more. In contrast, Clojure has a list of well-established 1-letter variables that are recognized by everyone in the community.
[1] This does not adhere to the classical definition of functional programming but I feel that it is a natural extension to it.
- goldfeld 8y agoPython formatting is egregious though, with hopelessly long lines and no sign of where to break them up, or at the most weird places. Yes I'm one of those persons who adheres to the terminal 80 column rule, it's neat for splitting and cascades into many benefits. Python often looks like unkempt code to me, like the developer has no care for how it looks or layouts (which isn't true, it's Python's fault.) The forced indentation (I love proper formatting with consistency and indentation in languages) is among the first reasons I never liked or used Python, until recently when I gave in because it's such a great ecosystem to build scripts and such, but I still hate the formatting everyday. Clojure is beautiful though. Even C is gorgeous compared to a Python 'forced' program layout. I'll start adding Hy to the mix and touch vanilla Python as little as possible, but I still have to read library code.
- growtofill 8y agoDoesn't Python have an autoformatting tool like gofmt or Prettier?
- dhuramas 8y agoYapf- https://github.com/google/yapf https://github.com/google/yapf
- baq 8y agothere's autopep8 and a few other tools but none are considered idiomatic.
- eirki 8y agoBlack (The uncompromising Python code formatter) is all the rage atm. https://github.com/ambv/black https://github.com/ambv/black
- sametmax 8y agoYes. Most of the projects now use black https://github.com/ambv/black https://github.com/ambv/black
- quietbritishjim 8y agoThe problem that black had last time I saw it on hacker news is that it only inserts whitespace. Unlike braces-and-semicolon languages, that is sometimes not enough to format code well. For example, given the following line: x[1][4] = a[2] + b[4] Black will format like either of these: x[1][ 4] = a[2] + b[4] x[1][4] = a[ 2] + b[4] But not like either of these, unless you insert the brackets yourself: x[1][4] = ( a[2] + b[4]) x[1][4] = (a[2] + b[4]) Maybe this sounds like just one little problem but I think it's a fundamental flaw. I have seen the result of a Python formatter (not Black but had the same problem) applied to a couple of files and it's a total mess. I'd take inconsistent column widths over that any day. I asked the creator of black about it and he was pretty dismissive.
- sifoobar 8y agoOnly as good as Rust allows you to be, which is fine for some until they stagnate or grow out of it; but far from the final answer to anything. I don't get at all how being forced to do anything could ever be a good thing. Smells like cognitive dissonance from here. I'm all for powerful tools that enables me to write better code faster; but being forced, really? That's the best thing about Rust? Ew.
- knocte 8y ago> I don't get at all how being forced to do anything could ever be a good thing If you don't prefer tools that can automatically check if you were a good developer or not, it not only does not scale (to trust the software you build), it's that I wouldn't want to work with you as a teammate.
- sheepmullet 8y ago> If you don't prefer tools that can automatically check if you were a good developer or not You are pretending there are no trade offs. > it not only does not scale (to trust the software you build) I think we should all be able to agree that empirically that is nonsense.
- GolDDranks 8y agoI have empirically witnessed that the larger a project gets, the harder it is to trust that the code does the thing you want it to do. It's far from nonsense.
- ElBarto 8y agoA programming language won't make you a good programmer in the same way as a brush won't make you a good painter.
- steveklabnik 8y agoI'm not aware of any paintbrushes that refuse to apply any paint unless you hold them in a certain way. They may apply it poorly, but you're still getting some paint on that canvas. I think a more proper tooling analogy is safety tools, like the Saw Stop. They don't guarantee that you make a good construction, but they do either prevent or significantly reduce the chance of you losing a thumb.
- ElBarto 8y agoSo you agree that a tool does not make a good programmer.
- steveklabnik 8y agoIt's like the Sapir-Whorf hypothesis. The strong version is nonesense, but the weak version has some evidence. A tool cannot make you a good programmer, but it can help you be a good programmer.
- ElBarto 8y agoOK, so a programming language won't make you a good programmer, indeed ;) Edit: This place is disappointingly childish... It does not reflect well on Rust, either.
- adwn 8y ago> Edit: This place is disappointingly childish... It does not reflect well on Rust, either. You're getting downvoted not because of the alleged childishness of this place, but because you're trying to win a discussion on a complex issue by scoring a simplistic "gotcha".
- TripleCrown 8y ago> Rust will force you to be a good programmer, > [if] you like it or not. Perhaps, but I'm convinced that it will at the same time prevent you from becoming a great programmer.
- Thiez 8y agoWhy?