programming – Parerga und Paralipomena http://www.michelepasin.org/blog At the core of all well-founded belief lies belief that is unfounded - Wittgenstein Mon, 27 Oct 2014 13:48:23 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.11 13825966 Agile vs Waterfall… a few misconceptions revealed http://www.michelepasin.org/blog/2013/02/27/agile-and-waterfall/ Wed, 27 Feb 2013 14:54:07 +0000 http://www.michelepasin.org/blog/?p=2325 Here’s a list of interesting concepts in software development. Now think about it, who do you think might have stated them so clearly?

  • Design for Iteration:

    ..as each step progresses and the design is further detailed, there is an iteration with the preceding and succeeding steps…

  • Get Feedback:

    If the computer program in question is being developed for the first time, arrange matters so that the version finally delivered to the customer for operational deployment is actually the second version..

  • Sharing Knowledge:

    Each and every worker must have an elemental understanding of the system…

  • Centrality of People:

    ..the personnel involved… They must have an intuitive feel for analysis, coding, and program design. They must quickly sense the trouble spots in the design, model them, model their alternatives, forget the straightforward aspects of the design which aren’t worth studying at this early point..

  • Code Review:

    ..every bit of an analysis and every bit of code should be subjected to a simple visual scan by a second party..

  • Automatic Tests:

    ..every logic path in the computer program at least once with some kind of numerical check.

  • Involve Customers:

    ..it is important to involve the customer in a formal way so that he has committed himself at earlier points before final delivery. To give the contractor free rein between requirement definition and operation is inviting trouble.

  • Who said that?

    I’m afraid these words are not the result of your favourite Agile programming guru. Quite the opposite.

    These are all sentences taken from the 1970 paper considered to be the manifesto of Waterfall design paradigm. Oh yeah. (it’s called Production of Large Computer Programs by Herbert Benington).

    How’s that possible? Agile, Scrum, Waterfall.. it’s like a war among ‘philosophical’ schools, each one promoting a different solution to the dilemma of how to achieve the most efficient software development process. In reality, there is often a big difference between what’s been proposed originally, and what people make of it in the years.

    That’s the main thesis of an inspiring keynote talk by Paolo Perrotta (italian only I’m afraid). Essentially, what he suggests is that waterfall wasn’t that evil after all. But waterfall has had success, and as a consequence of that it sold out. Or better, it’s been emptied from its original ideas and principles, and modified and misinterpreted so to cover for a multitude of usage scenarios and personal preferences.

    So, Perrotta warns us, we should recognise that the same is happening with Agile: its massive success is leading to the transformation of its principles into empty buzzwords, of its core functions into roles that are often played by people according to predefined scripts and with little understanding of its core ideas, which, at the end of the day, presuppose one central tenet: being reasonable.

    Thanks Paolo for these thought-provoking ideas (and tx to Enrico for mentioning it to me)!

     

    ]]>
    2325
    Opening a Finder’s window from Impromptu (alas how to use the applescript bridge..) http://www.michelepasin.org/blog/2011/01/30/opening-a-finders-window-from-impromptu-alas-how-to-use-the-applescript-bridge/ Sat, 29 Jan 2011 23:00:15 +0000 http://www.michelepasin.org/blog/?p=982 Imagine you’ve got a bunch of audio samples you want to load up while livecoding with Impromptu but you can’t remember exactly their names – it’d be handy to be able to open up the corresponding Finder window directly from scheme, without too much clicking around. Do-able or not?

    I spent some time trying to figure this out, and the answer is yes! Quite a nice learning experience… although it came with a surprise at the end.

    Originally I thought, let’s do it via impromptu’s ObjC bridge. I don’t know much about ObjC but after a bit of googling it seemed evident that the quickest way to accomplish this is by writing ObjC code that, in turns, runs a simple applescript command that opens a window:

     

    NSString *s = [NSString stringWithFormat:
         @"tell application "Terminal" to do script "cd %@"", folderPath];

    NSAppleScript *as = [[NSAppleScript alloc] initWithSource: s];
    [as executeAndReturnError:nil];

     

    So I translated the bottom part of the code above into impromptu/scheme:

     

    (define run_applescript
       (lambda (script)
          (objc:call (objc:call (objc:call "NSAppleScript" "alloc")
                                "initWithSource:"
                                script)
                     "executeAndReturnError:" )))

     

    That is a generic script-running function, that is, you can pass any script and it’ll run it, eg:

     

    (define script0 "
       tell application "Finder" to open folder "Macintosh HD:Users"
       tell application "Finder" to activate"
    )

    (define script1 "
       tell application "Terminal" to do script "cd ~; open .""
    )

    (define script2 "
                    tell application "System Events"n
                    tell dock preferencesn
                    set properties to {autohide:false}n
                    end telln
                    end tell"
    )

    ;; finally, let’s choose randomly one of the scripts above and run it
    (run_applescript (random ‘(script0 script1 script2)))

     

    Now, back to the original problem: in order to open a Finder’s window at a specified location we need to pass the location variable to our function run_applescript; also, we want to be able to pass unix path expressions (eg ‘/Users/mike/music/’), so we’ve got to transform that path syntax into the semicolon-delimited macintosh syntax (“Macintosh HD:Users:mike:music”) needed by the applescript function we’re using. That’s easily done with string-replace, so here we go:

     

    (define open_finder_at
       (lambda (location)
          (let* ((llocation (stringreplace location "/" ":"))
                  (script (string-append "tell application "Finder" to activate open folder "Macintosh HD" llocation """)))
             (objc:call (objc:call (objc:call "NSAppleScript" "alloc")
                                   "initWithSource:"
                                   script)
                        "executeAndReturnError:" ))))

    (open_finder_at "/Users/me/")

     

    That’s pretty much it really… now we can easily open OsX Finder’s windows from within Impromptu.

    But as I said above, there’s a surprise: after getting this far I thought I’d search impromptu’s mailing list for more examples of obj:call …. and guess what, there’s already a system function that runs applescripts, it’s called sys:run-applescript !

    Too bad, it’s been a rewarding learning experience anyways…

     

    ]]>
    2188
    Scheme and Lisp http://www.michelepasin.org/blog/2010/11/08/scheme-and-lisp/ Mon, 08 Nov 2010 12:57:13 +0000 http://www.michelepasin.org/blog/?p=866 If you’re coming from Lisp, and then start using Scheme (or the other way around) there are a few small differences between the two languages that it’s useful to always keep in mind. I tried to do that a number of times, but inevitably I find myself once again wondering: how do you say ‘progn’ in scheme?

    So, since I recently found online a succinct table that sums up the differences, I thought I’d pass it on to posterity here too.

    Screen shot 2010-11-08 at 14.29.12.png

    By the way, on the same site the authors report of a small scheme library (initdr.scm) that implements a few very common Lisp functions. Including [dotimes dolist intersection, union set-difference copy-list subset every some copy-tree subst sublis nconc nreverse]… Quite useful too!

    UPDATE 28/11/10:

    I realized that most of these lisp functions are already available in Impromptu, under the cl: namespace (check out the common-lisp library functions section on the wiki). Below are just a couple of additions to that, based on the initdr.scm library I was mentioning.. apologies for the confusion!

    ;;;;;;;;;;;;;;;;
    ;;; LISP ADDITIONS 
    ;; the rest of this is in the cl: impromptu library
    ;;;;;;;;;;;;;;;;
    
    
    (define cl:first car)
    (define cl:rest cdr)
    (define cl:count length)
    
    ;; reverse of cons: (cons 'b '(a))
    (define cl:l-put
       (lambda (obj lst)
          (reverse (cons obj (reverse lst)))))
    
    ;; dont know why but I like it reversed..
    (define cl:nth (lambda (x lst)
                   (list-ref lst x)))
    
    
    (define (1+ n) (+ n 1))
    (define (1- n) (- n 1))
    
    
    ;; (subst 9 7 '(5 (5 6 7(6 7))))    =>  (5 (5 6 9 (6 9)))      
    (define (cl:subst new old tree)
      (if (pair? tree)
          (let ((left (subst new old (car tree)))
                (right (subst new old (cdr tree))))
            (if (and (eq? left (car tree))
                     (eq? right (cdr tree)))
                tree
                (cons left right)))
          (if (eqv? old tree)
              new
              tree)))
    
    
    
    ;; (sublis '((6 . 9) (7 . 10)) '(5 (5 6 7 (6 7)))))  => (5 (5 9 10 (9 10)))
    (define (cl:sublis alist tree)
      (if (pair? tree)
          (let ((left (sublis alist (car tree)))
                (right (sublis alist (cdr tree))))
            (if (and (eq? left (car tree))
                     (eq? right (cdr tree)))
                tree
                (cons left right)))
          (let ((new (assv tree alist)))
            (if new
                (cdr new)
                tree) ) ) )
    
    
    ;; (copy-tree '(5 (5 6 7(6 7))))
    (define (cl:copy-tree x)
      (if (pair? x)
          (cons (copy-tree (car x))
                (copy-tree (cdr x)))
          x))
    
    
    ; Convert a floating-point number to a string of sign and at most 4 characters.
    ; Rounds the number so that 1.999 will come out as 2.00 , very small as 0.0 .
    ; numstring is written assuming that num is not too large or too small,
    ; i.e. num must be printable in 4 digits.
    (define (cl:numstring num)
      (let* ((numc (abs num)) (sign (if (< num 0) -1 1)) (exponent 0))
        (if (< numc 1.0e-6)
        "0.0"
        (begin
          (if (< numc 1.0)
              (begin (while (< numc 100)
                    (set! numc (* numc 10))
                    (set! exponent (1- exponent)))
                 (set! numc (* (round numc) (expt 10 exponent))) )
              (set! numc (* numc 1.0001)))
          (if (< sign 0)
              (string-append "-"
                     (substring (number->string numc) 0
                       (min 4 (string-length (number->string numc)))))
              (substring (number->string numc) 0
                 (min 4 (string-length (number->string numc))))) ) ) ))
    
    
    
    
    ;(list-flatten '(9 9 (9 9 9 ))))  = (9 9 9 9 9)
    
    (define cl:list-flatten 
       (lambda (l)
          (cond ((null? l)
                 '())
                ((atom? l)
                 (list l))
                (#t (append (cl:list-flatten  (car l)) (cl:list-flatten  (cdr l)))))))
    
    ]]>
    866
    A video that may convince you that LISPers are a bit crazy http://www.michelepasin.org/blog/2010/10/29/a-video-that-may-convince-you-that-lispers-are-a-bit-crazy/ Fri, 29 Oct 2010 14:25:26 +0000 http://www.michelepasin.org/blog/?p=860 Actually it’s not just a video, there’s a book too:

    Land of Lisp, Learn to Program in Lisp, One Game at a Time! by Conrad Barski, M.D.

    ]]>
    860
    Mmm that ruby is hot.. http://www.michelepasin.org/blog/2007/10/11/mmm-that-ruby-is-hot/ Thu, 11 Oct 2007 18:28:30 +0000 http://people.kmi.open.ac.uk/mikele/blog/?p=255 I havent written much in the last days – been busy writing a new browser for kmi’s semantic web services team, and moving on my phd thesis during the rest of the time. PLus – i did some research about ruby,which looks very lisp-alike BUT is web oriented.

    Anyways – that’s how I run into this pearl of wisdom (original here):

    #7 – PROGRAMMING LANGUAGES ARE LIKE GIRLFRIENDS: THE NEW ONE IS BETTER BECAUSE *YOU* ARE BETTER
    Rails was an amazing teacher. I loved it’s “do exactly as I say” paint-by-numbers framework that taught me some great guidelines.
    I love Ruby for making me really understand OOP. God, Ruby is so beautiful. I love you, Ruby.
    But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now! You look back at your old ugly PHP code, compared to your new beautiful Ruby code, and think, “God that PHP is ugly!” But don’t forget you wrote that PHP years ago and are unfairly discriminating against it now.
    It’s not the language (entirely). It’s you, dude. You’re better now. Give yourself some credit.

     

    ]]>
    1347