Write code that is easy to delete, not easy to extend.

“Every line of code is written without reason, maintained out of weakness, and deleted by chance” Jean-Paul Sartre’s Programming in ANSI C.

Every line of code written comes at a price: maintenance. To avoid paying for a lot of code, we build reusable software. The problem with code re-use is that it gets in the way of changing your mind later on.

The more consumers of an API you have, the more code you must rewrite to introduce changes. Similarly, the more you rely on an third-party api, the more you suffer when it changes. Managing how the code fits together, or which parts depend on others, is a significant problem in large scale systems, and it gets harder as your project grows older.

My point today is that, if we wish to count lines of code, we should not regard them as “lines produced” but as “lines spent” EWD 1036

If we see ‘lines of code’ as ‘lines spent’, then when we delete lines of code, we are lowering the cost of maintenance. Instead of building re-usable software, we should try to build disposable software.

I don’t need to tell you that deleting code is more fun than writing it.

To write code that’s easy to delete: repeat yourself to avoid creating dependencies, but don’t repeat yourself to manage them. Layer your code too: build simple-to-use APIs out of simpler-to-implement but clumsy-to-use parts. Split your code: isolate the hard-to-write and the likely-to-change parts from the rest of the code, and each other. Don’t hard code every choice, and maybe allow changing a few at runtime. Don’t try to do all of these things at the same time, and maybe don’t write so much code in the first place.

Source: Write code that is easy to delete, not easy to extend.

 

Let’s just try that again | The Economist

Reproducibility should be at science’s heart. It isn’t. But that may soon change

THE Journal of Irreproducible Results is a long-running satirical magazine, designed for the amusement of scientists. If the title were not already taken, though, it would be a good one for another, more serious publication that is being launched on February 4th. The Preclinical Reproducibility and Robustness Channel, an electronic rather than a paper journal, is dedicated to the task, found tedious by most academic researchers, of replicating and testing the experiments of others. Professional egos, the exigencies of career-building and the restricted sizes of grants and budgets all conspire against the rerunning, in universities, of old studies instead of the conducting of new ones.

Commercial researchers cannot afford to be so choosy. If they pick an idea up from academia, they have to be sure that it works. Often, it doesn’t. For example, when staff at Amgen, a Californian drug company, attempted to reproduce the results of 53 high-profile cancer-research papers they found that only six lived up to their original claims.

Source: Let’s just try that again | The Economist

 

How People Learn to Become Resilient – The New Yorker

Resilience is a set of skills—and psychologists know how you can learn them.

Norman Garmezy, a developmental psychologist and clinician at the University of Minnesota, met thousands of children in his four decades of research. But one boy in particular stuck with him. You can find more info here about him. when he was nine years old, with an alcoholic mother and an absent father. Each day, he would arrive at school with the exact same sandwich: two slices of bread with nothing in between. At home, there was no other food available, and no one to make any. Even so, Garmezy would later recall, the boy wanted to make sure that “no one would feel pity for him and no one would know the ineptitude of his mother.” Each day, without fail, he would walk in with a smile on his face and a “bread sandwich” tucked into his bag.

The boy with the bread sandwich was part of a special group of children. He belonged to a cohort of kids—the first of many—whom Garmezy would go on to identify as succeeding, even excelling, despite incredibly difficult circumstances. These were the children who exhibited a trait Garmezy would later identify as “resilience.” (He is widely credited with being the first to study the concept in an experimental setting.) Over many years, Garmezy would visit schools across the country, focussing on those in economically depressed areas, and follow a standard protocol. He would set up meetings with the principal, along with a school social worker or nurse, and pose the same question: Were there any children whose backgrounds had initially raised red flags—kids who seemed likely to become problem kids—who had instead become, surprisingly, a source of pride? “What I was saying was, ‘Can you identify stressed children who are making it here in your school?’ ” Garmezy said, in a 1999 interview.“There would be a long pause after my inquiry before the answer came. If I had said, ‘Do you have kids in this school who seem to be troubled?,’ there wouldn’t have been a moment’s delay. But to be asked about children who were adaptive and good citizens in the school and making it even though they had come out of very disturbed backgrounds—that was a new sort of inquiry. That’s the way we began.”

Source: How People Learn to Become Resilient – The New Yorker

 

Meet the Robin Hood of Science | Big Think

How one researcher created a pirate bay for science more powerful than even libraries at top universities.

The tale of how one researcher has made nearly every scientific paper ever published available for free to anyone, anywhere in the world.

On the evening of November 9th, 1989, the Cold War came to a dramatic end with the fall of the Berlin Wall. Four years ago another wall began to crumble, a wall that arguably has as much impact on the world as the wall that divided East and West Germany. The wall in question is the network of paywalls that cuts off tens of thousands of students and researchers around the world, at institutions that can’t afford expensive journal subscriptions, from accessing scientific research.

On September 5th, 2011, Alexandra Elbakyan, a researcher from Kazakhstan, created Sci-Hub, a website that bypasses journal paywalls, illegally providing access to nearly every scientific paper ever published immediately to anyone who wants it. The website works in two stages, firstly by attempting to download a copy from the LibGen database of pirated content, which opened its doors to academic papers in 2012 and now contains over 48 million scientific papers. The ingenious part of the system is that if LibGen does not already have a copy of the paper, Sci-hub bypasses the journal paywall in real time by using access keys donated by academics lucky enough to study at institutions with an adequate range of subscriptions. This allows Sci-Hub to route the user straight to the paper through publishers such as JSTOR, Springer, Sage, and Elsevier. After delivering the paper to the user within seconds, Sci-Hub donates a copy of the paper to LibGen for good measure, where it will be stored forever, accessible by everyone and anyone.

Source: Meet the Robin Hood of Science | Big Think