debuggable

 
Contact Us
 

Quickie: KISSing is for the experienced

Posted on 15/5/08 by Felix Geisendörfer

If you are new to a programming language, forget about the KISS principle. Experiment with crazy & complex code.

This might not be obvious but a conversation with somebody on #jquery today made this very clear to me. Trying to apply KISS when getting into a new technology is STUPID. Writing the most succinct and simple code is only possible if you know all nuances of what you are working with. Otherwise your simplicity will be based on wrong assumptions and lead to buggy code.

A prime example for PHP developers learning JavaScript:

var isEmpty = [];
if (isEmpty) {
  // You are not ready for your first KISS : )
}

(JavaScript type juggles empty objects / arrays to true in a boolean context)

 

You can skip to the end and add a comment.

Daniel Hofstetter said on May 15, 2008:

That's wrong. Even if you are new to a technology you should strive for simplicity. You might not find the simplest solution at the beginning, but over time you will find simpler solutions.

And regarding your example: if you are a PHP developer learning JavaScript you will also run in the same issue if your code is more complex. It has nothing to do with complexity, but with the differences between those programing languages.

Abhimanyu Grover said on May 15, 2008:

hehe... nice title.

Tarique Sani said on May 15, 2008:

Try KISSing before screwing - Sorry could not resist ;) but jokes apart if you strive to stick to the kiss principle then the chances of screwing up are much less.

Also KISS does not mean you don't continue to explore the language, your first kisses are always clumsy but you get better with time....

Felix Geisendörfer said on May 15, 2008:

Well maybe Tarique is right and I should have tried KISSing before screwing ; ). But I think all worthwhile advances in ones own skill and mindset are achieved by exploring the previously unknown, unreasonable and undoable. If my intuitive reaction to a concept is a very hard "That's wrong" without the slightest bit of consideration, thats usually what I set out to study and experiment with next.

Can't help but to quote einstein at this point:

"The most beautiful thing we can experience is the mysterious. It is the source of all true art and all science. He to whom this emotion is a stranger, who can no longer pause to wonder and stand rapt in awe, is as good as dead: his eyes are closed."

At the point where you are too afraid of adding a layer of abstraction every once in a while just to see what happens I think you should move on to a different programming language or career ; ).

In my experience programmers always write too complex or too simple code. If you want to be in the sweet spot in between you've got to know the extremes to your left and to your right. After all the map is not the territory.

Peter Goodman said on May 18, 2008:

An almost universal way to get this type of test right is to check against the length of the list/array/dict, as most languages will convert integers to booleans (this is not the case with every language though! Don't use PHP as a basis for type conversions, it's ridiculous in that sense). For example:

if([].length) ...
if(sizeof(array())) ... (although this is a case where empty() should be used, although it likely goes through the same motions)

Mark Story said on May 22, 2008:

Type conversions are definitely not something to be relied on when learning a language. Until you know the language well you shouldn't rely on the interpreter interpreting your thoughts. Case in point Python will test false for empty lists and empty dicts.

Nils R said on May 26, 2008:

I agree with Daniel.

Always try to keep it simple, stupid - as much as you can.
But saying "KISS is for experienced only" is just wrong.

(quite nice title though ;) )

Nils R said on May 26, 2008:

I agree with Daniel.

Always try to keep it simple, stupid - as much as you can.
But saying "KISS is for experienced only" is just wrong.

imho

(quite nice title though ;) )

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.