Day 17: Glider and Mandelbrot

autrijus on 2005-02-17T18:57:11

Today is the first day that I feel my imaginary perl6 adoption timeline may not be that far off.

The big news is that Pugs 6.0.7 is out, with examples/life.p6 and examples/mandel.p6 ported from the parrot tree; both runs just fine!

Also thanks to hcchien, we now have a beginning of synopsis-based unit tests in t/ (most tested using eval ""), which should grow into a more comprehensive acceptance test suite.

Another big news is that I'm moving I/O primitives and mutable variables forward on the schedule. I still want to do a purely functional ("Featherweight") evaluator inside Perl6, maybe as "func { ... }" instead of "sub { ... }", but popular feedback convinced me that getting something to work in the Real World is a better idea.

To that end, today I have finished:

  • The "time", "open", "close" and "<>" primitives
  • Errors are propagated upward using shiftT.
  • Postfix ++ and --
  • Ternary ?? ::
  • Assignment to mutable variables and to array slices
  • "loop", "for" and "if" constructs

There were also large number of lexer and evaluator tweaks to get life.p6 and mandel.p6 running at a reasonable speed.

Also, I've just been talking with Patrick Michaud (the perl6 compiler guy) on IRC #perl for a couple hours. Some interesting notes:

  • Both Patrick and Larry are seriously considering learning Haskell. Yay!
  • PGE (the Perl6 Rule Engine) can be built separately from the parrot tree, and hence can be inlined in Pugs for Perl6 Grammar support, by compiling down (via Haskell FFI) to Parsec primitives.
  • The official svn.perl.org repository may host Pugs tomorrow, with me becoming a committer.
  • Various parsing and rules-related corner cases are discussed, with many happily resolved.
  • Patrick also explained P6Rules' new quantified capturing semantics to me (a repetition marker other than '?', following a capturing group, will cause it to quantify and return a list of matches instead of just a match object), which actually makes sense. Hopefully the full detail can make to S05 soonish.

So. Lots of interesting developments. Stay tuned!


Wow!

Smylers on 2005-02-17T20:00:34

Autrijus, you are amazing!

Smylers

thank you and some questions

jeff on 2005-02-18T10:42:59

first, thank you. thank you. thank you.

it seems you have transitioned perl6 development from 'smoldering' to 'blazing'... the invigorated discussions on the language list would be accomplishment enough, but clearly this is only a start...

lucky for me, the 2 languages at the top of my list to learn for some time have been haskell and perl6 (in no particular order). your recent work has inspired me to work harder to realize this(i see the PUGS code base as a great way for me to kill 2 birds with one stone so to speak).

i've finished a quick read of 'A Gentle Introduction...' http://www.haskell.org/tutorial/

i found the discussion of monads less than gentle ;) but i did find the monad tutorial at http://www.nomaware.com/monads/monad_tutorial.zip very helpful...

now for some general questions:

in general, are there some specific docs for newbies that you recommend reading (particularly with an eye on trying to come up to speed with the growing PUGS code base?)

what tools do you prefer to use in your code/debug cycle?

is http://wagner.elixus.org/user/autrijus/darcs/pugs/_darcs/current/src/ a good place to peek at your codebase?

could you please explain the '$' operator in your code or point me in the direction of some documentation (i apologize if you defined it and i missed its definition) ? it doesn't seem to be explained in the docs i've read yet about haskell 98 (btw, is that the version you are using, or are there some new features you are using?)

any other helpful advice for a newbie? i doubt i'll get much farther than lurker mode in the near future but some day...

thanks again for injecting some excitement into Perl 6 development.

Jeff

Re:thank you and some questions

jeff on 2005-02-18T11:27:20

ok, poking into GHC docs, it seems the answer to the '$' operator question is related to templates, and is discussed at :

http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.html

no time to absorb it just yet, but will sleep on it for now ;)

jeff

Re:thank you and some questions

autrijus on 2005-02-18T11:48:42

Hmm, I sense a need of Perl6::Pugs::FAQ...

The use of $ is not Template Haskell... The binary operator ($) simply means "apply function"; f $ g is equivalent to f g.

The use of $ in Haskell code is for fixing precedence. For example, to calculate f(g(3)), one can write f $ g 3, or using the function composition, as (f . g) 3, but f g 3 will not work, as it means f(g, 3).

"Yet Another Haskell Tutorial" is a fine online tutorial. The books I'm currently reading are:

  • Algorithms : A Functional Programming Approach (International Computer Science Series) By: Fethi A. Rabhi, Guy Lapalme
  • Types and Programming Languages By: Benjamin C. Pierce
  • Introduction to Higher-Order Categorical Logic (Cambridge Studies in Advanced Mathematics) By: J. Lambek, et al
  • Advanced Topics in Types and Programming By: Benjamin C. Pierce (Editor)
  • Basic Category Theory for Computer Scientists (Foundations of Computing) By: Benjamin C. Pierce
  • Purely Functional Data Structures By: Chris Okasaki
  • The Haskell School of Expression: Learning Functional Programming through Multimedia By: Paul Hudak
  • Haskell: The Craft of Functional Programming (2nd Edition) By: Simon Thompson

I recommend the "Algorithms" book for Haskell newcomers; the other two introduction books by Thompson and Hudak are also quite pleasant to read.

To trace the latest source tree, use one of the three source repositories linked from the Pugs page.

As for development tools... I'm currently still using Vim, but Eclipse's Haskell support is excellent.