DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

JoΓ£o OsΓ³rio
JoΓ£o OsΓ³rio

Posted on

Preferred Programming Language Versus Getting Things Done

Go Fast
Getting skills in more than one programming language is a must for professional developers and multitaskers. You can try creating a toolbelt of ready-to-use code snippets, bookmark all the handy libraries, and even practice hypothetical situations. That's what I had in mind working on my automate-dotnetcore project.

But now and then you'll face some important task that needs to be done on the spot, with no delays. Usually single-shot operations. For that, the key performance indicator is GTD = Getting Things Done.
So forget your personal preferences, your level of comfort with any of the programming languages you have some seniority on, you just want to deliver, good and fast.

At the end of the day, what matters is that you do not add friction by depending on what you're comfortable with, you must be open to trying out new things. But remember, this comes with another philosophy in mind: if you're going to fail, fail fast.

"Fail fast is a philosophy that values extensive testing and incremental development to determine whether an idea has value."

To give you an example of what I'm writing about, consider the task of going through a folder filled with thousands of PDF files. You must read all of them, extract some text according to a given pattern and output the filename together with the extracted text.

Sure, I could fire up Visual Studio, begin to write a C# console project with some randomly chosen NuGet packages. Or... I could google for some wisdom from the Internet Archives (ex: Stack Overflow).
I did nothing of the sort. I created a local folder, opened it in VS Code, created a Virtual Environment for Python, and wrote a program based on Github Copilot suggestions. After some fine-tuning, this was the short, simple and effective result:

import PyPDF2
import re
import glob

def main():

    #iterate through all the pdfs in the folder
    for pdf in glob.glob("PDFs\\*.pdf"):
        #open the pdf
        pdfFileObj = open(pdf, 'rb')
        #create a pdf reader object
        pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
        pageObj = pdfReader.getPage(0)
        page_one_text = pageObj.extractText()
        #close the pdf file object
        pdfFileObj.close()

        pattern = '[your pattern]'
        result = re.findall(pattern, page_one_text)
        print(pdf, result)

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

Next time someone asks you for some improvisation in order to achieve immediate results, try something new!

Photo by John Baker on Unsplash

Top comments (0)

We want your help! Become a Tag Moderator.
Check out this survey and help us moderate our community by becoming a tag moderator here at DEV.