Today I wrote this little snippet:

LATEST_PARSEC_LIB="$(cd $HOME && ls parsecd-*.so | sort -V | tail -1 || true)"
[[ -z "${LATEST_PARSEC_LIB}" ]] && find "$HOME/" -maxdepth 1 -regex '^parsec-.*\.so$' -type f ! -newer "${HOME}/${LATEST_PARSEC_LIB}" ! -name "${LATEST_PARSEC_LIB}" -delete

It does quite some interesting stuff, like detecting the latest installed version of parsec, removing all older versions but the latest one.

Then I thought about it and noticed: Too smart, will cause problems.


Smart code is the most likely one to cause issues. When you try to detect something based on various factors, most likely there is an edge-case you haven't considered.

And when you can keep it simpler, keep it simpler. It'll make your life and especially debugging, easier, when the code is not smarter than you :blobfoxwink:

@sheogorath As a legendary programmer wrote, “Exploit the limitations of your problem.” You rarely need to solve the general problem. Overly general code always leads to strange stuff in the actual application. I think this relates to what you wrote above.

Sign in to participate in the conversation
Sheogorath's Microblog

This is my personal microblog. It's filled with my fun, joy and silliness.