Slashdot Mirror


A Better Way To Program

mikejuk writes "This video will change the way you think about programming. The argument is clear and impressive — it suggest that we really are building programs with one hand tied behind our backs. Programmers can only understand their code by pretending to be computers and running it in their heads. As this video shows, this is increadibly inefficient and, as we generally have a computer in front of us, why not use it to help us understand the code? The key is probably interactivity. Don't wait for a compile to complete to see what effect your code has on things — if you can see it in real time then programming becomes much easier."

28 of 467 comments (clear)

  1. Great but... by Anonymous Coward · · Score: 5, Interesting

    Seems like it mostly only applies to GUI programming or programming with results expressed through a GUI. What about, say, kernel programming?

    1. Re:Great but... by viperidaenz · · Score: 5, Funny

      Visualise them kernel then. They didn't have any problems in The Matrix.

    2. Re:Great but... by spyked · · Score: 5, Insightful

      That sounds simple but it isn't. While you could theoretically do this from a virtual machine, the difference between visualising” it and testing it on real hardware is significant especially when it comes to device drivers, which are known to be the most common source of bugs in kernels.

      Plus verifying a kernel or a compiler is a pretty hard problem, it's a miracle if you manage to do it in decent time, let alone manage to visualise it in any way.

    3. Re:Great but... by blahplusplus · · Score: 4, Informative

      You didn't see the point when he showed how you could find bugs in algorithms as you typed them.

    4. Re:Great but... by Junta · · Score: 5, Insightful

      In the video he covers that as well. Well, at least he conceptually says its covered, I disagree...

      Lets start with his abstract example. His binary search on the surface looks straightforward and he wanted to portray it as magically finding bugs as he got a float in one instance and an infinite loop in another. However the infinite loop example was found because he *knew* what he was doing as he intentionally miswrote it to start with and intentionally changed the inputs in accordance with this knowledge. There are a few more possibilities that you have to *know* to try out. For example, he didn't try a value that was lower than the lowest (would have panned out), he didn't try a value omitted from the list but still higher than the lowest and lower than the highest (which also would have been fine) and he didn't try an unordered list (which is incorrect usage, but accounting for incorrect usage is a fact of life). He didn't try varying dataset sizes (in this algorithm doesn't matter, but he has to *know* that) and different types of data. You still have the fact that 'B' is smaller than 'a' and all sorts of 'non-intuitive' things inherent in the situation.

      Now consider that binary search is a freshman level programming problem and therefore is pretty low in terms of the complexity a developer is going to deal with. Much of software development will deal with far more complicated scenarios than this, and the facility doesn't *really* cover even the binary search complexity.

      I know I may sound more negative than is appropriate, but his enthusiasm and some people's buy-in can be risky. I've seen poor developers suckered in by various 'silver bullets' and produce lower quality code because they think that unit test or other mechanisms passed and they can reast easy. Using these tools is good, but always should be accompanied with some wariness to avoid overconfidence.

      --
      XML is like violence. If it doesn't solve the problem, use more.
    5. Re:Great but... by sjames · · Score: 5, Funny

      What about, say, kernel programming?

      If you enter a syntax error, you get a video of Orville Redenbacher ripping you a new one.

    6. Re:Great but... by BasilBrush · · Score: 4, Insightful

      However the infinite loop example was found because he *knew* what he was doing as he intentionally miswrote it to start with and intentionally changed the inputs in accordance with this knowledge.

      It's was a demo. Demos by their nature tend to be both simplistic contrived.

      He was putting across a principle in the first half of his talk and a way of life in the second. Both very valid.

      From your comments it's clear that you're more of a craftsman than a visionary. There's room in the world for both.

    7. Re:Great but... by jythie · · Score: 4, Insightful

      TBH - at an hour of talking, no. A summary or argument with diagrams would be worth looking at, but a video? I am actually getting tired of this fad of posting videos to make a case. Very inefficient and can usually be summed up in something that only takes 10 minutes to read. I get the feeling the people who do things pieces just like hearing their own voice....

  2. Connecting to your creation in Clojure by slasho81 · · Score: 4, Interesting

    Here's an implementation of Bret's ideas in Clojure.

    1. Re:Connecting to your creation in Clojure by justforgetme · · Score: 5, Informative

      And here is the vimeo video for those who want to tear their eyes out when
      visiting i-programmer and their 180px content column.

      --
      -- no sig today
  3. They invented the debugger! by Giant+Electronic+Bra · · Score: 4, Insightful

    Yeeehaaa! ;)

    The tough problems aren't about running the code and seeing what happens, they're about setting up very specific situations and testing them easily.

    --
    "Malo periculosam, libertatem quam quietam servitutem." -- Jefferson
    1. Re:They invented the debugger! by vlm · · Score: 4, Insightful

      The tough problems aren't about running the code and seeing what happens, they're about setting up very specific situations and testing them easily.

      Handling non-specific unknown/unpredicted situations gracefully is also tough. Unsanitized user input, crazy failure modes, failure in other code making your state machines go bonkers... The trendy thing to do is just throw your hands up in the air and tell the user to reboot and/or reinstall, but that's not so cool.

      Maybe another way to phrase it is at least one of the specific situations needs to be the input of a random number generator doing crazy stuff.

      Your Arabic to Roman numeral converter accepts a INT? Well it better not crash when fed a negative, or zero, 2**63-1 (or whatever max_int is where you live), and any ole random place in between

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    2. Re:They invented the debugger! by ktappe · · Score: 5, Interesting

      The tough problems aren't about running the code and seeing what happens, they're about setting up very specific situations and testing them easily.

      another way to phrase it is at least one of the specific situations needs to be the input of a random number generator doing crazy stuff.

      Your Arabic to Roman numeral converter accepts a INT? Well it better not crash when fed a negative, or zero, 2**63-1 (or whatever max_int is where you live), and any ole random place in between

      This is still archaic thinking. A much more efficient way would be for the IDE to, when specifying a variable, ask there & then what the boundaries of the variable should be. Then the compiler could error any time it saw a situation where the variable could be (or was) handed a value outside those boundaries. Programmers should not be having to catch weird situations over and over; that's what computers are for. Allowing a variable to be any possible INT/FLOAT/REAL just doesn't make any sense in many situations so I'm quite curious why we're still having to even talk about random number generators for debugging & testing. It feels like we're still working for the computers instead of the other way around.

      --
      "We can categorically state we have not released man-eating badgers into the area." - UK military spokesman, July 2007
  4. Wait by bytesex · · Score: 4, Insightful

    Someone re-invented scripting languages ?

    --
    Religion is what happens when nature strikes and groupthink goes wrong.
    1. Re:Wait by gl4ss · · Score: 4, Insightful

      well. yes. but sold the idea as having someone(the computer, AI) to magically setup the situation you were thinking of when writing that code too.

      it's very easy to demo the benefits with something that for example just draws something, but such game engines have been done before and isn't really that different from just editing the code in an svg- however as you add something dynamic to it... how is the computer supposed to know, without you instructing it? and using mock-content providers for realtime ui design is nothing new either so wtf?

      --
      world was created 5 seconds before this post as it is.
  5. Re:Conjecture. by TheRaven64 · · Score: 4, Funny

    Yes, if only there were existing systems that worked that way. Such as the Lisp environment from 1958 or the Smalltalk environment from 1976. Such revolutionary new ideas about programming! I wonder if he will invent automatic refactoring tools next...

    --
    I am TheRaven on Soylent News
  6. Sounds like they have a GUI REPL by istartedi · · Score: 4, Insightful

    Unless somebody wants to give a better executive summary, there's no way I'm weeding through an hour of video. Do they have any idea how many hours there are of "the one video you must see this year" on YouTube?

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    1. Re:Sounds like they have a GUI REPL by Twinbee · · Score: 4, Insightful

      Okay, let's give this a go, well the first 25 minutes anyway. He's talking about seeing the effects of programming not after compiling and running, but while you're actually *typing*.

      The first example (with the fractal tree) is interesting. He changes a number in the code, and the trunk gets taller, or the number of leaves grow. He then adjusts the variable in the code as if it were a slider, and the picture updates accordingly in realtime.

      Second example is a platform game. He is able to user a slider to go back and forwards throughout time, and change certain parameters such as the gravity, or speed of the enemy turtle. To solve a problem at the end where he wants the character to jump at a very particular height, he employs a 'trail' of the character over time (so you can see all of 'time at once'). Adjusting the variable he can get that perfect jump height more intuitively. The 'character trail' changes in realtime as he adjusts the variable.

      The third example is where he talks through a binary search algorithm. Usually, you're blind as you have to figure out what the computer is doing behind the scenes. But let's say you can see the output as you're typing. The numbers of variables are drawn to the right as you're typing. If there's a loop, then there will be more than one value. In this case, the values are segmented horizontally in the output.

      I've thought of a lot of the things that this guy has said (and even semi-planned to incorporate his third idea into my OpalCalc program shown in my sig), but a couple of things were moderately surprising, and it's nice to see it all in action.

      --
      Why OpalCalc is the best Windows calc
  7. Been There Done That. by Anonymous Coward · · Score: 4, Informative

    I've been doing this for years with Python's interactive prompt. I write code and test it on a line by line basis as I'm programming when working with unfamiliar libraries. The code that works is then put into a permanent file for reuse as a script or compiled to an executable for distribution to my end users.

  8. Obligatory Dijkstra by 1729 · · Score: 4, Insightful

    "I remember how, with the advent of terminals, interactive debugging was supposed to solve all our programming problems, and how, with the advent of colour screens, "algorithm animation" was supposed to do the same. And what did we get? Commercial software with a disclaimer that explicitly states that you are a fool if you rely on what you just bought."

    From http://www.cs.utexas.edu/~vl/notes/dijkstra.html.

  9. My boss sent me this drivel as well by AdrianKemp · · Score: 4, Funny

    It is the most worthless, dumbass thing I've ever had to sit through.

    It's just another "wouldn't it be great if computers programmed themselves" video by someone too stupid to tie their own shoes.

    I know what the code I'm writing is going to do *before* I start writing it, as I hope for the love of god most programmers do.

    In fact, the biggest plague on programming ever has been this concept that changing what you want fifteen times along the way is perfectly okay and we just need to adapt methods to that idiocy. You don't need any of this crap if you just know what you want ahead of time.

  10. This interactive language already exists. by Anonymous Coward · · Score: 4, Interesting

    It's called Python. I use the interactive interpreter to test snipets of code al the time. This makes me 4 times more productive than Java, for example.

  11. Re:Conjecture. by SJS · · Score: 5, Insightful

    Smalltalk and Lisp are a good example, and they show (to me) that the problem isn't the language. The hard part about programming isn't the code.

    The hard part about programming is understanding and decomposing the problem. If you're not any good at that, then no matter what language you use, you're going to struggle and produce crap.

    This isn't to say that languages aren't important -- different languages lend themselves to particular problem-spaces by suggesting particular solutions. Picking the right language for the problem is as important as picking the right wrench for the nut.

    But there will never be a DWIM language, because the big problem is getting the programmer's brain wrapped around what needs to be done. Once that's done, what's left is only difficult if the programmer doesn't have the figurative toolset on hand.

    --
    Pick One: http://www-rohan.sdsu.edu/~stremler/sigs/sigs.html (Note - disable Javascript first!)
  12. Re:An observation... by Anonymous Coward · · Score: 5, Funny

    I'd guess it slips a $1 and $2 bill into a stripper's titties by the looks of it.

  13. The biggest Mistake Today by prefec2 · · Score: 4, Insightful

    Most programmers think, that coding takes the most part of the development. In some cases they would admit that testing is also very time consuming. But the real issue is the understanding of the problem. A lot of programmers design while their code. This results in strange development cycles which also includes trying to understand what the program does. As this can be done with a debugger, an interpreter or a trace analysis tool. The real issue is the problem description. First, understand the problem and its borderline cases. Second, come up with a solution for that problem. And third, try to implement it.

    BTW: Most programs of today do not contain that many surprising new algorithms. They collect data, the validate data to some constraints, they store data, they provide an interface to query the data. In desktop applications like Inkscape or Word the data is stored in in memory models. And there exist serializers and renderers for the content. So the code as such is not hard to understand, as we all know such structures.

  14. Re:An observation... by TuringTest · · Score: 4, Interesting

    You approach makes lots of sense for writing mathematical of physical code, where you have a perfect model of the world that is the basis of the problem to solve. Your ancient Slashdot ID seems to indicate that this is the kind of that you have experience with; that, or the essential infrastructure for big businesses, which is similarly model-based.

    But when your program is for a specific business flow application, for which there is no model and the logic and corner cases must be elucidated from the client by showing a partially working prototype, the only way to extract all the requisites for the program is to throw in a few lines, show it to the user and ask what it's missing or how the current version is wrong, and then fix it; because the program's behavior has not been fully defined yet when the first version was written, it's d^Hrefined as a reaction of the working code.

    --
    Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
  15. Re:understanding by doing... faster by Alex+Belits · · Score: 5, Insightful

    Congratulations, you are an idiot.

    "Tests", no matter how numerous, cover an infinitely small fraction of possible instances of your code being used (that would be an infinite number of, unless you take into account the maximum lifetime of the Universe). They are supposed to assist a developer finding some faults in his reasoning, nothing more than that.

    --
    Contrary to the popular belief, there indeed is no God.
  16. Re:An observation... by Cow+Jones · · Score: 4, Informative
    Around the last ':' character.
    * is a greedy "match as many as you can", and the first .* trumps the second.

    So the result of -- $_ = "foo:bar:baz:qux"; s/(.*):(.*)/$2:$1/; -- would be "qux:foo:bar:baz".

    --

    Ah, arrogance and stupidity, all in the same package. How efficient of you. -- Londo Mollari