Slashdot Mirror


Optimizing Development For Fun

chromatic writes "Geoff Broadwell has written an analysis of optimizing an open source project for fun, specifically the Pugs project. Broadwell argues that making development fun and easy leads to higher quality code and a faster velocity of development, even when implementing a frivolous project (a toy Perl 6 interpreter) in an uncommon language (Haskell). The Pugs leader, Autrijus Tang, will speak about both Pugs and Haskell at EuroOSCON."

8 of 144 comments (clear)

  1. Re:Want to make dev fun? by Eil · · Score: 4, Informative


    Mainly, Python is powerful but has a deliberately shallow learning-curve. The most often-cited reasons are the following Python mantras:

    - Everything is an object
    - Syntax is simple and predictable (but feels a little odd if you're coming from C, C++, Perl, Java, etc)
    - There's one obvious way to do it. (Contrast with Perl's, "There's more than one way to do it.")
    - Batteries included (comes with a large library of modules)

    Pretty sure there are more, but these are the biggies that I can recall. These are the same reasons that many quote for using Ruby as well, but I got around to trying it yet.

    I used to be a big fan of Tcl for it's insanely shallow learning curve. (Even more so than Python.) I wrote a usuable Tk (GUI) app within the first hour of even hearing about it. Too bad it didn't really catch on and mature as well as Python and Perl did over the same time-frame because it really is a nifty language.

  2. Pugs 6.2.10 has just been released. :-) by autrijus · · Score: 4, Informative
    I am delighted to announce Pugs 6.2.10, released during a slashdotting on geoffb's "Optimizing for Fun" column:

    http://developers.slashdot.org/article.pl?sid=05/1 0/09/1831219

    The release tarball will be available from CPAN shortly:

    http://pugscode.org/dist/Perl6-Pugs-6.2.10.tar.gz
    SIZE = 2394516
    SHA1 = 3d8669fdccc3616c99cdde68659759b8b5782859

    With two months of development, this release features more tightly integrated JavaScript and Perl5 code generator backends, a library interface to the Pugs system via support for the Haskell Cabal frameworks, as well as many new tests.

    After the release, the push toward 6.28.0 will begin in earnest, with the newly specified container model and object model integrated back to the main runtime, fleshing out support for the remaining OO features.

    Again, thanks to all the lambdacamels for building this new ship with me. :)

    Enjoy!
    /Autrijus/

    Changes for 6.2.10 (r7520) - Oct 10, 2005

    Feature Changes

    Shared components

    • Support for the Haskell Cabal framework, exposing Pugs as a library to other Haskell users, paving the way for use in IDEs, as well as future Inline::Pugs and Inline::GHC modules
    • Adopted the code convention of expanding literal tab chars to spaces
    • JavaScript backend can be invoked with pugs -B JS
    • Perl 5 backend can be invoked with pugs -B Perl5
    • Pugs will now compile version ranges in use/require statements
    • Significant backend enhancements; see below
    • $?PUGS_BACKEND can be used to tell which runtime is in use
    • exec emulated partially on Win32

    JavaScript backend

    • Passes 91% of the main test suite including TODO failures
    • Integrated with MetaModel 1.0
    • Faster code generation, taking advantage of -CPerl5 output.
    • Switched to continuation passing style CPS to properly support return, ?CALLER_CONTINUATION, coroutines, and sleep
    • Improved support for binding and autodereferentiation
    • Initial support for multi subs
    • Initial support for symbolic dereferentiation
    • List construction no longer creates new containers
    • Miscellaneous performance improvements
    • Named-only arguments +$x and ++$x cant be passed positionally anymore
    • Parts of the Prelude can be written in Perl 5 now to improve performance
    • Perl 5-like regular expressions mostly working
    • Proper UTF-8 handling
    • Support for monkey-but $foo but {...}
    • Support for $CALLER:: and $OUTER::
    • Support for lazy {...} blocks for delayed evaluation
    • Support for temp and let declarations
    • Support for array and hash autovivification
    • Support for array and hash slices
    • Support for evaluating expressions in the PIL2JS shell :e <exp>
    • Support for junctions
    • Support for loading JSAN modules by using use jsan:Module.Name
    • Support for lvalue subroutines foo = ...
    • Support for slurpy hashes in subroutine signatures
    • Support for the Proxy class not yet user-visible
    • Support for the eqv operator
    • Using for with only one element to loop over works now
    • int works correctly on special values like Inf or NaN now
    • substr returns a r/w proxy: substr$str, $pos, $len = $replacement

    Perl 5 backend

    • Passes 33% of the main test suite including TODO failure
  3. That's mistitled by Estanislao+Mart�nez · · Score: 3, Informative

    That shouldn't be called "Avoid Recusion," because you're not really avoiding recursion. What you're doing (as the wiki itself explains) is abstracting it into a higher-order function. Still a pretty damn important technique that one should master in functional languages--recognizing the "shape" of a loop (is it a map? a left or right fold? an unfold?), and implementing the looping logic as a higher-order function separately from its specific uses.

  4. Re:It's not frivolous by chromatic · · Score: 2, Informative

    I meant that Pugs started as a frivolous project in the same sense that the Linux kernel started as a frivolous project and as much as any learning experience refactorable into useful, non-frivolous code is frivolous.

    I'm not sure when Autrijus realized what he had, but I'm sure he didn't intend to write a full-fledged Perl 6 implementation with pluggable backends targeting Perl 5, Parrot, the JVM, and JavaScript, at least not at first.

  5. Re:Let's run with this idea a little by qbwiz · · Score: 2, Informative

    I think that that's where the unit tests come in. If something doesn't compile, or it doesn't pass the unit tests, then it cannot be checked in. There could also be known-good checkpoints, which enable users and possibly even developers to work on something that should work.

    --
    Ewige Blumenkraft.
  6. Re:Want to make dev fun? by jma05 · · Score: 2, Informative

    All good. But don't get confused between static and strong typing. Python is dynamically and strongly typed, not weakly typed.

  7. Re:Want to make dev fun? by jonastullus · · Score: 2, Informative

    EXAMPLE:

    def test(arr = []):
        return arr

    t = test()
    t.extend(["hello", "world"])

    u = test()
    print u

    RESULT:

    $ ./test.py
    hello
    hello hello

    REASON:

    the default value expression is evaluated once, when the function
    object is created, and the resulting object is bound to the argument.

    FIX / WORKAROUND:

    if you want to create a new object on every call, you have to do
    that yourself:

    def __init__( self, myList=None):
        if myList is None:
            myList = [] # create a new list
        self.myList = myList

  8. Re:Want to make dev fun? by jonastullus · · Score: 2, Informative

    *darn*, i totally bogged up the result:

    RESULT:

    $ ./test.py
    > ["hello", "world"]