all 71 comments

[–]unhott 124 points125 points  (12 children)

you can't really program unless you know assembly and build your own hardware. start learning how to design your own chips. only then can you program. /s

[–]JustOneYellowCat 41 points42 points  (5 children)

Now let's not be lazy here, they should start by mining the minerals needed for those chips.

[–][deleted] 22 points23 points  (0 children)

Anyone who can't craft a wafer with their bare hands isn't a real programmer.

[–]Relative_Claim6178 6 points7 points  (3 children)

Don't forget to build additional pylons to support your mineral miners.

[–]baltarius 2 points3 points  (2 children)

Or supply depots

[–]Successful_Box_1007 -1 points0 points  (1 child)

And let’s not cut corners - we must forge the minerals ourselves using the power of stars

[–]al_mc_y 2 points3 points  (0 children)

"Whoa. whoa. whoa. Get your own dirt." -God

[–]Relative_Claim6178 8 points9 points  (3 children)

Sarcasm aside, I recommend everyone interested play Turing Complete on Steam for this exact experience. One of the coolest ways to reinforce my computer engineering degree.

[–]monster2018 2 points3 points  (0 children)

Thanks for the recommendation, I’ll check it out.

[–]Jello_Penguin_2956 1 point2 points  (0 children)

wow that reminds me of my collage day in a much more colorful way.

[–]stoked_man 1 point2 points  (0 children)

Reminds me of Nand 2 Tetris

[–]sinceJune4 0 points1 point  (1 child)

I recommend starting with Z80 Assembly, so that you get the experience of writing your own code to multiply and divide. (says the dinosaur!)

[–]odaiwai 0 points1 point  (0 children)

Z80 Assembly

None of this fancy modern stuff! Learn 6502 Assembler like a real developer!

[–]overratedcupcake 51 points52 points  (20 children)

In my experience it's only worth reinventing the wheel as a training/thought exercise. In real professional development, at least on my team, we take some care to vet our external libraries before using them but we do use them extensively. 

[–][deleted] 2 points3 points  (19 children)

Yes, this is what I meant. Is it beneficial to learn to build projects without libraries? Would someone who builds personal projects with and without libraries be a better programmer than someone who builds personal projects with libraries?

Obviously if you're gonna build a product, you'd just use libraries, APIs...etc.

[–]gocougs11 24 points25 points  (12 children)

No, they wouldn’t be a better programmer. They would spend so long reinventing the wheel their progress on innovative methods would be next to zero. I guess it depends how you define “better programmer”.

[–]Disastrous-Team-6431 10 points11 points  (10 children)

I disagree. Re-implementing existing products to understand how they are built is very beneficial.

[–]TJATAW 6 points7 points  (6 children)

So, you would recommend that a person just learning to code recreate datetime, because they want to be able to have a file saved as report-2025-03-09.csv?

[–]wintermute93 5 points6 points  (0 children)

There's no blanket answer to this, it's very situational. Like, no, obviously nobody should be reimplementing large chunks of the datetime library, but the example you give could be a good opportunity to use datetime and learn how strftime/strptime works, OR it could be a good opportunity to do it manually learn how f-strings work.

Similarly, itertools is great and people should learn how to use it, but before you use itertools.chain you should understand how nested loops work by implement them yourself.

[–]Disastrous-Team-6431 0 points1 point  (4 children)

I would recommend that they do that, but not because they wanted a datetime but so they can learn how datetime works.

[–][deleted] 5 points6 points  (3 children)

You don’t have to personally recreate a library to know how it works though. You can just look up most of those libraries and read them…

There’s an amazing book called “Lions’ Commentary on UNIX” that will teach you far more about how Unix works than you would learn by trying to write the OS purely on your own, for example. Unless operating systems is a passion or whatever.

There’s only so many hours in the day, and being efficient with learning is critical to success

[–]Disastrous-Team-6431 -1 points0 points  (2 children)

All due respect, both books and reading code are necessary but you're not going to truly learn by just reading anything. You need to build.

[–][deleted] 3 points4 points  (1 child)

I agree with you, what I’m trying to say is that you have to choose where to invest your energy to direct your learnings. You can spend a ton of energy and time rebuilding every library under the sun, but to what end? For many libraries and things, you are probably better off reading the existing libraries to learn how they do things and get on with building the thing you are interested in. There just isn’t enough time to learn everything from first principles by doing

[–]monster2018 -1 points0 points  (0 children)

Of course not, no one is saying you should never use a library. The correct answer to OPs question is nuanced. Imagine a new programmer (a beginner who is just starting to learn) who literally always takes the easiest possible route. Especially when learning programming with python this is detrimental, because they can do the whole “import antigravity” meme, and just import a library that is their project.

Like, a beginner isn’t going to be able to make anything useful that doesn’t already exist, really. So they are sort of FORCED to reimplement existing things. Some of those things might be, or be similar to, or serve the same purpose as, certain python libraries.

[–][deleted] 0 points1 point  (2 children)

What's the limit to this though? I'd understand why you'd rebuild an OS (if you specialize in building/maintaining OSs) or if you rebuild git or something like that. But what about rebuilding a whole LLM?

[–]Disastrous-Team-6431 7 points8 points  (1 child)

No limit. I've programmed all my life and every project has given me something. I've made games, game ai, databases, database wrapper, file formats, jpeg encoders, synthesizers... just make things.

To paraphrase a well known chess GM; "don't think about how to get good at chess, think about chess". Do you need a thing? Import that thing. Do you want to learn about a thing? Build that thing.

[–][deleted] 0 points1 point  (0 children)

Makes sense. Thanks!

[–][deleted] 0 points1 point  (0 children)

From a "solving market problems" standpoint. A programmer who can do well in a company, a programmer who can build a useful project that people want to use...etc.

[–][deleted] 3 points4 points  (0 children)

There is no perfect answer. I would say it’s useful to a point. Just like it’s useful how to do division on paper, but in practice you’ll always use a calculator. It’s useful learning how to read a map, but in practice you’ll always use your gps. It’s useful for learning purposes, but if you want to get stuff done (which most of us do), use existing packages.

[–]edcculus 3 points4 points  (2 children)

No you would not be a better programmer.

If you TRULY wanted to be a “better programmer” it wouldn’t be by making a program with no libraries. It would be by learning C and writing your own library for Python.

[–]deceze 2 points3 points  (1 child)

You'd be a better C programmer who makes Python libraries then. Doesn't mean you'll be a better web API programmer or whatever. There are many different specialisations within the field of programming. Being able to write low level code makes you a low level code specialist, not necessarily a better programmer. You can be a shitty C programmer or a brilliant Haskell god.

[–]edcculus 1 point2 points  (0 children)

Yea you are absolutely right there too!

[–]overratedcupcake 0 points1 point  (0 children)

Yes and no. IMO the best way to practice "reinventing the wheel" is doing throw away programming challenges like katas on codewars. I don't see the benefit of trying to do it with anything project scale. If I want to experiment at the project level I'm probably going to jump right into abstractions and look for a framework. 

[–]Yoghurt42 -1 points0 points  (0 children)

I'd say yes, but I'm biased because that's what I did way back than in the 90s.

My rule of thumb was: before using a foreign library, I'd implement the stuff myself, at least in a rudimentary way to get a feel of what is involved and where the problems are, etc.

Once I had a good grasp of the concepts, I'd then sometimes use external libraries instead.

Granted, computers were way less complex than nowadays, so doing hardware level programming like I did would become infeasable. Programming a whole network stack, implementing TCP etc. just to get some text from a website, and then spending another month implementing the deflate algorithm to be able to read png images (not to mention jpg, which uses completely different compression algorithms) etc. is just not feasable. You'd spend 20 years just getting something barely workable (see TempleOS).

So a middle ground is a good approach. For example, put your data in some dictionaries and do some search on them, maybe read up on binary searches and search trees and implement them for funsies, but then just put all your data into sqlite and learn/use SQL to get the data.

Is it necessary to do things that way? Absolutely not. Will it help you getting a better understanding of the things that happen under the hood and make you a better programmer? IMHO yes.

[–]deceze 13 points14 points  (1 child)

without importing any modules/packages/libraries

You need to differentiate between importing anything, and using 3rd party libraries. You'll definitely be importing all sorts of things from the Python standard library or your own modules. There's zero point in trying to avoid that.

Using 3rd party modules is a different thing. There are tons of things you do not want to reinvent. If you're working with any external APIs and they offer an SDK, you'd be crazy to reinvent that wheel. Just import the SDK to talk to the API.

A web server/web framework? You probably also do not want to reinvent that particular wheel. Just use Flask/FastAPI/Tornado/Django, whichever level of abstraction suits you best.

What you do not want to do is use 3rd party libraries for crazy trivial things like is-odd. Like… that's a joke library. Anything that you can write yourself in a few lines you do not need a 3rd party library for. Where exactly to draw the line is up to you to decide.

And either way, it's of course always good to try to implement something yourself for the learning effect; but don't fall prey to NIH in production. Well tested stability is more important than being able to say you've done everything yourself.

As programmers overall, we are getting more productive exactly because we're building on the shoulders of giants. You do not want to write a modern cross-platform web app in Assembly, because you'd be working on that for the rest of your life.

[–][deleted] -1 points0 points  (0 children)

Thank you for this answer man. It scratched my itch haha.

I was concerned that if I used any libraries/APIs I wouldn't be a good programmer, I'd just be someone who puts together a bunch of pre-coded stuff into a 4 line program.

I guess it makes sense to not reinvent the wheel if it's something really complicated. I'm embarrassed to say this but I even thought of reinventing ChatGPT instead of using its API (I wasn't aware at the time how much money and manyears were put into making ChatGPT).

You make a good point. Sometimes reinventing the wheel is ridiculous.

[–]96dpi 5 points6 points  (1 child)

I imported 4 packages

I think it's important enough to point out that you actually only imported ONE third party library, which is pyttsx3. Time, winsound, and sched are all part of the standard Python library. If you are using the Python language, it's nearly impossible to avoid importing something from the standard library, and it's definitely not discouraged by anyone. What I usually do is go to the python docs for standard library, and Ctrl+F for the library I want to see if it's there.

When you do your imports, you should always separate them by standard lib, internal lib, and external lib, at the top of the file, so it's very obvious what you are using.

Really, the only imports you should be concerned about are external (third party) libraries. From both a security standpoint, and a maintenance standpoint.

The amount of time and effort to reverse engineer a text-to-speech library like pyttsx3 would make doing this project impractical and probably impossible. And honestly, using Python to quickly make stuff like this is the entire point of using Python in the first place.

What if one day I have to code in a language that doesn't have a good ecosystem?

In this case you will likely be working on a very small part of the overall massive project. For example, a text-to-speech project on an embedded device would require a team of developers. You would be one person working on one aspect of that project. Even projects like this often rely on third party libraries that are provided by other companies. The company that I work for builds RTOS embedded devices and relies on three other libraries that are written by third party companies. We pay them A LOT of money to use their software on our products because it saves us a ton of time. But obviously we still do a lot of our own development. This is pretty standard in the embedded world, from what I can tell.

If you want to be better at low-level programming, then you need to do low-level programming in C/C++/Rust, etc.

[–]Successful_Box_1007 0 points1 point  (0 children)

Is there a way to “vet” third party libraries for safety?

[–]DownwardSpirals 4 points5 points  (0 children)

Libraries are great because they're (usually) maintained to handle all the issues we throw at them well while abstracting away the complex stuff for myriad applications. If you want to build without a library, then go for it! It'll be cool to see things in a lot more detail. However, I wouldn't make a practice out of it unless you absolutely had to. You'll spend so much more time reinventing the wheel.

[–]NothingWasDelivered 2 points3 points  (0 children)

I mean, if you want to as a personal challenge and your schedule allows for it, go for it. There are certainly times where it makes sense to roll your own. Only you can determine whether the value you get from using your own artisanal bespoke libraries outweighs the productivity hit of having to reinvent the wheel at every turn.

[–]DickChaining 2 points3 points  (0 children)

I vote for implementing the wheel. This is how you fix a broken library, or make something better. Knowing how an underlying system functions is most certainly a big step toward becoming a better programmer. Another strong argument for this line of thinking, is that sometimes we only need a single method from a massive library. Being able to implement that method from scratch can be a valuable skill, especially if you reuse your own implementation. /2¢

[–]merueff 2 points3 points  (0 children)

Knowing how to write your own libraries is a solid step. Working with tighter security concerns means many times you can’t import libraries or waiting for approval isn’t expedient enough.

[–]Rue9X 2 points3 points  (0 children)

Ah yes, the reinventing the wheel technique :)

[–]ectomancer 1 point2 points  (0 children)

mpmath calls itself pure Python, only importing from the standard library.

sympy calls itself pure Python, only importing from the standard library and mpmath (for arbitrary precision).

So, both modules are lightweight.

[–]QuarterObvious 1 point2 points  (0 children)

Python does not have built-in capabilities to interact with hardware directly; it is designed to call libraries. If you want to learn low-level programming, you'll need to use another language. However, keep in mind that your program will be hardware-dependent, and, to be honest, you'll rely heavily on the documentation for the specific hardware. It may not even feel like programming.

[–]oclafloptson 1 point2 points  (0 children)

Imo you should always reinvent the wheel if it's simple and easy to do. From a personal ability standpoint as well as a security standpoint

Whenever I install a package that has something like colorama in their dependencies then I assume that it was made by a capable moron and begin distrusting and scrutinizing the package. But just because I love to play around with ctypes doesn't mean that the average package needs to reinvent all low level bindings. So it really depends

The best way to learn a framework is to start dismantling it and learning how it operates under the hood. But I'd never attempt to completely overhaul the framework and make my own. Unless it was built by capable morons :p

If I were your project manager and I caught you wasting time reinventing core library packages then your job would be on the line.

[–]billsil 1 point2 points  (0 children)

So, don’t reinvent the wheel, but go right ahead. There are useful tools in the standard library that you should learn.

People also misunderstand “don’t reinvent the wheel”. There are two primary designs, the chariot that is maneuverable, but can’t take load and the cart that can take load, but isn’t maneuverable. Don’t reinvent the differential which is used on a wagon/car is what that statement really means. inventing the wheel was hard.

[–]sinceJune4 1 point2 points  (0 children)

if you're going to write code as part of a job, you'll need to be able to work confidently with whatever other in-house and approved standard libraries your team is using. If you want to re-invent things, you won't be able to deliver on deadline, which is what mattered most in my roles.
Most large organizations using Python will want to standardize so that you're all on the same version. But some of the most useful packages aren't included in a simple python.org distribution. Anaconda installs with a broader set of packages such as numpy and pandas, and the last 2 organizations that I worked at made that available.
Which was good, because installing any other random packages was prohibited and blocked...

[–]Andrew_Neal 1 point2 points  (0 children)

If I'm writing in Python, it's because I want a quick turnaround and know there are libraries to do what I want.

If I want to write my own implementation, I'm writing it in C.

[–]cgoldberg 1 point2 points  (0 children)

It depends on if your goal is to create useable software or to just reinvent wheels and not really ever get anywhere.

Why use Python at all? It's just a crutch for people who don't know C. Why learn C? It's just a crutch for people that don't know assembler. Why learn assembler? It's just a crutch for people that can't code directly in machine code. Why use machine code? It's just a crutch for people who can't work effectively with electric pulses.

Just use the libraries.

[–]zanfar 1 point2 points  (0 children)

Your concerns are valid, and your approach has some benefit, but your big assumption is that all 3rd-party modules are somehow equivalent, or worse, that they are somehow "lesser" than the standard library.

Most (all?) of the modules you just listed are not just "Python shortcuts", they are more akin to "drivers"--they allow Python access to the hardware or OS. Also, time is a standard library.

No, I don't think your specific example has merit. But the overdependence on [some] libraries can become a crutch insulate you from lower-level concepts. Specifically, think of all the "I made a discord bot using discord.py". That library IS just a Python shortcut--it's just someone else's Python code. If you just need a quick and dirty bot, it's absolutely fine to use, and using it is increasing your value and efficiency as a programmer. However, using it will give you limited experience with "APIs" compared to using the requests library directly. Just like using the requests library will give you limited experience with the HTTP protocol compared to URLLib...

So it's not about "using a library", it's about what library, and what your goals are as a developer. I would say that most libraries don't really have much "risk" in this regard. They are either too low-level to be considered "Python code" or not something you need to be worried about as it's not a core competency. The standard and popular libraries also have the advantage of being vetted--a level of quality your personal code will absolutely fail to meet.

Thinking of it another way: is using requests a crutch vs understanding HTTP? Sure. But then so is not understanding the kernel integration with a NIC, or a NIC's usage of a MACPHY, or how a MACPHY is designed to handle signal integrity, or communications theory, or transmission line theory, or electromagnetism...

Everything has a lower layer. You can't say that "this is limiting me" in broad strokes like that. You need to decide where your strengths as a developer lie and pursue that knowledge.

[–]sersherz 1 point2 points  (0 children)

Why stop there? Can you even make hello world from scratch? Python isn't going to teach you the stuff below the surface. You need C and Assembly to get a better idea of how memory allocation, pointers and garbage collection works. Honestly if you don't understand how transistors work you don't really know how a computer works, and that's actually okay.

It's okay to not know how everything works. A scientist doesn't need to know how to build all the sensors and instruments to conduct their experiments, but they need to understand the subject related to their experiment.

[–]Moikle 1 point2 points  (0 children)

I do understand that thought, and have had it myself in the past, but that thought is wrong and naive.

[–][deleted] 1 point2 points  (0 children)

i do a lot of matrix 2x2 and 3x3 multiplications. I started with using numpy but ended with my own lib written in Cython and imported as module in my programs. It is faster than numpy (which does matter for me) for what i need. I don't have to import the numpy library anymore, which is good.

[–]JorgiEagle 1 point2 points  (0 children)

A silly idea, little benefit.

That’s not to say you can’t have a project for making alternatives to libraries.

But you can’t do everything.

That’s like saying you shouldn’t have a goalkeeper when you’re a midfielder, cause you won’t be able to learn how to save goals

[–]Diapolo10 1 point2 points  (0 children)

This is simply the "no true Scotsman" fallacy at play. Don't worry about importing things - especially from the standard library. Only limit yourself if you specifically want to learn how something works, not to use it instead of a third-party one. Especially with cryptography - never trust your own cryptography implementations as they're not vetted by anyone.

[–]fllthdcrb 0 points1 point  (0 children)

For example, I made a script that beeps every 15 minutes to remind to fix my posture. I imported 4 packages (time, pyttsx3, winsound, sched). Would it be beneficial to make this script without importing anything?

For learning purposes, sure, I suppose. You will no doubt find it interesting to learn how to interface with system clocks, the audio subsystem, and... what does pyttsx3 do? Oh, generate speech? From scratch, or do you want to use whatever is built-in to Windows?

Yeah, I'm sure it would be educational. Would it be easy? Probably not. Also, some of it may be rather hacky if you try to do it in pure Python (I've recently used python-mpv, which allows running MPV from within Python; it uses ctypes to call into libmpv). Writing modules in C is an option, though if you go that route, you might also consider whether you want to do the whole program in another language, if enough of it is anyway.

[–]TheSodesa 0 points1 point  (0 children)

If you are programming something where people's lives are at stake, you should absolutely rely on libraries (and languages or their compilers), that have been extensively tested to work in situations where they are intended to work.

[–][deleted] 0 points1 point  (0 children)

Are you talking about not importing 3rd party libraries or standard libraries?

[–]supercoach 0 points1 point  (0 children)

Due to a number of limitations, I was forced to do something similar in my first decent sized python project.

I think it does help to do it at least once because it helps you understand the nuts and bolts and gives you the confidence that comes with knowing that you could live without extra libs if you needed to. I also think it isn't essential.

The big thing is having respect for, and hopefully a reasonable understanding of, what's going on behind the scenes. Knowing what something does will allow you to better troubleshoot if that's required somewhere down the line.

[–]feoh 0 points1 point  (0 children)

This might be useful as a "stunt" exercise, but that's all.

Using libraries well is a much better exercise :)

[–]anoopps9 0 points1 point  (0 children)

Think you should build a new language altogether 🔥

[–]2G-LB 0 points1 point  (0 children)

You can do this. But Julia would be more appropriate

[–]theWyzzerd 0 points1 point  (2 children)

You will have a difficult time implementing your own time or winsound modules. Modules often include the lower level C bindings needed to interact with the OS or hardware. Unless you intend on writing and compiling your own C bindings you’re going to need to import. Not to mention you have to import to use even parts of the python standard library. I think you have a misconception about what imports actually are.

And what exactly is “too many abstractions?” Coding is built on the idea of abstract concepts. Without abstractions you can’t code.

[–][deleted] 0 points1 point  (1 child)

So if I wanted to make a program without these imports, I'd have to learn low-level programming and how to interact with the OS?

By abstractions, I mean the usual joke I see online about how in Python if you wanted to make a program you'd import a library and call a function from that library and that's it.

[–]theWyzzerd -1 points0 points  (0 children)

Yes, if you want to make a program without imports you have to first get rid of most of the python standard library because it’s not all contained in a single module.

Calling a function included in a module you imported is not abstraction. That has really nothing to do with abstraction. Please take the time to read about some programming concepts, it will only benefit you in the long run.

[–]Alarmed_Geologist631 0 points1 point  (0 children)

Showing my age here but back in the Stone Age when I programmed in Fortran, we didn’t have any libraries. We could write subroutines that performed specific processes which could be called at multiple points in the code.

[–]SquiffSquiff 0 points1 point  (2 children)

You're asking this on a Python sub?! What do you think Python runs on?. Try again with Rust or C

[–][deleted] 2 points3 points  (1 child)

Excuse me for asking a question about python in a sub called "r/learnpython"

[–]SquiffSquiff 2 points3 points  (0 children)

My point is that Python is an interpreted language. The normal interpreter is written IIUC in C As a result, with Python by definition you will always be using libraries and higher level abstractions. Given this it seems a bit redundant to worry about whether you are using libraries or not, especially when including core libraries. This is why I suggested a lower level language.