Pugs
From Wikipedia, the free encyclopedia
- This article is about the Perl 6 computer programming language implementation. For other meanings of Pug, see Pug (disambiguation).
Pugs is a compiler and interpreter for the Perl 6 programming language, started on February 1, 2005 by Audrey Tang.
Contents |
[edit] Overview
The Pugs project aims to bootstrap Perl 6 by implementing the full Perl 6 specification, as detailed in the Synopses. It is written in Haskell, specifically targeting the Glasgow Haskell Compiler.
Pugs includes two main executables:
- pugs is the interpreter with an interactive shell.
- pugscc can compile Perl 6 programs into Haskell code, Perl 5, JavaScript, or Parrot virtual machine's PIR assembly.
[edit] Version numbering
The major/minor version numbers of Pugs converges to 2π (being reminiscent of TeX and METAFONT, which use similar scheme); each significant digit in the minor version represents a successfully completed milestone. The third digit is incremented for each release. The current milestones are:
- 6.0: Initial release.
- 6.2: Basic IO and control flow elements; mutable variables; assignment.
- 6.28: Classes and traits.
- 6.283: Rules and Grammars.
- 6.2831: Type system and linking.
- 6.28318: Macros.
- 6.283185: Port Pugs to Perl 6, if needed.
[edit] Perl 5 compatibility
As of version 6.2.6, Pugs also has the ability to embed Perl 5 and use CPAN modules installed on the system. The example below show a use of the popular Perl DBI module to manage a SQLite database:
#!/usr/bin/pugs use v6; use perl5:DBI; my $dbh = DBI.connect('dbi:SQLite:dbname=test.db'); $dbh.do("CREATE TABLE Test (Project, Pumpking)"); my $sth = $dbh.prepare("INSERT INTO Test VALUES (?, ?)"); $sth.execute(<PGE Patrick>); $sth.execute(<Pugs Audrey>); $sth.execute(<Parrot Leo>); my $res = $dbh.selectall_hashref('SELECT * FROM Test', 'Pumpking'); # Just another Pugs hacker say "Just another $res<Audrey><Project> hacker";
[edit] Development model
Pugs has been praised as a particularly successful open-source project. Started at the beginning of 2005, progress has been rapid. Several factors have been suggested as reasons:
- Pugs' use of Haskell. Haskell's static typing means that a wider range of bugs are detected by the compiler at compile-time. In the tradition of functional languages, a few lines of Haskell can do a lot. Haskell is even better suited to language parsing thanks to the Parsec library[1], a monadic combinatorial parser written entirely in Haskell. Things get marginally trickier around the edges, where the functional code has to interact with the real world (inputs/outputs and time-driven environment). To achieve this, Pugs makes extensive use of monads, which are specific containers required to generate side effects or force in-order execution in purely functional languages (which are by design devoid of side-effects and built for out-of-order execution).
- Test-driven methodology. A feature of Extreme Programming, the aim is to ensure that absolutely everything has test code, probably long before the real code is written. It's then apparent what the state of the project is, simply from how many tests are passing or failing. It also makes it much easier to detect regressions. However, the habit of Pugs developers of silencing even regression test failures before a release diverges from XP practices.
- Audrey's liberal sprinkling of the commit bit. Pugs development is currently based around a Subversion repository, and access is given out quite freely - especially to people wishing to write tests. Because of this, a huge library of tests has accumulated. Other Perl 6 implementations rely on many tests developed for Pugs as an executable specification for Perl 6.
- Audrey's enthusiastic and frequent communications. Her journal (linked below) attracted many people to the project, mainly due to the astonishing pace of development. There's also usually a community on the #perl6 Freenode IRC channel.
Due to licensing and concerns about the lack of copyright assignments from contributors, it is unlikely that The Perl Foundation will bless Pugs as the official implementation of Perl 6.