Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

Rust changed me as a developer (https://blog.startifact.com)

292 points by speckx 4 days ago | 187 comments | View on ycombinator

bryanlarsen 4 days ago |

A standard piece of advice is that every developer should do a major project in every big language family. A Lisp, an OO language, a functional language, Prolog, VHDL or Verilog, a Forth, et cetera. They'll all make you think differently and teach you lessons you will use outside of the family.

dabinat 4 days ago |

One of the things that I think makes Rust unique is that it acknowledges the possibility of human error. I think it’s also one of the most controversial too: there are certain people who get an ego hit at the insinuation that they ever could have written C code with mistakes.

Instead of hoping you remember to check for NULL, Rust forces you to make a decision on how to handle the possibility of failure. Sure, you can still pick a bad decision (unwrap) but that is at least a specific decision and you can’t forget to do it.

You can take it even further with things like the newtype pattern. If you have lots of numeric IDs (project ID, user ID, etc) you can give them distinct types so you don’t mix them up.

So Rust taught me I can program defensively against my own brain, which sometimes gets tired or lazy or distracted.

edarchis 3 days ago |

I would like to suggest another improvement: stop doing first name, last name. A lot of cultures in the world don't follow that. W3 suggests using the full name and "how should we call you". You only ever address people by their full name or just for casual interactions. It leads to people asking to be called "Captain Foobuzz", but that actually becomes a security feature. If they ever get mail from you and it's calling them by what the script guessed their first name was, it'll raise their suspicion. https://www.w3.org/International/questions/qa-personal-names

JuniperMesos 3 days ago |

> Any language without sum types now feels impoverished to me.

I wholeheartedly agree. I learned this lesson from learning Haskell, before I was even aware of Rust and before Rust had its 1.0 release. One of the reasons I was first excited about Rust in fact was precisely that it had a type system like that of Haskell.

abbefaria27 3 days ago |

It’s so refreshing to read an “old fashioned” dev blog post written by a human with a passion for the topic. This is what got me hooked onto HN back in the day, not the endless posts about AI written by AI. I’m only half joking when I say this was a balm for my nerd soul.

sedatk 3 days ago |

It's ironic that these are the times of safety, but when C was getting popular in the 80's, it was the times of power. I clearly remember C was touted as being "so powerful that it lets you do anything without any checks". You were responsible to wield that power properly unlike more strict languages like Pascal, COBOL, or Fortran at the time, yet way more expressive than Assembly of course. Now, the pendulum seems to have swung to the other end.

jan_m_savage 3 days ago |

this has got to be the most beautifully designed blog I've read in a while. Esp the choice for code snippets.

also, the author is a great communicator who genuinely wants to convey his points in clear prose, instead of showing off their intellect (which seems to be the case in some other blogs)

xeubie 4 days ago |

Rust enums conflate the tag type with the union type that uses it. These should be separate things. In the example here, you can see that Rust gives no way to represent the tag type `{Human, Cat}`. In Zig there is an enum which is a set of tags, and a union which is backed by that enum and can have fields. It is obviously better to have these as separate concepts rather than conflating them. You often want the kind without the data, and Rust gives you no way to represent it. I'm not sure why I am bothering to rant about this but it's one of my biggest annoyances with the language.

scotty79 3 days ago |

> A weird thing happens: if you lean into this friction it can improve the architecture of your codebase.

Yeah. When I tried to code fairly complex thing in Rust, when I was learning it, as I struggled, I simply noticed that I don't have the freedom I'm used to when it comes to at which level of my architecture I create objects or perform writes or who can pass a reference to whom. Once I learned I can't do it, and not that I just don't know how, suddenly things had their proper place. Yes, I don't have full freedom how I architect things here, but until the end of the project, I haven't found a single case where this restriction would lead to worse not better architecture. Once I leaned into it, as the author says, later I caught myself many times thinking, that C++ would happily let me do it which would result in a bug that would be super hard to find, that would probably burry the whole project.

kator 3 days ago |

“Every computer language is an imperfect way of describing a potential solution to a poorly understood problem"

I wrote this on my website in like 2014. I raise it because I think poorly understood problem is usually the reality, and using many languages over time you find ways of describing solutions to those problems and then learning to hone your understanding of the problem.

To me learning new computer languages forces you to think differently about a problem, if you really try to learn the language. I often just write all my side projects in whatever I am trying to learn for as long as it takes from me to learn it. Sometimes I stay with them for very long times if I enjoy them.

That said I look at computer languages like tools. Focus on the right tool for the job. More than once that tool is what others on the project know, because it still solves problems and it’s better that we have a shared toolset to work from.

zzzeek 3 days ago |

> How does that work in Rust? Macros! Macros lets you write code that generates code during compile time. With serde, the macro generates a whole bunch of serialization code and deserialization code for the types annotated with it. This generated code gets compiled along with the rest of your code. The compiler can optimize it just like any other code.

This is happening in Python land as well. now that type annotations are a normal everyday thing we are doing a lot of code generation. Of course I'm sure how Rust does it is much better integrated and "correct" and all that but the Python thing of generating functions/classes/etc. on the fly is not quite the sole choice anymore for various reasons, and pep484 and related are making static code generation more feasible.

throwaway81523 3 days ago |

Everyone who starts using Haskell says similar things.

xiange 3 days ago |

As a multilingual user, I think the best thing about Rust is that there aren’t as many hidden pitfalls.

coldtea 4 days ago |

Such enlightenment was a common read back in the glorious days of before 2023.

But reading this in 2026, when the entirety of the profession has changed (for better or worse) due to LLMs, seems strange.

Like someone writing how some new preservation method for making food last longer revolutionized how they manage their pantry, shortly after the invention of the fridge.

I like the post - it's just sad how many will not have these epifanies anymore, or they wont mean anything, and how many starting today would already just say "how quaint" and move on.

srean 3 days ago |

This missing the mandatory quote:

“A language that doesn't affect the way you think about programming is not worth knowing.” -- Alan J. Perlis.

mrblinky 3 days ago |

Rate https://learnxinyminutes.com for quick language exploration.

user20180120 3 days ago |

Someone told me once, the spoken language you think in limits your thinking.

Guess it also applies to computer programming and hardware description languages.

undefined 4 days ago |

undefined

clench 3 days ago |

"A Person is either a human or a cat" -- Good article, but please use examples that makes sense.

kinfish 3 days ago |

i can say BEAM still the one that influeces me as developer.

atulvi 3 days ago |

Sapir-Whorf hypothesis

einpoklum 3 days ago |

I read the post, and frankly - I've had many/most of the poster's insights without having used Rust. Other languages have sum-types; ownership and mutation constraints are often in place, albeit not language-enforced; etc. That's not a problem with Rust, though, it's just that the poster noticed certain things because Rust bakes them in, while in other languages they are just a possibility.

I do want to push back on one point though:

> It also stops you from mutating data you're also reading elsewhere

No it doesn't. It stops you from mutating data _that it controls_ which you're also reading elsewhere _also within your Rust code_. But Rust presumes to be a systems programming language. In a system, there are other processes, other devices, interaction across the network, etc. Any of those breaks the integrity of Rust control, and forces you to contend with other independent entities which allocate or deallocate resources, write when they feel like it etc.

> making it impossible to stumble into whole classes of weird undefined behavior, especially with code that runs in parallel.

... and this is the half-false promise that belongs in marketing talk. Although if OP means "undefined behavior in the sense of "undefined by the language spec", that's a whole other kettle of fish.

wg0 3 days ago |

At this point - people should stop taking pride in their ability to write Rust because pennies cheap Chinese models can do the same too.

It's just another tool not a philosophy of life or benchmark of intellect.

madspaaskesen 3 days ago |

[dead]

Uptrenda 3 days ago |

im literally shaking, reddit

p-s-v 3 days ago |

[flagged]