News for hackers. Stuff that matters.
Re:It's not what programming languages do, it's what they sh... by lmm on Friday March 27, 2020 @04:35AM (#22701234)
> obviously UI tests are being run today so this is not really an issue, right ?

UI tests are notoriously slow, flaky and generally worse than other kinds of tests. They're absolutely a significant pain point in software development today.

> maybe, does not prevent writing a lot of very useful apps.

People write useful code with global state. People wrote useful code with gotos, with no memory safety... that computers are useful does not mean there isn't plenty of room for improvement.

Re:It's not what programming languages do, it's what they sh... by kazinator on Friday March 27, 2020 @09:52AM (#22702805)
Avoiding singletons in the app implementation will not put a dent in UI testability. If you instantiate the MainWindow as a local variable in the top-level function, and pass that object everywhere it is required as an argument, external testing of your UI is not any easier.
Re:It's not what programming languages do, it's what they sh... by lmm on Friday March 27, 2020 @11:43PM (#22709039)
It's a step in the right direction, and it gives some immediate value: you can see which functions don't actually need the MainWindow and can therefore be tested conventionally (you might argue that those were never actually UI tests, but in practice you'll end up using your UI testing techniques for things that don't actually use UI if you can't tell), and you're nudged towards only passing it where it's needed; also you could try to mock or stub it, which might cover at least some of the simple cases.