Real Python - artisanal from-scratch programmers

Hey there,

The other day I got this question from Newsletter member Newvick in my email inbox:

~~~

I found your post on books for people looking to move past the beginner's stage in python, and it was very timely for me.

With that goal in mind, one problem I have is:

When do you use libraries/frameworks and when do you make things from scratch? (whether for learning or developing something for a client/work)

~~~

When to code functionality from scratch and when to use libraries—that's a big question.

There's a fine balance you need to strike here:

When I learned programming I was "reinventing wheels" left and right— and it pushed my abilities forward quickly.

I was constantly writing all kinds of existing functionality from scratch and it was the right thing to do because it helped me grow my skills.

It was a great learning exercise.

But there comes a time in a developers life when that strategy doesn't work so well any more—

Eventually I got diminishing (learning) returns from trying to build everything from scratch.

Plus my development pace was dog-slow.

I spun my wheels—and my productivity began to plateau.

Another downside is this:

It's difficult to work on a team when someone always wants to approach every single problem from first principles. It can drive people NUTS.

These days I try to use (good and well-documented!) third-party libraries where possible.

But again, you'll want to find a balance there too:

I DO NOT recommend you pull in an external dependency for every little thing—

The people who got burned by the NodeJS "left-pad" incident know what I'm talking about...

Actually, this is a fun (ahem) "disaster" story by itself:

There was a little library called "left-pad" on Npm, the NodeJS package repository.

That "library" contained maybe 20 lines of code in total, but it was used in—literally—MILLIONS of JavaScript projects.

It added a tiny piece of functionality that was frequently needed but wasn't a part of the NodeJS standard library.

When the developer who created "left-pad" closed his Npm account last year, "left-pad" was suddenly no longer available for download...

And guess what happened to the dependency install process on projects using "left-pad"...

Well, it came to a SCREECHING HALT.

It was quite crazy. Even some newspapers reported about it.

And there was a lot of "bruhaha" about the NodeJS packaging system.

(But to tell you the truth the same thing could happen with PyPI.)

I guess the moral of the story is:

"Do use 3rd-party libraries and frameworks, but don't overdo it and only go for the trustworthy ones."

Sometimes it's just tough as nails to strike the right balance here...

By the way, if you want to dig deeper—I've got a complete step-by-step workflow for researching and making those dependency decisions (and explaining them to your team/manager) in my "Managing Python Dependencies" course.

But to bring this to a close and answer the original question:

As a rule of thumb, I'd only consider a "let's write it from scratch" strategy IF time is not an issue.

(Which it rarely is outside a pure learning environment.)

Happy Pythoning!

— Dan Bader

Older messages

New Python tutorials on Real Python

Saturday, September 26, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Python Practice Problems: Get Ready for Your

New Python tutorials on Real Python

Saturday, September 19, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Plot With Pandas: Python Data Visualization

Learn Python in 21 days!!!!11

Friday, September 18, 2020

Hey there, One of the first programming books I ever bought was "Teach Yourself C in 21 Days." This four pound tome came with a CD-ROM that included an ancient version (3.1) of the Borland

New Python tutorials on Real Python

Saturday, September 12, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Video Subtitles & Transcripts Now

What Pythonistas can learn from bestselling horror authors

Sunday, September 6, 2020

Hey there, I just finished reading Stephen King's "On Writing." It's a great little book where he shares some of the writing advice and stories he's picked up over the course of

You Might Also Like

Daily Coding Problem: Problem #1622 [Hard]

Thursday, November 28, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Amazon. Given an integer k and a string s, find the length of the longest substring that

Mapped | The Average Credit Card Debt in Every U.S. State 💳

Thursday, November 28, 2024

Households in richer states have higher average credit card debt but higher incomes allow them to pay it off faster as well. View Online | Subscribe | Download Our App Presented by: Defiance ETFs

Issue 341 - Free supercharging and FSD offer extended for new Teslas

Thursday, November 28, 2024

View this email in your browser If you are just now finding out about Tesletter, you can subscribe here! If you already know Tesletter and want to support us, check out our Patreon page Issue 341 -

Programmer Weekly - Issue 233

Thursday, November 28, 2024

View this email in your browser Programmer Weekly Welcome to issue 233 of Programmer Weekly. Let's get straight to the links this week. Quote of the Week "All programmers are playwrights and

Python Weekly - Issue 678

Thursday, November 28, 2024

View this email in your browser Python Weekly Welcome to issue 678 of Python Weekly. Let's get straight to the links this week. Articles, Tutorials and Talks Let's build a AI Photo Generator

Web Tools #593 - Frameworks, React Tools, Uncats

Thursday, November 28, 2024

WEB VERSION Issue #593 • November 28, 2024 Advertisement Power Your Web Projects with Cloudways This BFCM As a developer, designer, or tech professional, you need reliable hosting that adapts to your

Python Weekly - Issue 678

Thursday, November 28, 2024

View this email in your browser Python Weekly Welcome to issue 678 of Python Weekly. Let's get straight to the links this week. Articles, Tutorials and Talks Let's build a AI Photo Generator

Introducing the Revamped HackerNoon AI Image Gallery

Thursday, November 28, 2024

Top Tech Content sent at Noon! Advertise on this Newsletter! 50% off!! Read this email in your browser How are you, @newsletterest1? 🪐 What's happening in tech today, November 28, 2024? The

Black Friday Giveaway @ Real Python

Thursday, November 28, 2024

Hey there, Just wanted to let you know that we're doing a special giveaway for Black Friday this week at Real Python 🎁🎉 You can get Python education resources worth over $1210, including three

Dispatch 019 🦃

Thursday, November 28, 2024

Watching the Parade • Paying for the Parade • Pirate TV Raid • US v. Microsoft Round 2 • Trump's Anti-Antitrust? • Google Anti-Antitrust The Spyglass Dispatch is a free newsletter sent out daily on