What makes programming hard?

For everyone it’s different but what I find hard about it is finding the resources that can achieve the task I need to help my program run. To be a programmer you have to have this way of thinking in order to build anything. I realized this after developing the first piece of software that I was truly proud of (at the time). What is this way of thinking? Well it’s fairly simple. It all boils down to thinking one step at a time.

People who are new to coding always run into the same issue. They believe that their idea is over ambitious. I understand this because I had this problem as well. For example, if you just finished a course on Python, you aren’t going to want to keep doing tutorials over and over again. You want to build… but you have to build something. The amount of packages at your disposal is overwhelming and developing a brand new way to test your scripts has been done by so many people so what’s the point on even getting started? Don’t think that way. Take your idea and think one step at a time.

Say if you had to think one step at a time for grabbing a beer out of your fridge. You are sitting on the couch and thinking: “Wow, grabbing a beer out of the fridge sounds super complicated while I am comfy on my couch.” (It’s a Sunday).

When you think about the entire idea it just sounds too complicated and that’s what makes you lose your motivation to even get started. First you want to break down the steps it takes to get this to work. I usually do this in a word documents or a .txt file:

Get in position to get off couch Get off couch Walk to fridge Open Fridge Grab Beer SYNTAX ERROR: “Bud Lime” not beer

Joking aside, ever since I have taken the time to just plan out how the bot would run, my productivity has peaked. It keeps your mind in a clear train of thought while working on a task rather than getting overwhelmed at everything all at once. I want to show you the first bot that I was proud of. It would grab youtube videos of the show “How it’s Made”, make a gif out of a random point in the video and upload it to reddit periodically. Craziest part about this is that it worked. If you want to check it out on Github you can click here.

The main loop looks like this:

while True:

if directoryFlag is False:

createFolders()

youtube_link = findYoutubeVideoLink(linkQuery)

youtubeVideo = downloadYoutubeVideo(youtube_link)

(minutes, seconds) = grabTimeOfDownloadedYoutubeVideo(youtubeVideo) urlPath = turnYoutubeVideoIntoGif(youtubeVideo, minutes, seconds) imgurLink = uploadGifToImgur("gifs/" + "how-its-made" + str(gifName) + ".gif", imgurClientId, imgurClientSecret) uploadGifToReddit(imgurLink, redditUsername, redditPassword)

I apologize in advance because it’s very hard to read. As well as the fact that it goes against so many basic rules in basic loops (try, except is just one of them). The variable names make it very self explanatory.

Grab a youtube link (I actually used Beautiful Soup instead of the actual Youtube API). Using that link download the youtube video on to my computer. Grab the start and end times of the video to create a proper and random gif. Make the gif and return a path. Upload to Imgur. Post link to Reddit.

The “Reality” is just what you think it’s like.

If we look back at the whole process, the thought of creating a bot to create gifs out of youtube videos, upload to Imgur and post to Reddit seems very overwhelming. Realistically, the whole process took about 6 steps. If you check out the code for how I got the youtube links, you’ll see that I used a web scraper to grab the url’s which is way more complicated than it has to be. For example, all you would have to do is use the Youtube API and grab the link directly from them. There is even packages to do this.

No matter how overwhelming your project or your bot may be, there is always ways to go about it but the best way to think of it is in steps. It’s easier to fix bugs in your already developed code than it is to remake something from scratch. Open up that text editor or IDE and start planning and coding.

EDIT: Due to popular request, I decided to remove the word “bot” from the title as some find it has been misleading. I used the term originally so I could easily transition into newer blog posts that do mention bots.