Live data from Hacker News

Bad scientific code beats code following "best practices" (2014)

yosefk.com

41–50 of 333 posts

Re: Bad scientific code beats code following "best practices" (2014)

#41
I agree with the feelings of the author, most software is overengineered (including most of my software).

That being said, most scientific code I've encountered doesn't compile/run. It ran once at some point, it produced results, it worked for the authors and published a paper. The goal for that code was satisfied and than that code somehow rusted out (doesn't work with other compilers, hadn't properly documented how it gets build, unclear what dependencies were used, dependencies were preprocessed at some point and you can't find the preprocessed versions anywhere to reproduce the code, has hardcoded data files which are not in the published repos etc.). I wouldn't use THAT as my compass on how to write higher quality code.

Re: Bad scientific code beats code following "best practices" (2014)

#42
post #32

Earlier quoted context omitted.

It's a decent measure of complexity: It's not that "opening files" themselves is work-intensive. But having a lot of files smells of overengineered code. One long, yet simple function has less cognitive overhead than spreading the function across multiple classes or functions or call hierarchies (themselves spread over multiple files).

> One long, yet simple function has less cognitive overhead than spreading the function across multiple classes or functions or call hierarchies Not if you are encapsulating and naming effectively... Why read 100 lines when you can read 20 and find concerns in one routine you are concerned with? Function calls can be expensive. However, optimization can come whenever you need it, and if what you need is one call vs 5…

I like long simple functions because it makes them easy to reason about when debugging.

Rarely does having more functions solve “does this do what I expect.”

Re: Bad scientific code beats code following "best practices" (2014)

#43
numerical code isn't like application code. the rules of application code don't always apply. for example, i think one character variable names are totally fine if they come from equations or papers where in most applications it's generally frowned upon.

this is why i'm a little skeptical of languages that blur the lines. sometimes ideas from application programming can complicate numerical code and sometimes numerical programmers don't fully understand the systems abstractions they're building on and end up reinventing wheels to avoid simpler solutions they feared or didn't know existed.

the moral of the story is to keep an open mind, to not be a zealot and to avoid dogmatic thinking.

Re: Bad scientific code beats code following "best practices" (2014)

#44
post #23

Earlier quoted context omitted.

Wrong. How maintainable code is is measured in how well you know where to change something, and how certain you are that it did the right thing without side effects. The fatal error of the linked article is that bad scientific code often suffers from correctness problems - not just theoretical concerns, but the "negates the main point of this paper" kind of thing.

What if a new person takes your place and they do not know it and are not certain in anything?

That's how you measure job security, which is a slightly different concept than maintainability.

Re: Bad scientific code beats code following "best practices" (2014)

#45
post #16
post #6

Earlier quoted context omitted.

You know, 96% of businesses (and by extension codebases) have to get by software wise without high priced software engineers. They couldn't afford it. The vast majority of running code is produced by people whose understanding of computer systems and programming goes as deep as how much documentation they need to ctrl+f through to get some specific tasks done.

>The vast majority of running code is produced by people whose understanding of computer systems and programming goes as deep as how much documentation they need to ctrl+f through to get some specific tasks done. I doubt this very much. Surely the vast majority of running code is some chunk of Chrome, Android, or the JVM ("billions of devices run Java...") or something. All those things were produced by software engi…

For every well-engineered application used by millions of users, you've got thousands of poorly-engineered, bespoke applications in use by one or two users (often internal corporate tools or expensive middleware with minimal customization besides changing the corporate branding).

Re: Bad scientific code beats code following "best practices" (2014)

#46
I think we have a case of survivorship bias.

A considerable majority of the science-non-SWE crowd are de facto incapable of writing more than 100 lines of runs-in-my-notebook code.

Hence, if a change/bug is necessary, it is much likelier to fall under a SWE jurisdiction, and hence is much more likely to be industrial code.

Add to that a further confounder (tiptoeing a "no true Scotsman" here): academia is not a first choice of workplace for strong SWEs.

Re: Bad scientific code beats code following "best practices" (2014)

#47
post #28

Earlier quoted context omitted.

Working with a 300 line method is not fun, believe me. Everything is in one place and you don't have to change many files, yes, but due to the cognitive load, it's so much more effort to maintain it.

There's a happy middle path here I think. Long functions are hard to grok. Spreading the logic across 20 files also increases cognitive load. There's a balance to strike.

Right, but the article seems to imply that all code should be in a single file.

It seems the author indeed is not a SW Engineer and thus does not really grok the benefit of "modules".

This of course depends on the size of the program. Small program "fits" into a single module.

And I think that scientific programs are basically small and simple because they don't typically need to deal with user-interaction at all, they just need to calculate a result.

Further I think scientific programs rely heavily on existing libraries, and writing a program that relies heavily on calls to external libraries produces simple, short programs.

Scientists produce science, engineers produce code-libraries.

Re: Bad scientific code beats code following "best practices" (2014)

#48
post #15

When scientific code is not required to be published with its research literature who really knows how bad it is?

A few responses come to mind. Who is requiring? What counts as code that needs to be published?

But perhaps the most relevant response is that few people read papers, even fewer are going to look into their zip. The whole idea of papers is to condense a whole lot of work into concise digestible information.

Re: Bad scientific code beats code following "best practices" (2014)

#49
I'm not so sure that this claim is valid as a general observation.

Multiple times in my career, I have seen scientific code written by academics dramatically sped up by developers who used parallelisation, vectorisation using SIMD etc.

So in terms of performance, naively written scientific code is generally easy to beat in terms of performance for a reasonably adept programmer.

That said, "enterprisey" Java/.NET software engineering shops can indeed make scientific code sub-optimal sometimes. Have come across that sometimes too but I wouldn't generalize.

Re: Bad scientific code beats code following "best practices" (2014)

#50
Meh.

Who actually works as a software dev at one of these academic institutions? The pay is beyond terrible. Presumably you have either:

- Young and keen. Young and keen are the source of all kinds of terrible things. That’s why you need old and bitter to balance it out. Old and bitter is off working for much more money in a boring corporate.

- Side hustlers/other incompetents. “I’m now a software dev!”

It’s not that proper software shops don’t struggle against “complexification” and all manner of other deviant behaviours. There are so many ways to turn software into hell - “All happy families are alike; each unhappy family is unhappy in its own way.” But if this is your problem, the problem isn’t “the software industry” or “best practice” or “devs jobs are so easy they just have to make up complexity”. The problem is incompetence. Managerial/leadership incompetence.

Post reply on HN