Pugs
Encyclopedia
Pugs is a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 and interpreter
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

 for the Perl 6
Perl 6
Perl 6 is a major revision to the Perl programming language. It is still in development, as a specification from which several interpreter and compiler implementations are being written. It is introducing elements of many modern and historical languages. Perl 6 is intended to have many...

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

, started on February 1, 2005 by Audrey Tang
Audrey Tang
Audrey Tang is a Taiwanese free software programmer, who has been described as one of the "ten greats of Taiwanese computing."-Biography:...

.

Pugs development is now placed on hiatus, with most Perl 6 implementation efforts now taking place on Rakudo
Rakudo Perl
Rakudo Perl is a compiler that implements the Perl 6 specification and runs on the Parrot virtual machine. Rakudo Perl is currently in development....

; however, its source repository is still used for storing the official Perl 6 test suite.

Overview

The Pugs project aims to bootstrap
Bootstrapping (compilers)
In computer science, bootstrapping is the process of writing a compiler in the target programming language which it is intended to compile...

 Perl 6 by implementing the full Perl 6 specification, as detailed in the Synopses. It is written in Haskell
Haskell (programming language)
Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...

, specifically targeting the Glasgow Haskell Compiler
Glasgow Haskell Compiler
The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source native code compiler for the functional programming language Haskell. The lead developers are Simon Peyton Jones and Simon Marlow...

.

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
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

    , or Parrot virtual machine
    Parrot virtual machine
    Parrot is a register-based process virtual machine designed to run dynamic languages efficiently. It uses just-in-time compilation for speed to reduce the interpretation overhead. It is currently possible to compile Parrot assembly language and PIR to Parrot bytecode and execute it...

    's PIR
    Parrot intermediate representation
    The Parrot intermediate representation , previously called Intermediate code , is one of the two assembly languages for the Parrot virtual machine. The other is Parrot assembly language or PASM...

     assembly.


Pugs is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

, distributable under the terms of either the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....

 or the Artistic License
Artistic License
The Artistic License refers most commonly to the original Artistic License , a software license used for certain free and open source software packages, most notably the standard Perl implementation and most CPAN modules, which are dual-licensed under the Artistic License and the GNU General Public...

. These are the same terms as Perl.

Version numbering

The major/minor version numbers of Pugs converges to 2π (being reminiscent of TeX
TeX
TeX is a typesetting system designed and mostly written by Donald Knuth and released in 1978. Within the typesetting system, its name is formatted as ....

 and METAFONT
METAFONT
Metafont is a programming language used to define vector fonts. It is also the name of the interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into e.g. PostScript...

, which use a 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.

Perl 5 compatibility

As of version 6.2.6, Pugs also has the ability to embed Perl 5 and use CPAN
CPAN
CPAN, the Comprehensive Perl Archive Network, is an archive of nearly 100,000 modules of software written in Perl, as well as documentation for it. It has a presence on the World Wide Web at and is mirrored worldwide at more than 200 locations...

 modules installed on the system. The example below demonstrates the use of the popular Perl DBI
Perl DBI
In computing, the Perl DBI offers a standardized way for programmers using the Perl programming language to embed database communication within their programs. The latest DBI module for Perl from CPAN can run on a range of operating systems....

 module to manage a 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();
$sth.execute();
$sth.execute();

my $res = $dbh.selectall_hashref('SELECT * FROM Test', 'Pumpking');
# Just another Pugs hacker
say "Just another $res hacker";

Development model

Several factors have been suggested as reasons for Pugs's progress:
  • Haskell's static typing can make it easier for program bugs to be detected at compile time. Haskell code is also often thought to be concise. The Parsec library http://www.cs.uu.nl/~daan/parsec.html, a monadic
    Monads in functional programming
    In functional programming, a monad is a programming structure that represents computations. Monads are a kind of abstract data type constructor that encapsulate program logic instead of data in the domain model...

     combinatorial parser written entirely in Haskell, simplifies parsing. Because Haskell is a purely functional language
    Purely functional
    Purely functional is a term in computing used to describe algorithms, data structures or programming languages that exclude destructive modifications...

    , making the functional code interact with the real world (inputs/outputs and time-driven environment) requires thought. To achieve this, Pugs makes extensive use of monads
    Monads in functional programming
    In functional programming, a monad is a programming structure that represents computations. Monads are a kind of abstract data type constructor that encapsulate program logic instead of data in the domain model...

    .
  • Pugs's use of test-driven methodology
    Test-driven development
    Test-driven development is a software development process that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new...

     (a tenet of Extreme Programming
    Extreme Programming
    Extreme programming is a software development methodology which is intended to improve software quality and responsiveness to changing customer requirements...

    ). This methodology dictates that every module should have test code, even before the modules are implemented. Advocates of this methodology argue that it improves software quality
    Software quality
    In the context of software engineering, software quality refers to two related but distinct notions that exist wherever quality is defined in a business context:...

    . However, the project often silenced failed regression tests before releases, removing much of the benefit of test-driven development.
  • Tang's liberal granting of the commit bit
    Commit bit
    The Commit bit is permission to contribute to a shared source code for a software project.To contribute source code on most large projects, one must make modifications and then "commit" those changes to a central repository such as CVS. To have "a commit bit" on one's user account means that one is...

    . Pugs development is currently based around a Subversion repository, and access is freely given - 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.
  • Tang's communication style; her journal (linked below) attracted many people to the project. Pugs developers also gather on the #perl6 freenode
    Freenode
    freenode, formerly known as Open Projects Network, is an IRC network used to discuss peer-directed projects. Their servers are all accessible from the domain name [irc://chat.freenode.net chat.freenode.net], which load balances connections by using the actual servers in rotation...

     IRC channel.


Despite these factors, progress on the Haskell implementation stalled in late 2006, as personal issues kept Audrey from devoting as much time to the project as she had in 2005.

Many Pugs contributors have since moved on to implement Perl6-inspired systems as CPAN modules on Perl 5, such as the Moose
Moose (Perl)
Moose is an extension of the Perl 5 object system. It brings modern object-oriented language features to Perl 5, making object-oriented programming more consistent and less tedious.-Features:...

project.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK