Hacker News new | ask | show | jobs
by doubled112 320 days ago
Code will tell you what but not the why. It also doesn’t always tell you the intent.
2 comments

They should invent a programming language that only compiles if the why is still true.
They have, but they're beyond grasp of most developers.

Tests were invented to express the "why" for the normal guy. They don't strictly prevent compilation, but a proper workflow will see them halt your process in the same way, offering the same outcome.

Granted, there are a lot of horribly written tests out there that don't tell you "why" — or, well, anything. As always, people will find a way to abuse anything you put in front of them. But when used well...

With a test, it might link up some functionality with "why" and pass, but then what happens if a business requirement just isn't a requirement anymore? The test will still pass. I'm thinking of something sillier, like a language that forces you to justify why for your code, and then regularly quizzes you if the business reasoning is still true. If anything changes, it rips out the code and breaks your site. :) So then you have to go in to fix it.

I'd also love it if this were applied to politics and laws.

It wouldn't be too hard to add such logic to your tests. If it proves useful, someone will no doubt turn it into a language feature.
Good commit logs or comments may tell you why
What about function names, class names and variable names?
Helluva wish.