\documentclass[pdf]{prosper}
\usepackage[toc,highlight,clifford,notes,hlsections]{HA-prosper}

\usepackage{svn}
\SVNdate $Date: 2006-05-30 23:00:00 +0200 (Tue, 30 May 2006) $

\title{SPL Feature Show}
\author{Clifford Wolf\\
\institution{SPL - \href{http://www.clifford.at/}{http://www.clifford.at/}}\\
\institution{Csync2 - \href{http://oss.linbit.com/csync2/}{http://oss.linbit.com/csync2/}}\\
\institution{ROCK Linux - \href{http://www.rocklinux.org/}{http://www.rocklinux.org/}}}

\DefaultTransition{Wipe}
\TitleSlideNav{FullScreen}
\NormalSlideNav{ShowBookmarks}
\LeftFoot{\href{http://www.clifford.at}{Clifford Wolf}, \today}
\RightFoot{\href{http://www.clifford.at/spl/}{SPL}}

\begin{document}

\maketitle

% ============================================================================

\tsectionandpart{Introduction}

\begin{slide}{Kickstart}

\vspace*{1cm}
Let's start with a simple example:

\vspace*{.2cm}
\begin{verbatim}
for(var d,i=<obfuscated>just</obfuscated>,j=function(
){d~=i~(defined(i=next[*],i)?" ":" ");},just,another,
SPL,hacker;defined i||({write("$d\n");return;});j());
\end{verbatim}

\vspace*{1cm}
\begin{verbatim}
$ splrun kickstart.spl
just another SPL hacker
\end{verbatim}

\end{slide}

\begin{slide}{What is SPL}
\begin{itemize}

\item SPL is a powerful scripting language

\vspace*{.5cm}
\item Small runtime (<200kB including compiler)

\vspace*{.5cm}
\item Easy C-API and easy to embedd

\vspace*{.5cm}
\item C-like syntax - Easy to learn

\vspace*{.5cm}
\item Statefull - The VM state can be dumped and resumed

\vspace*{.5cm}
\item Support for precompiled bytecode

\vspace*{.5cm}
\item Well documented - manual with about 180 A4 pages

\end{itemize}
\end{slide}

\begin{slide}{Language Feature Overview}
\begin{itemize}

\item Dynamically typed

\vspace*{.5cm}
\item Arrays, Hashes, Complex data types

\vspace*{.5cm}
\item Flexible function arguments passing

\vspace*{.5cm}
\item Real OO programming

\vspace*{.5cm}
\item Builtin localization support

\vspace*{.5cm}
\item String substituions and regular expressions

\vspace*{.5cm}
\item Powerful and extendable template language

\end{itemize}
\end{slide}

\begin{slide}{Module Overview}
\begin{itemize}

\item Builtins library with some basic math and string functions

\vspace*{.5cm}
\item Arrays, Bit-Manupulation, File-I/O, Time handling

\vspace*{.5cm}
\item CGI support and two Web Application Frameworks

\vspace*{.5cm}
\item Complete Qt and KDE bindings

\vspace*{.5cm}
\item Powerful XML module

\vspace*{.5cm}
\item SQL Support (SQLite, MySQL and PostgreSQL)

\vspace*{.5cm}
\item OpenGL, FANN, ...

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{Language Features}

\begin{slide}{Operators}
\begin{itemize}

\item Dynamically typed operators: \\
{\tt + - * / \% ** ...}

\vspace*{.5cm}
\item Integer operators: \\
{\tt \#+ \#- \#* \#/ \#\% \#** ...}

\vspace*{.5cm}
\item Floating point operators: \\
{\tt .+ .- .* ./ .\% .** ...}

\vspace*{.5cm}
\item Object operators: \\
{\tt (+) (-) (*) (/) (\%) (**) ...}

\vspace*{.5cm}
\item Casting operators: \\
{\tt \#(...) .(...)}

\end{itemize}
\end{slide}

\begin{slide}{Variables (1/2)}
\begin{itemize}

\item Only one extrem flexible variable type.

\vspace*{.5cm}
\item Looks a bit like a hash with ordering for the elements and an optional
scalar value.

\vspace*{.5cm}
\item In fact there are much more optional fields \\
(code pointer, context pointer, class pointer, ...)

\vspace*{.5cm}
\item Member variables are accessed using {\tt var[42]} or {\tt var.foobar}.

\vspace*{.5cm}
\item There are {\tt foreach} and {\tt foreach[]} loops.

\vspace*{.5cm}
\item As well as special {\tt next} and {\tt prev} keywords.

\end{itemize}
\end{slide}

\begin{slide}{Variables (1/2)}
\begin{itemize}

\item Arrays, hashes and structured can be defined \\
using the {\tt [ ... ]} operator:

\vspace*{.5cm}
\begin{verbatim}
var a1 = [ "a", "b", "c" ];

var a2 = [ "x" => "a", "y" => "b", z: "c" ];

var a3 = [ x: "a", 100 => "b", "c" ];
\end{verbatim}

\vspace*{.5cm}
\item Scalar variables are passed and copied by value, complex variables are
passed by reference.

\vspace*{.5cm}
\item The {\tt :=} operator can be used to create recursive copies.

\end{itemize}
\end{slide}

\begin{slide}{OO Programming}
\begin{itemize}

\item SPL supports real OO programming:
\begin{itemize}
\item Inheritance and multiple inheritance
\item Member functions and member variables
\item Operator overloading, Type classes, Closures
\end{itemize}

\vspace*{.5cm}
\item Objects and classes are almost the same in SPL
\item Objects are like read-write derives of classes
\end{itemize}

\vspace*{.5cm}
\begin{verbatim}
object Value {
    var value = 42;
}

object GetsetValue Value {
    method get() { return value; }
    method set(val) { value=val; }
}
\end{verbatim}

\end{slide}

\begin{slide}{Advanced Functions}
\begin{verbatim}

// example_advfunc.spl

function a(prefix, @args, %opts) {
        foreach[] i (args)
                debug "$prefix: $i -> ${opts[i]}";
}

function b(@args, %opts) {
        a("example", @args, "a", a: "test", %opts);
}

var opts = [ "hello" => "Sol-3",
        "this" => "is", "a" => "demo" ];

b("hello", "this", hello: "world", %opts,
        foo: "bar", a: "program");

\end{verbatim}
\end{slide}

\begin{slide}{String Substitutions}
All string substitutions start with the dollar sign. \\
Some examples:

\vspace*{.5cm}
\begin{verbatim}
"The value of variable 'xyz' is $xyz."

"The answer is ${40 + 2} and always has been."

"foo $( var x = "SQL"; x =~ s/Q/P/; return x; ) bar"

"little $[ this is a comment ] demo"
\end{verbatim}

\vspace*{.5cm}
Strings can be qutoted using single or double quotes. In both styles
dollar substitutions and backslash sequences are supported.
\end{slide}

\begin{slide}{Templates}
A template is a special style of here document with some nice additional
feature. Example given:

\vspace*{.3cm}
\begin{verbatim}
write(<:foobar>
    : This is an SPL template
    <spl:foreach var="i" list="a">
      : Element $i has the value '${a[i]}'.
    </spl:foreach>
    <spl:if code="x < y">
      : The variable x is smaller than y.
    </spl:if>
    <spl:else>
      : The variable x is not smaller than y.
    </spl:else>
    <?spl for (var i=0; i<10; i++) { ?>
      : This is line number $i.
    <?spl } ?>
</foobar>);
\end{verbatim}
\end{slide}

\begin{slide}{Localization}

The string prefix {\tt \_} or {\tt \_{\it textdomain}\_} can be used to
localize a string:

\vspace*{.5cm}
\begin{verbatim}
var a = "tiny", b = "test";
debug _"This is a $a localization $b.";
\end{verbatim}

\vspace*{.5cm}
The dollar substitutions are automatically replaced by placeholders which are
later substituted after the translation has been looked up. The special
compiler mode {\tt -XN} can be used to produce dummy C file for xgettext:

\vspace*{.5cm}
\begin{verbatim}
$ splrun -XN demo.spl
/* Dummy C file for xgettext */
gettext("This is a {0} localization {1}.");
\end{verbatim}

\end{slide}

\begin{slide}{Regular Expressions}

\begin{itemize}
\item SPL is using PCRE for regular expressions.

\vspace*{.5cm}
\item All the regex features of Perl are also available in SPL,
and more. Some examples:
\end{itemize}

\vspace*{.5cm}
\begin{verbatim}
"the answer is 42" =~ /(?P<answer>\d+)/I;
debug "What is the question that leads to $answer?";

foreach[] word ("this is a test" =~ /\S+/Ag)
        debug word =~ s/[aeiou]/<$0>/Rg;

var text = "A = #A, B = #B, C = #C, D = #D";
debug text =~ e/#(.)/Rg ord($1);
\end{verbatim}

\end{slide}

% ============================================================================

\tsectionandpart{Module Features}

\begin{slide}{XML}
\begin{verbatim}
load "xml";
load "file";

var x = xml_parse(file_read("example_xml.xml"));

foreach[] p (x["//person"].nodes)
  debug "${p["name"]} is ${p["age"]} years old.";

delete x["//person[age < 26]"];

foreach[] p (x["//person"].nodes)
  debug "Person '${p["@id"]}' is >25 years old.";

write(xml_dump(x));
\end{verbatim}
\end{slide}

\begin{slide}{Qt/KDE}
\begin{verbatim}
load "kde";
qt_kdeinit("simplebrowser", "HTML Browser", "1.0");

var kapp = new qt.KApplication();
var win = new qt.QVBox();
var browser = new qt.KHTMLPart(win);

qt_signal_callback(browser.browserExtension(),
  "openURLRequest(const KURL&,const KParts::URLArgs&)",
  function(url) { browser.openURL(new qt.KURL(url)); });

var url = "file:/opt/postgresql/doc/html/index.html";
browser.openURL(new qt.KURL(url));

win.resize(640, 480);
win.show();
kapp.setMainWidget(win);
kapp.exec();
\end{verbatim}
\end{slide}

\begin{slide}{CGI and WebSPL}
\begin{itemize}

\item There is a simple CGI module for SPL.

\item WebSPL is a special SPL runtime for managing virtual processes per
sessions.

\item Sessions can be kept in memory or dumped to and restored from disk.

\end{itemize}

\vspace*{.3cm}
\begin{verbatim}
load "cgi";
load "task";

for (var i=0; i<10; i++) {
  write(<:>
    : [$i] Hello World! &nbsp;
    : <b>[<a href="$cgi.url?sid=$cgi.sid">next</a>]</b>
  </>);
  task_pause();
}

write("That's it!\n");
\end{verbatim}
\end{slide}

\begin{slide}{WSF, W2T and WebDebug}
\begin{itemize}

\item WSF and W2T are two application development frameworks based on WebSPL.

\vspace*{.5cm}
\item Both are ment for web applications, not dynamic web pages.

\vspace*{.5cm}
\item Developping dynamic web pages can be easily done directly with WebSPL.

\vspace*{.5cm}
\item WebDebug is a little web-based debugger that can be used in any WebSPL
programs.

\vspace*{1cm}
\item Demos: {\tt SPLCMS}, {\tt w2tdemo\_*.webspl}, {\tt SPL Poker}

\end{itemize}
\end{slide}

\begin{slide}{More Demos...}
If there is still some time left..
\begin{itemize}

\vspace*{.5cm}
\item Optimizer example

\vspace*{.5cm}
\item SDL Bindings (Pong)

\vspace*{.5cm}
\item SPL Ticket

\vspace*{.5cm}
\item Quick review of the manual

\vspace*{.5cm}
\item QCake Demo

\end{itemize}
\end{slide}

% ============================================================================

\tsectionandpart{References}

\begin{slide}{URLs}
\begin{itemize}

\item SPL Homepage: \\
http://www.clifford.at/spl/

\vspace*{.5cm}
\item Clifford Wolf: \\
http://www.clifford.at/

\end{itemize}
\end{slide}

\end{document}

