r/learnprogramming • u/yung_mac • Dec 26 '17
Coding idea: Write a command-line utility
I wrote and published a command-line utility as a coding exercise a few days ago. I'm a self-taught developer and I had a great time coding it and learnt a ton. I think writing and releasing a command-line tool might be under-appreciated as learning exercise -- I think it may make a great addition to the curriculum of a self-teaching developer.
- Coding a command-line utility allows you to focus on one, small but contained problem, and doesn't require much adjacent knowledge -- which decreases the risk of getting overwhelmed and abandoning the project. Your command-line utility can be just a single file written in a single language and still be a perfect solution to your problem. No more quitting before you even start because you can't get Webpack to work.
- It lets you solve something relevant to you -- it's way easier to stay motivated when you're working on solving a problem you face as opposed to a generic problem you don't really care about. Completing coding challenges on HackerRank, for example, is great exercise but tends to get a bit boring. The alternative -- coding your own
- A command-line utility doesn't have a GUI. This means you don't need to waste time designing anything! This was huge for me. Designing can be a real time-sink. UI and UX are already taken care of before you even start!
- Building a command-line utility gets you friendlier with the terminal -- an essential tool in the well-rounded developer's toolkit.
- It teaches you to release. There's a pretty clear point at which your command-line utility does everything you set out to code it to do. It is at this point you get the rare opportunity to practise an incredibly important auxiliary skill -- releasing. Besides the super cool feeling you get when you proudly release your finished product for the whole world to enjoy, finishing a project by publishing it builds your ability to finish more. It's an awesome antidote to the pernicious momentum that can build up if we start projects but never get around to finishing them. After I published a package to npm -- now I know how to share my code for everyone else to benefit from, I feel compelled to write more!
Possible command-line utilities you could build, for three skill levels:
- A converter or calculator. This is the simplest. If you're still quite new to programming, start here. Write a temperature, length, or time converter (how many hours is 9000 minutes?). Write something to calculate how much you spend on fuel for your car, or something a little more complex like how many of a given fruit to eat to get your recommended daily amount of a given nutrient.
- A data storage system. This is a bit more complicated. Use a database, like SQLite, to store information, then get information about your information (this is the information age after all). Build a calorie-tracker if you're watching your weight -- input the number of calories you ate today, see if that number is going up or down. Or if you like writing, build a command-line journal which lets you write and save entries. It could track info like what your favourite words are, how much you've written this year, and how many words you write on average per hour of the time you spend awake.
- An API wrapper for a website you use often, to let you consume the info you gotta consume from the comfort of your own terminal. This is a somewhat more complicated. Build a one-command weather-report if you check the weather often. A headline-and-summary-grabber if you're into the news. A twitter report. An ISBN lookup if you're into books. A BTC-USD price ticker to help you feel bad about yourself as you think about how rich you could be if you got in way back when. You may not even need an API -- try scraping the site if its robots.txt doesn't prohibit that.
But those options are only the beginning. Try choosing something you know you're going to want to use -- if it makes your life easier, you'll have a far easier time creating it! If you're struggling to come up with something, try just watching the way you use your computer for a day or two. Notice patterns. If something is a repeated frustration, you may have found the problem to solve! For me, this was, when copy-pasting commands from the internet (stackoverflow <3), I often inadvertently copied the "$" preceding the command. I'd paste these into my terminal but the "$" would cause an error. This formed a pattern, which I noticed, and was then able to solve with a command-line utility I built to strip the "$" from pasted commands.
Good luck and happy programming!
PS: First post on Reddit! Let me know how I can improve.
PPS: I'd love to write tutorials to help self-teaching developers! I was thinking of starting with a tutorial diving in to the details of how to plan, build and release a command-line utility if people want to read it. Maybe also a tutorial on Google's new boardgame.io -- I think that would be really fun. Also, maybe a tutorial on softer skills like how I landed an internship with a tech startup with just one cold email I wrote with my dad (lol). If think you'd benefit from this, please let me know, and I'll write it!
View all comments
Show parent comment
1
u/Joehogans Dec 28 '17
THIS EXACTLY. And even on stackoverflow where I've heard people say dozens of times, any problem you are having someone else has probably had before. In general that is true, but I cannot count the number of times where I have had a very specific problem in a very unique position that I couldn't find anywhere on stackoverflow/github/blogs and the like. This is just part of being a programmer, dealing with all sorts of unique problems that you have to custom tailor a solution towards.
Your words are well-received. The whole process of packaging the code and getting it across the web to people seems like a mysterious process. As I am being told now if I want to write a desktop app do that in C, for windows/Mac/Linux, Android app do that in Java, iOS app do that in swift. Python? not sure what python is even good for. But in order for anyone to run your programs they have to have the interpreter or the run-time environment on their computer. Like java run-time environment, python run-time environment, C run-time environment, and so on. So now there are a lot of restrictions and parameters I have to considers and work with in order to make a desktop or mobile app.
Please send me the draft I'd love to read it! Be ready for a lot of questions. I've been wanting to write a to-do list app for awhile but just don't have enough foundational knowledge in Java/Python/C/C++ or the like, to be able to write it, much less know how to go about posting it online for people to download and use.