Essentials: Pointer Power! - Computerphile

Поделиться
HTML-код
  • Опубликовано: 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

Комментарии • 687

  • @DUANEYAISER
    @DUANEYAISER 6 лет назад +204

    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 7 лет назад +419

    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?

  • @VitruvianSasquatch
    @VitruvianSasquatch 7 лет назад +560

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

    • @sebastianramadan8393
      @sebastianramadan8393 7 лет назад +7

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

    • @procactus9109
      @procactus9109 7 лет назад +4

      Can I guess and just say ARM ?

    • @peterfireflylund
      @peterfireflylund 7 лет назад +27

      SIM cards? Java bytecode, I think.

    • @mausmalone
      @mausmalone 7 лет назад +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 7 лет назад +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.

  • @w.m.4077
    @w.m.4077 7 лет назад +56

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

  • @jrajesh11
    @jrajesh11 4 года назад +102

    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 2 года назад +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..

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

  • @CharlesVanNoland
    @CharlesVanNoland 7 лет назад +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.

  • @unlokia
    @unlokia 7 лет назад +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 7 лет назад +14

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

    • @davor12
      @davor12 7 лет назад +8

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

    • @wir8
      @wir8 7 лет назад +16

      I like Mike Pound too

    • @kiri101
      @kiri101 7 лет назад

      Agreed, with the exception of Robert Miles

    • @yoowon-hye9270
      @yoowon-hye9270 4 года назад

      I love the mentioning of breadth and depth though 😂

  • @memk
    @memk 7 лет назад +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: ...

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

  • @CODcanbefornoobs
    @CODcanbefornoobs 7 лет назад +76

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

    • @sebastianramadan8393
      @sebastianramadan8393 7 лет назад +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?

    • @w花b
      @w花b 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

  • @nateshrager512
    @nateshrager512 6 лет назад +6

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

  • @fakhermokadem11
    @fakhermokadem11 7 лет назад +135

    Please make video on C compiler and how it works.

    • @anant6778
      @anant6778 4 года назад +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”

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

  • @RichardEricCollins
    @RichardEricCollins 7 лет назад +67

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

    • @sebastianramadan8393
      @sebastianramadan8393 7 лет назад +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.

  • @paulmann1289
    @paulmann1289 7 лет назад +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.

  • @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 7 лет назад +519

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

    • @TheMixedupstuff
      @TheMixedupstuff 7 лет назад +38

      That is why I am sticking with managed languages.

    • @MrDiarukia
      @MrDiarukia 7 лет назад +4

      Luckily C# can run natively without interpreter by now

    • @Edgerino
      @Edgerino 7 лет назад +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 7 лет назад +20

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

    • @MrDiarukia
      @MrDiarukia 7 лет назад +3

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

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

  • @JLSoftware
    @JLSoftware 7 лет назад +513

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

    • @sebastianramadan8393
      @sebastianramadan8393 7 лет назад +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 7 лет назад +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 7 лет назад +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 7 лет назад

      correct

    • @peterfireflylund
      @peterfireflylund 7 лет назад +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 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

  • @antonw6455
    @antonw6455 7 лет назад +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.

  • @code-dredd
    @code-dredd 7 лет назад +31

    "You need two fingers" -Prof. Brailsford 😏

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

  • @MPflugga
    @MPflugga 7 лет назад +10

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

  • @glarynth
    @glarynth 7 лет назад +144

    #define 😠 NULL

  • @ambitious1001
    @ambitious1001 7 лет назад +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.

  • @CodyHoskin
    @CodyHoskin 2 года назад

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

  • @morsecode9223
    @morsecode9223 3 года назад +1

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

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

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

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

  • @methodinsane
    @methodinsane 4 года назад

    Love Computerphile. Well done guys.

  • @Halesnaxlors
    @Halesnaxlors 2 года назад +1

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

  • @MECHANISMUS
    @MECHANISMUS Год назад

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

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

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

  • @SebGruch
    @SebGruch 7 лет назад +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.

  • @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 4 года назад +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).

    • @golangismyjam
      @golangismyjam 2 года назад +3

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

  • @conkerconk3
    @conkerconk3 2 года назад +1

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

  • @SjoerdTheDev
    @SjoerdTheDev 7 лет назад

    Very interesting and nice way of visualizing!

  • @theamjolnir9641
    @theamjolnir9641 6 лет назад

    Thank you for the explanation this channel is awesome!

  • @firepower01
    @firepower01 2 года назад

    This is such a good demonstration.

  • @ruroruro
    @ruroruro 7 лет назад +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 7 лет назад +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!

  • @Phalc0n1337
    @Phalc0n1337 7 лет назад +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 7 лет назад +3

      yes you are correct.

    • @AndrewVaca
      @AndrewVaca 7 лет назад +2

      yes, it should

    • @jeffirwin7862
      @jeffirwin7862 7 лет назад +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 7 лет назад +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 7 лет назад

      If the next pointer was the first value it would have technically been correct.

  • @aeebeecee3737
    @aeebeecee3737 3 года назад

    This channel has high quality contents.

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

  • @gbbsc
    @gbbsc 7 лет назад

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

  • @akashverma5756
    @akashverma5756 Год назад

    I can listen to him for hours.

  • @NeuroDeveloper
    @NeuroDeveloper 4 года назад +8

    Imagine this guy on a modular synthesizer.

  • @jonathanbecker6373
    @jonathanbecker6373 7 лет назад

    That model is delightful.

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

  • @morgwild
    @morgwild 5 лет назад

    I love this man.

  • @landon5030
    @landon5030 Месяц назад

    This man is amazing with his explanations

  • @nap3xdnicholas_3infosec23
    @nap3xdnicholas_3infosec23 2 года назад

    This was amazing, thank you sir. Cheers.

  • @diverfede
    @diverfede 6 лет назад

    his teaching is fantastic!

  • @Morax
    @Morax 5 лет назад +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.

  • @diamondtroller1253
    @diamondtroller1253 3 года назад

    Brilliant explanation!

  • @synchronizerman
    @synchronizerman 7 лет назад

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

  • @XKCDism
    @XKCDism 6 лет назад

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

  • @GameCyborgCh
    @GameCyborgCh 3 года назад

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

  • @dancingbubbles1126
    @dancingbubbles1126 4 года назад +6

    "Demon programmer," such a cool phrase.

  • @IllidanS4
    @IllidanS4 7 лет назад +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.

  • @aeebeecee3737
    @aeebeecee3737 3 года назад

    The best video about pointer

  • @krishcm3016
    @krishcm3016 4 года назад

    Great explanation!

  • @busyrand
    @busyrand 7 лет назад

    Beautiful. I really appreciate this and learned allot.

  • @dinoflame9696
    @dinoflame9696 6 лет назад

    Love this guy

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

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

  • @mikesummers-smith4091
    @mikesummers-smith4091 4 года назад

    May your pointers never dangle!

  • @computersagain
    @computersagain 6 лет назад

    He is such goals.

  • @caprica9240
    @caprica9240 7 лет назад +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.

  • @dipi71
    @dipi71 7 лет назад +3

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

    • @profdaveb6384
      @profdaveb6384 7 лет назад +6

      Yes indeed. Apologies for the slip-up .

  • @huypt7739
    @huypt7739 3 года назад

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

  • @mkuroglu
    @mkuroglu 3 года назад

    Much respect

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

  • @LowescC
    @LowescC 2 года назад

    fantastic.... thank you..

  • @dewdop
    @dewdop 3 года назад

    What an endearing fellow.

  • @davidmurphy563
    @davidmurphy563 4 года назад

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

  • @khadijahflowers5566
    @khadijahflowers5566 7 лет назад

    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?

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

  • @Bl00drav3nz
    @Bl00drav3nz 7 лет назад

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

  • @Wanderer3639
    @Wanderer3639 2 года назад

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

  • @KaletheQuick
    @KaletheQuick 7 лет назад

    This guy is my favorite :D

  • @zenmaster24
    @zenmaster24 7 лет назад +1

    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.

  • @codeman99-dev
    @codeman99-dev 7 лет назад +17

    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 лет назад +1

      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.

  • @philipgeorge1253
    @philipgeorge1253 7 лет назад +35

    i love the idea of indentation wars

  • @shantanusharma5624
    @shantanusharma5624 2 года назад

    Thanks to learning c I understood pointers very well

  • @calabiyou
    @calabiyou 4 года назад

    Great talk.

  • @nexusclarum8000
    @nexusclarum8000 5 лет назад +1

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

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

  • @LadyTink
    @LadyTink 4 года назад +1

    pointers are amazing.
    I abuse them while making games all the time.

  • @ttthttpd
    @ttthttpd 7 лет назад +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 7 лет назад +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.

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

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

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

  • @mohammadshahabrafiq
    @mohammadshahabrafiq 11 месяцев назад

    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.

  • @emmanuelokose6713
    @emmanuelokose6713 Год назад

    nobody is talking about his great voice