Essentials: Pointer Power! - Computerphile

  Рет қаралды 467,678

Computerphile

Computerphile

Күн бұрын

Пікірлер: 704
@DUANEYAISER
@DUANEYAISER 6 жыл бұрын
Creates a lego model as a concrete example of the abstract idea. Renders a beautiful, fully 3-D digital visual display of the lego model. I love you so much, Computerphile.
@michaelkohlhaas4427
@michaelkohlhaas4427 3 жыл бұрын
*Yes, little kiddos love it!*
@Triantalex
@Triantalex 11 күн бұрын
??
@MrSlowestD16
@MrSlowestD16 7 жыл бұрын
Oh man, I remember when I started programming in C and had trouble wrapping my head around this. Now years later it seems so trivial. You take it for granted. Great explanation.
@brendethedev2858
@brendethedev2858 5 жыл бұрын
Man I'm watching this now and I'm having trouble. Been programming for 4 years without pointers as a hobby but now that I'm wanting to write an inturpriter I'm rushing to figure them out but just can't
@vedantganesh4954
@vedantganesh4954 4 жыл бұрын
I've just started learning pointers, but i do it in C++. A lot of my hackathons that i participate in just don't allow C, but it seems so fun :(
@MrSlowestD16
@MrSlowestD16 4 жыл бұрын
@@brendethedev2858 Write an interpreter for a higher level language then, is my recommendation. Honestly if I was creating an interpreter I'd just create my own. Normal forms of syntax and semantics for programming languages gets really complicated - there's a whole domain of computer science which focuses purely on that. So if you make up a language you can keep it simple and use your own rules. Best way to learn BNFs and how that related to syntax parsing is to start with simple languages, IMO. C is simple, but it also has a lot of nuance to it.
@MrSlowestD16
@MrSlowestD16 4 жыл бұрын
@@vedantganesh4954 Weird that they don't allow C, not sure why that would be the case. Though depending on the hackathon, I'd think C is a bad language to use anyway. Usually from what I understand they have more elaborate goals, not really systems per-se. . I would say in C++ pointers are generally easier to deal with. There's a few reasons for this, but mostly you often have references used in place of pointers, which greatly simplifies things (syntax, NULL checks, etc.), and also you're most often using pointers/references to objects (containers, such as vectors), not pointer offset arrays per-se. This means you're less liable to have to do pointer arithmetic and what-not, C++ generally tries to shield raw access like that in the std and boost libraries, so I'd say it's easier. Plus the addition of std strings goes a long way given that you don't have to do pointer manipulations for simple string manipulations.
@vedantganesh4954
@vedantganesh4954 4 жыл бұрын
@@MrSlowestD16 ah, i guess, but C is more... elegant? uncomplicated?
@VitruvianSasquatch
@VitruvianSasquatch 7 жыл бұрын
Everyone complaining that their language is better and doesn't need pointers, try coding on small microcontrollers. They are useful.
@sebastianramadan8393
@sebastianramadan8393 7 жыл бұрын
Please remind me, what kind of machine bytecode does a SIM card execute?
@1st_ProCactus
@1st_ProCactus 7 жыл бұрын
Can I guess and just say ARM ?
@peterfireflylund
@peterfireflylund 7 жыл бұрын
SIM cards? Java bytecode, I think.
@mausmalone
@mausmalone 7 жыл бұрын
No, ARM is a legit CPU. Microcontrollers are the extremely low power sort of chips you find embedded in cheap electronics. You can program them in hobby kits like Arduino but you'll find one in just about any digital device that really can't be considered a computer. (like a watch, a computer monitor, a thermostat, etc ...)
@jimstanley_49
@jimstanley_49 7 жыл бұрын
Exactly. I taught myself assembly for 8-bit PIC micros on a couple of somewhat simple projects at work. Manually stuffing values into memory and figuring out how to math on 16-bit numbers really helped when I went back to school and had to take C. All the type size and malloc and pointer stuff made a lot of sense because I could see shadows of how the compiler would translate my code into the type of stuff I was doing in micros. It also gave me a great appreciation for Python, where you can easily put together all sorts of list-like "structs" without having to worry about dereferencing Null or updating the start pointer. There's a lot of housekeeping *you* have to put together to keep linked lists working properly that the video only hinted at. It's nice to spend time getting work done instead of reinventing the wheel all the time. I'm not saying it's better, just that after a single class in C I was barely ready to solve intermediate problems in C, and even simple problems would probably require too much time and effort (my job description does not include programming). After teaching myself Python, I can throw together a script in 10 minutes to help analyze some data that would be pretty much impossible for me to do in C in a reasonable amount of time.
@w.m.4077
@w.m.4077 7 жыл бұрын
"We're gonna use lego to explain linked lists" Oh my lord I think I'm in love with this man...
@pilzfreak9662
@pilzfreak9662 4 жыл бұрын
I would give a lot to just have an hour of time to talk about computer science with professor Brailsford. Such a genious person and how freaking well he explains the stuff.
@jrajesh11
@jrajesh11 5 жыл бұрын
From childhood experiences most of us can relate a train as a linked list. Each train car is connected to a similar one. The data items are passengers
@grn1
@grn1 3 жыл бұрын
That's an excellent example, not sure I've ever heard it explained that way.
@paulspl2581
@paulspl2581 3 жыл бұрын
great metaphor
@phanhung485
@phanhung485 2 жыл бұрын
What if that train transports both people and cargos together?
@mattbox87
@mattbox87 2 жыл бұрын
@@phanhung485 Well, in each carriage you might find a list of passengers and another (different) list of cargo. Why wouldn't we just keep a list of cargo and passengers for the whole train? Well of course we would, and we did, when we were dealing with trains; but a CS list could be very, very long indeed!
@davidoconnor8224
@davidoconnor8224 Жыл бұрын
Damn, that's brillant..
@aplcc323
@aplcc323 3 жыл бұрын
I hope professor Brailsford is here for a lot more years so he can keep teaching us the history of computer science. It is truly an honor to be taught by such a well informed, clear person (:
@CODcanbefornoobs
@CODcanbefornoobs 7 жыл бұрын
It took me a year to figure out how pointers work, I'm glad I didn't give up
@sebastianramadan8393
@sebastianramadan8393 7 жыл бұрын
It can take a long time to find the right mentor... and it seems most explain it in a way that's much too confusing :) have you considered Binky pointer fun?!
@michaelkohlhaas4427
@michaelkohlhaas4427 3 жыл бұрын
You should try harder. Didn't you notice that the code is wrong?
@w花b
@w花b 2 жыл бұрын
@@sebastianramadan8393 Well I think the best way to understand It best is to play around with it. Get a really simple explanation and figure out the edge cases or exceptions. It can't be done for every field but we have the chance in programming to be able to try something a 100 times. Might as well use It to its fullest
@unlokia
@unlokia 7 жыл бұрын
The best Computerphile teacher *bar none* - happy, relaxed, enigmatic, affable, funny, and knowledgeable, incredibly articulate, not only in breadth but in extremes of depth. Sorry guys but NONE of you even get anywhere near close, (apart from Brian Kernighan.)
@Conenion
@Conenion 7 жыл бұрын
And we now know his diet: Burgers, chips and beer. Great selection! :)
@davor12
@davor12 7 жыл бұрын
....and thinks HTML is a programming language.
@wir8
@wir8 7 жыл бұрын
I like Mike Pound too
@kiri101
@kiri101 7 жыл бұрын
Agreed, with the exception of Robert Miles
@yoowon-hye9270
@yoowon-hye9270 5 жыл бұрын
I love the mentioning of breadth and depth though 😂
@CharlesVanNoland
@CharlesVanNoland 7 жыл бұрын
I'm a C coder for life: I can't imagine coding without pointers, I use them for a variety of things beyond simple linked lists, but IIRC it was the linked list that I first learned how to wield them back in the 90s.
@kandysman86
@kandysman86 6 жыл бұрын
You have helped me on my late in life(35) journey into coding more than any other teacher on the internet. You make these concepts accessible. Thank you.
@nateshrager512
@nateshrager512 7 жыл бұрын
Intellectual older folks develop such great voices and habits of speech. So nice to listen to
@RichardEricCollins
@RichardEricCollins 7 жыл бұрын
Great explanation, using lego is a great leaning tool. Pointers are one of C's most powerful tools.
@sebastianramadan8393
@sebastianramadan8393 7 жыл бұрын
Yeh... screw procedural abstraction! Pointers make C turing complete, almost entirely by themselves! -coughs-
@MrPolluxxxx
@MrPolluxxxx 7 жыл бұрын
Pointers are powerful and all but I don't use them if I don't need to. Using an angle grinder to cut bread, you can, it's badass, but you'll probably hurt yourself.
@JulianOnions
@JulianOnions 7 жыл бұрын
char ***avp = &argv; Enough to scare most programmers!
@TheMixedupstuff
@TheMixedupstuff 7 жыл бұрын
That is why I am sticking with managed languages.
@MrDiarukia
@MrDiarukia 7 жыл бұрын
Luckily C# can run natively without interpreter by now
@Edgerino
@Edgerino 7 жыл бұрын
avp points to a char **, which points to a char *, which points to the first byte of memory at the location that *argv points to.
@AlqGo
@AlqGo 7 жыл бұрын
Edgerino, strictly, there's no guarantee argv is a pointer.
@MrDiarukia
@MrDiarukia 7 жыл бұрын
Isn't the & there to make it a pointer to whatever argv represents?
@jessesullivan4811
@jessesullivan4811 7 жыл бұрын
Though all this information has been hammered into me since my freshman year at uni, I just love hearing him talk about this.
@fakhermokadem11
@fakhermokadem11 7 жыл бұрын
Please make video on C compiler and how it works.
@anant6778
@anant6778 4 жыл бұрын
that's a web series of 5 or more seasons and 10 ep in one season
@skhotzim_bacon
@skhotzim_bacon 4 жыл бұрын
Lol that would be a very long video but I'd watch it
@divanvanzyl7545
@divanvanzyl7545 4 жыл бұрын
Someone should do that though
@skhotzim_bacon
@skhotzim_bacon 4 жыл бұрын
@@divanvanzyl7545 Read the documentation on the C compiler
@gumbilicious1
@gumbilicious1 3 жыл бұрын
@@skhotzim_bacon this. It’s not mysterious and hidden, it’s openly documented. In fact, the request for a video sounds like “make a surface level non-informative short video about a subject that is incredibly detailed and intricate so I can enjoy it rather than gain deeper understanding”
@memk
@memk 7 жыл бұрын
(void*) Now things get interesting
@KangJangkrik
@KangJangkrik 4 жыл бұрын
Me: grahhh I need to restart my brain The code: void(* resetFunc) (void) = 0; Me: ...
@Triantalex
@Triantalex 11 күн бұрын
??
@paulmann1289
@paulmann1289 7 жыл бұрын
It's been a long time since I mucked around in C, and pointers where always my headache, but this is the best explanation I've seen. I might actually break out the compiler again.
@JLSoftware
@JLSoftware 7 жыл бұрын
He never even said what a pointer is - an integer specifying a memory location!
@sebastianramadan8393
@sebastianramadan8393 7 жыл бұрын
If a pointer is an integer, then why can't you multiply and divide pointers? Think about it! Pointers may commonly use the underlying representation of an integer, but they're not a type of integer!
@TheWeepingCorpse
@TheWeepingCorpse 7 жыл бұрын
Sebastian Ramadan the c++ language deliberately prevents you from multiplying\dividing a pointer because its part of the language spec, but its still stored as an unsigned integer (either 32 or 64 bits) in memory. A simple cast can be used to work around this restriction.
@alcar32sharif
@alcar32sharif 7 жыл бұрын
correct
@peterfireflylund
@peterfireflylund 7 жыл бұрын
Probably 'cause they *aren't* just integers. They are abstract references that may be *implemented* as simple integers... or they may not.
@levaChier
@levaChier 7 жыл бұрын
They are and aren't integers. Heck even integers **aren't** integers. In the end of the day integers are just memory areas of 8, 16, 32, or 64 bits. It is then up to you to translate them to whatever you want. If you want to see 32bits as an unsigned integer, then you just have to go from base 2 to base 10. If you want to see them as a signed integer, then it's a bit more complicated, but it's the same concept. In C/C++ you can always cast types of equal length between them. So saying that a *pointer* is an *integer* is just like saying a *char* is a *uint8* or a *byte*. It's not exactly wrong, but if you want to be type-safe and write maintainable code it's not the way you should see things. That being said, I would agree that it's important to realise a pointer is indeed the stored address of memory location. I just don't like saying it's an integer because you should never manipulate a pointer as an integer.
@xOWSLA
@xOWSLA 4 ай бұрын
What a lovely guy, and a beautiful way of explaining pointers. He locked me to the screen for 20 min.
@MECHANISMUS
@MECHANISMUS 2 жыл бұрын
Explaining a simpler subject by means of a more complex subjects is a THING to behold.
@ijoyner
@ijoyner Күн бұрын
The professor is talking about linked lists. Links might be implemented as pointers (Strachey-style CPL/C style), but they are abstractly different. Links are between logical data objects, pointers are to blocks of memory.
@Phalc0n1337
@Phalc0n1337 7 жыл бұрын
@14:30 shouldn't the long pointer from "beer" to "burger" go at the start of the "thing", similarly to the rest of the list? As I see it right now the pointer on "beer" just points to the blue lego, which itself just points on to "chips", thus not reading the string in the red lego?
@KohuGaly
@KohuGaly 7 жыл бұрын
yes you are correct.
@AndrewVaca
@AndrewVaca 7 жыл бұрын
yes, it should
@jeffirwin7862
@jeffirwin7862 7 жыл бұрын
The more important question is why are brits bringing pizza and wine to a bbq? They could use some serious help from us yanks.
@andruloni
@andruloni 7 жыл бұрын
I can understand bringing wine as you don't normally prepare the drinks *on* the barbecue, in case of pizza it's like taking your own glass and soda to a restaurant.
@0x0404
@0x0404 7 жыл бұрын
If the next pointer was the first value it would have technically been correct.
@morsecode9223
@morsecode9223 3 жыл бұрын
Clearly understood after 3 years of struggling,all thanks to you sir. Thank you.
@user-eg6xu7cr8e
@user-eg6xu7cr8e 5 жыл бұрын
This is the most complicated explanation I've ever seen and it blows my head. I can explain pointer in two sentences: Pointer is an unsigned integer containing a memory address (or nothing - then it's null-pointer, which in most programming language means that value of pointer = 0, but sometimes it's special constant for null-pointers) . Making pointer to particular *type* is basically an information for programming language how to interpret arithmetic operations with that pointer : addition and subtraction - so that adding 1 to the pointer doesn't increase stored memory address value by 1 , but by the size of *type* .
@Nikage23
@Nikage23 5 жыл бұрын
bravo!
@annieperdue6140
@annieperdue6140 7 жыл бұрын
Immensely helpful Sir. I am a novice computer scientist and this video has probably saved me a couple of weeks or months of figuring it all out on my own!
@shivashankar28
@shivashankar28 6 жыл бұрын
I am a C guy and I can't live without pointers too. Pointers are a magical creatures !! A Truly magical beast
@blakethingstad
@blakethingstad 2 жыл бұрын
Any time I ever see anything about C, I’m just so happy I work in C# and don’t have to deal with this silliness.
@peterdegelaen
@peterdegelaen 5 жыл бұрын
In my 40 year's carreer in IT, I have written programs in S/370 assembler, Macro 11 assembler, Cobol, Fortran, PL/I, RPG II, B-Code (= Sigma assembler, from the former Xerox Sigma computers), Progress (Now OpenEdge), Bash, Korn Shell, REXX, Python and, unfortunately, also in C. I have designed and written compilers, full screen editors, programming environments, printing systems, operations automation systems, backup management systems, tape library management systems, production control systems and much more. Some of the systems I wrote more than 20 years ago, are still in use today in the company I used to work for (I'm retired now) (the more recent programs are also still in use). All of the languages and environments I mentioned were manageable, ... except C. I have never been able to write a complex C program that was fool proof. And nobody of the army of C programmers I used to work with was. I cannot count the number of C-programs I had to rewrite from pure misery in some other language (often assembler for the low-level stuff, in combination with some other language) to make them fool proof. C is a design disaster. No wonder that so many systems have bugs in them.
@morfanaion
@morfanaion 4 жыл бұрын
14:56 Professor Brailsford, in keeping with your pictoral explanation, what you have done here is set the pointer for the next item in "beer" to a pointer to next in the item of "burgers". In C and C++ this is obviously possible to do, because a pointer, in the end, is, dependent on whether it's a 32 bit or 64 bit system, either 4 or 8 bytes of memory, no matter what you're pointing at. As such, a pointer to an integer and a pointer to an elaborate struct is interchangeable. In fact, and this is something that many students do not realize, when you look at the following struct: typedef struct _thing2 { int index; char something; struct _thing2 next; } THING2 a point to any real instance of THING2 will have the exact same value as a pointer to the index integer of that same instance. And a pointer to char something will be (dependent on whether int is 16 or 32 bit) exactly 2 or 4 memory addresses higher that the pointer to that instance of THINGS2 and int index. This is both the great strength and weakness of pointers in C and C++. Because, as long as you stay within the confines of the memoray allocated to your program, you can do whatever you like with this. The following code would work, would not give any problems, but still won't do what we intended with the struct: THING2 peter; peter.index = 0; peter.something = 'P'; peter.next = NULL; char * hiThere = (char *)&peter; Right now, I am taking the memory address of peter (which is the same as the memory address of peter.index) and putting it into a character pointer. Now, if use that pointer to read the data, what it will do is simply deliver me the first 8 bits of peter.index and treat it as a character.
@antonw6455
@antonw6455 7 жыл бұрын
I think you did a wonderful job of introducing pointers to beginners. The only thing I would stress for data structures such as linked lists is that a programmer should *always* populate the next field of the inserted node before doing anything else.
@MPflugga
@MPflugga 7 жыл бұрын
19:32 This simple trick will solve all of your programming problems!
@SebGruch
@SebGruch 7 жыл бұрын
Yellow "pointer" is connected improperly :) It shall be connected to the base of "burger" THING, not it's 'next' field. Sorry for pointing out (sic!) such a detail :)
@MiffyNichen
@MiffyNichen 6 жыл бұрын
It's very important. Thanks.
@chrikrah
@chrikrah 5 жыл бұрын
I was thinking that, too. That's for confirming my suspicion.
@glarynth
@glarynth 7 жыл бұрын
#define 😠 NULL
@comradepeter87
@comradepeter87 5 жыл бұрын
char* a = 😬;
@ajtan2607
@ajtan2607 4 жыл бұрын
This thread is 😂.
@KangJangkrik
@KangJangkrik 4 жыл бұрын
@E K with UTF-8 configuration, maybe
@Triantalex
@Triantalex 11 күн бұрын
??
@chamalinni
@chamalinni 5 жыл бұрын
Long ago I submitted Latin American Subtitles for this wonderful video, today I came back and noticed they are not available yet. I don't know how the process works, but I think it would be great if they can be approved and non-English speakers can also have access to this great learning material.
@lucianoosinaga2980
@lucianoosinaga2980 4 жыл бұрын
Latin American isn't a language tho
@cmyk8964
@cmyk8964 3 жыл бұрын
@@lucianoosinaga2980 It’s one of the two major dialects of Spanish, the other being Castillan, spoken in Spain. It’s like how technically American isn’t a language, but American English is very different from British English (while mutually intelligible).
@golangismyjam
@golangismyjam 2 жыл бұрын
@@cmyk8964 American english is not very different at all compared to British English. The difference is a handful of words and spellings.
@hamsterjam738
@hamsterjam738 7 жыл бұрын
Took a look at the code. The way you indented the malloc is MAD, and I love it. I think I'm going to do the same from now on.
@mattbox87
@mattbox87 2 жыл бұрын
18:52 "what I like about C is it's a nice half-way house" Yep, pretty much nailed it there! I should say I love C dearly
@ruroruro
@ruroruro 7 жыл бұрын
A great idea, to represent memory and pointers with legos, but there are a few things that could have been done better. 1) Attach char[20] or int or something that isn't explicitly a pointer as data, so that people don't confuse pointers to strings and pointers, which we are learning about. 2) Represent directionality of hoses in some way. 3) Make pointers point to memory, not to structures. (Attach the end of hose to the green breadboard) To represent, that no matter what you do to a structure, the pointers pointing TO it don't auto adjust or anything.
@octubre_lilaka
@octubre_lilaka 3 жыл бұрын
I'm gonna try jumping down from JavaScript to C and then to C++, and this video helped me understand the usage and point of a pointer
@MobiusStrip321
@MobiusStrip321 7 жыл бұрын
This kind of makes me happy. At the school I go to we had to deal with pointers within the first 4 weeks of the course. Not everyone gets it but hopefully this video will help those who hasn't gotten it yet. And also passing by referance instead of by value is something that was quite new that had made code a lot more cleaner. BTW trying to sort numbers in a doubly link list using an a* method is really hard but really fun. Still need to get it working
@Halesnaxlors
@Halesnaxlors 3 жыл бұрын
A nice and concise explanation. Just what I needed to refresh. Thanks!
@code-dredd
@code-dredd 7 жыл бұрын
"You need two fingers" -Prof. Brailsford 😏
@conkerconk3
@conkerconk3 3 жыл бұрын
doing this sort of "lower level" memory manipulation like pointers... idk why but its so fun and awesome to do
@nonnullptrhuman504
@nonnullptrhuman504 3 жыл бұрын
Agree!
@aeebeecee3737
@aeebeecee3737 3 жыл бұрын
This channel has high quality contents.
@ambitious1001
@ambitious1001 7 жыл бұрын
Amazing Video. Please release the next one soon. The last time I watch a video with double pointer it was Linus Torvalds on a TED talk.
@casperghst42
@casperghst42 Жыл бұрын
I have meet people who have an MsC in Computer Science who work as developers ... who does not understand pointers and references.
@akashverma5756
@akashverma5756 Жыл бұрын
I can listen to him for hours.
@landon5030
@landon5030 7 ай бұрын
This man is amazing with his explanations
@necropola
@necropola 7 жыл бұрын
What I take from the video and the comments is that the world is split into people who are able to understand that a pointer is simply the address of a value and those that praise C++ as the solution to all problems.
@maxwellstrange4572
@maxwellstrange4572 7 жыл бұрын
love this explanation. understanding pointers seems to be a big barrier for most beginner programmers, but this really boils it down in the same way that most CS can be boiled down: straightforward and clever once you can abstract away the syntactic constructs of something like C and use legos instead :)
@IllidanS4
@IllidanS4 7 жыл бұрын
Pointers are a concrete realization of a reference, the former in practice, the latter in theory.
@OpenGL4ever
@OpenGL4ever 5 жыл бұрын
Well, in Java you don't have pointers, you call them references. And you can't do much with references in Java. They're not as powerful as pointers in C or in other words they're rather limited. You can't really do pointer arithmetic with Java references. So in my opinion, pointers and references are not really the same.
@methodinsane
@methodinsane 4 жыл бұрын
Love Computerphile. Well done guys.
@Morax
@Morax 5 жыл бұрын
Here I am as a grown adult trying to learn about pointers from Professor Brailsford, and all my brain can remember is "If I've named my thing, which I haven't". Me neither Professor, me neither.
@vephovandenberg3181
@vephovandenberg3181 4 жыл бұрын
I think you shouldn't be afraid of pointers. It is a really powerful thing to use. And in my opinion C/C++ programmers are elite.
@CodyHoskin
@CodyHoskin 3 жыл бұрын
I love this guy. You can learn so much from him.
@NeuroDeveloper
@NeuroDeveloper 4 жыл бұрын
Imagine this guy on a modular synthesizer.
@asterdogma
@asterdogma 3 жыл бұрын
I am feeling quite hungry now 😁 UPDATE! (31/12/2022: just went to write the exact same thing!!)
@m4rt_
@m4rt_ 2 жыл бұрын
A youtuber I watch sometimes compared pointers to street adresses, as a way of explaining how they are usefull. You can tell someone you adress to point them to where they need to go to find you, instead of literally moving the house by picking it up and putting it next to them.
@edcrypt
@edcrypt 7 жыл бұрын
You should make one (maybe not on this series) about the Actor Model of computation, that kinda inspired Smalltalk (and was inspired by it apparently too?), Scheme, and more directly influenced Erlang and the IO Language and lots of concurrency libraries for other languages. And continuing the ones on lambda calculus/the Y combinator, maybe make one on the Lambda Papers that originated Scheme? Thanks!
@codeman99-dev
@codeman99-dev 7 жыл бұрын
16:07 AHHHHH! You lost your list. You updated your head *before* setting next of your new thing. First rule of linked-list insertion: assign to next first! No matter where head points, the complete least should always be available.
@OpenGL4ever
@OpenGL4ever 5 жыл бұрын
First rule: Store the address of the previous object somewhere before you swithc to the next object. Second rule: assign to next or go to previous object by using the value you stored somewhere.
@firepower01
@firepower01 2 жыл бұрын
This is such a good demonstration.
@jonathanbecker6373
@jonathanbecker6373 7 жыл бұрын
That model is delightful.
@ttthttpd
@ttthttpd 7 жыл бұрын
Java everything is a pointer (except primitive types ex int, long), but there is no direct pointer manipulation. So there are simultaneously pointers everywhere, and "no pointers". Also arguments are always passed by value, but those values are either pointers or primitive types which is confusing when you're learning. It's weird, but I love it so much more than C++ with its implied rather than stated storage and passing modes.
@satannstuff
@satannstuff 7 жыл бұрын
Java was designed to have "no pointers at the user end" because that's where most mistakes are made. Python does basically the same thing, though not necessarily the same way. A Python list for example is actually an array of pointers.
@OpenGL4ever
@OpenGL4ever 5 жыл бұрын
You should take a look at Rust.
@GameCyborgCh
@GameCyborgCh 3 жыл бұрын
i wish my professor for introductory programming (C++) used this to explain what a pointer is and how it works
@oqardZ
@oqardZ 7 жыл бұрын
I took a quick look at the code linked in the description and one thing caught my eye: #define TRUE 1 #define FALSE 0 typedef int BOOL; I would suggest to use this instead: typedef enum { false, true } bool; to define boolean type in C. If you ever move from C to C++ compiler, all the code remains the same except for the typedef line which you have to remove or comment out.
@electronicwoe
@electronicwoe 7 жыл бұрын
oqardZ or just use . It can cope with c++ if it needs to.
@aeebeecee3737
@aeebeecee3737 3 жыл бұрын
The best video about pointer
@swathipai1254
@swathipai1254 6 жыл бұрын
@ 14:30 I think the the yellow tube(long pointer) was actually to be at the "item" thing than on the pointer.Well maybe I might be wrong though?!
@caprica9240
@caprica9240 7 жыл бұрын
Prof. Brailsford mentions that it didn't occur to him to try to explain this concept (and presumably others) in lectures by using a more visual approach - which he does now with the lego. Why did it not occur to him earlier? Was it perhaps that using visualizations to teach computer science was simply considered unnecessary, or perhaps because it seemed too 'low level' and simple according to the CS culture of the time? In short, I am asking if any specific attitudes of the culture surrounding CS in past decades could have (unconsciously or otherwise) negatively influenced how new concepts were/are presented to students.
@nexusclarum8000
@nexusclarum8000 5 жыл бұрын
David Wheeler: "All problems in computer science can be solved by another level of indirection"
@XKCDism
@XKCDism 7 жыл бұрын
I never would of thought of demonstrating this idea in Lego. brilliant
@oribarmatz5840
@oribarmatz5840 6 жыл бұрын
you play lego as a child. you enjoy playing lego as a child. suddenly, adulthood strikes. you say byebye to the lego, and carry on with your life. then the passion to the lego strikes again. but you are an adult, you can not mess with those things. so you work hard all your life in order to make an excuse to play your lego again. nice job, professor, you have earned your lego back sincerely.
@philipgeorge1253
@philipgeorge1253 7 жыл бұрын
i love the idea of indentation wars
@LikelyToBeEatenByAGrue
@LikelyToBeEatenByAGrue 7 жыл бұрын
Philip George tabs for life
@mohammadshahabrafiq
@mohammadshahabrafiq Жыл бұрын
Great video. Just ❤ Professor Brailsford. I have always thought of a pointer as a variable that stores a memory address. Like any other variable, i.e int stores an integer a pointer stores a memory address. That's how the penny dropped for me.
@zenmaster24
@zenmaster24 7 жыл бұрын
visual explanation is fine, but might have been nice to have the code to also illustrate the visualisation's point. that way you can see the techniques being talked about, in working code
@OpenGL4ever
@OpenGL4ever 5 жыл бұрын
He showed the code in 1:45.
@dipi71
@dipi71 7 жыл бұрын
1:38 Each element didn’t contain a string, it did contain a *pointer to a string.*
@profdaveb6384
@profdaveb6384 7 жыл бұрын
Yes indeed. Apologies for the slip-up .
@dancingbubbles1126
@dancingbubbles1126 4 жыл бұрын
"Demon programmer," such a cool phrase.
@SjoerdTheDev
@SjoerdTheDev 7 жыл бұрын
Very interesting and nice way of visualizing!
@emmanuelokose6713
@emmanuelokose6713 2 жыл бұрын
nobody is talking about his great voice
@mikesummers-smith4091
@mikesummers-smith4091 4 жыл бұрын
May your pointers never dangle!
@sebastianhaslinger9439
@sebastianhaslinger9439 6 жыл бұрын
There are so many reasons for pointers. i.e. try something like this: void myStackOverflow( char[] myCopyOfJunk ) { printf("I can still handle this. "); return; } //...and feed this function with more and more data (bigger arrays). //increase this and compile again (ie. to 30000000) to see, what I mean: #define BYTES_OF_JUNK 128 int main() { char junk[BYTES_OF_JUNK]; myStackOverflow(junk); return 0; } At some point you'll get an error like: BAD_ACCESS or STACK_OVERFLOW or ... etc.
@panjak323
@panjak323 3 жыл бұрын
I hate being traced by Google, But suggesting me a video with a topic I'm just learning, and the video's name isn't even the name of the topic. I'm stunned.
@eratonysiad2582
@eratonysiad2582 7 жыл бұрын
I just had a C exam where I had to do and know all this stuff. I blew it. Now I see this video and I'm tempted to write a letter to the head of my dept. to ask them if they could hire this guy and fire my current teacher.
@huypt7739
@huypt7739 3 жыл бұрын
It is just a variable for the address. Typedef could be used instead of the cryptic c syntax
@diverfede
@diverfede 6 жыл бұрын
his teaching is fantastic!
@Sejiko
@Sejiko 7 жыл бұрын
Is there any advantage for using pointers ? I dont get the point where pointers are necessary for any problem solving.
@jakejakeboom
@jakejakeboom 7 жыл бұрын
If you're familiar with a pointer-less language like Java or Python, no, there's nothing that having pointers available makes possible. The Java virtual machine and Python interpreters are relying on pointers in the background to get the expected performance, because at some level of compilation you need pointers for efficiency. But they aren't necessary when higher-level constructs (like String primitives, first-class functions, arrays, and objects) are provided. But any time you're using a Java String or a Python object or a Haskell function there are pointers being generated under the hood to keep track of data and instructions across memory. Also, it's worth knowing that primitive pointers allow for some extremely efficient algorithms that just aren't possible in higher-level languages (I think some of the non-comparison sorting algorithms).
@justice4g
@justice4g 7 жыл бұрын
There are probably many but I recall like 20 years ago being able to speed up a C program hugely by replacing a conditional statement within a loop that called one of 2 functions with a single check before the loop which assigned a function pointer to the function to be called as it didn't need to change. People don't seem to be so obsessed with optimizing these days though.
@timn5066
@timn5066 7 жыл бұрын
When you want to pass a (huge) structure to a function, you can do it two ways. You either copy over the whole structure, modify it in the function, and then copy the whole thing back again. The other way is to just pass a single number (the pointer) and work on the original copy. The second method is way less resource intensive. A decent analogy would be the following: Say your toilet is clogged, do you then move your house over to a plumber, let him fix it and then move your whole house back to where it was? No, just just give the plumber your address and he'll come over and fix the drain.
@Mythricia1988
@Mythricia1988 7 жыл бұрын
But most languages without explicit pointers do exactly that. They generally don't copy the structure wholecloth, they give you a reference to it, and you modify the original structure directly. It's the same thing, just less complicated to use, and it being less complicated makes it less likely that the programmer makes a mistake.
@waqar_asgar__r7294
@waqar_asgar__r7294 7 жыл бұрын
So (conceptually at least) a linked list basically a better version of an array cuz if you wanna add (or remove) stuff from your "list" you can just create new memory and manipulate the pointers instead of all that "pushing" and "popping" in the case of arrays right?
@Improbabilities
@Improbabilities 6 жыл бұрын
Linked lists are easier to manipulate, but they take up more space (each item on the list has to store a pointer to the next item). Moving through a linked list is also slower (instead of just moving to the next address in memory, you have to jump to the address stored in the pointer, which usually takes twice the time). The biggest downside of linked lists is that getting information out from the list is really slow. If you have an array stored sequentially in memory, and you want the 6th value in the list, you can calculate the exact memory location of that value (list_Pointer+5*(size_of_list_element)), and jump to the right value directly. In a linked list, you have to move through every element, which is very inefficient for big lists.
@yankomirov4290
@yankomirov4290 6 жыл бұрын
If only my professors were like Professor Brailsford... life would be so much more easier
@0x0404
@0x0404 7 жыл бұрын
I prefer dual linked lists myself. It only requires one more pointer but you can go back to the previous item. Very nice for removing things without needing to travel all the way through the list(to find the previous item) to remove it properly.
@cigmorfil4101
@cigmorfil4101 6 жыл бұрын
Micah Chase and you can also insert by continuing the search ftom the current position in either direction
@gbbsc
@gbbsc 7 жыл бұрын
Can you do a profile video for professor Brailsford? I'd love to know more about this interesting man.
@shantanusharma5624
@shantanusharma5624 3 жыл бұрын
Thanks to learning c I understood pointers very well
@jackofnotrades15
@jackofnotrades15 4 жыл бұрын
I am not sure I am right, but I think the yellow connector @14:40 is not in the correct position, it needs to be pointing to the base of the 'new THING' and not to the next of the 'new THING'. But he did the same thing correctly when updating the head pointer. Great use of legos...😎
@jouebien
@jouebien 7 жыл бұрын
if I'm going to write a linked list I'll make sure it uses void pointers - both the next and the stored data are void pointers. Allocate data on the heap and store a pointer to said data in the linked list. One linked list to rule them all! Year casting later on from void * to char * or int * etc is a little bit of a pain but at least I only have to maintain one data structure.
@MobiusStrip321
@MobiusStrip321 7 жыл бұрын
JOUE BIEN TECH this is actually what we do at my school. we had to create our own library of functions and having a void *data has helped a lot with generic functions. admittedly we are only 3 months into the course so there is still much to learn.
@synestematic
@synestematic 5 жыл бұрын
function calls to delelement at the end of main function should also be catching the return value into start pointer or you will be dereferencing a NULL pointer sooner than later.
@nap3xdnicholas_3infosec23
@nap3xdnicholas_3infosec23 3 жыл бұрын
This was amazing, thank you sir. Cheers.
@theamjolnir9641
@theamjolnir9641 6 жыл бұрын
Thank you for the explanation this channel is awesome!
@jony7779
@jony7779 7 жыл бұрын
Great video! A bit of constructive feedback: I think theoretical computer science topics fit much better in video format than coding/programing topics.
@dreamdrifter
@dreamdrifter 2 жыл бұрын
Great explanation of pointers. However, 14:35 the "extra long" (yellow) pointer should be attached to the grey plate of burgers, not the "next" field (blue lego) of burgers. Pointing to the blue lego will just circumvent burgers and point straight to chips. This comment out of context though 😜
@samweldon8104
@samweldon8104 2 ай бұрын
We just wrote a linked list library in C a couple weeks ago in my advanced programming class, why couldn't I have stumbled onto this video a little earlier 😭 would have helped to have been picturing Legos the whole time lol
@Wanderer3639
@Wanderer3639 2 жыл бұрын
5 years later, I barely understand what I saw but I just finished the exercise on the code.
@ayyubshaffy3612
@ayyubshaffy3612 4 жыл бұрын
This guys facial expressions are legendary 17:30 - 17:40
Arrays vs Linked Lists - Computerphile
29:57
Computerphile
Рет қаралды 496 М.
Triple Ref Pointers - Computerphile
8:28
Computerphile
Рет қаралды 150 М.
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
Roadrunner 1.0 Autonomous Guide (Part 3)
8:08
FTC Team Code Blue
Рет қаралды 70
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 341 М.
Programming Loops vs Recursion - Computerphile
12:32
Computerphile
Рет қаралды 1,5 МЛН
Where did Bytes Come From? - Computerphile
11:31
Computerphile
Рет қаралды 481 М.
UNIX Special: Profs Kernighan & Brailsford - Computerphile
28:16
Computerphile
Рет қаралды 330 М.
Garbage Collection (Mark & Sweep) - Computerphile
16:22
Computerphile
Рет қаралды 253 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
C++ Super Optimization: 1000X Faster
15:33
Dave's Garage
Рет қаралды 333 М.
Someone improved my code by 40,832,277,770%
28:47
Stand-up Maths
Рет қаралды 2,7 МЛН
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 1,1 МЛН
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН