Preferences

WalterBright parent
Good taste is writing code that looks so simple, everyone else says "pshaw, anyone could have written that!"

WalterBright OP
I have another example. I have a '72 Dodge Challenger. I've taken the thing apart, and put it back together. I never cease to be surprised at how well-engineered it is in its simple, direct, and inexpensive solutions to making an amazing car.

For example, consider the instruments. They run off of 5 volts, while the system voltage of the car is anywhere from 10-18 volts. How to get 5 volts? It has a sort of buzzer which is an electromagnet. When the voltage is above 5 volts, it breaks the circuit, when it is below 5 volts, it closes the circuit. It happens fast enough that the result is a rough 5 volts.

Many restorers of these cars decide to replace it with an electronic voltage regulator, that gives it a rock solid 5 volts.

Then they discover the instruments don't work.

It turns out that the (mechanical) instruments tend to get stuck. The roughness of the 5 volts keeps them from getting stuck. So now the the electronic voltage regulator needs another circuit added to make the 5 volts rough.

That little, simple voltage regulator hidden inside a can is a marvel of simplicity and effectiveness.

sethhochberg
I think you've actually buried a much broader commentary on tolerances and complexity and interoperability in here, too.

The mechanical-averaging voltage regulator worked for the design because it only had to work in the context of the specific model of car it was going into. It didn't have to produce 5v for any application that needs 5v; it just had to produce "5v" for the instruments in the '72 Dodge Challenger. That makes it a pretty terrible 5v regulator, but a pretty great part for the system it was designed to fit into if the mechanical-averaging version is more reliable or cheaper or more robust than the fancy electronic versions.

But if I'm designing a 5v regulator to be sold as a 5v regulator, well... I don't know what system its getting installed into so I won't have much luck selling one that, over a long enough time span, averages out to supplying 5v of power when its supplying power. So I have to design in tight tolerances, and everyone integrating my regulator has to design for tight tolerances, etc.

The good news is that now anyone can buy my regulator and get a reliable 5v - interchangeable parts! But the bad news is now every system on both sides has additional complexity for the sake of complying with our standard.

We see this _all the time_ in software, especially comparing old software to new. Why is Roller Coaster Tycoon so much more elegant and efficient than a modern game written on Unity? Sure, good tastes probably factor in - but that taste from the author was allowed to shine because it was designed as a complete system, not a bunch of component subsystems from different teams and vendors stitched together.

WalterBright OP
You make a great point. With the Dodge regulator, I seriously doubt it was just for the Dodge Challenger. It was probably used across the entire Chrysler line, for years. Enough cars were built to totally justify its design. I don't know when semiconductor voltage regulators appeared in a single package.

In 1972, the electro-mechanical regulator was also likely far cheaper than a solid state one. The car didn't have a single transistor in it outside of the (rather expensive) radio. (There was an upgrade available for the ignition to make it "electronic" - it had one transistor!) The alternator of course had diodes in it.

The rough 5V also enabled the instruments to be made cheaper.

I thought by 72 they were using the electronic ignition module instead of points? I thought MY72 was the year it was introduced even?
WalterBright OP
The electronic ignition was an option at the time.
WalterBright OP
Another example. The V2 rocket engineers had a problem with the nozzle. It would burn through. The flame was just way too hot for any known metal.

The solution was simple and pure genius.

The nozzle was composed of tubes welded together. The liquid oxygen was run through the tubes, which pre-heated the oxidizer and cooled the nozzle. But that still wasn't enough. Then the engineers simply drilled tiny holes in the tubes, so some of the oxygen would leak out into the nozzle. The gas would form a barrier between the flame and the nozzle, and would carry away the heat. (This is known as boundary layer cooling.) If you ever get a chance to look at a rocket nozzle, you'll see the tubes and the holes.

stickfigure
I don't know that I'd describe this as "good". It's a hack solution that mostly worked at the time.

Those mechanical voltage regulators wore out and had to be replaced periodically. They weren't great at maintaining consistent voltage so consumers had to accept loose voltage tolerances. They made noise and generated electrical interference.

Modern cars are more reliable, despite their complexity. I'll take solid state.

WalterBright OP
> Modern cars are more reliable

I would hope so, after 55 more years of development!

nickd2001
And the tragedy is that authors of such code often (usually?) don't receive recognition for saving time and effort on others' part by following KISS principles. For whatever reason its apparently opaque to others. And so there are entire jobs or even teams in the tech industry whose purpose is to work with and/or maintain systems that have needless complexity.
WalterBright OP
My life as the leader of the D team is one of a constant battle against complexity.
Exactly. It's occasionally handy if your engineers are capable of doing extraordinary things, but it's even better if they consistently find simple, ordinary solutions to problems that seem formidable at first glance.
silisili
That's always been my benchmark as well. I'm always super impressed by people who are able to distill complex things into simple steps. Much like K&R C example code, but please, please leave better comments.
> everyone else says "pshaw, anyone could have written that!"

it really depends on the problem domain tho, doesnt it?

Would you call the fast inverse square root[0] code good taste?

[0] https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overv...

Etheryte
Being a good fit for a given purpose doesn't mean that something is in good taste. That piece of code is very performant, yes, but I'm pretty sure none of us would want to meet it in code review, save for a few niche edge cases. To draw a parallel from fashion, for most part, arctic snow gear does not win fashion prizes, but it does keep you alive. There's a time and place for both, doesn't mean that everything useful is in good taste.
AlotOfReading
What is "most" here? Traditional Arctic clothing (e.g. Inuit clothing) has huge fashion aspects. Being able to look good and stay comfortable in a blizzard are both important to many people in the far north.

I highly recommend checking out the clothing and fur stores to accessorize if you're in an Inuit town with nothing but "purely practical" Western clothing. A fashionable design will improve both the look and the cold weather performance.

This sometimes gets taken to the extremes of high fashion, like this design by an Inuit woman:

https://vafashion.ca/pages/the-ukiaksaq-collection-nyfw-2020

01HNNWZ0MV43FF
> I'm pretty sure none of us would want to meet it in code review, save for a few niche edge cases.

It does no I/O and has no action-at-a-distance. The float-long-float casts are the worst part.

If a coworker brought it to me with a performance justification and some unit tests I'd be pretty happy to pass it.

peterfirefly
Yes, but the "good taste" part lies mainly in three things: 1) recognizing that a reciprocal square root is more useful than an actual square root (and likely cheaper), 2) recognizing that full precision isn't necessary, 3) recognizing that one (or two) Newton-Raphson iterations is good enough with a decent starting approximation.

The starting approximation is just magic.

WalterBright OP
As a young programmer, I would have also written the the function name "Q_rsqrt".

As an old programmer, I would write "FastInverseSquareRoot()".

It took a looong time for the penchant to write identifiers adhering to the FORTRAN limit of 6 characters to fade away.

(Yes, I know Q_rsqrt is 7.)

rapsey
One is an algorithm, a purely technical solution. The other is the way code is structured in an application.
RHSeeger
Really the post you're replying to should have been written the other way around

Writing code that looks so simple, everyone else says "pshaw, anyone could have written that!" is good taste.

Not all dogs are golden retrievers, etc

kmoser
That's not good taste, it's good engineering.
RHSeeger
./venn diagram comments...
WalterBright OP
Another one:

People will watch a ballet and remark "they make it look so easy and effortless!"

The reality is, it is easy and effortless to them, because they practiced it 10,000 times.

HPsquared
That's the best kind of work to get into. Something where you've got a rare skill, do something that looks amazing, but it's easy. Like ballet, the hard part is getting yourself to that skill level and finding opportunities to use it.
jongjong
Yes. It's a great irony. It's so simple that anyone could have written that and yet it feels like less than 1% of people write code like that in practice.
Cthulhu_
The challenge though is getting people to appreciate it, because the code looks / is boring as well. A lot of junior but good and driven developers (...myself included) want to write clever code, code that makes them feel smart, but often in an environment where the problem doesn't need it. CRUD back & front-end has this problem, where the complexity isn't (shouldn't be) in the code itself but the higher level stuff - domain, architecture, etc.

And then there's a class of people that overcomplicate the architecture out of boredom, perceived possible problems (like scaling) or cargo cult, and they introduce stuff like microservices or lambdas instead of just solving the problem at hand with proven and simple solutions.

But you won't find good developers if your job listing is "looking for a java developer for a straightforward CRUD application".

pyrale
Obligatory simple made easy.

Just because something is simple doesn't mean anyone has the wherewithal to understand it.

[1]: https://www.youtube.com/watch?v=SxdOUGdseq4

dominicrose
I loved working in a team that wasn't allowed to use local variables (Rich Hickey decided that Clojure shouldn't have them). The menu of the website was basically implemented as a state machine and it just worked because every possible user interaction was taken into account.
arunix
Do you mean local variables per se, or mutable local variables? Clojure, like most Lisps has let.
While balancing that to performance requirements appropriate for the project. And picking dependencies that do the same while having a healthy community likely to keep going.

The same applies to picking vendors, asking questions like "will they extort me next contract renewal" and "what options do I have if they extort me".

WalterBright OP
Sometimes, simple code is viewed as an invitation to make it more complicated.

This item has no comments currently.