Live data from Hacker News

Clever code is probably the worst code you could write (2023)

read.engineerscodex.com

201–204 of 204 posts

Re: Clever code is probably the worst code you could write (2023)

#201

Earlier quoted context omitted.

I tend to use for loops in Rust for this reason; simple, and understandable by anyone who's programmed in an imperative language. The one-liner approach tends to include an explicit type declaration (Or turbofish), `iter()`, and `collect()`, at minimum.

FYI I think you've misinterpreted the parent. To my eyes it looks like they're agreeing that Rust makes summing a list easy using combinations. For example, this is how I would do it in Rust: x.iter().sum()

I think they’ve understood and are claiming that a simple loop is cleaner than what you wrote. I’m not sure how since that 1 line communicates what’s happening at a high level with 1 word “sum” whereas a loop requires me to read the loop to confirm it’s a plain summation.

This sounds like someone complaining that the concepts they learned when they were first starting out are the only concepts that programming languages should introduce which is silly - technology evolves as we find better and new ways of accomplishing old tasks.

Re: Clever code is probably the worst code you could write (2023)

#202

Earlier quoted context omitted.

> the fundamental problems of programming have not changed over the centuries It hasn't been a whole century yet. Grace Hopper's career started in 1944, eighty years ago.

Ada Lovelace predates her

Although it is very common for laypeople to be told that Ada is the "first programmer" in some sense, I don't find that very convincing at all. For Ada this was purely an intellectual exercise.

Grace's machine really existed, and her insight really works, even if today we would not call what she initially built a "compiler". The machine processes data, the program is data, have the machine process the program. This is recursively meta-applicable, and it's notable that rather than being something higher ups or intellectuals had specified should be done, Grace was being entirely practical.

When you write some typescript inside a C# program today and then somehow in a web browser the equivalent code ends up executed by its JS engine, that's all the fruit of Grace's insight just applied over, and over, and over.

Re: Clever code is probably the worst code you could write (2023)

#203
post #182

Earlier quoted context omitted.

This transformation is only legal if order of summation doesn't matter. So the compiler can do it for ints, but not floats.

Applying std::reduce to floats would be a similarly bad idea for having the compiler do it, except people will write it without thinking. Of course, people always struggle with writing correct floating point so I doubt it makes things better or worse, but it’s conceptually the library equivalent of -fast-math (which coincidentally would also auto-vectorize the loop but can impact more than just that).

Using fast math in one particular expression is way different and less risky than doing it globally.

Re: Clever code is probably the worst code you could write (2023)

#204
post #186

Earlier quoted context omitted.

TL;DR - OOP obsession is a common python developer phase. it's a dangerous phase. - maintainable code is not minified code. minified code is minified code. - stoopid code is often stoopid enough when it satisfies real world / human concerns, not technical concerns. ---- I've done all of these, and I see other people repeating them. 1. hyper optimised and utterly fragile class based inheritance / abstractions. Not opt…

I find functional programming is where things get bad. It does give some pretty elegant ways to do things, but it can become a nightmare when debugging. Sometimes I need to dig into Django code to work out what's going on. It's all fine while the code is imperative, but as soon as you hit a functional part, then following what's going on gets difficult.

> It's all fine while the code is imperative

ah sorry, i may have had a brain fart here. I use functions imperatively like you say and that's the concept i wanted to get across. failed to do so because I just mentioned don't over-do it on the math.

my bad.

should probably have been an extra one between 6 + 7 for do things imperatively

Post reply on HN