Essentials: Pointer Power! - Computerphile

preview_player
Показать описание
Pointers are fundamental in programming and Professor Brailsford couldn't live without them!

Many thanks to Microsoft Research UK for their support with the 'Essentials' mini-series.

This video was filmed and edited by Sean Riley.

Рекомендации по теме
Комментарии
Автор

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.

MrSlowestD
Автор

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.

CharlesVanNoland
Автор

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.)

unlokia
Автор

What a lovely guy, and a beautiful way of explaining pointers. He locked me to the screen for 20 min.

xOWSLA
Автор

Please make video on C compiler and how it works.

fakhermokadem
Автор

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

Phalcn
Автор

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

morsecode
Автор

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.

blakethingstad
Автор

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.

morfanaion
Автор

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

egxucre
Автор

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

SebGruch
Автор

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.

peterdegelaen
Автор

16:07 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.

codeman-dev
Автор

The professor is talking about linked lists. Links might be implemented as pointers (Strachey-style CPL/C style), but they are abstractly different. Links are between logical data objects, pointers are to blocks of memory.

ijoyner
Автор

This man is amazing with his explanations

landon
Автор

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

CodyHoskin
Автор

Bro 100% brings wine to a bbq and I respect that attitude.

blacktinibis
Автор

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.

necropola
Автор

Pointers are a concrete realization of a reference, the former in practice, the latter in theory.

IllidanS
Автор

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.

vephovandenberg
visit shbcf.ru