Lecture 8 | Programming Paradigms (Stanford)

Поділитися
Вставка
  • Опубліковано 5 лют 2025

КОМЕНТАРІ • 41

  • @qazimashhood
    @qazimashhood 7 місяців тому +2

    This lecture alone is worth my entire programming career, absolutely gold.

  • @AaronCohn84
    @AaronCohn84 12 років тому +8

    Can't emphasize enough how valuable this insight into what's going on behind the scenes is. The people who make it through this and the other lectures will be more aware of those nuances and their consequences.

  • @Krzysztow1985
    @Krzysztow1985 14 років тому +3

    I really like the way He explains everything. So easy, yet so good! thank You Stanford for sharing those lectures.

  • @mohamed-hassan-
    @mohamed-hassan- 7 місяців тому

    my god all of these things happen with memory, and we take it for granted.. cannot fathom the idea of this course being free.

  • @ManavAgarwal-n9u
    @ManavAgarwal-n9u 10 місяців тому

    No assignment is random, I mean they took care that even how they stored data in assignment 2, was on the same lines so students can get good feel of it before this lecture. I am blown away. Professor Jerry Cain and TAs thanks a lot.

    • @qazimashhood
      @qazimashhood 7 місяців тому

      hi user, can you link to the assignment repo for this course for this specific year?

  • @maengu2
    @maengu2 6 років тому +2

    Full of insight in every sentence. Thank you!

  • @gobwas
    @gobwas 8 років тому +6

    This is a golden lectures! =) Thanks!

  • @Qladstone
    @Qladstone 2 роки тому

    Finally getting to the interesting part in the last part of the lecture.

  • @Arashyou18
    @Arashyou18 13 років тому

    He is really good, easy, complete and precise.

  • @paulchen355
    @paulchen355 3 роки тому

    this intro class is gold !! my college's intro class was meh...

  • @riteshbajaj6
    @riteshbajaj6 11 років тому +1

    just great !! The professor rocks..

  • @tomnichlson
    @tomnichlson 15 років тому

    You mean the mac os bit? Basically just saying that when you compact the heal you change the pointers to the beginning of each allocated block,. they had a compactable heap (which I guess is not really necessary now ram is so cheap compared to processing power) with a seperate memory block that would hold the pointers memory blocks in that section the heap (handle) so that when compacted and the memory changed, the client could still access the data correctly

  • @brodigy254
    @brodigy254 8 років тому

    Very usefull lecrute.Thx!

  • @sabriath
    @sabriath 14 років тому +1

    the structure I like using for Heap implimentation is: void*Prev; void*Next; void*NextFree; int ThisSize; It fits boundary and makes it easier to link in and out for the nodes. The parent is pointing to dummy nodes at beginning and end of heap space. But that's just how I do it *shrugs*

  • @Maisonier
    @Maisonier 5 років тому +1

    Year 2019, there is no AI yet that organize the heap memory for better performance?

  • @ypey1
    @ypey1 12 років тому +1

    This makes sence man!

  • @orlowska3
    @orlowska3 15 років тому +1

    yes it happens also on youtube university:D

  • @AyanTazhibayev
    @AyanTazhibayev 11 років тому +9

    He says -"I've got about 25 seconds."
    My god do they keep track of the lectures down till seconds?!

  • @girlyvoice3210
    @girlyvoice3210 12 років тому

    At around 16:30 he doesn't seem to explain how the size of each 'free' block is known by malloc/realloc. He explains how the location of the next free node is known but not the length of the region. Surely it needs to store the length of the free block also? I cannot be calculated by subtracting the node addresses for example.

  • @sfBlackFox
    @sfBlackFox 13 років тому +1

    @wobblejuice I think it's the lack of prof Mehran Sahami :)

  • @TreacleMary
    @TreacleMary 13 років тому

    "Does that make sense to people?" x 1000

  • @cjsalda
    @cjsalda 15 років тому +1

    the part how the heap get compacted kill me

  • @wobblejuice
    @wobblejuice 16 років тому +1

    a lot less views than from the first lecture. people dropping off like flies.

  • @pgsinitsyn
    @pgsinitsyn 7 років тому

    Sorry, but www.CS107.stanford.edu/ doesn't work anymore. Instead, web.stanford.edu/class/cs107/ should be used

  • @RepublikSivizien
    @RepublikSivizien 7 років тому

    Good video, does this makes sense? I now understand a lot more, does this makes sense to people? Ok?

  • @vichin28
    @vichin28 8 років тому

    So I made an experiment:
    Main()
    {
    A();
    B();
    Return 0;
    }
    A()
    {
    Char string[]="test";
    }
    B()
    {
    Char newstring[5];
    Printf("%s
    ", newstring);
    }
    Does anyone know why it doesn't work?

    • @sealwithawkwardness3951
      @sealwithawkwardness3951 8 років тому

      First off, what are you trying to accomplish here? What do you mean it doesn't work?
      If you are trying to print "test" to the screen, string and newstring are two different character arrays, which are not scoped in.

    • @vichin28
      @vichin28 8 років тому

      1) yes, I was trying to print "test"
      considering both functions have the same (in theory) local variables, in the same locations in memory, the second function should pick up "test" as a garbage value

    • @sealwithawkwardness3951
      @sealwithawkwardness3951 8 років тому +1

      It actually does not have the same local variables. The two variables inside the function A and B are stored in two different locations. If you wanted B to get the string, you'd have to call A which returns or has an out parameter for the string. Then store it in newstring.

    • @vichin28
      @vichin28 8 років тому

      So I compiled it again, to try to fix whatever the problem was.
      It works! I have no idea why it does now but it didn't when I commented that.
      Code (works in both gcc and clang in linux):
      ----
      #include
      void A()
      {
      char string[] = "test";
      }
      void B()
      {
      char newstring[5];
      printf("%s
      ", newstring);
      }
      int main()
      {
      A();
      B();
      return 0;
      }
      ----
      if you put printf("%p
      ")s in each function, you should see that they're the same adresses
      Edit: tried it on termux and it didn't work until I put the lines to print the adresses. Looks like it's implementation dependant unless you do that.

    • @sealwithawkwardness3951
      @sealwithawkwardness3951 8 років тому

      Interesting, but not surprised. When you call a function it is placed on the stack and the stack pointer is incremented. Once it returns the function gets popped off the stack and the pointer gets decremented. If the functions have similar structures I'm sure the some of the variables will have the same address in the stack as the other variables from different functions, depending on how the function gets called.
      So lets say you called A inside B, after you print out the address. You should get a different address for it's variable from the first call you did to A, correct?
      Try saving the string. Use a void* which is globally visible, and set it to one of the strings inside the functions. Cast it and print it in the main function, what do you get? I'm gonna guess something that looks like garbage

  • @Realitydenizen
    @Realitydenizen 13 років тому +2

    *glug*

  • @DukeMcManhands
    @DukeMcManhands 13 років тому +1

    I like the way he says "Mmm" after everything. Kind of sexy.

  • @maiajikhvadze9404
    @maiajikhvadze9404 11 років тому +1

    druble O.o

  • @AstralAbraxas
    @AstralAbraxas 15 років тому

    don't know why... what he's saying is common sense really =/ the only problem i can see people having is if they aren't familiar with the terminology.

  • @TheOhyaaa
    @TheOhyaaa 11 років тому

    potato

  • @johncameron7319
    @johncameron7319 7 років тому

    P.S. If you want to learn C I suggest you will not learn much from CS 107. The professor that they all rave about makes more errors than you can shake a stick at.