Code Libraries - Computerphile

  Рет қаралды 92,336

Computerphile

Computerphile

5 жыл бұрын

Standard progamming #INCLUDEs libraries - but how do they work? Dr Steve Bagley links us to the details.
What Happend When I Press a Key: • What Happens When I Pr...
AI Safety Gridworlds: • AI Gridworlds - Comput...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 189
@FortoFight
@FortoFight 5 жыл бұрын
I already regularly use libraries but I always enjoy a new computerphile video even if I don't necessarily learn something new. Never be complacent, there may be a gap in your knowledge that you weren't even aware of.
@mavhunter8753
@mavhunter8753 5 жыл бұрын
FortoFight God, I couldn't agree more, with everything you said lol.
@simpletongeek
@simpletongeek 5 жыл бұрын
FortoFight I'm really upset that standard C libraries don't include graphics and input devices such as keyboards, mouse, and sound cards. Most computer systems have had frame buffers and USBs for decades! Why not? The usual response of "not all systems have it" rings false. After all, not all system have file system. Just return an error if unavailable. Then another excuse of lack is standards. Keyboards and mouse (and touch screens) are pretty standardized by now. Maybe not the advanced features, but Keyup, Key down, Mouse press, x,y, is very standard. Graphic resolutions can be decided on the fly, and color depth can be like PBM: BW, 256, 24 bit. I really don't see what the problem is, do you?
@aidanjt
@aidanjt 5 жыл бұрын
+simpletongeek: That's far beyond the job of the C standard library, though. It only needs a very simple I/O abstraction which can run on any machine going back decades. The implementation of hardware is down to the OS, and there's very many different ways of handling those devices. Even Linux and BSD doesn't agree with each other on that score, much less the other operating systems. We can't just pile every new flanged device that comes out into cstdlib and expect clean backwards ABI and API compatibility.
@IIARROWS
@IIARROWS 5 жыл бұрын
That hurts my OCD...
@DrewWalton
@DrewWalton 5 жыл бұрын
@@simpletongeek you clearly don't understand how operating systems work then. Each different OS has varying ways of defining syscalls, and one single implementation of, say, printf() would this be incompatible. Thus it's left to the libraries on the OS to define how things like this should be implemented.
@DamaKubu
@DamaKubu 5 жыл бұрын
Been programming for years, still watch this.
@christopherg2347
@christopherg2347 5 жыл бұрын
I am a Coder for Fun and Profit.
@Guitarm4n99
@Guitarm4n99 5 жыл бұрын
This really nicely brings linkers, static libraries, and dynamic libraries together
@isaac6560
@isaac6560 5 жыл бұрын
I see what you did there
@grn1
@grn1 2 жыл бұрын
@@isaac6560 Legit though while I've long known what a library is and that DLL stands for Dynamic Linked Library I never really considered the way they are actually used.
@bariswheel
@bariswheel 5 жыл бұрын
Elegant description of static and dynamic libraries. I wish KZfaq was around during my CS undergrad days. Or this channel.
@joedeshon
@joedeshon 5 жыл бұрын
Those classic vintage PCs in the background! Those things had personality!
@TheSpinTensor
@TheSpinTensor 5 жыл бұрын
Libraries are very very important. I use a lot of libraries for my code, and even abstracted a lot of recurring stuff in my own library, to link to my different small programs.
@ambhaiji
@ambhaiji 5 жыл бұрын
TIL this channel is the most subscribed Tech channel in GB
@mavhunter8753
@mavhunter8753 5 жыл бұрын
C can be used in environments where you just don't need "print". Like perhaps on bare-metal embedded systems. On such systems you also want your program to be tiny as well, in which case "print" just becomes superfluous.
@user-qf6yt3id3w
@user-qf6yt3id3w 5 жыл бұрын
In a lot of embedded systems stdout goes to a UART port for debugging. So printfs still work - you attach a cable that goes from USB to UART and you can see 'em.
@mavhunter8753
@mavhunter8753 5 жыл бұрын
Tom T Ah, that's interesting.
@raykent3211
@raykent3211 5 жыл бұрын
Your first point is correct. An on off switch may not need to convert these states into character sequences saying on and off in text, but just light an led, or not. Printf () serves no purpose for those, and can be left out of a C program.
@blipman17
@blipman17 5 жыл бұрын
Also note that for defining and implementing a printf() function you don't need printf() to exist. C is a language you would typically use to implement such a function and hence won't need it to exist before it.
@mavhunter8753
@mavhunter8753 5 жыл бұрын
Sjoerd Nijboer Exactly!
@ImSquiggs
@ImSquiggs 5 жыл бұрын
I hope you never stop making videos. I watch a lot of KZfaq channels, but I get excited for a new Computerphile video in a completely different way than most of the rest.
@JaccovanSchaik
@JaccovanSchaik 5 жыл бұрын
I can't stop looking at that Amiga 1000 in the background.
@Infantry12345
@Infantry12345 5 жыл бұрын
4 years of college and 4 years of industry work, but it took one video to finally really understand what a library is trying to do. Thanks for this video, I feel a little less like a horse at the steering wheel now.
@MikelNaUsaCom
@MikelNaUsaCom 5 жыл бұрын
its always good to have either a review of your toolbox... or if needed nice to add a new tool to your toolbox / tool belt. =D
@philwatts
@philwatts 5 жыл бұрын
I want that shirt. Well, not that particular one, but one exactly like it.
@patrickthepure
@patrickthepure 5 жыл бұрын
I guess they are called hawaiian shirts.
@theporcupine9993
@theporcupine9993 5 жыл бұрын
@@patrickthepure no
@patrickthepure
@patrickthepure 5 жыл бұрын
What are they called then?
@user-qf6yt3id3w
@user-qf6yt3id3w 5 жыл бұрын
If you stare at a long enough you can see a sailboat.
@theporcupine9993
@theporcupine9993 5 жыл бұрын
@@patrickthepure a shirt, with just a strange pattern. Maybe it's arbitrary but I'd say Hawaiian shirt have the kind of flowers and stuff on them.
@StephenFarthing
@StephenFarthing 5 жыл бұрын
Thanks for an interesting introduction to the subject. I’m an old school programmer from the 70s. Back then using libraries was pretty fraught because often they didn’t perform as specified. Now I’m retired and mostly program embedded systems for fun. Even now it’s not uncommon for a library to have faults. Even something as innocent as recompiling with a different version of a compiler can alter the way a library behaves.
@StephenFarthing
@StephenFarthing 5 жыл бұрын
Yes, now I use C pretty exclusively. For a lot of microcontrollers there is no other choice. And often it’s the case that there is no operating system to hide the hardware functions. I’ve programmed in many other languages over the years but have come to appreciate the minimalism and universality of C, warts and all. For what I do now it’s fine.
@alwysrite
@alwysrite 5 жыл бұрын
very straightforward explanation, nicely done, thankyou.
@kardeef33317
@kardeef33317 5 жыл бұрын
Most of, if not all librarys for visual basic are written in C or C++. I started with C and when I started playing with visual basic I wrote libraries for it because I wanted to do something or didn't know it existed in VB. I found C and VB worked great together. I think the first few versions of windows the code started in Pascal. Mixing Pascal and C/CPP can be a pain because they put the arguments in function on the stack backwards. Lol . Thanks , always great videos!
@ScottLahteine
@ScottLahteine 5 жыл бұрын
I'm fond of the way that NEXT and macOS use structured .framework folders to group the headers along with the compiled libraries and other resources. It's more sensible than the old-school *nix approach of scattering the components among several folders, such as within the /usr/local folder. It's worth mentioning that dynamically-linked libraries are at the heart of all modern operating systems, and that software applications are nice and small because they only need to contain their own logic, and are linked to the system resources they need when they are loaded for execution.
@Jet-Pack
@Jet-Pack 5 жыл бұрын
Awesome, I think I finally understood what a linker does!
@JeeMorpheus
@JeeMorpheus 5 жыл бұрын
Compilation error. Your function must return int, but it does return nothing.
@bersl2
@bersl2 5 жыл бұрын
Are you sure it's an error? Your typical compiler will only issue a warning of undefined behavior, if anything.
@fouzaialaa7962
@fouzaialaa7962 5 жыл бұрын
it is an error !!!!
@valeriodalessio191
@valeriodalessio191 5 жыл бұрын
Indeed, you are right, I spotted right away but I guess it was just a quick sample with no intention of explaining how functions with return value work
@SirCutRy
@SirCutRy 5 жыл бұрын
_control reaches end of non-void function_
@ben-mx3cs
@ben-mx3cs 5 жыл бұрын
Yes, it's an error, because returning void or nothing is different from returning null. It means you forgot a return statement entirely when the compiler expected one.
@gregf9160
@gregf9160 5 жыл бұрын
First class, as usual, from Dr. Bagley
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
7:50 It allows the shared library to be updated separately from your executable. For example, a newer version with newer features, bug fixes etc ... so long as it remains backward compatible, you don’t need to recompile or relink your executable to take advantage of it.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
But then you end up with both a dependency mess and more data transfer to update all the general use libraries than you would need for a whole new [optimized] self contained executables. I see dynamic libraries like a nice matching set of automotive tools, great in theory if you actually need most of them like a general repair and fabrication shop that gets everything from lawn mowers to logging trucks. In practice for the end user most vehicles stick to a few standard size items and you end up with a 20 pound bag of wrenches but only use the screw driver and 1/2" combo wrench, then the next car is metric so you get another 20 pound set and only use the 12 and 14mm sockets. With static libraries and even basic optimization the compiler/linker keeps only the few tools that are used for the task at hand.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
This is why Linux systems have a package manager, to automatically keep track of these dependencies on a systemwide basis. E.g. apt-cache rdepends libcairo2 | wc -l 1557 That’s right, that’s 1557 other packages that depend on the Cairo graphics shareable library on my Debian system. Yet I only need one copy installed, and it only needs to be updated once.
@blipman17
@blipman17 5 жыл бұрын
wolfedog99 You wouldn't statically link top OpenSsl, would you? If there was a bug in OpenSsl I want it to be updated asap using a general updater and be done with it for my entire pc. I don't want to have to update every program on my pc. There are projects which allow you to have a real-time operating system as a library of your program. Those are very useful for specific usecases, but are horrible for the end-user which now needs to install two programs on his computer. He needs a new operating system after all alongside his existing one.
@replicaman9215
@replicaman9215 Жыл бұрын
Finally after two or three decades I (partially) understand what a .dll is.
@cmdlp4178
@cmdlp4178 5 жыл бұрын
I think, #include or similar things like \input in LaTeX is the most powerful tool in computing. Splitting up files and even organizing it into subdirectories helps a lot, when you want to find a part of your code. With this you only need a simple texteditor, but today many source-code files of codebases on the internet get too large and you need an advanced IDE to find specific functions again. I personally make a file for every bigger function or structure/class definition, if it takes more than 10 lines. The "subfiles" are saved in a subdirectory with the name of the module and included by a header file with the same name. The header file also contains forward definitions before the deeper includes(C/C++), which creates an overview of all elements in the module and even can solve cyclic dependencies, which should only happen inside a module and never escape it (however you should avoid cyclic dependencies). Here is some sample code: structs.hpp ------------- #pragma once // this is the root file of the module structs namespace structs { // overview struct a; struct b; void connect(a* lhs, b* rhs); }; // implementation in some subfile depends other modules: #include #include "utilities.hpp" // subfiles #include "structs/a.hpp" #include "structs/b.hpp" #include "structs/connect.hpp" structs/a.hpp --------------- #pragma once namespace structs { struct a { b* p; }; }; structs/b.hpp --------------- #pragma once namespace structs { struct b { a* p; void foo() const; }; }; // include function definition #include "b/foo.hpp" structs/connect.hpp ----------------------- #pragma once // this submodule/function depends on the actual implementation, not only the typename, which can be used for pointers without definition -> opaque pointers #include "a.hpp" #include "b.hpp" namespace structs { void connect(a* lhs, b* rhs) { a->p = b; b->p = a; }; }; structs/b/foo.hpp --------------------- #pragma once namespace structs { void b::foo() const { std::cout
@oisnowy5368
@oisnowy5368 5 жыл бұрын
I'd love to see that BBC Master behind Dr Steve in action. Wonder if it has any upgrades, like a second processor.
@RussTeeTrombone
@RussTeeTrombone 5 жыл бұрын
These blokes are great.
@aydencook03
@aydencook03 4 жыл бұрын
So would you be able to use c all by itself, without any library? For example, if you knew the architecture of the computer very well, would you still be able to draw graphics, manipulate registers, etc, all with bareboned c?
@oddarneroll
@oddarneroll 5 жыл бұрын
Awsome video. I wish I watched this 25 years ago 🤔😢
@Ismael-iw4tm
@Ismael-iw4tm 5 жыл бұрын
Computerphile your great.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Actually printf is an interesting case, because it shows up the drawbacks of trying to do everything as a library routine within the limited type system offered by C. The trouble is that printf needs to be _polymorphic_ -- accept arguments of any mixture of different types -- which C really cannot handle. So it simply gives up and doesn’t bother checking the argument types. There is another approach, which is illustrated by the memory-allocation API in Modula-2. The language defines built-in “NEW” and “DISPOSE” routines, which are fully type-safe, because they are constructs known to the compiler. But the language itself doesn’t define any memory-allocation routines. Instead, these constructs are translated to lower-level calls to routines named “ALLOCATE” and “FREE”, which are type-unsafe, and not defined anywhere in the language. Instead, they have to be provided somewhere in the program, or imported from some library. This way you get the best of both worlds -- type-checking at the high level, but full versatility of implementation at the low level. Imagine if something similar could be done on a more general scale, for I/O and possibly for other things. C++ uses a similar idea for its memory-allocation mechanism, but unfortunately its “” I/O operators are a bit rubbish. And its printf support is just as unsafe as in C. GCC tries to do some type-checking of printf format strings. But this cannot work if the string is dynamic, since that requires the argument type information to be available at run-time.
@kendrickjg
@kendrickjg 5 жыл бұрын
C is C dude. If you like other languages better then use them. C is meant to be lightweight and besides, a pointer is just pointer to memory when its all said and done. It can be whatever you want it to be.
@jagardina
@jagardina 5 жыл бұрын
Dynamically linked also saves disk space which used to be an issue. Not so much anymore.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
3:00 Consider that the Unix kernels were themselves written in C. So a userland C program calling printf would pass control through the runtime library into the kernel, which would then do ... what? It can’t be language builtins all the way down, at some point there has to be actual reusable code to implement I/O.
@JakeN482
@JakeN482 5 жыл бұрын
This is where a previous video detailing "bootstrapping" comes in. C isn't on the bare metal, but it's close enough that you can see the assembly and byte code holding it up.
@trevinbeattie4888
@trevinbeattie4888 5 жыл бұрын
This comes back to what he said earlier in the video that routines like printf don't need to be part of the C language. The printf function handles formatting of strings into a stream or block of bytes at the user level in C, then when it needs to call the kernel there is a little peice of OS-dependent assembly code that triggers a system trap to the I/O driver. At that point the kernel picks up the parameters to the driver and passes control to its handler, which is again mostly written in C up until the point where it needs to send the bytes to the output device (file, terminal, network, etc.) which will be another small assembly language routine. The parts that are in assembly are small enough that it doesn't take much effort to rewrite (port) them to every supported CPU and hardware platform; the majority of the code can be in C so it can be re-used on all platforms.
@DannyBurkeBanjo
@DannyBurkeBanjo 5 жыл бұрын
y u no return int
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
2:49 Because then the language gets *bloody huge* . This was the approach taken with BASIC back in the days of 8-bit micros -- every vendor’s implementation had built-in commands to do screen graphics, disk file I/O, play sound, and every other feature they could think of sticking in. It just made the language too complicated.
@floating_ghost
@floating_ghost 5 жыл бұрын
Please add/enable subtitles.
@giuseppe4870
@giuseppe4870 5 жыл бұрын
+1
@minihjalte
@minihjalte 5 жыл бұрын
You add them yourselves. Just press the 3 dots.
@Computerphile
@Computerphile 5 жыл бұрын
at some point I hope KZfaq fix their problem - the subtitles are enabled already. But, also 'Community Subtitles' are enabled - and the two don't play nicely together - so until the community subtitle this, a work-around could be to go to the community subtitling page and watch the automatically generated ones there. I'm sorry about this but I don't know why YT doesn't allow the auto ones to be shown until the community ones are ready >Sean
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Where does he get all that tractor-feed paper from? There’s nobody still making it, is there?
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
I had to search this. Yes it is readily available.
@mazharsaid4812
@mazharsaid4812 5 жыл бұрын
Hello does anyone know about the acorn risc os lander game did this game have sound back in 1987.thanks
@gigglysamentz2021
@gigglysamentz2021 5 жыл бұрын
Very intetesting ! Not the clearest explanation but after two views I think I understood XD Had to figure out what compiling and printf were in the story
@christopherg2347
@christopherg2347 5 жыл бұрын
Yes, he is not the best explainer. But then again, I am only a decent one in text myself. Compiling, linking and even printf are a very C-centric way of thinking about programming. While there are many ways to go about Code Library implementation, the basic concept is something that is shared across all of them. Or at least the ones that are in use.
@ianhamilton350
@ianhamilton350 5 жыл бұрын
Something I've been learning about recently is how dynamic linking isn't nearly as useful as it's purported to be. Apparently it introduces security risks, slows down program execution, causes dependency issues (.dll hell), and doesn't even save very much space. Everyone still uses it though because everyone expects it to be there
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
In most cases dynamic libs actually use much more space because a library comes whole, likely only a tiny piece is to be used and then only by one or two applications. In [modern] static linking all the unused parts of the library are discarded by the compiler-linker. ie rather than dragging the whole 600pound toolbox out to change a flat tire you take only the one wrench and a jack.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Dependency issues are solved by integrating package management into the OS. That’s how we do things on Linux.
@ianhamilton350
@ianhamilton350 5 жыл бұрын
I use Linux as well. Package managers don't solve all dependency issues, although they do eliminate most of them and take care of the work of putting all the config files and other resources where they need to go
@imrank340
@imrank340 2 жыл бұрын
Sheer delivering Verbal Diarriaha!
@thePronto
@thePronto 5 жыл бұрын
I can't remember the last time I saw fanfold printer paper. Maybe the late 80s? I guess that they probably still sell it, but who uses it? And for what?
@GrayShark09
@GrayShark09 4 жыл бұрын
And now imagine the Code Library of Babel!
@Memnoch4711
@Memnoch4711 5 жыл бұрын
Kept staring cross-eyed at his shirt but no 3D image popped up. :(
@MattExzy
@MattExzy 5 жыл бұрын
"It's 3-D art. Computers generate it. Big computers!" ~ Kramer, Seinfeld
@jmalmsten
@jmalmsten 5 жыл бұрын
Nah, you don't use cross eye vision. No. You need to focus behiind the image, man!
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
“#include” is such a crude mechanism. Why isn’t Ada-style separation of module interfaces and module bodies more popular? Or look at Python’s module system. The nice thing about both is that they don’t pollute the global namespace without you asking them to.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Probably because C invented the concept so didn't have 20 years of hindsight to build on, later changes would break too much existing code.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
C was hardly the first. At that point we had over a decade of experience with building large systems -- for example, IBM had already created PL/I by this point, and that was used for implementing MULTICS, which Bell Labs participated in for a while before pulling out and creating their own UNIX. And there was an even earlier language called JOVIAL, quite popular among the US military, which had the COMPOOL concept -- an early form of system library -- for storing common reusable definitions.
@smurfyday
@smurfyday 5 жыл бұрын
*hindsight
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
"Large systems", MULTICS, and crude system libraries used for paper based programming(terminal screens were very rare into the late '60s) have little to do with mechanisms like #include or ADA and Python modules. "large systems" in 1970 were still measured in kilobytes and were pretty much limited to business and scientific style computing; security was a lock and key on the building, no concern for cross platform compatibility, no graphics or other extraneous hoopajoop; just numbers, numbers, a few minor messages, and more numbers. Most programs were not much more than raw algorithms possibly with a few I/O interrupts from fixed data collection devices, well into the '70s.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
They took large numbers of programmers, working for years, to develop.
@jeremiastoledo3921
@jeremiastoledo3921 5 жыл бұрын
Esto le puede servir a muchísima más gente. por favor agreguen los subtitulos!! aunque sea en Inglés!!!!
@FortoFight
@FortoFight 5 жыл бұрын
Deberías crear un canal que se llama "computerphile español".
@lincolnsand5127
@lincolnsand5127 5 жыл бұрын
What would we do without libraries?
@stefanjud6345
@stefanjud6345 5 жыл бұрын
I really like the series. But it is often a little to"consumerfriendly". Wouldnt it be possible to have two versions of such a video, were one of the videos is like todays while the additional video contains more tech-savy information?
@mynamesaretakenwtf
@mynamesaretakenwtf 5 жыл бұрын
if this is how this works, why is it I can't just run windows binaries on linux, or have some translator code to convert it but it'd all be one big jumble of a file so it's not actively looking for compiled libraries? Just a question out of curiousity after hearing how the concept works.
@JuddMan03
@JuddMan03 5 жыл бұрын
At some point the program has to get the hardware to do something. Disk, screen, keyboard, etc. those functions have to be managed by the kernel and drivers which are still external to your program. For one program to run on all OS, it can be done if you have an interpreter, ie. Java, or a 3rd party tool that simulates the environment your program was designed to interface with. ie. Wine or docker, or even a virtual machine. Otherwise every program would need to have all of the GPU, keyboard, mouse, sound drivers, etc. bundled. Only feasible if you are compiling for a small set of hardware, such as an embedded system.
@brod515
@brod515 5 жыл бұрын
@ 7:50 He says It doesn't even have to be the same language... How does the compiler link to pieces of code that are not the same language; how does that work?
@christopherg2347
@christopherg2347 5 жыл бұрын
They either share a common intermediate language (like anything in .NET) or are both in the local machine language.
@rageagainstthebath
@rageagainstthebath 5 жыл бұрын
I think the latter is the case. You can write a program in any language, calling any dynamic library (DLL), which is already compiled and it doesn't matter in which language.
@_____7704
@_____7704 5 жыл бұрын
Someone do a video on Numbers Stations!!!
@Trias805
@Trias805 5 жыл бұрын
Doesn't it make the program bigger than it's necessary?
@brotherlui5956
@brotherlui5956 5 жыл бұрын
Did anyone of you recognizes the computer models standing in the background? I do know them all.
@trickshotmonkey
@trickshotmonkey 5 жыл бұрын
Q.Can you make your own library for functions which you usually use? */I ask this because. Does fetching functions from multiple libraries make you code slower to react? instead of using one library with all the functions you have call for, in a code. _warning complete beginner!*/
@talrofe5558
@talrofe5558 5 жыл бұрын
I wonder how this channel has haters that dislike videos always
@Leroset
@Leroset 5 жыл бұрын
They're bots
@ollieb9875
@ollieb9875 5 жыл бұрын
Far as KZfaq is concerned even dislikes count as "engagement", so they're not all together a bad thing anyway.
@konkos5473
@konkos5473 5 жыл бұрын
0:40 int function doesn't return anything
@spiralgaming8940
@spiralgaming8940 5 жыл бұрын
alert("I love computerphile");
@brylanjacobs9139
@brylanjacobs9139 5 жыл бұрын
Just a question.. If i write a program in a language such as python or java which does not compile the code directly into an executable file.. will all end users who utilize my program have to download a python or java compiler just to run my software?
@XoddamCXVII
@XoddamCXVII 5 жыл бұрын
To actually answer your question, not exactly. With Java, you compile your finished code into some sort of JAR file. This file is an archive which contains (among other things) many *.class files containing Java bytecode. Users of your application would only need to have an appropriate version of the Java Runtime Environment (JRE) installed on their device. When you run code from a JAR, the JRE turns the bytecode from the class files into native machine code at runtime. This is known as "just-in-time" (JIT) compilation. This is what allows Java programs to be run on many operating systems easily. All you need is a JRE to convert the bytecode into a device's machine code and you can run it. Python is quite similar, though there do exist bundling tools which wrap your python code, as well as all of the necessary python source code into an executable archive and allow it to be run without having Python installed. However, it's worth noting that many people already have Java and/or Python on their computer. Many Linux distributions and Mac OS come with Python installed, and Java is relatively common across all operating systems. Anyone who has played Minecraft on their computer should have Java. I hope this long-winded explanation answered your question. Happy coding!
@XoddamCXVII
@XoddamCXVII 5 жыл бұрын
Well, that wasn't really the main point I was making. I was simply stating that these are fairly common languages for applications to be written in, so it's common for people to have one or both them on their computers whether they know it or not. We all understand your disdain for Python, you've made that clear. But that wasn't really the point of the original question, nor my initial response. We were discussing at a high level interpreted/JITC languages, using those languages as concrete examples.
@XoddamCXVII
@XoddamCXVII 5 жыл бұрын
Fair point, I agree with you. I wouldn't recommend Python either, just answering the question. I don't ever use it, personally or professionally. I prefer statically-typed languages with C-like syntax. That's how I make a living. I think it's an okay language for learning the basics of programming (variables, functions, control structures, importing code, etc.), and _maybe_ simple prototyping. But I don't understand the desire some companies have to use it in a commercial capacity, especially very large and/or mission critical code bases.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Python is standard on Linux systems, so they shouldn’t have any problem running your Python code. But then, your Python code might in turn depend on other libraries. If they are common enough to be standard packages in the main Linux distros, then fine. Otherwise it all gets a bit complicated.
@JuddMan03
@JuddMan03 5 жыл бұрын
Brylan Jacobs yes. You need to download Java to run Java programs and you need to download Python to run Python programs. This is why you provide an installer that includes those things when you ship your app. (On Windows)
@_John_Sean_Walker
@_John_Sean_Walker 5 жыл бұрын
My Windows 10 calculator has a fault; if want to rase two by the power of pi, it gives me a invalid input error message.
@namesurname201
@namesurname201 5 жыл бұрын
Please add subtitless
@pdrg
@pdrg 5 жыл бұрын
Where does "void" come from, BTW?
@aphilra
@aphilra 5 жыл бұрын
What do you mean exactly? The expression void to declare "nothing is returned", do you mean "void pointers"?
@martixy2
@martixy2 5 жыл бұрын
The need to have a primitive value that signifies "nothing". Like 0 in maths. Otherwise know as null, or undefined, or none in various languages. The more interesting primitive value is NaN(stands for Not a Number). It's special because it isn't equal to anything. Even itself.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Possibly ALGOL 68. Type VOID in there has only a single value, called EMPTY. So it was actually permissible to return a VOID value (i.e. EMPTY) from an expression.
@JuddMan03
@JuddMan03 5 жыл бұрын
Martin Ninov void is so nothing that it's not even 0, or NULL.
@austinedeclan10
@austinedeclan10 5 жыл бұрын
import java.IO; using system.IO;
@Slarti
@Slarti 5 жыл бұрын
Having started as a COBOL programmer back in 1989 and currently working as a 'full stack developer'(make what you will of that term) I am slightly concerned about all the libraries the young developers just pull in to projects willy-nilly. To show how ridiculous thing have become our UI testing framework requires a framework with 500MB of Javascript and related xml files. I think it's all a bit over the top.
@joaquinmessano916
@joaquinmessano916 5 жыл бұрын
What if you include a library but don't use all its functions? Do you just waste disk space?
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Dynamic yes they keep all the fluff, because they can't see into the future. Modern static linkers, no, they will discard all or most of the bits that are not called in the executable.(unless you explicitly set them to not optimize, which is common for debugging)
@Hauketal
@Hauketal 5 жыл бұрын
@@TheDuckofDoom. Link-time-optimization is something very different, available in the last few years only. For static linking the linker used only those parts of the library which are necessary to resolve undefined symbols.
@abpccpba
@abpccpba 5 жыл бұрын
Has Computerphile ever looked at SmallTalk?
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Yes, that was a very influential language -- well worth a look.
@beskamir5977
@beskamir5977 5 жыл бұрын
It's annoying how hard some libraries are to get working on Windows... actually almost anything programming related seems to be an absolute pain to get working on Windows but for various reasons I still hadn't switched to Linux. I guess with VS it's not _too_ bad but I'd rather use CMake and VSC or CLion over an incredibly bloated IDE like VS.
@lumpyfishgravy
@lumpyfishgravy 5 жыл бұрын
When a library is OO is it still just code? Seems a bit inadequate to describe a library as a set of routines. That's only a fraction of the picture, surely?
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
What difference does OO make?
@russellthompson3201
@russellthompson3201 5 жыл бұрын
I am an old-fart. One of the biggest reasons for dynamic libraries was to save space. If you had five programs that all use the same 20K IO library, you could store the library once on the disk and free up 80K, lots of space on a 360K floppy. The sport of byte counting came to an end about the same time as the 1G drives came out. Now I have 5TB on my home development server. 20K is nothing.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Even then it only saves space if the various software is designed as a coherent set and the library trimmed of any unused bits. To day we download three 500MB dynamic libraries to link to a 100MB executable that only calls 5 functions from the whole mess and the next executable requires a completely different set of libraries.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
I can remember writing a program on VAX/VMS (this was the 1980s) to implement “pushd” and “popd” commands (save the current directory to switch to another one, then restore where you were before). The initial executable was just 10 blocks (5kiB) in size as I recall, but it took an appreciable fraction of a second to run each time, which I felt was too slow. But the VMS linker gave you the option of linking against a static version of the system library, instead of the dynamic one. I tried this, and the executable size went up to 50 blocks (25kiB). But it launched a lot faster. These days, on Linux, I really couldn’t notice the difference.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Not really. The original PDP-11 Unix system didn’t have dynamic libraries, and that had to fit within a 64KiB address space. VAX/VMS, by contrast, had a huge address space available, and typically ran on systems with memory measured in MiB. But that had shared libraries right from the beginning. These were not common on Unix systems until a few years later.
@daniela9171
@daniela9171 5 жыл бұрын
You can't call an int function without returning an int value. Should had been a void.. Basic stuff
@grivar
@grivar 5 жыл бұрын
import this
@jeffirwin7862
@jeffirwin7862 5 жыл бұрын
fatal error: antigravity: No such file or directory
@Borszczuk
@Borszczuk 5 жыл бұрын
"printf()" is a function, not a command
@catharperfect7036
@catharperfect7036 Жыл бұрын
I'll show you a function...
@helium73
@helium73 5 жыл бұрын
The most important thing about C isn't C it's how to compile C. You have to know Makefiles and the difference between Includes and Libraries even thought the two have a one to one correspondence and you have to be able to include all the C libraries when you compile them. Getting a program just to compile is huge. Make-files are in a completely separate language from C. I think it's M4 but I'm not even sure. In 1993 I bought a public domain C compiler for the Amiga and never got it to work because I couldn't figure out how to get it to compile at the command line. Finally I bought an assembler when I went down to LA. I was able to get that to work because it had a GUI. But with compilers you pretty much still have to know how to compile at the command line because relying on a GUI just mean's at some point you aren't going to know why your program isn't compiling.
@alerighi
@alerighi 5 жыл бұрын
Makefiles are just a build system, that it's the standard only on UNIX-like OS, there are other build systems, pretty much every OS has their own (on Windows you have Visual Studio projects, on Apple Xcode projects, etc). You can also use another build system, like automake, or cmake that it's cross platform, you can write your own build system in the language that you prefer, or even not have a build system at all (for small project, you can compile everything with a single command) If you have an IDE most of the times you don't have to care about the build system, it's managed automatically by the IDE itself.
@helium73
@helium73 5 жыл бұрын
It's just surprising none of the books explained anything about build systems. It was always on C syntax. It would have been nice then to have a build system that used C syntax. Every build system should use an interpreter which is a subset of the language you are compiling.
@Lttlemoi
@Lttlemoi 5 жыл бұрын
+helium73 that would make a build system only useful for a single language, while the point of a good build system is to be more universal. Furthermore, some projects have parts in different languages using different compilers (e.g. a C library with some Fortran code, a C++ library with CUDA code or a C library with python bindings), so it would make sense if one build system can handle them all. Programming books about a language typically don't explain anything about build systems because they are completely optional and completely separate from the language. It would be like explaining Bash in a C language book.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
Makefiles on their own aren’t even enough these days, you need another layer on top, like CMake. For example, Blender is built with CMake. It also used to offer the option of building with SCons, but having two alternative build systems in the source tree seemed like a needless complication -- particularly when they got out of sync.
@beamjohn9753
@beamjohn9753 5 жыл бұрын
Knowledge for knowledge everything is recycled nowadays if you tech one person how to grow an apple tree tell him to pass it on to the next person and so on!
@rafaelacosta5662
@rafaelacosta5662 5 жыл бұрын
despaci
@elgalas
@elgalas 5 жыл бұрын
Too
@mateface1313
@mateface1313 5 жыл бұрын
dame tu cosito*
@johnfrancisdoe1563
@johnfrancisdoe1563 5 жыл бұрын
Way too shallow. As other comments show, too many programmers educated in the past 20 years don't understand the fundamentals of how actual (static) libraries work in the common model of C and C++ compilers, some are mislead by advanced "dead code removal" features of premium IDEs, some think everything should be DLLs, some don't understand the concept of DLL unloading, and some are caught in a vortex of language/vendor syntax. It's an increasing burden cleaning up their garbage, and I would have hoped that a video like this would at least have explained that libraries work on a file / compilation unit basis and will include functions that are in the same file on an all/nothing basis, but different files in the same library on an "if referenced" basis. There are more advanced engineering principles (to be taught elsewhere) that need to be applied when writing public libraries, such as API/ABI stability, unloading support, multicaller support, portability beyond ones favorite OS (be it Unix, Linux, Windows, whatever), documentation beyond data type dumps etc.
@vertexedgeface3141
@vertexedgeface3141 5 жыл бұрын
Unfortunately object-oriented programming makes code reuse far more difficult and inefficient than it needs to be.
@christopherg2347
@christopherg2347 5 жыл бұрын
I do not see any issues. Maybe the really early ones did, but we learned a lot since the early "C with Objects" days. Most code libraries in .NET are just a bunch of static functions.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Plain functions have always been easy to reuse, I think Vertex may be referring to the reuse of other "objects", like classes and members.
@Ali_k20
@Ali_k20 5 жыл бұрын
Just don't delete a library on a blockchain... especially one which is a requirement to unlock a wallet! Parity wallet 'hack'...
@JuddMan03
@JuddMan03 5 жыл бұрын
You can't delete anything from a blockchain. Ever. That's kind of the point.
@sobanya_228
@sobanya_228 5 жыл бұрын
C language is not the best for explaining libraries. It has the most complicated system today. Any modern language can just include and never think about all these details C language has.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Opposite day? How do you explain how libraries are linked when all the linking is hidden? Your comment reminds me of the poor k-12 math curriculum in my country, they don't really teach the kids what the calculator is doing, instead they say "memorized this button sequence to get the answer to this problem". (and they don't even use the correct terms when doing that, I here teachers say garbage like "red-key 5, 7-key, arrow over a bunch, yellow-key squiggle button" rather than the actual operations "mode, angle, set radians, scroll right to x, inverse tan". In this case color keys are a form of shift key.)
@sobanya_228
@sobanya_228 5 жыл бұрын
"Linking" - is the biggest implementation leak. You are not supposed to know what it is. It's only relevant to C.
@LFSPharaoh
@LFSPharaoh 5 жыл бұрын
Only script kiddies use libraries. Real men code everything from scratch.
@elgalas
@elgalas 5 жыл бұрын
Make a website.
@LFSPharaoh
@LFSPharaoh 5 жыл бұрын
elgalas tried. Couldn’t even install bootstrap lol
@LFSPharaoh
@LFSPharaoh 5 жыл бұрын
Toshiya Tanabe now you’re talking. Gives it meaning. Kinda like cooking requires love and passion as ingredients too.
@martixy2
@martixy2 5 жыл бұрын
Real programmers blow on a butterfly's wings, triggering a tornado on the other side of the world that causes cosmic rays to refract through the atmosphere to flip memory bits.
@TheDuckofDoom.
@TheDuckofDoom. 5 жыл бұрын
Sometimes it is easier to write from scratch than to use a lot of the poorly documented libs out there. Documentation is a generally massive failure in computer land.
@_Everyone__
@_Everyone__ 5 жыл бұрын
booooring, "Computer for dummies". Who's the target for this generic babbling ?
@SuviTuuliAllan
@SuviTuuliAllan 5 жыл бұрын
/r/iamverysmart
Multithreading Code - Computerphile
15:54
Computerphile
Рет қаралды 380 М.
Cracking Enigma in 2021 - Computerphile
21:20
Computerphile
Рет қаралды 2,4 МЛН
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 13 МЛН
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 111 МЛН
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 220 М.
Where did Bytes Come From? - Computerphile
11:31
Computerphile
Рет қаралды 475 М.
Essentials: Pointer Power! - Computerphile
20:00
Computerphile
Рет қаралды 462 М.
Quantum Instruction Set - Computerphile
19:05
Computerphile
Рет қаралды 206 М.
Dealing With Big Data - Computerphile
16:16
Computerphile
Рет қаралды 75 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 626 М.
Write Better Code!  |  How to Create Shared Libraries in C/C++
13:59
Low Level Learning
Рет қаралды 52 М.
Inside the CPU - Computerphile
11:16
Computerphile
Рет қаралды 359 М.
why do header files even exist?
10:53
Low Level Learning
Рет қаралды 377 М.
Where GREP Came From - Computerphile
10:07
Computerphile
Рет қаралды 934 М.
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 13 МЛН