– What are programming libraries and how do they work, can you just make them?

279 views

– What are programming libraries and how do they work, can you just make them?

In: 1

6 Answers

Anonymous 0 Comments

Programming libraries do what you hope is a common, reusable set of operations. The idea is to implement them once and then use them in a lit of programs, saving money in the long run. Yes, you can just make them, that’s what many open source libraries are.

Anonymous 0 Comments

A library is just software that was written with the intention of other programmers (or maybe even the same programmer?) using it.

Here’s a simple example: how do you convert a number, written in binary, to a number written in human readable form? It’s an incredibly common thing to need to do since humans read numbers all the time but computers run in binary. Someone wrote the code to do that a long time ago, give the function a name, and put it into a very common programming library. Now you don’t need to think about the actual conversion process, you just request it by giving the binary version of a number and you get back the text version of it.

Well these sorts of things exist on large scales for all kinds of purposes. Most simple graphics stuff was written by Microsoft and so if you’re writing a Windows program you can make an app with buttons and menus without worrying about things like text sizes, system font settings, or whatever. It’s so much less work for you, but also makes the rest of the system consistent since everyone loads the same settings, fonts, etc.

Anonymous 0 Comments

So a library is just a code file(s) that are written ahead of time to do a specific function. And then you can call functions in that library wherever you need them. For example, of you need to do math, you use an existing library where someone else has already figured out how to make it work in whatever language you’re using.

The way you make them is by making a file with all your functions and then set it up so that it can be imported into other programs. At it’s core it’s just like any other code file, but its meant to get lower level stuff written ahead of time, and then your actual program just automates calling those functions.

Anonymous 0 Comments

Yes you can make your own but, for the most part they’re a part of the Object Oriented Programming.

Once upon a time in early programming you had functions which you could call to do tasks and even pass information into or receive information from… repeatedly.

Let’s say (for instance) that coding out the addition of two numbers was actually some big deal instead of something easy and built in, so every time you wanted to do it you had to write a heap of code… and you need to add two numbers a lot. So instead you write it once in the code and make it a function that accepts two numbers as input and returns the sum as the output. Now you easily call that function every time you need to add two numbers at it reference that segment of code on the program you already typed out to do it.

NOW, you realise you need to add two numbers in more than one program. It’s actually something you do in many programs. Now imagine there’s a whole heap of useful functions like that out there, and you don’t want to rewrite their functions every time you make a new program.

Enter “Libraries”. Pretty much each is a connection of useful functions grouped together. Now, instead of rewriting the same functions for every program, you call the library where it’s prewritten and voila.

Now, of course, there are many different libraries with different collections of functions, but not every program needs them all and they can often be grouped around common themes such as more mathematics or word/text editing.

I’m oversimplifying but it’s good enough EiLI5 IMHO.

Anonymous 0 Comments

You can think of a software library as being like a toolbox full of useful little doodads, like hammers and wrenches. The toolbox on its own isn’t exactly a fully functional program that does a specific thing, but add one to any project and it can significantly speed up development and ease of use.

If you wanted to start building a small hobby project out of wood, are you going to forge your own hammer and nails from raw iron yourself? You *could*, no one is stopping you. Someone has to make them. But why spend a ton of time making them yourself and end up with a cruder, inferior product when someone else has already made robust, affordable versions for you that are designed with more care and attention than you could ever hope to invest into something so tangential to your primary goal?

Software is the same way. Generally, unless we software developers are doing something for the educational or entertainment value, we don’t like to reinvent wheels. If our program needs the digital equivalent of a hammer, we could make it ourselves. But we usually don’t, because there’s a load of toolboxes out there with hammers in them we could be using instead. We just go out and get the toolbox and add the whole toolbox to our project.

Anonymous 0 Comments

A library is a bunch of code that you plan to re-use in multiple programs.

The specifics depend largely on the programming language.

> can you just make them?

Yes.

If you’re interested in programming, I suggest the /r/learnprogramming subreddit.