Essentials: Pointer Power! - Computerphile

  Рет қаралды 460,498

Computerphile

Computerphile

6 жыл бұрын

Pointers are fundamental in programming and Professor Brailsford couldn't live without them!
Professor Brailsford's Code: bit.ly/Computerphile_C_Pointer...
Many thanks to Microsoft Research UK for their support with the 'Essentials' mini-series.
/ 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

Пікірлер: 687
@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 2 жыл бұрын
*Yes, little kiddos love it!*
@MrSlowestD16
@MrSlowestD16 6 жыл бұрын
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 4 жыл бұрын
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 3 жыл бұрын
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 3 жыл бұрын
@@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 3 жыл бұрын
@@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 3 жыл бұрын
@@MrSlowestD16 ah, i guess, but C is more... elegant? uncomplicated?
@VitruvianSasquatch
@VitruvianSasquatch 6 жыл бұрын
Everyone complaining that their language is better and doesn't need pointers, try coding on small microcontrollers. They are useful.
@sebastianramadan8393
@sebastianramadan8393 6 жыл бұрын
Please remind me, what kind of machine bytecode does a SIM card execute?
@procactus9109
@procactus9109 6 жыл бұрын
Can I guess and just say ARM ?
@peterfireflylund
@peterfireflylund 6 жыл бұрын
SIM cards? Java bytecode, I think.
@mausmalone
@mausmalone 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
"We're gonna use lego to explain linked lists" Oh my lord I think I'm in love with this man...
@jrajesh11
@jrajesh11 4 жыл бұрын
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 2 жыл бұрын
great metaphor
@phanhung485
@phanhung485 2 жыл бұрын
What if that train transports both people and cargos together?
@mattbox87
@mattbox87 Жыл бұрын
@@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..
@CODcanbefornoobs
@CODcanbefornoobs 6 жыл бұрын
It took me a year to figure out how pointers work, I'm glad I didn't give up
@sebastianramadan8393
@sebastianramadan8393 6 жыл бұрын
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 2 жыл бұрын
You should try harder. Didn't you notice that the code is wrong?
@whannabi
@whannabi 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
@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.
@memk
@memk 6 жыл бұрын
(void*) Now things get interesting
@KangJangkrik
@KangJangkrik 3 жыл бұрын
Me: grahhh I need to restart my brain The code: void(* resetFunc) (void) = 0; Me: ...
@unlokia
@unlokia 6 жыл бұрын
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 6 жыл бұрын
And we now know his diet: Burgers, chips and beer. Great selection! :)
@davor12
@davor12 6 жыл бұрын
....and thinks HTML is a programming language.
@wir8
@wir8 6 жыл бұрын
I like Mike Pound too
@kiri101
@kiri101 6 жыл бұрын
Agreed, with the exception of Robert Miles
@yoowon-hye9270
@yoowon-hye9270 4 жыл бұрын
I love the mentioning of breadth and depth though 😂
@fakhermokadem11
@fakhermokadem11 6 жыл бұрын
Please make video on C compiler and how it works.
@anant6778
@anant6778 3 жыл бұрын
that's a web series of 5 or more seasons and 10 ep in one season
@skhotzim_bacon
@skhotzim_bacon 3 жыл бұрын
Lol that would be a very long video but I'd watch it
@divanvanzyl7545
@divanvanzyl7545 3 жыл бұрын
Someone should do that though
@skhotzim_bacon
@skhotzim_bacon 3 жыл бұрын
@@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”
@RichardEricCollins
@RichardEricCollins 6 жыл бұрын
Great explanation, using lego is a great leaning tool. Pointers are one of C's most powerful tools.
@sebastianramadan8393
@sebastianramadan8393 6 жыл бұрын
Yeh... screw procedural abstraction! Pointers make C turing complete, almost entirely by themselves! -coughs-
@MrPolluxxxx
@MrPolluxxxx 6 жыл бұрын
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.
@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 (:
@jessesullivan4811
@jessesullivan4811 6 жыл бұрын
Though all this information has been hammered into me since my freshman year at uni, I just love hearing him talk about this.
@CharlesVanNoland
@CharlesVanNoland 6 жыл бұрын
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.
@paulmann1289
@paulmann1289 6 жыл бұрын
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.
@nateshrager512
@nateshrager512 6 жыл бұрын
Intellectual older folks develop such great voices and habits of speech. So nice to listen to
@hamsterjam738
@hamsterjam738 6 жыл бұрын
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.
@kandysman86
@kandysman86 5 жыл бұрын
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.
@JulianOnions
@JulianOnions 6 жыл бұрын
char ***avp = &argv; Enough to scare most programmers!
@TheMixedupstuff
@TheMixedupstuff 6 жыл бұрын
That is why I am sticking with managed languages.
@MrDiarukia
@MrDiarukia 6 жыл бұрын
Luckily C# can run natively without interpreter by now
@Edgerino
@Edgerino 6 жыл бұрын
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 6 жыл бұрын
Edgerino, strictly, there's no guarantee argv is a pointer.
@MrDiarukia
@MrDiarukia 6 жыл бұрын
Isn't the & there to make it a pointer to whatever argv represents?
@morsecode9223
@morsecode9223 2 жыл бұрын
Clearly understood after 3 years of struggling,all thanks to you sir. Thank you.
@chamalinni
@chamalinni 4 жыл бұрын
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 3 жыл бұрын
Latin American isn't a language tho
@cmyk8964
@cmyk8964 2 жыл бұрын
@@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).
@repairtech9717
@repairtech9717 Жыл бұрын
@@cmyk8964 American english is not very different at all compared to British English. The difference is a handful of words and spellings.
@ambitious1001
@ambitious1001 6 жыл бұрын
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.
@annieperdue6140
@annieperdue6140 6 жыл бұрын
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!
@Halesnaxlors
@Halesnaxlors 2 жыл бұрын
A nice and concise explanation. Just what I needed to refresh. Thanks!
@MobiusStrip321
@MobiusStrip321 6 жыл бұрын
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
@antonw6455
@antonw6455 6 жыл бұрын
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.
@MECHANISMUS
@MECHANISMUS Жыл бұрын
Explaining a simpler subject by means of a more complex subjects is a THING to behold.
@CodyHoskin
@CodyHoskin 2 жыл бұрын
I love this guy. You can learn so much from him.
@glarynth
@glarynth 6 жыл бұрын
#define 😠 NULL
@VivekYadav-ds8oz
@VivekYadav-ds8oz 4 жыл бұрын
char* a = 😬;
@ajtan2607
@ajtan2607 3 жыл бұрын
This thread is 😂.
@KangJangkrik
@KangJangkrik 3 жыл бұрын
@E K with UTF-8 configuration, maybe
@methodinsane
@methodinsane 4 жыл бұрын
Love Computerphile. Well done guys.
@JLSoftware
@JLSoftware 6 жыл бұрын
He never even said what a pointer is - an integer specifying a memory location!
@sebastianramadan8393
@sebastianramadan8393 6 жыл бұрын
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!
@MrCrackbear
@MrCrackbear 6 жыл бұрын
No, pointers are definitely integers, but in hexadecimal form (base 16) instead of in decimal form (base 10). Other than a number, how else would memory addresses be referenced?
@TheWeepingCorpse
@TheWeepingCorpse 6 жыл бұрын
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 6 жыл бұрын
correct
@peterfireflylund
@peterfireflylund 6 жыл бұрын
Probably 'cause they *aren't* just integers. They are abstract references that may be *implemented* as simple integers... or they may not.
@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
@aeebeecee3737
@aeebeecee3737 3 жыл бұрын
This channel has high quality contents.
@MPflugga
@MPflugga 6 жыл бұрын
19:32 This simple trick will solve all of your programming problems!
@mattbox87
@mattbox87 Жыл бұрын
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
@blakethingstad5052
@blakethingstad5052 Жыл бұрын
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.
@code-dredd
@code-dredd 6 жыл бұрын
"You need two fingers" -Prof. Brailsford 😏
@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.
@firepower01
@firepower01 Жыл бұрын
This is such a good demonstration.
@user-eg6xu7cr8e
@user-eg6xu7cr8e 4 жыл бұрын
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 4 жыл бұрын
bravo!
@shivashankar28
@shivashankar28 5 жыл бұрын
I am a C guy and I can't live without pointers too. Pointers are a magical creatures !! A Truly magical beast
@theamjolnir9641
@theamjolnir9641 6 жыл бұрын
Thank you for the explanation this channel is awesome!
@Phalc0n1337
@Phalc0n1337 6 жыл бұрын
@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 6 жыл бұрын
yes you are correct.
@AndrewVaca
@AndrewVaca 6 жыл бұрын
yes, it should
@jeffirwin7862
@jeffirwin7862 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
If the next pointer was the first value it would have technically been correct.
@SjoerdTheDev
@SjoerdTheDev 6 жыл бұрын
Very interesting and nice way of visualizing!
@morfanaion
@morfanaion 3 жыл бұрын
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.
@maxwellstrange4572
@maxwellstrange4572 6 жыл бұрын
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 :)
@SebGruch
@SebGruch 6 жыл бұрын
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 5 жыл бұрын
It's very important. Thanks.
@chrikrah
@chrikrah 5 жыл бұрын
I was thinking that, too. That's for confirming my suspicion.
@edcrypt
@edcrypt 6 жыл бұрын
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!
@aeebeecee3737
@aeebeecee3737 3 жыл бұрын
The best video about pointer
@akashverma5756
@akashverma5756 Жыл бұрын
I can listen to him for hours.
@nap3xdnicholas_3infosec23
@nap3xdnicholas_3infosec23 2 жыл бұрын
This was amazing, thank you sir. Cheers.
@jonathanbecker6373
@jonathanbecker6373 6 жыл бұрын
That model is delightful.
@XKCDism
@XKCDism 6 жыл бұрын
I never would of thought of demonstrating this idea in Lego. brilliant
@conkerconk3
@conkerconk3 2 жыл бұрын
doing this sort of "lower level" memory manipulation like pointers... idk why but its so fun and awesome to do
@nonnullptrhuman504
@nonnullptrhuman504 2 жыл бұрын
Agree!
@GameCyborgCh
@GameCyborgCh 3 жыл бұрын
i wish my professor for introductory programming (C++) used this to explain what a pointer is and how it works
@ruroruro
@ruroruro 6 жыл бұрын
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.
@morgwild
@morgwild 5 жыл бұрын
I love this man.
@diamondtroller1253
@diamondtroller1253 3 жыл бұрын
Brilliant explanation!
@busyrand
@busyrand 6 жыл бұрын
Beautiful. I really appreciate this and learned allot.
@profdaveb6384
@profdaveb6384 6 жыл бұрын
Thank you!
@diverfede
@diverfede 6 жыл бұрын
his teaching is fantastic!
@gbbsc
@gbbsc 6 жыл бұрын
Can you do a profile video for professor Brailsford? I'd love to know more about this interesting man.
@mohammadshahabrafiq
@mohammadshahabrafiq 9 ай бұрын
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.
@krishcm3016
@krishcm3016 4 жыл бұрын
Great explanation!
@NeuroDeveloper
@NeuroDeveloper 4 жыл бұрын
Imagine this guy on a modular synthesizer.
@dinoflame9696
@dinoflame9696 6 жыл бұрын
Love this guy
@shantanusharma5624
@shantanusharma5624 2 жыл бұрын
Thanks to learning c I understood pointers very well
@mikesummers-smith4091
@mikesummers-smith4091 4 жыл бұрын
May your pointers never dangle!
@caprica9240
@caprica9240 6 жыл бұрын
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.
@Morax
@Morax 4 жыл бұрын
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.
@IllidanS4
@IllidanS4 6 жыл бұрын
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.
@ttthttpd
@ttthttpd 6 жыл бұрын
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 6 жыл бұрын
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.
@yankomirov4290
@yankomirov4290 5 жыл бұрын
If only my professors were like Professor Brailsford... life would be so much more easier
@dancingbubbles1126
@dancingbubbles1126 4 жыл бұрын
"Demon programmer," such a cool phrase.
@synchronizerman
@synchronizerman 6 жыл бұрын
You can also use sentinels to avoid many of the special cases.
@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.
@mkuroglu
@mkuroglu 3 жыл бұрын
Much respect
@LowescC
@LowescC 2 жыл бұрын
fantastic.... thank you..
@swathipai1254
@swathipai1254 5 жыл бұрын
@ 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?!
@dewdop
@dewdop 3 жыл бұрын
What an endearing fellow.
@m4rt_
@m4rt_ Жыл бұрын
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.
@philipgeorge1253
@philipgeorge1253 6 жыл бұрын
i love the idea of indentation wars
@SpeakShibboleth
@SpeakShibboleth 6 жыл бұрын
Philip George tabs for life
@zenmaster24
@zenmaster24 6 жыл бұрын
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.
@eratonysiad2582
@eratonysiad2582 6 жыл бұрын
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.
@computersagain
@computersagain 6 жыл бұрын
He is such goals.
@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.
@khadijahflowers5566
@khadijahflowers5566 6 жыл бұрын
Can you guys do another video on Linked Lists where there are many variables pointing to the same Linked List and show us how one change to a variable's pointer affects the pointers of the others?
@KaletheQuick
@KaletheQuick 6 жыл бұрын
This guy is my favorite :D
@Antagon666
@Antagon666 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.
@nexusclarum8000
@nexusclarum8000 4 жыл бұрын
David Wheeler: "All problems in computer science can be solved by another level of indirection"
@Wanderer3639
@Wanderer3639 2 жыл бұрын
5 years later, I barely understand what I saw but I just finished the exercise on the code.
@eazypeazy8559
@eazypeazy8559 2 жыл бұрын
Computer science in action be like: gentleman playing lego and telling stories.
@HemmligtNavn
@HemmligtNavn 6 жыл бұрын
should probably also be pointed out that "sean" is located in the stack frame where as anything dynamically allocated lives on the heap. would have been nicer to write sean = (THING*)malloc(sizeof(THING));
@oqardZ
@oqardZ 6 жыл бұрын
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 6 жыл бұрын
oqardZ or just use . It can cope with c++ if it needs to.
@0x0404
@0x0404 6 жыл бұрын
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
@huypt7739
@huypt7739 3 жыл бұрын
It is just a variable for the address. Typedef could be used instead of the cryptic c syntax
@jouebien
@jouebien 6 жыл бұрын
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 6 жыл бұрын
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.
@dipi71
@dipi71 6 жыл бұрын
1:38 Each element didn’t contain a string, it did contain a *pointer to a string.*
@profdaveb6384
@profdaveb6384 6 жыл бұрын
Yes indeed. Apologies for the slip-up .
@necropola
@necropola 6 жыл бұрын
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.
@calabiyou
@calabiyou 3 жыл бұрын
Great talk.
@davidmurphy563
@davidmurphy563 4 жыл бұрын
By "thing" does he mean an instance of an object? And is a "pointer" the memory location?
Triple Ref Pointers - Computerphile
8:28
Computerphile
Рет қаралды 148 М.
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 280 М.
YouTube's Biggest Mistake..
00:34
Stokes Twins
Рет қаралды 46 МЛН
😱СНЯЛ СУПЕР КОТА НА КАМЕРУ⁉
00:37
OMG DEN
Рет қаралды 1,7 МЛН
Kitten has a slime in her diaper?! 🙀 #cat #kitten #cute
00:28
What Are Pointers? (C++)
41:55
javidx9
Рет қаралды 557 М.
Pointers in C / C++ [Full Course]
3:47:23
freeCodeCamp.org
Рет қаралды 3,4 МЛН
How AI 'Understands' Images (CLIP) - Computerphile
18:05
Computerphile
Рет қаралды 122 М.
Where GREP Came From - Computerphile
10:07
Computerphile
Рет қаралды 930 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 314 М.
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 305 М.
Why C is so Influential - Computerphile
10:50
Computerphile
Рет қаралды 1,9 МЛН
YouTube's Biggest Mistake..
00:34
Stokes Twins
Рет қаралды 46 МЛН