In Defense of Code Conciseness

Written by sanchit.gera | Published 2016/12/13
Tech Story Tags: software-development | web-development | programming | android | mobile-app-development

TLDRvia the TL;DR App

I share your sentiments, insofar that people must avoid learning a new language simply because everybody else is. If Java works for you and you find yourself being productive in it, you should continue to write in it. As I personally do.

But I think that, at the same time, the post undermines the value of code conciseness. Of course, when you break down the components of a language on such an atomic level, nothing seems like a big deal.

Typing a semi-colon requires only an additional 200ms or so. As does typing a couple of additional braces. Or maybe a few additional keywords here and there. No biggie. Except that the reasons that most people care about code terseness have very little to do with saving keystrokes. And if so, it’s a terrible reason in and of itself.

This might be a non-issue for people who have been programming for a couple of years. But try explaining this piece of code to someone who is just starting out.

public class HelloWorld {public static void main(String[] args) {System.out.println('Hello World');}}

What are classes? What are public classes? What does void mean? Does the class need to be named HelloWorld? What does main mean? What is System? And most importantly, why do I need to know all this in order to simply print something to the screen? All this jargon tells me nothing about the behaviour of my program, it’s just something I have to do.

Surely, this Python script would appear more appealing! (Also valid Ruby syntax)

print 'Hello World'

Again, I understand that these seem like VERY trivial questions. But constructs like these make the code more difficult to understand while providing very little in the way of benefits for simple problems. This kind of verbosity increases the time between a person starting to learn a language and being productive in it.

The thing with languages like Java and C++ is that they give you this massive toolset and a myriad of concepts that you could fit together to solve all sorts of complex problems. But when applied to simpler problems, they lead to overly complicated solutions with tons of unnecessary syntactic noise.

This is precisely why modern languages made the move away from manual memory management to garbage collection. So that programmers spent less time debugging memory leaks and more time building things.

It’s the same reason people tend to prefer simple, easy to understand answers when asking a question instead of long winded, complex explanations filled with all sorts of irrelevant technical jargon.

Having said all of this, I also think that there are tons of times when verbosity can be a wonderful thing. Just as a better vocabulary enables you to better express your ideas, so does a programming language with tons of well designed constructs. And besides, you can’t get the performance benefits of Java/C++ without making SOME sacrifices.

PS: I do not mean to attack your writing or yourself, personally. The only point I was trying to make was that it is important to not undermine the value of well written, easy to read and — as you put it — “elegant” code. Cheers :-)

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising &sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!


Written by sanchit.gera | Sanchit is a software developer with a strong passion for startups and tech entrepreneurship.
Published by HackerNoon on 2016/12/13