title | date | cover | author | category | tags | layout | preview | ||
---|---|---|---|---|---|---|---|---|---|
How learning how to script can save you time |
2021-07-14 |
scripting.jpg |
jokevo |
tips |
|
article |
Code is one of those things in life, where you don't know how useful it is until you get really proficient at it. |
Code is one of those things in life, where you don’t know how useful it is until you get really proficient at it.
When you are out of shape and you start training in the gym, after a while, you are carrying your groceries and notice you’re not out of breath. You have a lot more energy during the day, think back and remember you started sleeping enough hours. Knowing scripting is one of those things, where you’ll realize, all of a sudden, that some things you need to do become effortless.
You have 50 files to rename, you have a line of text that you want in lowercase, the length of a line, the amount of characters, you want to convert a file, you want to validate json, you want to avoid repetitive actions in your word/excel, you want.. well the possibilities are endless.
I use scripting almost everyday, for the small things. Now, I am pretty allergic to doing the same thing over and over, I made it into my job. There is very little I do in bulk that is done faster manually than by scripting it.
In my opinion, scripting is one of those tools that you’ll love to have in your toolbox. Here are my tips on getting that tool nice and shiny:
If I have convinced you to start with a scripting language, I recommend python. Start with a language where you don’t have to look far to get a basic interpreter going and to see your results. Once you are proficient in one scripting language, it doesn’t take too long to adjust to others if you want or need to.
This can be very good support tool when learning a language. My preferred editor is Visual Studio Code. I install the code completion plugin for my languages and run code plugin. Both of them are absolute life savers. Run code allows you to run only specific selected text.
This will take a while to get good and fast at. Practice is key. The only way you’ll get there is to keep practicing every opportunity you get. I pinky promise, once you are on the other side it becomes so automatic, you’re not even thinking about it anymore.
Every time I need to create a script, chances are I have already created part of it. Keep a folder with your scripts so that you can copy from these and adjust to your current needs. Reading/Writing a file is very common, you’ll need it more. Having that saved up, ready for use in the exact way you want it, will make you even faster than when you made the script last time.
An unpopular opinion sometimes, and one that is harder to master. If you ask me, it’s a life saver. I like it when everything can be parsed in one line and is ready to go. I don’t want to write multiple lines to parse out what I actually need. it takes longer to do. If that isn’t convincing, search (and replace) with regex alone is worth having learned it.
It sounds like a lot of work, but honestly there is a point where it’s not work anymore. Scripting knowledge is a tool that you have at your disposal that can make your life easier. I have great pleasure at scripting something small that can take away those few minutes to hours I would have spent doing it otherwise. I have been scripting the small things for years, and it became pure relaxation. If it stresses you out, by all means use other tools available. Mac Automator and Windows XYPlorer get you a long way and there are definitely other tools out there for your other needs.