Essentials: Pointer Power! - Computerphile

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ส.ค. 2017
  • 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

ความคิดเห็น • 686

  • @DUANEYAISER
    @DUANEYAISER 6 ปีที่แล้ว +199

    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.

  • @MrSlowestD16
    @MrSlowestD16 6 ปีที่แล้ว +414

    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 ปีที่แล้ว +20

      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 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +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 ปีที่แล้ว +2

      @@MrSlowestD16 ah, i guess, but C is more... elegant? uncomplicated?

  • @w.m.4077
    @w.m.4077 6 ปีที่แล้ว +55

    "We're gonna use lego to explain linked lists"
    Oh my lord I think I'm in love with this man...

  • @VitruvianSasquatch
    @VitruvianSasquatch 6 ปีที่แล้ว +559

    Everyone complaining that their language is better and doesn't need pointers, try coding on small microcontrollers. They are useful.

    • @sebastianramadan8393
      @sebastianramadan8393 6 ปีที่แล้ว +7

      Please remind me, what kind of machine bytecode does a SIM card execute?

    • @procactus9109
      @procactus9109 6 ปีที่แล้ว +4

      Can I guess and just say ARM ?

    • @peterfireflylund
      @peterfireflylund 6 ปีที่แล้ว +27

      SIM cards? Java bytecode, I think.

    • @mausmalone
      @mausmalone 6 ปีที่แล้ว +39

      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 ปีที่แล้ว +51

      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.

  • @jrajesh11
    @jrajesh11 4 ปีที่แล้ว +97

    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 ปีที่แล้ว +13

      That's an excellent example, not sure I've ever heard it explained that way.

    • @paulspl2581
      @paulspl2581 2 ปีที่แล้ว +2

      great metaphor

    • @phanhung485
      @phanhung485 2 ปีที่แล้ว

      What if that train transports both people and cargos together?

    • @mattbox87
      @mattbox87 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +76

    It took me a year to figure out how pointers work, I'm glad I didn't give up

    • @sebastianramadan8393
      @sebastianramadan8393 6 ปีที่แล้ว +8

      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 ปีที่แล้ว +1

      You should try harder. Didn't you notice that the code is wrong?

    • @whannabi
      @whannabi 2 ปีที่แล้ว +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 ปีที่แล้ว +28

    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 ปีที่แล้ว +162

    (void*)
    Now things get interesting

    • @KangJangkrik
      @KangJangkrik 3 ปีที่แล้ว +11

      Me: grahhh I need to restart my brain
      The code: void(* resetFunc) (void) = 0;
      Me: ...

  • @unlokia
    @unlokia 6 ปีที่แล้ว +194

    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 ปีที่แล้ว +14

      And we now know his diet: Burgers, chips and beer. Great selection! :)

    • @davor12
      @davor12 6 ปีที่แล้ว +8

      ....and thinks HTML is a programming language.

    • @wir8
      @wir8 6 ปีที่แล้ว +16

      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 ปีที่แล้ว +135

    Please make video on C compiler and how it works.

    • @anant6778
      @anant6778 3 ปีที่แล้ว +10

      that's a web series of 5 or more seasons and 10 ep in one season

    • @skhotzim_bacon
      @skhotzim_bacon 3 ปีที่แล้ว +6

      Lol that would be a very long video but I'd watch it

    • @divanvanzyl7545
      @divanvanzyl7545 3 ปีที่แล้ว +2

      Someone should do that though

    • @skhotzim_bacon
      @skhotzim_bacon 3 ปีที่แล้ว +2

      @@divanvanzyl7545 Read the documentation on the C compiler

    • @gumbilicious1
      @gumbilicious1 3 ปีที่แล้ว +1

      @@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”

  • @CharlesVanNoland
    @CharlesVanNoland 6 ปีที่แล้ว +10

    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.

  • @nateshrager512
    @nateshrager512 6 ปีที่แล้ว +6

    Intellectual older folks develop such great voices and habits of speech. So nice to listen to

  • @aplcc323
    @aplcc323 3 ปีที่แล้ว +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 (:

  • @RichardEricCollins
    @RichardEricCollins 6 ปีที่แล้ว +67

    Great explanation, using lego is a great leaning tool. Pointers are one of C's most powerful tools.

    • @sebastianramadan8393
      @sebastianramadan8393 6 ปีที่แล้ว +4

      Yeh... screw procedural abstraction! Pointers make C turing complete, almost entirely by themselves! -coughs-

    • @MrPolluxxxx
      @MrPolluxxxx 6 ปีที่แล้ว +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.

  • @kandysman86
    @kandysman86 5 ปีที่แล้ว +8

    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 ปีที่แล้ว +520

    char ***avp = &argv;
    Enough to scare most programmers!

    • @TheMixedupstuff
      @TheMixedupstuff 6 ปีที่แล้ว +38

      That is why I am sticking with managed languages.

    • @MrDiarukia
      @MrDiarukia 6 ปีที่แล้ว +4

      Luckily C# can run natively without interpreter by now

    • @Edgerino
      @Edgerino 6 ปีที่แล้ว +74

      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 ปีที่แล้ว +20

      Edgerino, strictly, there's no guarantee argv is a pointer.

    • @MrDiarukia
      @MrDiarukia 6 ปีที่แล้ว +3

      Isn't the & there to make it a pointer to whatever argv represents?

  • @jessesullivan4811
    @jessesullivan4811 6 ปีที่แล้ว +4

    Though all this information has been hammered into me since my freshman year at uni, I just love hearing him talk about this.

  • @glarynth
    @glarynth 6 ปีที่แล้ว +144

    #define 😠 NULL

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 4 ปีที่แล้ว +10

      char* a = 😬;

    • @ajtan2607
      @ajtan2607 3 ปีที่แล้ว +1

      This thread is 😂.

    • @KangJangkrik
      @KangJangkrik 3 ปีที่แล้ว

      @E K with UTF-8 configuration, maybe

  • @paulmann1289
    @paulmann1289 6 ปีที่แล้ว +3

    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.

  • @morsecode9223
    @morsecode9223 2 ปีที่แล้ว +1

    Clearly understood after 3 years of struggling,all thanks to you sir.
    Thank you.

  • @code-dredd
    @code-dredd 6 ปีที่แล้ว +31

    "You need two fingers" -Prof. Brailsford 😏

  • @chamalinni
    @chamalinni 4 ปีที่แล้ว +21

    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 ปีที่แล้ว +3

      Latin American isn't a language tho

    • @cmyk8964
      @cmyk8964 2 ปีที่แล้ว +10

      @@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 ปีที่แล้ว +3

      @@cmyk8964 American english is not very different at all compared to British English. The difference is a handful of words and spellings.

  • @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.

  • @Halesnaxlors
    @Halesnaxlors 2 ปีที่แล้ว +1

    A nice and concise explanation. Just what I needed to refresh. Thanks!

  • @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!

  • @CodyHoskin
    @CodyHoskin 2 ปีที่แล้ว

    I love this guy. You can learn so much from him.

  • @MPflugga
    @MPflugga 6 ปีที่แล้ว +10

    19:32 This simple trick will solve all of your programming problems!

  • @MECHANISMUS
    @MECHANISMUS ปีที่แล้ว

    Explaining a simpler subject by means of a more complex subjects is a THING to behold.

  • @methodinsane
    @methodinsane 4 ปีที่แล้ว

    Love Computerphile. Well done guys.

  • @JLSoftware
    @JLSoftware 6 ปีที่แล้ว +515

    He never even said what a pointer is - an integer specifying a memory location!

    • @sebastianramadan8393
      @sebastianramadan8393 6 ปีที่แล้ว +94

      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 ปีที่แล้ว +66

      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 ปีที่แล้ว +143

      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 ปีที่แล้ว +40

      Probably 'cause they *aren't* just integers. They are abstract references that may be *implemented* as simple integers... or they may not.

  • @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

  • @ambitious1001
    @ambitious1001 6 ปีที่แล้ว +1

    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.

  • @aeebeecee3737
    @aeebeecee3737 3 ปีที่แล้ว

    This channel has high quality contents.

  • @shivashankar28
    @shivashankar28 5 ปีที่แล้ว +3

    I am a C guy and I can't live without pointers too. Pointers are a magical creatures !! A Truly magical beast

  • @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.

  • @antonw6455
    @antonw6455 6 ปีที่แล้ว +2

    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.

  • @firepower01
    @firepower01 ปีที่แล้ว

    This is such a good demonstration.

  • @Phalc0n1337
    @Phalc0n1337 6 ปีที่แล้ว +50

    @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 ปีที่แล้ว +3

      yes you are correct.

    • @AndrewVaca
      @AndrewVaca 6 ปีที่แล้ว +2

      yes, it should

    • @jeffirwin7862
      @jeffirwin7862 6 ปีที่แล้ว +17

      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 ปีที่แล้ว +1

      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.

  • @jonathanbecker6373
    @jonathanbecker6373 6 ปีที่แล้ว

    That model is delightful.

  • @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

  • @SjoerdTheDev
    @SjoerdTheDev 6 ปีที่แล้ว

    Very interesting and nice way of visualizing!

  • @landon5030
    @landon5030 3 วันที่ผ่านมา

    This man is amazing with his explanations

  • @SebGruch
    @SebGruch 6 ปีที่แล้ว +38

    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 ปีที่แล้ว +1

      It's very important. Thanks.

    • @chrikrah
      @chrikrah 5 ปีที่แล้ว

      I was thinking that, too. That's for confirming my suspicion.

  • @akashverma5756
    @akashverma5756 ปีที่แล้ว

    I can listen to him for hours.

  • @aeebeecee3737
    @aeebeecee3737 3 ปีที่แล้ว

    The best video about pointer

  • @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

  • @NeuroDeveloper
    @NeuroDeveloper 4 ปีที่แล้ว +8

    Imagine this guy on a modular synthesizer.

  • @theamjolnir9641
    @theamjolnir9641 6 ปีที่แล้ว

    Thank you for the explanation this channel is awesome!

  • @diamondtroller1253
    @diamondtroller1253 3 ปีที่แล้ว

    Brilliant explanation!

  • @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.

  • @user-eg6xu7cr8e
    @user-eg6xu7cr8e 4 ปีที่แล้ว +3

    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!

  • @nap3xdnicholas_3infosec23
    @nap3xdnicholas_3infosec23 2 ปีที่แล้ว

    This was amazing, thank you sir. Cheers.

  • @conkerconk3
    @conkerconk3 2 ปีที่แล้ว +1

    doing this sort of "lower level" memory manipulation like pointers... idk why but its so fun and awesome to do

  • @diverfede
    @diverfede 6 ปีที่แล้ว

    his teaching is fantastic!

  • @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.

  • @krishcm3016
    @krishcm3016 4 ปีที่แล้ว

    Great explanation!

  • @XKCDism
    @XKCDism 6 ปีที่แล้ว

    I never would of thought of demonstrating this idea in Lego. brilliant

  • @LowescC
    @LowescC 2 ปีที่แล้ว

    fantastic.... thank you..

  • @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 :)

  • @busyrand
    @busyrand 6 ปีที่แล้ว

    Beautiful. I really appreciate this and learned allot.

  • @dancingbubbles1126
    @dancingbubbles1126 4 ปีที่แล้ว +6

    "Demon programmer," such a cool phrase.

  • @morgwild
    @morgwild 5 ปีที่แล้ว

    I love this man.

  • @ruroruro
    @ruroruro 6 ปีที่แล้ว +3

    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.

  • @edcrypt
    @edcrypt 6 ปีที่แล้ว +2

    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!

  • @GameCyborgCh
    @GameCyborgCh 3 ปีที่แล้ว

    i wish my professor for introductory programming (C++) used this to explain what a pointer is and how it works

  • @mkuroglu
    @mkuroglu 3 ปีที่แล้ว

    Much respect

  • @dinoflame9696
    @dinoflame9696 6 ปีที่แล้ว

    Love this guy

  • @shantanusharma5624
    @shantanusharma5624 2 ปีที่แล้ว

    Thanks to learning c I understood pointers very well

  • @gbbsc
    @gbbsc 6 ปีที่แล้ว

    Can you do a profile video for professor Brailsford? I'd love to know more about this interesting man.

  • @computersagain
    @computersagain 6 ปีที่แล้ว

    He is such goals.

  • @calabiyou
    @calabiyou 3 ปีที่แล้ว

    Great talk.

  • @dewdop
    @dewdop 3 ปีที่แล้ว

    What an endearing fellow.

  • @philipgeorge1253
    @philipgeorge1253 6 ปีที่แล้ว +35

    i love the idea of indentation wars

  • @mikesummers-smith4091
    @mikesummers-smith4091 4 ปีที่แล้ว

    May your pointers never dangle!

  • @IllidanS4
    @IllidanS4 6 ปีที่แล้ว +1

    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.

  • @Morax
    @Morax 4 ปีที่แล้ว +2

    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.

  • @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?!

  • @davidmurphy563
    @davidmurphy563 4 ปีที่แล้ว

    By "thing" does he mean an instance of an object? And is a "pointer" the memory location?

  • @caprica9240
    @caprica9240 6 ปีที่แล้ว +2

    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.

  • @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.

  • @KaletheQuick
    @KaletheQuick 6 ปีที่แล้ว

    This guy is my favorite :D

  • @synchronizerman
    @synchronizerman 6 ปีที่แล้ว

    You can also use sentinels to avoid many of the special cases.

  • @yankomirov4290
    @yankomirov4290 5 ปีที่แล้ว

    If only my professors were like Professor Brailsford... life would be so much more easier

  • @ttthttpd
    @ttthttpd 6 ปีที่แล้ว +21

    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 ปีที่แล้ว +9

      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.

  • @Spongman
    @Spongman 6 ปีที่แล้ว +14

    "3rd year undergrads". wow, what do they do the 1st two years?

  • @nexusclarum8000
    @nexusclarum8000 5 ปีที่แล้ว +1

    David Wheeler: "All problems in computer science can be solved by another level of indirection"

  • @mohammadshahabrafiq
    @mohammadshahabrafiq 10 หลายเดือนก่อน

    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.

  • @necropola
    @necropola 6 ปีที่แล้ว +16

    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.

  • @huypt7739
    @huypt7739 3 ปีที่แล้ว

    It is just a variable for the address. Typedef could be used instead of the cryptic c syntax

  • @dipi71
    @dipi71 6 ปีที่แล้ว +3

    1:38 Each element didn’t contain a string, it did contain a *pointer to a string.*

    • @profdaveb6384
      @profdaveb6384 6 ปีที่แล้ว +6

      Yes indeed. Apologies for the slip-up .

  • @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.

  • @romanemul1
    @romanemul1 6 ปีที่แล้ว

    my wish has been fulfilled.

  • @waqar_asgar__r7294
    @waqar_asgar__r7294 6 ปีที่แล้ว

    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.

  • @darogajee3286
    @darogajee3286 6 ปีที่แล้ว

    They are just dope to me...

  • @Bl00drav3nz
    @Bl00drav3nz 6 ปีที่แล้ว

    14:45 this is a pretty good visualization of how linked lists induce lots of cache misses

  • @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.

  • @Wanderer3639
    @Wanderer3639 2 ปีที่แล้ว

    5 years later, I barely understand what I saw but I just finished the exercise on the code.

  • @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?

  • @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.

  • @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.