NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
▲Rust changed me as a developer (blog.startifact.com)
bryanlarsen 22 hours 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.
nomel 21 hours ago [-]
> Verilog

My favorite side quest that I definitely recommend. Physical parallelism is so fun to reason about.

I had the advantage of sitting next to a proper professional to bounces questions off of, so I was able to get an SPDIF decoder to work in about a week! It was a very interesting lesson in the costs of abstraction, and why you will never really find abstraction layers in hardware.

pastel8739 19 hours ago [-]
> why you will never really find abstraction layers in hardware

This is interesting to me, in the very little HDL I’ve done there were abstractions: you set up modules with inputs and outputs that provided a consistent interface despite complexity inside the model. Is this not what you mean by abstraction layer?

kingstnap 18 hours ago [-]
The only real abstraction layer in Verilog is encapsulation.

The rest of synthesizable Verilog is a pretty thin abstraction over muxes, d flip flops, and adders, and other basic gates.

That being said registers is a pretty big abstraction on top of what actual circuits on chips look like so turtles all the way down right.

fork-bomber 14 hours ago [-]
There are some innovative solutions like Chisel which leverage a higher level language's composability (Scala) to enable the generation of Verilog in order to get a workable notion of abstraction.
Bratmon 18 hours ago [-]
> It was a very interesting lesson in the costs of abstraction, and why you will never really find abstraction layers in hardware.

That's literally the exact opposite of my experience with Verilog! The experience of using it feels farther away from the actual hardware than Python does!

Grimblewald 21 hours ago [-]
This sounds quite interesting to me, if you have the time, could you please elaborate a bit on the cost of abstraction?
IshKebab 21 hours ago [-]
It's just a shame that (System)Verilog is such an awful awful language. And we're basically stuck with it, at least for ASICs, despite the availability of alternative HDLs that compile to SV.
taldo 20 hours ago [-]
I worked for a couple of years in a SystemVerilog compiler, and I couldn't agree more with your sentiment.

From the compiler construction standpoint, it's grossly underspecified, to the point that our customers' designs were way more expressive than the spec.

And from the users' perspective, it's confusing, quite limited, and you end up having to resort to hacks to achieve what should be part of the language... Fortunately I can't remember any particularly bad examples, it's been 15 or so years since I left for greener pastures.

Still, I sometimes wonder, how much of HW design is influenced by the language decisions, these ugly hacks, and the emerging (System)Verilog design patterns? Could it be measurably better in a different world?

rcxdude 20 hours ago [-]
Yeah, using (system)verilog is essentially a process of "think of the digital circuit you want, then figure out how to write it as a 'sequential' process so that the compiler can then generate the circuit you want". The way it works feels quite clever when you first learn about it but the way it works in practice is bizarre.
tialaramex 19 hours ago [-]
Could we fix that do you think?

I think 25 years ago I would not have believed we would ever fix (La)TeX but here's Typst.

IshKebab 12 hours ago [-]
Potentially now that LLMs exist. It's fairly easy to vibe code tools that legitimately compete with the commercial tools (which are the main reason we're stuck with it).

It's going to take a long time though. All IP vendors provide Verilog, often encrypted which only the commercial tools can legally support. And there's a very very long tail of SystemVerilog features that you need in ASICs - coverage, timing, etc.

kreyenborgi 20 hours ago [-]
Will I have the same learning effect if I use https://github.com/clash-lang/clash-compiler instead of straight verilog, or is the language a necessary part of it?
rowanG077 20 hours ago [-]
As the maintainer of clash I would say yes definitely! Clash is at the same level of hardware specifications as VHDL and verilog. You lay down every wire and register. It's just that you get all the niceties of Haskell, the very powerful type system and abstraction capabilities.
Lramseyer 20 hours ago [-]
It's awful by design! Do you know how much Cadence, Synopsys, and Siemens profit off of the bloated LRM?
brightball 22 hours ago [-]
100% agree with this.

Elixir was somewhere between my 12th-14th language and nothing changed my perspective so much as understanding why the BEAM works the way it does.

mitchm 20 hours ago [-]
The BEAM is so underrated
sitzkrieg 19 hours ago [-]
the whole erlang ecosystem is imo. its not exciting and works great in real systems. no bay buzz
Rendello 15 hours ago [-]
Starting from Python, the languages that really changed how I saw the world were (in order of use) HolyC, then Erlang, then Rust. I'm glad I had the low-level (Holy)C and the functional Erlang before really getting into Rust, otherwise I don't think I would've appreciated or understood its concepts nearly as much.

(I wanted Prolog to blow my mind too but I could never figure out what the hell was going on!)

MomsAVoxell 21 hours ago [-]
I have applied this for decades, with multiple languages under my belt, and multiple million-dollar projects on my CV, and meanwhile I have found another similar rule that I think also sharpens a developers mind:

Put Lua in things.

Now, before you anti-Lua types start jumping on that 0-indexed down-vote, let me explain. Its not just about the language, its about the "thing" you're putting it in, its about using the VM effectively, its about planning and using the stack properly. It's about using one language to leverage the strengths - and discover the weaknesses - of other languages, runtimes, ABI's.

Putting Lua in things is easy - and it is hard. It teaches you how to treat other things with respect, and it teaches you how to disregard other things and "Just Use Lua™".

You can learn the language - multiple variants of it. You can learn the 'things' you're putting it in. You can learn how a VM works, what byte code is, how it can be used effectively - and how it can be used counter-productively, too.

It will teach you the limits of a language - Lua, and C - and it will teach you the strengths of both (as well as Rust, and all the other things you can get an FFI scaffolding built around).

You can use Lua to produce your own domain specific language. You can use it to (almost, or indeed completely) replace whatever other language the "thing" is using. You can use it to minimize the impact of a VM and scripting and byte code - you can learn how to maximize these things as well. You can learn byte code and you can leverage that understanding to learn machine language - two ends of a very similar (yet vastly different) spectrum.

You can learn how slow/fast pieces of the system interact productively and effectively - you can learn how things get mightily messed up, also, if you use the wrong lubricant.

In the end, you may not even end up using it for productive things - but you might also do something extremely powerful. (I have.) Either way, by applying this maxim and applying the skills needed to master doing it (or screw it up entirely), you can learn pretty much everything interesting there is to learn about software (besides LLM's) in today's modern stack madness .. and then some.

Seriously, give it a try.

The other one of these developer-tuning activities (there are a few), is to do a Linux From Scratch session at least twice a year. Do it this year, but plan on doing it again next year as well. Do it a few more times this decade.

Iterate. Extend. Ignite.

pseudony 12 hours ago [-]
Hear hear!

I put lua in most things I make now. Whether a orchestrator/ansible like replacement or even to support hooks in a mail reader I make or a integration testing style tool - if there is any configuration, I generally pick lua over saddling anyone with another config file that only reflects what the program author could foresee a need for or thought was worth supporting.

Please, if you make tools for others, don’t impose yourself unnecessarily, give people a sandbox- give them lua :)

MomsAVoxell 4 hours ago [-]
Lua started life as a config language so it’s quite an appropriate usage .. just be sure to block off os.* as appropriate … :)
archimedes237 20 hours ago [-]
Lua variant used in Roblox is a great example of how it can be used effectively and powerfully.
jan_m_savage 18 hours ago [-]
there is also moonscript which compiles to Lua and is clearer and terser.
jghn 22 hours ago [-]
This. It's not Rust in the author's case. It's being exposed to a language that's enough different from what they're used to that it affects their big picture.
pjmlp 22 hours ago [-]
Yes, especially since many of the type system features younger devs assign to Rust, are present in most Standard ML derived languages.

It is a scale, and there are other languages that go beyond Rust, with dependent types, effects, capabilities, linear types, formal profs,...

jghn 18 hours ago [-]
This is an issue I have with Rust hype in general.
metaltyphoon 16 hours ago [-]
So… what’s the issue again? Is the issue making it mainstream?
pjmlp 12 hours ago [-]
In a way, many folks coming to Rust never seen a ML type system in action, thus they assign all those features to Rust, when in reality they predate Rust for almost 40 years.

Similarly how folks get impressed with Go compile speeds because they weren't around in the last century to have used Turbo Pascal, Modula-2, Oberon,.... compilers

Or assume most Zig improvements over C are innovations, when even languages that predated C like PL/I had most of the same safety features.

The issue is lack of understanding where we come from.

bryanlarsen 6 hours ago [-]
The only truly novel thing in Rust AFAICT is zero-cost async. It was built as part of a Ph.D. thesis.

One could also argue that the Rust ownership system is also unique. It was inspired by other work but the difference between the inspirations and what Rust ended up with is fairly drastic.

Pretty much everything else came fairly directly from elsewhere; ML primarily.

But note that zero-cost async and the ownership system are the worst parts of rust! Ownership and zero-cost async bring enough benefits that people use Rust to get them, but it's always a little bit begrudgingly. There are sharp edges.

OTOH, the parts of Rust that it borrowed from elsewhere are beautiful, IMO. They've used the advantage of hindsight to refine them.

At some point in the future another language will do the same to Rust, refining zero-cost async and ownership. And creating their own sharp edges to add a more novel capability.

jghn 4 hours ago [-]
Scala had many of the same things and was mainstream over a decade ago. And this is before you go deeper down rabbit holes of ML & Haskell.

The issue is that people should understand their history. Instead of saying Rust is amazing because it invented certain concepts, they should be digging in further to understand from where those concepts came. That's not at all a knock on Rust, purely the fanboys who make it their identity.

IshKebab 21 hours ago [-]
Well, different in a good way. There are plenty of different and worse languages.
jghn 18 hours ago [-]
Learning bad languages and weird paradigms can still help. You never know when you will pick up some technique or idea that you can apply elsewhere.
ivanjermakov 21 hours ago [-]
Advent of Code is coming in two weeks, I highly recommend completing 12 challenges in 12 different languages!
socalgal2 17 hours ago [-]
I think this is great advice but, my experience is most people don't really grok a language for long time. Maybe "major project" solves that but for example, A company I was at was a Java company a long time go and that team treated JavaScript as Java, completely ignoring all the strengths of JavaScript. They even had a Java to JavaScript compiler to ignore it.

I made the same problem. I started JavaScript as a C++ programmer. I didn't get prototype based inheritance and kept trying to shovel my C++ style into JS. It took 2-3 years to stop trying to coerce JS into C++ and instead use it as JS.

Now, for many projects I can't stand how I have to write 1000x more code in C++ to insert a debug wrapper around some native API that in JS I can do in a few lines in a few minutes.

Similarly, lisp is great, but it takes a while to really get out to take advantage of its strengths and not treat it like whatever language you're most comfortable in.

shagie 16 hours ago [-]
The AI (mid 90s) class I took in college was taught in lisp. I recall that it was a program to identify the variables that would be needed in order to have it be a true statement (one of the functions named 'hamletp' that identified structures that were `(or twobe not (twobe))` and rapidly resolve it to true).

When done with the assignment I asked the emacs fan in then lab to look at it and his comment was "you write beautiful C in lisp."

https://www.ee.torontomu.ca/~elf/hack/real-programmers.html

    ... Besides, the determined Real Programmer can write FORTRAN programs in any language.
---

My first revelation with functional programming was when I was dabbling with Clojure based on a Coding Horror question with giving a person being given an algorithim more difficult than Fizzbuzz (which has been memorized)... compute e or pi were the ones that I thought of.

pi / 4 = 1/1 - 1/3 + 1/5 - 1/7 ...

I was trying to figure out if I could use cycle to handle that and then the lightbulb for first class functions hit him.

The solution I came up with was:

    (defn pi
      ([] (float (* 4 (pi 1 0.01 0 true))))
      ([term tol accum pn]
        (let
          [t (/ 1 term)
           a ((if pn + -) accum t)]
          (if (< (* 4 t) tol)
            a
            (pi (+ term 2) tol a (not pn))
          )
        )
      )
    )
The lightbulb was the `((if pn + -) accum t)` bit where `pn` was a boolean that flipped each call... and `(if pn + -)` returned the function.

That was May 9th, 2013 (I can find where I was explaining it in a web chat that is still out there).

Turskarama 16 hours ago [-]
> A company I was at was a Java company a long time go and that team treated JavaScript as Java, completely ignoring all the strengths of JavaScript. They even had a Java to JavaScript compiler to ignore it.

This happens if the developers don't _want_ to learn. If you're trying out a bunch of languages of your own volition then you won't have this problem.

forinti 21 hours ago [-]
I had so much fun with Lisp and Scheme at uni that it makes me sad to have never coded professionally with them. On the other hand, I have written PostScript for money, which was completely unexpected.
packetlost 21 hours ago [-]
I've seen Lisps used by contractors for small-team sized projects, but it's pretty rare. Clojure is probably the most popular Lisp in common use, but I think its popularity has been fading (unfortunately).

Both Scheme and CL suffer really badly from a lack of modernization primarily in their stdlibs (or equivalent SRFIs) that tend to make them poor choices for most new professional projects IMO. Great for side projects though. I really wish the next generation of Scheme would take a page from Clojure's book and rework all the SRFIs and bake in immutability as a core requirement.

eviks 8 hours ago [-]
That's a huge waste of time, why not instead learn by trying smaller cases that are pedagogically prepared to teach those lessons without requiring you to do the other 99% of the work?
alexhans 17 hours ago [-]
There was a book called seven languages in seven weeks that was quite fun for some exposure to different paradigms.

For prototypes it had Io, it had prolog, erlang for "let it crash" (like elixir).

rjzzleep 17 hours ago [-]
It was also the only exposure I ever had to prolog.
eithed 1 hours ago [-]
Ada is missing from that list
toolslive 10 hours ago [-]
I used to do this, but I kept the project topic (a chess engine) constant. I built this in 6502 assembly, Pascal, Prolog, C++, Java, Python, OCaml, Rust. It's also quite interesting to see where the strong/weak points are of every language.
bear8642 9 hours ago [-]
> every big language family.

I feel you're missing the Array languages from your list (APL, J, BQN, ?FORTRAN)

Indeed, new perspectives reveal new ways of thinking.

agumonkey 20 hours ago [-]
but then you suffer from working in places where people only knew one language, because they won't grasp your code or ideas and you will have to live in their limited conventions
democracy 19 hours ago [-]
maybe it's because your idea doesn't belong in the specific language/environment?
alpinisme 18 hours ago [-]
While that may be true, it reopens the question of the value of the original comment’s point about learning other languages. If they won’t change how you write in your day job, is it all that significant that they taught you to think differently? And if they do change how you write in your day job, then why wouldn’t you feel frustrated that others on the team don’t see the things you do and continue to write from a more limited/parochial perspective?
sedatk 20 hours ago [-]
Even minor projects can have great impact when developed using different paradigms.
democracy 19 hours ago [-]
what kind of impact a minor project would have all of a sudden if you use different paradigms?
lnenad 22 hours ago [-]
Agreed 100%. This is the single most useful thing I experienced in my career.
jahnu 22 hours ago [-]
What counts as a major project?
RussianCow 22 hours ago [-]
I don't know if it counts as "major" to the OP, but early in my career, I wrote a Sudoku solver in several languages as part of learning them. It was just complex enough of a problem that I got a glimpse into the patterns that succeed or fail for different languages, especially when it comes to things like optimization, which is sometimes hard to observe in business applications.
alpaca128 20 hours ago [-]
Just yesterday I finished my small sudoku "game" including generator in Odin and it was such a fun project. Not major by line count but optimizing it to generate a new puzzle in <100 ms was a fun exercise.

For anyone curious, I generate the sudokus by first randomly filling an empty grid in a way that follows the sudoku rules, then emptying random cells where doing so doesn't make the solution ambiguous (a sudoku has exactly one valid solution). The first step to fill the grid works almost exactly like a normal backtracking solver but going through the cells in random order, and for a major speed boost the backtracking is far more aggressive (always resetting half the progress so far instead of just going back one step). Checking if a sudoku has multiple solutions is again normal backtracking but only exiting at the second time it finishes or after going through all combinations. The rest is modern computers being fast and limiting the number of iterations to avoid the super slow worst cases.

QuantumNomad_ 21 hours ago [-]
At the beginning of my university studies (second or third semester), one of the homework assignments was to write a Sudoku solver. I spent a lot of time on it, prototyping it with JS and HTML so that I could visualize step by step how to solve Sudoku in general, implementing the techniques in code that I had previously been doing by hand when doing Sudoku puzzles in the past.

I am not sure if everyone else looked up techniques online or what for how to do it, or if they skipped that assignment, or made a very simplified solver that only handled some basic techniques. We hadn’t really learned much of anything yet in any of the classes of the course that would be useful for making a general solver. I thought I was supposed to figure it all out on my own, and that it should be able to handle any Sudoku puzzle that a person could solve. And in the end, despite many, many hours of working on it over many days it was still far from a complete solver. And I also didn’t have time to write it in the programming language we were using in the course. I was prototyping in JS and HTML because I wanted to see visually the sudoku puzzle and be able to switch between having the computer find next number and clicking on the number myself, to discover in detail how I was thinking when I was solving Sudoku puzzles, so that in turn I could implement those techniques in code.

I lost a little bit of motivation for the class with that, and dropped out of the class soon after because I found the class to be generally uninspiring and hard to stay motivated for, in spite of being interested in programming in general and having learned programming languages and made little programs of my own already since High School. Later I dropped out of the whole study, as I was struggling to study across most subjects and wasn’t passing enough classes to be able to continue.

My interest in programming continued, however, and I’ve been developing software both professionally and as a hobby with sometimes pretty good results during the years since, and having done so for companies both small and big, and in multiple different programming languages.

But I think the way I handled trying to implement the Sudoku solver is a way of working on things that I already had since before then and that I continued also later, and that that is also part of the reason that things go wrong for me when they do. Both professionally and also elsewhere in life.

The last job I had, I was laid off for not performing well enough. And I think in part I was still working on tasks at that job in some sort of wrong way all these years later, that may be similar in some ways to what I may have done wrong with for example that Sudoku solver assignment. And probably in many other cases too both before and after.

And now that AI is here I’m not really sure how to land a new job as developer at all. Even though I would like to. Combined with the sense that there is too much ups and downs in success rate of what I’ve been working on over the years to be able to present myself in an impressive manner to employers. I value honesty and integrity, and I find it difficult to really imagine that I could sell myself well at this point when I look back at my life so far, in spite of sometimes doing things well, because of the times that projects have not gone well.

CamperBob2 16 hours ago [-]
Is it possible that you're a little too reluctant to ask for help? That's one way to interpret your story about the Sudoku programming assignment ("I thought I was supposed to figure it out on my own.")

If so, that particular shortcoming might be easier to address than many of the other possibilities.

QuantumNomad_ 13 hours ago [-]
> Is it possible that you're a little too reluctant to ask for help?

Yes I think that is probably the case, at least some of the times.

treyd 22 hours ago [-]
Could be lots of things.

A common example I give is a basic chat client/server, to learn how networking code feels, especially nonblocking IO. Especially if you're implementing the same protocol in the different languages since it means you won't necessarily be as biased by what protocol patterns are easy to implement in one language.

fasterik 21 hours ago [-]
I think the advice works well for projects that are on the order of 10k lines of code. "Major" is subjective, but that's big enough to be non-trivial yet small enough not to be a huge time investment.
kccqzy 22 hours ago [-]
Depending on what kind of concepts you want exposure to.

If you just want generic pure computation: write an interpreter for a toy language. If it’s too large, write a macro expander that can handle C style or TeX style macros.

If you want events and concurrency: write a tmux clone that can work with multiple terminals.

If you want IO but specifically networking: write a toy HTTP server that only supports 1.0.

neko_ranger 21 hours ago [-]
That is up to you to decide
whartung 19 hours ago [-]
Something you can’t readily fit into your head.

Something that has a lifespan longer than a month.

Something developed under time pressure.

Something that is forced to change due to outside real world impacts.

Something that when you come back to it, you find some code that prompts you to say “What the heck was I thinking here?”.

win311fwg 21 hours ago [-]
One that has expanded enough to be able to read email.
flykespice 21 hours ago [-]
"Show HN: I wrote my own kernel in [insert niche language here], here is what I learned"
democracy 19 hours ago [-]
lisp, prolog, forth, etc - no such standard piece of advice
deterministic 15 hours ago [-]
And LEAN! I have done all of the above but LEAN (and proving code correct) absolutely blew my mind.
harveymadeunico 21 hours ago [-]
If you could maybe reduce that down a bit that would be great. No one in their right mind has the time for major projects in all of those.

Another way to do it would be the standard low->high level and then one based on lambda calculus. Von Neumann and Church.

Assembly, C, Java, Clojure.

Assembly, C, C#, F#.

Assembly, Fortran, Rust, Rust, Brainf*ck.

bryanlarsen 21 hours ago [-]
I've been programming for about 40 years now, so I've had time. You will too, eventually.

I should have made the list bigger, not smaller. I missed assembly and Erlang.

harveymadeunico 20 hours ago [-]
I suppose but I was thinking take a path that derives from one path or the other. Like start with Von Neumann derived ones or Alonzo Church. Since there’s so much overlap, that’s the start of the families right? Just trying to give more structure to what you’re suggesting.

At the heart of it all it’s just math and logic, and that’s where the different thought studies happen, regardless of which language quirks are navigated.

Personability 4 hours ago [-]
I've had far more than enough time to write code in all of those languages, even big projects. I've not touched all of them, but I've found myself working through the list without even being told. It's a good practice, not a rule.
begueradj 21 hours ago [-]
It's like saying a novelist should write a major novel in every important spoken language.
Jtsummers 21 hours ago [-]
> It's like saying a novelist should write a major novel in every important spoken language.

No, it's not. It's more like saying a writer should try their hand at different styles and formats of writing. So a novelist who periodically writes non-fiction essays or journalistic content or poetry (whether intended for publication or as a writing experiment), and that practice can in turn inform their writing as a novelist.

Besides, learning programming languages is much easier than learning natural languages. Most experienced programmers today know multiple languages, and most college grads in CS and Software Engineering graduate having used at least 5 or 6 languages if their school is halfway decent.

democracy 19 hours ago [-]
"language" and its concepts can be learnt quickly - now to go from ~60 java keywords to being able to understand its landscape of libraries and frameworks and use it appropriately - one would always choose a java dev over someone with a knowledge of keywords and paradigms in dozens of languages
Personability 4 hours ago [-]
It's not about the keywords, but what each language teaches you. Working in forth, for instance, gives you an intimate understanding of the stack. Every family of language has something to teach you. If you want to land a job, being a really good java dev will obviously benefit you more than being a general dev, but having more broad experiences will help benefit your personal understanding, and consequently, your personal fulfillment and satisfaction.

If you program just for money, that's one thing. People who only look for money tend to use AI. But if you enjoy programming, that's why you'd pursue exploring languages. And I'd recommend it even to people just looking for jobs as well.

pjmlp 12 hours ago [-]
This is the other part, the main reason languages succeed or fail adoption at scale.

The language and its concepts is easy as you put it, now taking off the rest of the ecosystem, that is the hard part, which on average based on history, takes around a decade to take off.

raincole 21 hours ago [-]
It's like saying a novelist should write a story (not necessarily a book) in every important genre, which is, excellent advice.
kreyenborgi 20 hours ago [-]
Actually, many of my favorite novelists have done a lot of translations, so that tracks. You probably become a better writer by extending your brain in that direction too. (But they tend to translate to their native language of course.)
unrented7977 18 hours ago [-]
Most of your favorite novelists have experimented with other styles of writing. I'd highly encourage you to go find and read them.
flykespice 21 hours ago [-]
At first glance this seems like a invalid analogy because spoken language didn't exist to suit a specific domain just like some programming languages (lua for scripting, Pascal for teaching, Rust for systems programming..).

But there are example of "dead" languages whose everyday usage have devolved to only lithurgical functions like: Latin (Catholicism), Pali Cannon (Buddhism) and Sanskrit (Hinduism).

wizzwizz4 21 hours ago [-]
At the very least, a short story.
dabinat 21 hours 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.

PaulKeeble 21 hours ago [-]
This was always the same thing that Unit tests were trying to bring, defend against your own errors and try to get the most quality out of the tools as possible. A lot of language progress has been exactly this over the years, from removing goto and introduction of for/if/while to constraining types and everything since. As an industry we could do with more of this mindset in general, just use everything we can to try and catch bugs earlier when they are cheaper to find and fix and avoid them happening at all.
bunderbunder 19 hours ago [-]
I have always had a love/hate relationship with unit tests. I love them for all the obvious reasons. I hate them for all the times I read a test suite where 80% of the tests could have been eliminated by just improving the design of the system under test so that error condition wasn’t possible in the first place.
pjmlp 12 hours ago [-]
Most programming languages acknowledges the possibility of human error, even those that predate C, like Fortran, Lisp, JOVIAL, ESPOL, NEWP, ALGOL, COBOL, PL/I.

The ego hit has been mostly a C culture thingie.

LtWorf 9 hours ago [-]
C does have compiler warnings. Ignoring them is a decision as well.
ardit33 21 hours ago [-]
Null should not exist, and Optionals are an anoying workaround/hack to it. Old languages like Tcl eliminated it, (every object has an initial value, it is never null).

It creates an interesting problem, as sometimes you want to know the absence of value. Usually done with the empty "" string.

The other way to handle is that every Object is initiated (pointing) to an starter initial value. (prototype based languages).

ratorx 21 hours ago [-]
> Optionals are an annoying workaround/hack to it

Sometimes you do want to represent the concept of “this whole datatype OR nothing”. How do you suggest this is modelled? I think optionality is pretty fundamental. What’s wrong about classical null is that it ascribes optionality to all types regardless of whether they need it.

Being forced to represent optionality with a “special” default is terrible design IMO - see the recent SSH RCE on Musl, largely due to the poor choice of indicating “crypt failed”. Default values can be quite dangerous. Sometimes the domain you are modelling supports such a value, but having “default value” be the default (and not a choice) is a similar evil to default null.

rhdunn 20 hours ago [-]
1. Have declared nullability (e.g. `String? foo` / `val foo: String?`)

2. Use null coalescing (e.g. `foo?.bar?.baz`)

Languages such as Kotlin and C# support this style o programming.

The thing that I don't like about Optional types (in e.g. Scala or Java) is that they are too verbose. For example, instead of:

    return foo?.bar?.baz ?? 0
you have something like:

    return foo.flatMap(_.bar).flatMap(_.baz).getOrElse(0);
This is even harder to read if you have more complicated logic, requiring implicit lambdas and other machinery.
glandium 19 hours ago [-]
You can mostly write the former in rust: https://rust.godbolt.org/z/5M6nr3dzs

There are caveats, such the function using ? having to return an Option, which can be worked around by using a closure.

I think try blocks will make this slightly easier.

kaelwd 10 hours ago [-]
`(try { foo?.bar?.baz? }).unwrap_or(0)` is maybe more understandable at a glance than the closure version but still more verbose than other languages.
hiimkeks 12 hours ago [-]
To me, foo?.bar?.baz ?? 0 looks really hard to reason about, if I imagine it sits in the context of some wider processing code.

Explicit options nudge you towards a data model that handles the None/null case early, so you don't have to write code that does the coalescing. If you parse-dont-validate early, you more often than not end up with a data model that is simpler and easier to process.

But then, this also depends on the sort of code you write. In the code I write, matching/"if-let"ing on Options to understand their value and then translating that into some enum that encodes the value on the abstraction level of the domain or algorithm has often been really really helpful.

Fluorescence 10 hours ago [-]
It's nice.

I'm an old developer... I recognise the instinct to resent and avoid new unfamiliar syntax when I've got something that works for me. After some resistance, I give it a go, maybe working on someone else's code that uses it... and then it's suddenly "damn, the lang designers knew what they were doing".

This is one of those. What you might miss is that nested optionality is often the cleanest accurate representation and not error states e.g. a hierarchy of capabilities as a tree of options getting progressively more fine-grained yet you need to work with fine-grained capabilities at the leaves.

Nested optionality appears to be a bad data-structure to avoid when the code it requires is verbose and gruelling. Workarounds to reshape or design for less gruelling code are anti-patterns, adding complexity not to model the problem but to solve a language design weakness, which this solves.

tcfhgj 20 hours ago [-]
Both variants are just different syntax for the same thing.
nine_k 15 hours ago [-]
The second is twice as long as the fist. The difference matters.
15 hours ago [-]
bunderbunder 19 hours ago [-]
Empty string is not a valid alternative to null because the empty string is still a string. There are valid cases where “this value is not set” and “this value is set to an empty string” mean two different things.

There are even more valid cases where “this integer is not set” and “this integer is set to 0” are different things.

It’s also a type safety concern. Using sentinel values is comparable to the “billion dollar mistake” version of nulls because it creates a special value that implicitly exists and is not part of the variable’s type definition. This means the compiler can’t help you remember to check it. You have to just remember, and forgetting is a bug. With optionals (including opt-in nullability like in Kotlin), on the other hand, the compiler knows when you do and do not have to worry about a value not being present, and can raise a compile time type error when you forget.

setr 21 hours ago [-]
I don't see how initial values solves for much, or how an Optional constitutes a workaround; if anything, I see initial/null values being a hack to get around Optional, which is an explicit declaration of what possibilities exist.

Initial values, like null, is an attempt to smuggle the "unset" case into the type without declaring it. And like null, the defensively written logic should prefix every single usage with a check for validity.

Optional is just a natural subset of the generalization that multiple possible states exist; in this case, just the two, and sum types to properly handle bigger sets.

Initial/null never admit more than 2 possible states, and also believe everything is always in one of those 2 states.

rcxdude 20 hours ago [-]
"Always has a value" just creates an in-band signaling problem, where the "absense of value" overlaps with the valid values.
zeratax 12 hours ago [-]
I feel like youre trying to replace one sentinel value with another? Now instead of doing NULL checks I do empty string checks or look for that starter initial value. Honestly it seems worse than NULL cos now I can't even represent an empty string
vrmiguel 15 hours ago [-]
> Usually done with the empty "" string

That seems so much worse than a `Option<String>`

einpoklum 53 minutes ago [-]
> Instead of hoping you remember to check for NULL

You really don't need Rust for that. There are plenty of languages with non-nullable reference-types, and in other languages it's fairly easy to make your own or use a library.

> Rust forces you to make a decision on how to handle the possibility of failure

Let me introduce you to this invention called the ? operator ... also known as the "let somebody else worry about it" operator.

If you mean that errors are not in some global variable that's easy to ignore, then, ok, yes, Rust is not like C in that respect.

slopinthebag 20 hours ago [-]
yes i love rust because i acknowledge my own limitations as a programmer. compare that to c/zig devs handwaving away vulnerabilities as "skill issues", any serious engineering discipline eliminates the possibility of human error wherever possible.

fwiw john carmack agrees with me

soon_to_be_sb 6 hours ago [-]
>handwaving away vulnerabilities as "skill issues"..

It is a skill issue. But there are only so many skilled programmers. So rust makes sense that even though it made programming a lot boring, you could use droves of unskilled laborers.

slopinthebag 4 hours ago [-]
all of the checks and procedures when flying an airplane are also skill issues by this standard. because no pilot is so skilled to never make mistakes, same as programmers. it’s a human skill issue really.

of course you couldn’t help but call rust programmers unskilled couldn’t you. ego.

jamincan 4 hours ago [-]
> But there are only so many skilled programmers.

There might well not even be one by this standard.

edarchis 12 hours 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
nedt 10 hours ago [-]
Exactly this. Here we have a couple of people named "Fullname ." in Outlook because we can't just enter a single word name and are forced to use a dot to fill the second field.

Would have also been a much better example for the enum to have the second type being a human with just a single name instead of a cat which is stretching what a person is.

scotty79 7 hours ago [-]
A lot of cultures don't use Western calendar. I won't stop printing dates in my software though, when I need them.
JuniperMesos 17 hours 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 13 hours 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 20 hours 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.
bunderbunder 19 hours ago [-]
Things have changed so much since then. In the 80s compilers didn’t optimize as well, and generally couldn’t because of resource constraints on the computer. The limited power of 1970s and 1980s computers is all over the design of C. Header files are meant to reduce the memory needed to compile programs, for example.

The last time I needed C’s power to fit something into memory and compute limitations, it was code running on a microcontroller and better systems languages like Zig and Rust weren’t a thing yet.

Jtsummers 5 hours ago [-]
> Header files are meant to reduce the memory needed to compile programs, for example.

That is not very accurate. Back then, C was compiled file by file and the outputs from those separate compilations were linked into the final binary (each C file is a translation unit, a term still used today). Header files were reprocessed for each new translation unit that included them, they did not save memory for compilation. They saved some memory on disk storage because shared bits of programs were extracted to a common file, but that savings was also not their purpose.

The purpose was to extract the shared bits and reuse them to prevent errors and reduce duplication. Imagine having to recreate the contents of some or all of stdio.h at the top of all your C files that import it. Now you have hundreds of places to update if that library changed, or hundreds of places to make an error in one of the function specs.

Saving memory was not a benefit, nor an intended benefit of header files. The header still has to be read for each translation unit and processed so there are no memory savings in compilation (back then) from using them. Now, today there can be some with precompiled headers, that come much later than the invention of headers for C, though.

MisterMunchkin 12 hours ago [-]
That explains a lot. Why do we still have header files? I suppose the C people wouldn’t let us change it at this point, but it does seem quite pointless now that we have computers with 10,000x more memory.
bunderbunder 10 hours ago [-]
It would be a very disruptive change. For example, you can’t do away with header files without also rethinking how shared libraries work, too. Which then leads to hairy questions like, “Where do you put a library’s preprocessor macros if not in the .h file?” Any such changes you make would need to be coordinated with operating system vendors, since it would touch bits of how shared libraries work that are OS-specific.

And we already have header-only libraries, which are often close enough.

jan_m_savage 18 hours 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)

bunderbunder 18 hours ago [-]
Agreed. And it made a much stronger case for Rust than I’m used to seeing. For most of us non C/C++ programmers memory safety is a problem that’s more easily (not necessarily better) handled with a garbage collector.

But there are times when I really want to come to Rust from the other direction, and almost think of it as a Haskell alternative that doesn’t bring all the headaches that come from being lazy. The examples the author chose beautifully illustrate some of Rust’s virtues that lend themselves to that perspective.

(But no, we are not going to talk about higher programming. I did say “almost”.)

xeubie 22 hours 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.
ai_ 21 hours ago [-]
The function you seek already exists before you: https://doc.rust-lang.org/std/mem/fn.discriminant.html

Is there anything you can do with separate types for the tag and the union that std::mem::discriminant and pattern matching can't do?

Jtsummers 20 hours ago [-]
As someone who hasn't used Rust enough, and not knowing Zig but it appears Zig does something similar to Ada which I do know, how would you use the same discriminant across multiple Rust enums and guarantee that you implemented variants for each discriminant value?

In Ada, if I use an enum (carrying the example from a link I used in a cousin comment):

  type Expr_Kind_Type is (Bin_Op_Plus,
                           Bin_Op_Minus,
                           Num);
https://learn.adacore.com/courses/intro-to-ada/chapters/more...

Variant records using this enum have to implement the variant for each element of the enum. If I, for some reason, have multiple records using the same discriminant I can know that each one implements it for each value of the discriminant. Does Rust have a way to synchronize your enums similar to that?

bombela 19 hours ago [-]

  pub trait Payloads {
      type Read;
      type Write;
  }

  pub enum FileOp<P: Payloads> {
      Read(P::Read),
      Write(P::Write),
  }

  pub struct Inputs;

  impl Payloads for Inputs {
      type Read = ();
      type Write = u8;
  }

  pub type Request = FileOp<Inputs>;

  pub struct Outputs;

  impl Payloads for Outputs {
      type Read = u8;
      type Write = ();
  }

  pub type Reply = FileOp<Outputs>;

  pub fn execute(request: Request) -> Reply {
      match request {
          Request::Read(()) => Reply::Read(42),
          Request::Write(_) => Reply::Write(()),
      }
  }
Jtsummers 19 hours ago [-]
This looks like it would handle synchronizing multiple variant records/enums, and if you just wanted the "plain" enum without any payload, you'd need to do:

  pub struct Bare;
  impl Payloads for Bare {
    type Read = ();
    type Write = ();
  }

  pub type BareFileOp = FileOp<Bare>
Correct? So you'd need to create it with BareFileOp::Read(()), but at least it wouldn't carry any overhead of actually containing data.
bombela 18 hours ago [-]
Yes, all correct. "()" the unit type, is a zero sized type (zst).

And you don't have to have 1:1 type to enum discriminant:

  trait Payloads {
      type Read;
      type Write;
  }

  enum FileOp<P: Payloads> {
      Flush,
      Read(P::Read),
      Write { data: P::Write },
  }

  struct Inputs;

  impl Payloads for Inputs {
      type Read = ();
      type Write = u8;
  }

  type Request = FileOp<Inputs>;

  // enum item construction
  Request::Flush;
  Request::Read(());
  Request::Write { data: 42 };

You can also make an item impossible to exist using the never type:

  struct WriteOnly;

  impl Payloads for WriteOnly {
      type Read = !;
      type Write = u8;
  }
afdbcreid 20 hours ago [-]
Why do you need to do that? You can't be generic over "any enum using this tag" anyway (in Rust, at least). If you just want to make sure you make no mistake, you can use a dead match from the tag to the enum, or automate it with a macro, and the compiler will enforce exhaustiveness (though not on both sides, unless you use a macro).
Jtsummers 20 hours ago [-]
If I'm building up a type checker and an interpreter, I very well could (continuing that example) end up with different data structures using the same discriminant (but containing different data about the system). In Rust I'd have to do something like:

  enum Parser {
    bin_add(...),
    bin_sub(...),
    ...
  }

  enum Typer {
     bin_add(...),
     bin_sub(...),
     ...
  }
And I'd have to hope they were both complete and match (at least according to what I know now, that's why I'm asking). If I go back in to the Parser enum and add a `un_minus`, then I have to also go into the Typer enum (apologies for the bad naming, I'm at work and commenting between my way too many meetings) and manually add it. I have no compile time guarantee that both are complete and synchronized. In Ada, I modify the existing enum and both will fail to compile until I add in the variant for `un_minus`. One edit, multiple failures distributed across the code base as a result telling me all the places where I have to add in a new code branch or new variant.

EDIT: Run on sentence broken up.

bombela 19 hours ago [-]
You can use one generic enum with a trait holding the payload type. I posted an example as response to your first comment.
tcfhgj 20 hours ago [-]
yeah, but fortunately strum exists.

I have found it quite useful to be able to generate a dedicated SomeEnumDiscriminants enum for SomeEnum, using the following derive:

https://docs.rs/strum/latest/strum/derive.EnumDiscriminants....

xeubie 21 hours ago [-]
Yes, there is something you can do with separate types. You can name a variant without having a value of it. `discriminant` only works on an existing value, so to refer to "cats" you'd have to build a dummy `Cat`, and the result is opaque. You can't match on it, iterate over it, or create one from a byte you parsed off the wire. This is so obviously worse, I can't believe you bothered to ask.
afdbcreid 20 hours ago [-]
This is a minor advantage (but is an advantage) and when needed (rarely) you can usually workaround with a different fieldless enum and potentially a proc-macro to autogenerate it.
xeubie 20 hours ago [-]
It's not at all minor. Sometimes the tag enum already exists. Rust can't build a data enum on top of it: a derive macro only sees its own enum, so it generates a new tag enum instead. Now you have two tag enums to keep in sync by hand. Proc macros are always used to resolve deficiencies in the rust language, and they always lead to greater complexity and longer compile times.
tcfhgj 20 hours ago [-]
sagarm 19 hours ago [-]
You design the enum. If you need kinds separate from the union itself, you have that power.

The union type always implies a kind, after all, so it's a generalization of the concept.

xeubie 18 hours ago [-]
You missed the point as well. You can't define a union type in Rust that is backed by a custom enum type. In rust it's a single conflated type. I can't make a Person enum that is backed by a PersonKind. I don't know how else to describe this. I'm not sure how else to explain this.
pamcake 15 hours ago [-]
Code snippet you think should compile but doesn't, or vice versa.
clownstrikelol 21 hours ago [-]
Sure you can, bringing data along for the ride is optional in Rust. Nothing is forcing you to use it like a tagged union, it’s an optional (but useful) feature.

If you want specific values (integer or otherwise) associated with specific variants (i.e. Human = 1, Cat = 4) you can do that too. Use the #[repr(T)] or impl the From / Into traits yourself.

xeubie 21 hours ago [-]
No, you can't, because you're misunderstanding my point. You can make an enum in rust that doesn't contain data, but you can't make an enum that is explicitly backed by a tag type. `#[repr(u8)]` lets the tag be a u8 with values like Human = 1, Cat = 4, but you can’t say "Person's tag is my PersonKind enum." Zig lets you do exactly that with `union(PersonKind)`. In Rust, PersonKind would always be a separate type you keep in sync by hand.
clownstrikelol 17 hours ago [-]
Ok from reading through your other comments on this thread and the links out to Ada and Zig docs, I think what is roughly equivalent would be aliases of unit.

i.e. type Whatever = ()

That gets you a “tag” that is compile time enforced. You can explicitly match against these aliases and one alias will never == another alias (unless you explicitly write out a from / into impl, and a deref impl to make it happen implicitly).

What you seem to be ultimately asking for is being able to use a tag that is freely floating around to determine the variant of a union. This would need to be explicitly handled inside an unsafe block though.

The “happy path” here explicitly ties them together. Letting them not be handcuffed together is not memory safe, and the compiler has no way to guarantee you’re reading a value correctly.

You can of course bypass all of that inside an unsafe block and pinky promise to the compiler you made no mistakes.

dralley 17 hours ago [-]
I doubt that would be too difficult to write a macro for.
22 hours ago [-]
speed_spread 17 hours ago [-]
Being a replacement for C, Zig is definitely lower level than Rust and readily exposes its own internal structures. Rust can get you there if you need it but you have to work for it. Having enums work as a black box makes them safer and enables the compiler to possibly optimize more.
slopinthebag 21 hours ago [-]
i dont understand what rust doesn't give you that zig does?
Jtsummers 21 hours ago [-]
https://zig.guide/language-basics/unions/ - Seems like it's more similar to Ada's variant records: https://learn.adacore.com/courses/intro-to-ada/chapters/more...

Instead of just getting one type that includes the discriminant and records, Zig and Ada have a tag of some type whose value determines which variant is being used, and then the union (Zig) or record (Ada) is its own type.

slopinthebag 20 hours ago [-]
why would you ever need them to be seperate?
12_throw_away 20 hours ago [-]
Because sometimes you just want to talk about the types of variants without having to construct a value. But, you probably don't want to manually maintain a separate enum just for the discriminants. Nor do you want to manually maintain the mappings between the original enum and the discriminant-only enum.

I've had it come up when dealing with ASTs, although I don't recall the specifics. This is a problem that's certainly pretty easy to solve with macros. I'm pretty sure last time I ran into this I used `strum` [1] and its `EnumDiscriminants` macro to handle this.

[1] https://lib.rs/crates/strum

slopinthebag 20 hours ago [-]
ahh ok ive run into this before, yes either strum or i assumed i was doing something non-optimal if i had to talk about types like this
Jtsummers 20 hours ago [-]
To use the discriminant type on its own without carrying the baggage of the entire record and all its data, or to use the discriminant type across multiple records rather than creating some mega-record or manually synchronizing them. In Ada (again, don't know Zig but from the docs it's similar to what Ada is doing), adding a new value to the discriminant enum would cause a compile time error in all the variant records using it and all the case statements (match, but Ada's version), as long as they didn't have a catchall branch.
knorker 20 hours ago [-]
I still don't get it. Is it like a Rust enum, but worse, because you can accidentally only detect the problem at runtime?
kator 15 hours 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.

Rendello 15 hours ago [-]
I think there's some overlap in sentiment with the aphorism "All models are wrong, but some are useful."

https://en.wikipedia.org/wiki/All_models_are_wrong

throwaway81523 10 hours ago [-]
Everyone who starts using Haskell says similar things.
xiange 18 hours ago [-]
As a multilingual user, I think the best thing about Rust is that there aren’t as many hidden pitfalls.
mrblinky 15 hours ago [-]
Rate https://learnxinyminutes.com for quick language exploration.
user20180120 20 hours 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.

bunderbunder 18 hours ago [-]
As someone who speaks multiple languages and uses multiple programming languages, I would say it’s much more true of programming languages than it is of natural languages.

Spoken languages have the odd idiom that doesn’t translate well, and certain languages express certain ideas more or less succinctly. But it’s not like Chinese’s lack of verb tense makes it harder to think about how things are happening in time. The concept still exists, it’s just expressed differently. But not so differently that I can’t translate decently well on the fly.

Programming languages have much more variability in what kinds of concepts they can easily express. In Smalltalk I’m going to use dynamic dispatch to express damn near everything because it’s just about the only sane way to do domain modeling. In Standard ML I’m going to lean instead on algebraic data types and pattern matching. Those tend to lead to very different ways of breaking down a problem. In Scheme I don’t have either built in but both are easy enough to implement as a library, so I’ll freely choose whichever option seems most appropriate to the problem at hand. In assembly language I’ll avoid any such abstraction altogether because, while I could probably implement versions of both, it would be a total PITA and probably result in incomprehensible code. And translating among any of them is likely to be the work of multiple hours or even days.

nrvn 9 hours ago [-]
Language is a communication tool. Thinking process goes beyond that. Conflating internal dialogue and thinking or even forcing thinking through internal dialogue will apparently hit the cognitive limits for a number of reasons.
mdswanson 20 hours ago [-]
coldtea 22 hours 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.

bingobongo84 21 hours ago [-]
Agreed. My first thought reading this was “does this really matter anymore?”
DonaldPShimoda 21 hours ago [-]
As someone who enjoyed learning advanced derivation and integration by hand despite also owning a TI-84+ at the time: yes, it still matters.
dominotw 21 hours ago [-]
This is not like that at all
Viliam1234 21 hours ago [-]
I learned how to calculate the square root using pen and paper, and it was fun, but... I am not going to write blogs about how it made me a better person and why everyone should do this. There are so many cool things one could do, and people have different hobbies and preferences; what is fascinating for me is not necessarily so for someone else, and vice versa.
DonaldPShimoda 14 hours ago [-]
I actually think there's a meaningful distinction between my math example (calculus) and yours (square roots), which is that yours is purely numeric. I think learning to solve complex abstract problems is fundamentally useful, regardless of whether the specific problems you practice solving are themselves of any use: it's practice in problem-solving, which generalizes in often unexpected and nuanced ways.
William_BB 21 hours ago [-]
Yikes. I hope the second thought was more insightful..
genxy 21 hours ago [-]
Let them eat PHP.
esikich 21 hours ago [-]
Ugh. Swap out LLMs for formal logic, mathematical proofs, the calculator or the printing press if you want.

You're just getting older and times change. Your adolescence wasn't any more pure than the kids today.

One could argue you've frittered away your life fiddling bits around instead of becoming a thespian, writer, or musician. Alas, the epiphanies you could have had.

oblio 15 hours ago [-]
> a thespian, writer, or musician.

Even in an ideal world, some people would just not want to become artists.

democracy 19 hours ago [-]
Thank god llms/harnesses are smart enough to figure out and follow existing approaches rather than bringing "new paradigms"
srean 12 hours 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.

clench 21 hours ago [-]
"A Person is either a human or a cat" -- Good article, but please use examples that makes sense.
EdwardDiego 21 hours ago [-]
I suspect it's a reference to catgirls, an old joke about Rust. In fact: https://crates.io/crates/catgirl-engine
22 hours ago [-]
kinfish 19 hours ago [-]
i can say BEAM still the one that influeces me as developer.
atulvi 21 hours ago [-]
Sapir-Whorf hypothesis
scotty79 7 hours 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.

wg0 13 hours 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.

zzzeek 16 hours 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.

tancop 11 hours ago [-]
> I'm sure how Rust does it is much better integrated and "correct"

Not really. There are two different macro systems, one of them has you writing cryptic functional style pattern matching on expressions and the other just gives you a stream of tokens to parse yourself.

Neither of them lets you create types, functions or traits as objects like in Zig. You need to build Rust expressions that produce them and keep track of all the names while doing it. If the macro fails to put out valid code the user gets a confusing error, unless you make them use the nightly compiler. It's one level above C style string manipulation.

And did I mention that if your macro extends Rust syntax you need to pull in a third party Rust parser, because the one in the compiler is strictly internal?

einpoklum 1 hours 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.

madspaaskesen 20 hours ago [-]
[dead]
Uptrenda 18 hours ago [-]
im literally shaking, reddit
p-s-v 20 hours ago [-]
[flagged]
spartanatreyu 20 hours ago [-]
You cannot fix what you did not understand.

You do not understand what you did not create.

GeorgeTirebiter 16 hours ago [-]
I quite honestly and innocently asked if anybody was hand-writing new code on an HN thread six months ago, and got downvoted to invisible. I don't get it -- except for fun on old machines, I stopped writing new code last year. The AIs are just better and faster at it than I am. Even when needing to go a few rounds to get something exactly the way I want it -- it's still faster with AI than my hand-coding. What can I learn from specific computer language learning that I could not learn by understanding the core concepts well enough to tell an AI to use those concepts? Do I care about syntax? Or how much time do I want to look things up in the docs? To me, learning details about specific programming languages -- at this point -- is like learning new knitting patterns: interesting, but largely irrelevant. What am I missing?
bigstrat2003 14 hours ago [-]
> The AIs are just better and faster at it than I am.

Well they aren't better at it than me, or most programmers. So we continue to use the most effective tool for the job, which is ourselves.

MrMontyBurns 19 hours ago [-]
I am programming, sir
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 19:16:18 GMT+0000 (Coordinated Universal Time) with Vercel.