16 votes

Reinventing notebooks as reusable Python programs

10 comments

  1. [8]
    scarecrw
    Link
    I love the idea of notebooks, but have been confused by where they have and haven't become popular. I was first introduced to their use for data analysis, mostly by non-programmers, and in that...

    I love the idea of notebooks, but have been confused by where they have and haven't become popular. I was first introduced to their use for data analysis, mostly by non-programmers, and in that context their popularity seemed to stem from being a friendlier environment than a traditional write-compile-test-iterate workflow. I don't know how it got popular in the ML world, perhaps just as an extension of data analysis? The article mentions it being "the only programming environment that let you see your data while you worked on it", but that seems like an overstatement.

    Regardless, I'd love to see them used more as a way to bridge the programmer vs non-programmer gap. It's a great way to share mixed-level content, where those with experience with programming can see and tinker with the document, and those without can still read a narrative and see the results. I haven't seen it yet, but I would love to see something like Wolfram notebooks become a standard format for math textbooks or similar.

    5 votes
    1. [7]
      JesusShuttlesworth
      Link Parent
      Personally I think all intro to programming classes should be taught with notebooks. Especially considering that you can just share a co lab link with an entire lesson plan.

      Personally I think all intro to programming classes should be taught with notebooks. Especially considering that you can just share a co lab link with an entire lesson plan.

      4 votes
      1. [6]
        Greg
        Link Parent
        It's a tricky tradeoff, though - notebooks are great for exploring concepts and getting instant feedback on what you're doing, but they actively encourage bad habits around scope and state...

        It's a tricky tradeoff, though - notebooks are great for exploring concepts and getting instant feedback on what you're doing, but they actively encourage bad habits around scope and state handling in general. Lots of globals, almost no modularity, and a structure that lends itself to treating the whole program as a top to bottom procedural script rather than a composable collection of functions.

        I get that all this probably sounds premature for a class where you're explaining what a for loop does, but the problem I see is where to then make that cutover and say "now ditch this environment you've just spent N weeks getting used, unlearn your assumptions, and pick up a whole different one".

        If anything I'd say you want something less capable than a notebook for intro classes: some kind of notebook-style environment where you can test out a few lines of code and submit an answer to a homework problem makes sense, but you want the students to hit the limitations and naturally grow into using a more scalable dev environment relatively quickly. Jupyter is just capable enough that people can and will put multi-thousand-line pieces of serious work in there, and that's not good for anybody in the long run.

        4 votes
        1. [2]
          JesusShuttlesworth
          Link Parent
          Reminds me of programming 2 in Java where we were suddenly forced to learn vim. Talk about a mind blower.

          but the problem I see is where to then make that cutover and say "now ditch this environment you've just spent N weeks getting used, unlearn your assumptions, and pick up a whole different one".

          Reminds me of programming 2 in Java where we were suddenly forced to learn vim. Talk about a mind blower.

          1 vote
          1. Greg
            (edited )
            Link Parent
            Oof, I'm two and a half decades in at this and I never did really get vim, that sounds like a brick wall of a learning curve. I will say I'm forever grateful to the professor who made us submit...

            Oof, I'm two and a half decades in at this and I never did really get vim, that sounds like a brick wall of a learning curve. I will say I'm forever grateful to the professor who made us submit assignments in LaTeX, though! I just use markdown 99% of the time nowadays, but when you've got to typeset something mathematical there's still no substitute.

            3 votes
        2. [3]
          Akir
          Link Parent
          That’s just what education tends to be. An American child might think that Christopher Columbus was a hero for discovering the Americas and then later in their schooling about the slaves he took...

          I get that all this probably sounds premature for a class where you're explaining what a for loop does, but the problem I see is where to then make that cutover and say "now ditch this environment you've just spent N weeks getting used, unlearn your assumptions, and pick up a whole different one".

          That’s just what education tends to be. An American child might think that Christopher Columbus was a hero for discovering the Americas and then later in their schooling about the slaves he took back with him.

          Programming is complex. You could try to teach the whole concept and good practices at once but then risk them not understanding. Likewise teachers will often omit important information about how things work to ensure that students learn the basic skill of using a particular function or whatnot. It is, for instance, rather fruitless to tell a student that String.format() is a method when they do not yet understand what objects are.

          For the record, I’m still something of a believer in concepts-first education for programming. But I am teaching programming to kids in a program that has a mandated curriculum and is built around delivering finished programs which demands students to produce code. But I walk them through the code so thoroughly it doesn’t usually feel like they are the ones who are actually writing their code.

          1 vote
          1. [2]
            Greg
            (edited )
            Link Parent
            That makes sense, and I'm certainly not objecting to simplification or suggesting that students need a full theoretical basis before they go hands on - I just think that notebooks as they exist...

            That makes sense, and I'm certainly not objecting to simplification or suggesting that students need a full theoretical basis before they go hands on - I just think that notebooks as they exist aren't quite one thing or another. If anything I'm saying they're actually too powerful for the job! It's the "unlearning" part that bothers me, more than anything; I'd rather a more limited environment than a flexible one where exploration leads to the wrong conclusions.

            What I'm envisaging is things like the teacher pre-setting the import statements so they aren't editable, only allowing one cell to be used for a given problem (maybe even with a maximum number of lines), that kind of thing. Not "you have to learn to use fully featured dev environment before you start" or anything like that, more "once you're growing beyond the scope of the teaching environment, you're pushed into learning the real tools to keep going".

            With a fully featured notebook as things stand now you don't need to take that step to doing things "properly" as your skills grow, and from what I'm seeing that leads to using the notebook as a safe, familiar hammer when learning about screwdrivers would be more beneficial.


            [Edit] Just to be super clear, I'm thinking of everything above in an educational context - there can be totally valid reasons a developer might choose to use a notebook for a specific task, but it's a different situation when it's the only thing someone's learned.

            2 votes
            1. Akir
              Link Parent
              In my personal opinion, as someone who is pretty far away from data science, is that notebooks have one killer feature; you can have pretty documentation written in them. And then it has niceties,...

              In my personal opinion, as someone who is pretty far away from data science, is that notebooks have one killer feature; you can have pretty documentation written in them. And then it has niceties, like letting you execute just one cell or being able to split things into pages. When I quit my job a while back it had been a long time since I had used python, so I skimmed through an online course to refamilliarize myself with the syntax. It used Jupyter notebooks, and I thought it was a really great tool.

              But at the same time, i don’t see why they’re used for anything critical. Apparently it was made for data science in particular, and as the author of this piece states, it allows users to see both the data and code at the same time. But I, for one, appreciate the separation of data and code. If you have a notebook that isn’t reproducible and is highly prone to user error, then it seems like a bad tool. But I’m sure that I’m missing a lot of the reasons why people are choosing to use them.

              2 votes
  2. JesusShuttlesworth
    Link
    Can anyone vouch for this framework? Sounds decent but the article is obviously from the folks who make it.

    Can anyone vouch for this framework? Sounds decent but the article is obviously from the folks who make it.

    4 votes
  3. fxgn
    (edited )
    Link
    Jupyter notebook sucks. It's weird that nothing better exists for python. Don't get me wrong, it was probably an awesome tool when it got first released, but since then, tools like Pluto for Julia...

    Jupyter notebook sucks. It's weird that nothing better exists for python. Don't get me wrong, it was probably an awesome tool when it got first released, but since then, tools like Pluto for Julia or LiveBook for Elixir have been made, which are so so much better. It's insane how, for example, you can get a different result in Jupyter by running cells twice or in the wrong order.

    (Though LiveBook is working on python support now, but it's still a second class citizen there)