News for hackers. Stuff that matters.
Re:Simple, correct, fast: in that order by SamuelAdams on Monday July 09, 2018 @09:51AM (#17490111)
I would argue that correct is more important than simple.

Consider timezones: it's simpler to pretend there's 24 time zones, one for each hour. But the correct assertion is there's 37 time zones (as of this writing). So, the simple solution results in a third of your potential user base having issues.

Other issues to pick: accessibility, cross-browser compatibility, legacy device compatibility... the list goes on.

Re:Simple, correct, fast: in that order by lopatin on Monday July 09, 2018 @10:07AM (#17490236)
I think it's more in the spirit of the article to say, forget timezones, use UTC millis everywhere. If the server doesn't speak in timezones, then you eliminated all bugs where the server mishandles timezones.
Re:Simple, correct, fast: in that order by masklinn on Monday July 09, 2018 @11:23AM (#17490884)
> I think it's more in the spirit of the article to say, forget timezones, use UTC millis everywhere. If the server doesn't speak in timezones, then you eliminated all bugs where the server mishandles timezones.

That's a flagrant example of "simple and wholly incorrect". If you don't store timezones, your future dates will eventually turn out incorrect when timezone offsets change e.g. create a meeting at 9AM local, store as UTC, country decides to not follow DST that year bam your reminder will ping an hour early or late.

Or a day off when the country decides to jump across the international date line (https://en.wikipedia.org/wiki/International_Date_Line#Samoan...).

Re:Simple, correct, fast: in that order by y4mi on Monday July 09, 2018 @02:26PM (#17492304)
most applications don't need to schedule events into the future though and its a smart strategy if all you need to worry about is the past
Re:Simple, correct, fast: in that order by masklinn on Tuesday July 10, 2018 @02:39AM (#17495905)
For very specific cases? Sure, but none of the comments talking about UTC everywhere cares to specify this rather important bit.

Unless restrictions are specified I will assume we're talking about the general case, and for the general case it's just plain wrong.

Re:Simple, correct, fast: in that order by y4mi on Tuesday July 10, 2018 @09:10AM (#17497702)
from my point of few its the other way around.

There are very few applications that need to schedule events into the future, and that is literally the only situation where you have to worry about the timezone.

Btw, keeping the timezone is insufficient as well if you're building a calendar/scheduler. If the user changes the timezone after scheduling the event... do you keep to the old one and alert him whenever, or do you adjust? There are a lot of edge cases with schedulers -- yet as i said before, most applications don't schedule into the future. They're mostly just doing things right now or within the next few minutes and keeping a log of their actions.

Re:Simple, correct, fast: in that order by masklinn on Tuesday July 10, 2018 @09:19AM (#17497782)
> from my point of few its the other way around.

> There are very few applications that need to schedule events into the future, and that is literally the only situation where you have to worry about the timezone.

My experience is the exact opposite: there are few applications which only store past dates, and in those said date is usually indicative/barely even relevant and could just as well be part of a freeform comment or removed entirely.

Re:Simple, correct, fast: in that order by dredmorbius on Monday July 09, 2018 @11:27AM (#17490922)
The UTC example allows the user to translate output using localised tools.

The solution isn't incorrect, it is modular.

Re:Simple, correct, fast: in that order by masklinn on Monday July 09, 2018 @11:29AM (#17490941)
> The UTC example allows the user to translate output using localised tools.

So you provide an alarm clock which is works as neither a clock nor an alarm.

> The solution isn't incorrect, it is modular.

It's either not correct or not a solution, either way it's useless.

I also like how proponents of "simplicity at all cost" apparently assume/assert the composition of two systems is no more complex than either, and that there is no additional complexity to the composition layer.

Re:Simple, correct, fast: in that order by s3m4j on Monday July 09, 2018 @10:26AM (#17490364)
In my experience, it's been easier to push UTC time all the way from the db to the user javascript and operate on time then, than trying to manipulate time before sending to the user. YMMV, and it's only web dev.
Re:Simple, correct, fast: in that order by marcosdumay on Monday July 09, 2018 @10:33AM (#17490414)
There are many kinds of data that get saved as time. For some, yes, it's better to add and remove the TZ at the interface. For some the TZ carries meaning by itself, and it must be stored and keep constant everywhere. For some the TZ carries meaning, but the time must be converted for display.

Know your data, and most of your problems get easy.

Re:Simple, correct, fast: in that order by everybodyknows on Monday July 09, 2018 @06:29PM (#17493928)
Yes, that's the crucial distinction -- whether the TZ, with its coarse encoding of the geography of origin, carries significance to the consumer of the data.
Re:Simple, correct, fast: in that order by taeric on Monday July 09, 2018 @10:30AM (#17490394)
This works for things that have happened. It doesn't work too well for schedules. In those cases, the timezone of the source matters, heavily.
Re:Simple, correct, fast: in that order by majewsky on Monday July 09, 2018 @10:43AM (#17490494)
For example, a task that occurs "daily at 15:00" does not always happen every 24 hours. When DST comes into effect, the interval shortens to 23 hours once.
Re:Simple, correct, fast: in that order by falcolas on Monday July 09, 2018 @03:13PM (#17492658)
Or, at "2:30 am" in the continental US can occur twice in a day, or not at all. Of course, even that isn't guaranteed, if you're in AZ.

Even "notify me in exactly 24 hours has its own complications. Leap seconds will screw up your day (as will the vague request of "exactly 24 hours").

Corner cases, the bane of simplicity everywhere.

Re:Simple, correct, fast: in that order by s3m4j on Monday July 09, 2018 @02:34PM (#17492367)
To this day, knock on wood, I have had success at voluntarily avoiding those issues ^^ (aside from school assignements)
Re:Simple, correct, fast: in that order by SamuelAdams on Monday July 09, 2018 @10:34AM (#17490423)
I agree - UTC is the way to go. The point of the example was to illustrate how simple could be detrimental to a significant portion of your userbase.

How about another example? You're building an android application. Let's pretend there's an API in the latest version of Android that reduces a dozen lines of code down to one function call - ShinyNewMethod().

You can use that ShinyNewMethod() call. It's certainly simpler.

But the vast majority of android devices in use are not running the latest OS. So the NewShinyMethod(), while being simple, will cause your app to not work for them.

Hopefully the framework designers figured a way to have this auto-reverse engineer for older devices, but that's not always a guarantee.

Re:Simple, correct, fast: in that order by AstralStorm on Tuesday July 10, 2018 @01:51AM (#17495755)
This results in funny things like android support library.
Re:Simple, correct, fast: in that order by jstimpfle on Monday July 09, 2018 @10:35AM (#17490428)
But no, what about UTC leap seconds? Use TAI! :)))
Re:Simple, correct, fast: in that order by michaelcampbell on Monday July 09, 2018 @10:12AM (#17490275)
The old yarn I'd heard for years is close to this.

Make it work. Make it work right. Make it work fast.

In that order.

Now it could be argued that "work right" can be read as "make it (work right)", or "(make it work) right", or both, but I think the point of this saying is that the "fast" part should always come later.

Re:Simple, correct, fast: in that order by taneq on Monday July 09, 2018 @10:37AM (#17490448)
Yep, this is the version I heard. I think the distinction between "make it work" and "make it work right" is important, though - where "work" means "solve the problem", and "work right" means "solve the problem in a robust and reliable manner."

If your software doesn't solve the problem, it's useless, no matter how correct or fast it is. Once it solves the problem, then you can work on making it bug free and elegant. Once you're done with that, only then should you look at making it fast.

Note, of course, that "make it fast" refers to gratuitous optimisation. If it's too slow to solve the problem, then it doesn't work, and that needs to be fixed.

A similar adage states the rules of code optimisation:

1) Don't.

2) (For experts only) Do it later.

Re:Simple, correct, fast: in that order by sethrin on Monday July 09, 2018 @12:04PM (#17491231)
3) Profile before optimization.
Re:Simple, correct, fast: in that order by AstralStorm on Monday July 09, 2018 @01:19PM (#17491807)
4) After thinking how to get beat bang for buck when optimizing. Profilers don't always pinpoint the culprit.
Re:Simple, correct, fast: in that order by kungtotte on Monday July 09, 2018 @02:41PM (#17492418)
I have a hard time seeing how profilers don't at least point you in the right direction. Or are we using different definitions of the word? They tell you how much time is spent in any given section of your program. If 80% of the time is spent in 20% of the code, it's usually a safe bet that's where you should start looking!
Re:Simple, correct, fast: in that order by taneq on Monday July 09, 2018 @07:30PM (#17494270)
Generally I agree, but after you've picked off a few low hanging fruit, you'll end up with the profiler pointing at the function which does most of your grunt work, at which point you'd expect that to take up most of the time.

Once you've got this pretty optimized and it's still taking up the lion's share of your execution time, you have to look elsewhere (probably changing your overall approach or applying some higher level optimisation) to improve things further.

Re:Simple, correct, fast: in that order by AstralStorm on Tuesday July 10, 2018 @01:41AM (#17495727)
Yes, at that point you typically get to apply far reaching architectural changes or switch out the algorithm.

Sometimes it is quicker to start with just that instead of "polishing a turd". You can get it to be shiny but still nowhere near as shiny as gold.

Hope the code is testable and reasonably easy to modify. Otherwise it's going to be a rewrite.

The profile is then useful as a benchmark on real data. If you have enough time, you can turn that into a high level performance test.

Re:Simple, correct, fast: in that order by sethrin on Monday July 09, 2018 @03:05PM (#17492610)
Profilers have limitations like anything else, and it's possible to be pointing the flashlight in the wrong place. I probably wouldn't include that as a list item.

By the by, is there more than one kungtotte on the Internet? It took me a minute to think why that name was so familiar, but then I remembered watching a few hundred Beaglerush videos.

Re:Simple, correct, fast: in that order by kungtotte on Monday July 09, 2018 @11:08PM (#17495132)
There must be more than one, because I've never heard of Beaglerush.

I've used this handle for a long time though (20 years or so), so it's all over the internet.

Re:Simple, correct, fast: in that order by sethrin on Tuesday July 10, 2018 @02:33AM (#17495882)
Kk, thank you for indulging my curiosity. Beaglerush is a very humorous Aussie who is notable for a video series on the Long War mod for the game XCOM. Long War turns a moderately challenging game of thirty or forty hours into an extremely complex, impossibly difficult ordeal of at least 400 hours per game. Beagle apparently often uses the handles of his friends as character names, and one of the best/worst parts of XCOM is that it's really good at making you care about the little blobs of pixels you order into virtual mortal peril, so to me kungtotte is like, the hero of 100 missions :)

If you're into strategy games, XCOM is good, and Long War is matchless. However, Beaglerush is actually surprisingly entertaining even if you don't care for his subject; the girlfriend is still not much into the game, but after the first couple episodes she insisted on watching the other hundred-thirty-odd videos. It's probably not everyone's cuppa, but it could be a thing.

Re:Simple, correct, fast: in that order by kungtotte on Tuesday July 10, 2018 @05:31AM (#17496533)
Oh, that's me then :) I didn't put two and two together because I knew him as just beagle, and it was a long time ago that I hung out with him. We played together in a gaming community known as ShackTac or ShackTactical, playing a game called Armed Assault/ArmA.

Way back when a bunch of us put our names into a custom name file for XCOM so people could make campaigns featuring ShackTac people instead of generic dudes. I completely forgot about that until you reminded me. It must be five years since I talked to him :)

Re:Simple, correct, fast: in that order by sethrin on Tuesday July 10, 2018 @09:18AM (#17497775)
Oh cool :) Yeah, I did get the impression that the name list represented more former acquaintances than current ones, and I think he got pretty burnt out on YouTube generally. He seemed like a pretty great guy, and the series was excellent, so it seems you have a small measure of reflected glory at least :)
Re:Simple, correct, fast: in that order by Buttons840 on Monday July 09, 2018 @02:21PM (#17492262)
Sometimes I try to implement a common task in a new library, and I find that if I chain these 4 API calls and then extract some data with a regex, it will do what I want. I rarely actually implement the task this way though, because I know it's a common task, and there must be a better way. Sure enough, after some more research and reading of documentation I find one simple API call that does what I want.

I take this to the extreme, I probably wouldn't implement the complicated API / regex chain without 4+ hours of reading documentation and other research. It bothers me that much. If it seems like a simple and common task, I refuse to believe that there isn't a simple API call already to do what I want, I just have to find it. Sometimes, the simple API call really doesn't exist though, and you have to do what you can, with some comments explaining why.

I've noticed some developers will implement the 4 API chain followed by a regex as soon as they find it, and never give a second thought that there might be a simpler way.

Re:Simple, correct, fast: in that order by nicbou on Tuesday July 10, 2018 @12:28PM (#17499590)
This is good, because that process now becomes the API's problem and not yours. Their tests cover it, not yours, and it makes your work simpler.
Re:Simple, correct, fast: in that order by cbsmith on Monday July 09, 2018 @10:39AM (#17490466)
The make it work fast portion isn't controversial. Premature optimization and all that...

The "make it work" implies a level of correctness & performance that is acceptable, which is why any subsequent steps are after thoughts.

Re:Simple, correct, fast: in that order by AstralStorm on Tuesday July 10, 2018 @01:55AM (#17495766)
The missing part is "make it workable". By that I mean reasonably easy to modify. This may or may not involve simplicity but usually involves modularity and lack of hard impingement interdependencies - weak coupling.

If you skip that, you will relatively quickly reach the point of a full rewrite.

Re:Simple, correct, fast: in that order by martingxx on Monday July 09, 2018 @09:58AM (#17490169)
Correctness (and any other kind of change in behaviour) is easier to achieve if things are simple.

Changes are not necessarily easy or even possible to make safely if things are correct but not simple.

"Simple" is a proxy for "can be changed safely" and so IMO is the most important quality to have.

Re:Simple, correct, fast: in that order by DannyB2 on Monday July 09, 2018 @10:14AM (#17490291)
I think you do whatever it takes to achieve correctness.

If simplicity helps achieve correctness, then great.

But correctness is not always simple.

Most people think there is a leap year every four years. They are wrong.

Re:Simple, correct, fast: in that order by rbonvall on Monday July 09, 2018 @10:59AM (#17490644)
I know a couple of guys that would probably implement isLeap by checking that the lower two bits of the year are not set, then boast about how fast it was, and finally, when told that the logic was incorrect, push back because the additional checks would make it "slower".

In their minds, when things stop being simple, fast trumps correct.

Re:Simple, correct, fast: in that order by adrianmonk on Monday July 09, 2018 @12:43PM (#17491525)
One nuance is that some parts of correctness may be negotiable.

If I'm writing a file backup program, it absolutely must back up all the files without leaving any out or corrupting the data.

But let's say it has a feature that prints progress indicator percentages on the command line, ranging from 0% to 100%. Maybe under certain circumstances (like files added to a directory after the backup starts), it prints 102%. It's not what I had in mind, nor is it something I'd call correct. But if fixing it complicates the code a lot, maybe leaving it that way is the better choice.

(This is a bit of a contrived example because you could just clip the value at 100, but you get the idea.)

Re:Simple, correct, fast: in that order by ythn on Monday July 09, 2018 @10:20AM (#17490335)
The simple thing to do then is to call an `isLeapYear` function that abstracts any complexity.

Abstraction allows you to hide complexity and make it a simple, reusable part again.

Re:Simple, correct, fast: in that order by DannyB2 on Monday July 09, 2018 @10:37AM (#17490449)
But I could write a simpler (incorrect) leap year function than yours!
Re:Simple, correct, fast: in that order by ythn on Monday July 09, 2018 @10:50AM (#17490546)
You missed the point of the article if you interpreted it as correctness being intentionally sacrificed for simplicity.

Plus, a complete leap year implementation is already what I would consider simple and most standard libraries already have an implementation for it you can use directly.

Re:Simple, correct, fast: in that order by gkya on Monday July 09, 2018 @11:28AM (#17490929)
I don't think simple means discard if complex. It means using the simplest and most obvious tools (algorithms, libraries, &c) possible in order to achieve a correct enough software. So it does not mean discarding intricacies of timekeeping, but implementing it with the clearest, simplest use of abstractions and methods possible.
Re:Simple, correct, fast: in that order by pofilat on Monday July 09, 2018 @11:54AM (#17491168)
My calculator watch worked perfectly for 50 years on that "wrong" assumption.
Re:Simple, correct, fast: in that order by JackFr on Monday July 09, 2018 @10:34AM (#17490420)
> But the correct assertion is there's 37 time zones (as of this writing). So, the simple solution results in a third of your potential user base having issues.

That assumes your user base is evenly distributed across time zones. The US has 6 time zones, but if you only handled 4, you'd cover 99.3% of people.

Re:Simple, correct, fast: in that order by kbsletten on Monday July 09, 2018 @10:56AM (#17490616)
The US has more than 6. There's a big difference between Denver and Phoenix, even though they're both "Mountain Time". Grouping them together would be overly simplistic. Things like "weekdays at 10 A.M." mean different things half the year.
Re:Simple, correct, fast: in that order by vinceguidry on Monday July 09, 2018 @09:57AM (#17490153)
Obviously to solve the problem, a certain amount of correctness is implied. But once that threshold is reached, simplicity is a better use of your time. At least, that's the thesis of the article.
Re:Simple, correct, fast: in that order by k__ on Monday July 09, 2018 @01:07PM (#17491718)
True.

The problem is always, how to get enough correctness that your customers are happy, but don't spent too much time on it so that rivals won't overtake you.

Re:Simple, correct, fast: in that order by quietbritishjim on Monday July 09, 2018 @10:02AM (#17490195)
All general rules like this are terrible if you apply then blindly, but can still be useful if you apply them loosely.

In your example, I would take simple to mean "only use UTC". As soon as you need timezones I would say you've moved into correctness territory and need to do them all properly (you would use a good library, of course).

Re:Simple, correct, fast: in that order by collyw on Monday July 09, 2018 @09:59AM (#17490175)
Every piece of software that has bugs could be considered not correct, which is the vast majority of it.
Re:Simple, correct, fast: in that order by ionforce on Monday July 09, 2018 @10:02AM (#17490192)
Depends on the definition of bug.
Re:Simple, correct, fast: in that order by coryfklein on Monday July 09, 2018 @01:18PM (#17491799)
I don't think what you're saying is in conflict with the OP:

> The complex problem comes later, and it’ll be better served by the composition of simple solutions than with the application of a complex solution.

Complicated problem domains can be made into simple ones by breaking them down into their constituent components. You can solve time zones by having 5000 Rube-Goldberg-esque lines of if/else-if statements, or you can organize the system into simple components that build on each other.

At any given component or level the problems are clear, simple, and identifiable, and the complexity arises as the components join to form abstractions upon which higher levels operate.

Re:Simple, correct, fast: in that order by AstralStorm on Tuesday July 10, 2018 @02:00AM (#17495781)
Or you can end up with a mishmash of components instead of statements.

Premature abstraction is a kind of premature optimization, except you're not buying performance.

Bad abstractions tend to stay in for a long time.

What matters is clear delineation between functional components and weak binding, so that internals can change, and that the interfaces are relatively minimal.

Re:Simple, correct, fast: in that order by meheleventyone on Monday July 09, 2018 @10:03AM (#17490204)
The point is that it should be as simple as possible to solve the problem but no simpler.
Re:Simple, correct, fast: in that order by betacat on Monday July 09, 2018 @10:14AM (#17490292)
This generic expression indicates why "correct" comes first. "Simple" has it as a dependency. ;)
Re:Simple, correct, fast: in that order by meheleventyone on Monday July 09, 2018 @10:34AM (#17490421)
It's order of importance though rather than an expression of dependencies and I'd definitely err on wanting my solution to be as simple as possible over merely correct. The idea being that whilst you are solving a problem you are always striving to solve it simply and only add complexity as needed.
Re:Simple, correct, fast: in that order by grok2 on Monday July 09, 2018 @10:13AM (#17490284)
So long as the software will only be shipped after all three stages, it's a useful metric to go by, I guess. It prevents you getting overwhelmed by the myriad amount of decision-making that writing software is. And also, so long as you accept the fact that you will need minor or major redesigns by the time you get to the "fast" version that is production ready.
Re:Simple, correct, fast: in that order by theandrewbailey on Monday July 09, 2018 @09:58AM (#17490168)
Agreed. Software that does what it's supposed to is better than software that is simple (or fast), but buggy.
Re:Simple, correct, fast: in that order by AnIdiotOnTheNet on Monday July 09, 2018 @11:09AM (#17490760)
Which is why everyone uses OpenBSD instead of making a tradeoff with a different OS that isn't designed as securely.
Re:Simple, correct, fast: in that order by AstralStorm on Tuesday July 10, 2018 @01:49AM (#17495747)
Users go for usability features first, with an OS that is good enough. Good looks second. They can tolerate a few weirdness and quirks as long as they can get the job done without cursing the thing. They will even tolerate non critical crashes sometimes (no or little data loss).

OpenBSD is not bug free at all, it is just security oriented in the implementation.

Windows got traction because it has even better hardware support, a bunch of backroom OEM deals and nice UI features (at the time of 95), then went far on software availability.

Re:Simple, correct, fast: in that order by slx26 on Monday July 09, 2018 @10:14AM (#17490293)
as I understand it, both simplicity and correctitude are requirements for most programs, but imo the article talks about the design, the writing process, where you should focus first on writing a program that's not more complex than it needs to be, because you are likely compromising the other parts too. this doesn't mean incorrect code is acceptable.

in any case, I think it's also worth mentioning that the article is probably talking about "incorrect" as in "accidental bugs", not as in "purposely ignoring the complexity of the problem". with the idea of preventing over-engineering rather than dismissing the specifications of a valid solution

Re:Simple, correct, fast: in that order by koolba on Monday July 09, 2018 @09:57AM (#17490161)
My read of this that simple means not necessarily handling all possible edge cases yet having enough of a skeleton in place that the core functionality is there. Correct is extending (or replacing) that skeleton with coverage for all cases.
Re:Simple, correct, fast: in that order by DannyB2 on Monday July 09, 2018 @10:16AM (#17490305)
Edge cases? You mean we can't test for leap year by simply checking if the year is a multiple of four?
Re:Simple, correct, fast: in that order by koolba on Monday July 09, 2018 @10:29AM (#17490386)
No that’s a silly example.

I meant more for dealing with edge cases like an external API invocation failing. A final “correct” implementation would need to handle failures but an initial simple one would only handle success.

Re:Simple, correct, fast: in that order by tomp on Monday July 09, 2018 @10:08AM (#17490244)
Indeed. During my visit to India in February this year, I didn't even realize they were at a half-hour time-zone offset, all thanks to the miracle of modern technology (and hardworking people maintaining it).
Re:Simple, correct, fast: in that order by aunty_helen on Monday July 09, 2018 @10:04AM (#17490209)
But would it be better to account for non-end of year leap second additions vs something simplier that just ignores them but is wrong once every... decade?
Re:Simple, correct, fast: in that order by imron on Monday July 09, 2018 @10:08AM (#17490245)
Depends on the software.
Re:Simple, correct, fast: in that order by comboy on Monday July 09, 2018 @11:32AM (#17490972)
He made up his mind, don't confuse him with facts.
Re:Simple, correct, fast: in that order by purpleidea on Monday July 09, 2018 @10:09AM (#17490254)
Came here to say the same thing. OP doesn't know what he's talking about.
Re:Simple, correct, fast: in that order by Sir_Cmpwn on Monday July 09, 2018 @10:26AM (#17490365)
If you cannot achieve correct without simple, redefine correct.
Re:Simple, correct, fast: in that order by JoeAltmaier on Monday July 09, 2018 @10:43AM (#17490493)
Some problems are just hard and complicated. You can try to make code that dissects it into lots of simpler pieces, but then they have to be put together in a complicated way. Someplace in the code there will be some point of irreducible complexity. In my experience.
Re:Simple, correct, fast: in that order by ythn on Monday July 09, 2018 @11:01AM (#17490671)
In my experience you need a paradigm shift then. If your earth centric approach is creating a need for epicycles of complex code, then you need to paradigm shift to heliocentric which eliminates the epicycles and replaces them with a simple elliptical model.
Re:Simple, correct, fast: in that order by AnIdiotOnTheNet on Monday July 09, 2018 @11:07AM (#17490731)
I'm willing to believe that there are sometimes problems that are inherently complex, but I find that much of the time the problem is complex only because you've insisted it be complex. If you take a step back and re-examine the problem you often see that redefining the problem makes everything much more simple.
Re:Simple, correct, fast: in that order by jpalomaki on Monday July 09, 2018 @11:29AM (#17490945)
Having software people interact directly with the user/customer (internal or external) can be very useful because minor changes in requirements can make a huge difference in implementation complexity.
Re:Simple, correct, fast: in that order by rhapsodic on Monday July 09, 2018 @10:36AM (#17490441)
> If you cannot achieve correct without simple, redefine correct.

More hand-waving.

Re:Simple, correct, fast: in that order by jstimpfle on Monday July 09, 2018 @10:45AM (#17490510)
"redefine correct" = "find a better version of the problem". Software development starts with requirements analysis.
Re:Simple, correct, fast: in that order by Sir_Cmpwn on Monday July 09, 2018 @10:43AM (#17490488)
I disagree. I just can't get more specific without specific cases to examine. Like others have pointed out, take the matter of timezones: if "correct" is defined as "handling timezones", you should instead store time in UTC everywhere and redefine "correct" to be "convert times to local time when displayed and back again when input", which can be accomplished with much smaller, simpler, and focused tools.
Re:Simple, correct, fast: in that order by jasode on Monday July 09, 2018 @11:00AM (#17490658)
>", you should instead store time in UTC everywhere

It is not possible to store UTC unambiguously on the db server for all future local wall-clock times. (Previous comment about the erroneous assumption of "UTC everywhere" being a "simple solution".[1])

Therefore, redefining "correct" to be "store UTC everywhere" achieves the exact opposite: an incorrect and buggy program. That's because the "universal" in Universal Time Code doesn't apply to governments changing DST and Time Zone rules in the future.

Pure UTC doesn't have enough metadata to encode future unknowns. For correct handling with zero loss of data, one must store the user's intended "wall-clock" time in his local TZ in the db.

There's irreducible complexity when dealing with user-specified appointment times so an uncompromising fixation on programming a "simple" implementation with pure UTC-on-dbserver and localtime-at-only-at-browser-Javascript ... will lead to a broken calendaring program.

[1] https://news.ycombinator.com/item?id=10990240

Re:Simple, correct, fast: in that order by Sir_Cmpwn on Monday July 09, 2018 @11:21AM (#17490875)
You're right, future times are more complex and might require more attention to detail. But I think you can still achieve the requirements in a simple way, perhaps by storing it as UTC + lat/long and running a script to update future dates when someone changes their rules.
Re:Simple, correct, fast: in that order by masklinn on Monday July 09, 2018 @11:32AM (#17490973)
> But I think you can still achieve the requirements in a simple way, perhaps by storing it as UTC + lat/long and running a script to update future dates when someone changes their rules.

Congratulation, your emotional refusal to deal with zoned datetimes has led you to a non-standard ad-hoc reinvention of timezones, your misguided quest for simplicity and obstinate rejection of reality has thus led you to a system which is definitely more complex, probably less correct and likely less performant than if you'd just done the right thing in the first place.

Re:Simple, correct, fast: in that order by jasode on Monday July 09, 2018 @12:17PM (#17491320)
>a simple way, [...] and running a script to update future dates

I've commented previously that it's not a good idea to change the rows of UTC times in the database.[1]

Designing "system correctness" to depend on on the reliability of a correctly written SQL statements completing atomic transactions for millions of rows is not a good idea. In addition to batch db updates of UTC being extremely fragile, it's also not simple.

(It's fascinating to note that the multiple programmers independently arrive at the approach to update database rows of UTC times. There's something about it that's cognitively satisfying that attracts repeated reinvention.)

[1] https://news.ycombinator.com/item?id=10991894

Re:Simple, correct, fast: in that order by Sir_Cmpwn on Monday July 09, 2018 @12:37PM (#17491481)
The event's time has changed, though. The local representation of when it will occur has not changed, but if you set a timer today and they change their timezone tomorrow, the timer will expire at the wrong time.

We should store the actual time of an event and update it when the scheduled time changes.

Re:Simple, correct, fast: in that order by jasode on Monday July 09, 2018 @01:02PM (#17491682)
>, the timer will expire at the wrong time.

A countdown timer is a runtime concept.

Storing pure UTC and/or intended_localtime_plus_TZ in the database is a static concept of data-at-rest.

A timespan/timer is a different abstraction than a desired point-in-time.

Depending on the use case, the correct timer/timespan value can be derived from pure UTC (e.g. scientific celestial events) -- or -- user_specified_localtime_plus_TZ (recurring yoga class at 5:30pm every Wednesday, or take medication every morning at 7:00am).

For user calendaring and scheduling of social appointments, storing pure UTC will lead to data loss and errors. Instead of complicated mass updates of millions of db rows, it's much more straightforward to take a stored localtimeTZ, and then calculate an up-to-date UTC time at runtime, and then derive a countdown timer from that. The key insight is that the best time to use UTC is when the users need that timer at runtime -- and not when they store the row in the db.

Re:Simple, correct, fast: in that order by falcolas on Monday July 09, 2018 @03:35PM (#17492809)
> We should store the actual time of an event and update it when the scheduled time changes.

I would love to see some (simple) code which will send a single alert to me at 1:30 am and another at 2:30am. My client registered me as MST (-7) when I set these two alarms in Feburary.

Of particular note for corner cases: Nov 4th and Mar 10, 2019.

The "scheduled time" will change, for many locations, twice yearly.

EDIT: For added fun, instead consider the registration date as May 10th with the same timezone.

Re:Simple, correct, fast: in that order by rhapsodic on Monday July 09, 2018 @12:37PM (#17491484)
>You're right, future times are more complex and might require more attention to detail. But I think you can still achieve the requirements in a simple way, perhaps by storing it as UTC + lat/long and running a script to update future dates when someone changes their rules.

Seriously? That, in your opinion, is simpler?

Re:Simple, correct, fast: in that order by rhapsodic on Monday July 09, 2018 @11:33AM (#17490983)
>I disagree. I just can't get more specific without specific cases to examine.

You should probably mention somewhere that you're the author of the blog post under discussion. And it looks like you're going to make a reputation for yourself as the guy who argues that it's more important for software to be simple than for it to function correctly.

Good luck with that.

Re:Simple, correct, fast: in that order by cbsmith on Monday July 09, 2018 @10:35AM (#17490434)
Noop is pretty simple...
Re:Simple, correct, fast: in that order by close04 on Monday July 09, 2018 @11:08AM (#17490749)
And if the opening statement of the article is to be considered correct, noop is by design the only way to do things since its simplicity will always win against trying to create more complex code that does the task.

"The single most important quality in a piece of software is simplicity. It’s more important than doing the task you set out to achieve. It’s more important than performance. The reason is straightforward: if your solution is not simple, it will not be correct or fast."

It praises a quality that is great as an add-on, not really by itself. Pretty sure everyone prefers a complex thing that "does the task" than a simple one that doesn't.

Simple "helps". Simple never "does". I think the author's values are a bit mixed up.