10 Seconds can Save you an Hour if you use the Right Tools
As I was trying to learn a new programming language, I stumbled across with one simple problem, string manipulation. And if you are a programmer you know that, you can’t hide from it.
But here the deal, I was trying to delete some data that was useless, but at the same time keep the important one. So as an avid learner I was trying to crawl my way through, and spend almost an hour looking for a solution. In the end was pretty upset, not with the language, or the community, or anything else but myself. Wanna know why?
I’ll tell you in a second, but first, we need some context so you will understand more easily such a frustration. The programing language that I was/am trying to learn is called R. Used for data science and it’s pretty powerful on the hand of an experienced programmer. So, I have a variable inside a data frame with the following syntax:
First name last name\id
I only want that variable to hold the person’s name, once the id is useless in this case. If you are an R programmer you probably laughing right now thinking, it’s easily done with this or that function, and you right. But as far as I know about R, it’s not designed to handle text, i. e., the language can do, but it’s better at doing something else, which is data analysis, not some silly text manipulation.
As I was saying, I spend almost an hour looking in the help system and googling about the subject. But in the back of my mind was some simple idea, do what is easy and simple. So when I got pissed off looking for answers too simple to be asked, I opened the dataset on Vim and typed the following characters in verbatim
qq/\dt,0jq3666@q
Et voila, problem solved. It didn’t take me more than 10 seconds to solve it. A little explanation for what happened in those 16 characters. I recorded a macro that finds the pattern that I want to delete and then executed the macro itself. With 16 keystrokes.
I use Vim for almost 4 years now, and I know that is possible to do the task even with fewer keystrokes. But which is more important is that every tool is designed to do something, and if it is well designed, will do one thing and do it very well. Vim is a text editor, and was designed to work very well and effective in string manipulation. if I tried to make a linear regression with it, I would spend more than an hour, but to delete some text in 3666 lines, didn’t take 10 seconds.
What’s the point?
My point in all this is, if you want to learn a more effective way to do things you should use the better tools. You are no going to eat soup with a fork. So why not practice some Occam razor in the learning process. What I mean is, when a tool is simple, it is easy to learn and use. And that, even if you can do something, doesn’t mean that you should do it.
The learning process in every aspect of life does not come without a trade off. We have to weight which is important. If at the time, you want to learn new ways to do things you should be able to waste some time at the beginning. But let’s you want to do the task at hand more easily and fast. Then you should stick with the things you know, and be lazy about it, don’t try to reinvent the wheel at every new corner. My final take about this, you should always use the most simple tool you can find at any given time.