Thoughtstream | Seminars

Transparadigm Programming in Perl 6

Each of the standard programming paradigms (imperative, functional, OO, declarative, concurrent) provides a collection of problem-solving tools that is optimized for particular kinds of tasks...and for particular ways of thinking about problem-solving.

But no single paradigm provides tools that are optimal for all kinds of tasks...or for all ways of thinking about problems.

Normally this means you have to adapt your software solutions to the limitations of your programming language's unique world-view: if all you have is a hammer, every problem looks like a nail; if all you have is C, every problem looks like bit manipulation; if all you have is Haskell, every problem looks like the multiple dispatch of implicitly typed functions; if all you have is Java, every problem looks like loading another class library.

Perl 6 is a programming language that seeks to create a single unified toolbox, integrating the major features of all five major paradigms to create a development platform that lets you select and combine the optimal linguistic tools for each job, no matter which universe they come from.

More importantly, Perl 6 allows you to compose those tools together in natural ways within a single code block or subroutine. For example, you could implement a class method using functional programming. Or combine distributed and SIMD tests to control a single procedural 'while' loop that's embedded in an otherwise pure function. Or inherit a set of imperative actions that are nested inside the OO rules of a declarative grammar.

This means that a single Perl 6 solution can easily combine C-like bit-manipulation (where that makes sense), with Haskell-ish multiple dispatch (when it's convenient), with Java-y class hierarchies (if they also happen to be the right tool). Except that Perl 6 has better bit-manipulation than C, much better multiple dispatch than Haskell, and a vastly better OO model than Java.

This talk will explore the idea of transparadigm programming in Perl 6 using a series of simple (but real-world) examples, such as: LZW data compression, SHA-256 digests, AWS Glacier hash-trees, concurrent data validation, and parsing LaTeX documents.