The first time I learned about the ternary operator, I thought it was so cool. I used it all the time like a kid with a new toy. Like that same kid, though, I eventually abandoned it because I felt that saving a few lines wasn’t worth the potential confusion someone might experience down the road.
And now I’m learning about arrow functions and already feeling the same way. Sure, it saves lines of code, but at the cost of clarity. Yes, we should understand what these things are and how they work, but we’re also drilled (depending on how we learn) to consider the ‘readability’ of our code. These arrow functions don’t appear to be very ‘readable’, especially once you start chaining them.
To me, these ‘syntactic sugars’ are just like slang in any spoken language: Great for your friends, but not so great in a professional setting. I’m approaching year 2 of my self-taught coding journey, but I believe in developing best-practice habits from the beginning. Seems to me that there’s a distinct clash here between ‘syntactic sugar’ and ‘readability’. Especially considering my career of nearly 10 years has been teaching English, I will always favor ‘readability’, but I’m curious about other thoughts on this matter.
What do you think?