The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM - The SPVM Language

SPVM cat

Description

SPVM is a statically typed programming language that has Perl-like syntax.

SPVM has not yet reached a stable release of version 1.0. For now, there is currently no policy to keep the backward compatibility.

Usage

One Liner

Run a one liner using spvm command.

# Hello World!
spvm -e 'say "Hello World!";';

Run a one liner with loading a class.

# foo,bar,baz
spvm -M Fn -e 'say Fn->join(",", ["foo", "bar", "baz"]);'

Executing An SPVM Program

Write a SPVM class named hello.spvm to print "Hello World!" using the say operator.

# hello.spvm
class {
  static method main : void () {
    
    say "Hello World!";
  }
}

This class is an anon class and has main method that is an bootstrap method.

Run the SPVM program using spvm command.

spvm hello.spvm

Generating An Executable File

Generate an executable file using spvmcc command.

spvmcc -B ~/.spvm_build -o ./hello --no-config hello.spvm

Run the executable file.

./hello

Calling An SPVM Method from Perl

Write an SPVM class.

# lib/SPVM/MyMath.spvm
class MyMath {
  static method sum : int ($nums : int[]) {
    
    my $total = 0;
    for (my $i = 0; $i < @$nums; $i++) {
      $total += $nums->[$i];
    }
    
    return $total;
  }
}

Write a Perl program calling an SPVM method using exchange APIs.

# sum.pl
use FindBin;
use lib "$FindBin::Bin/lib";

use SPVM 'MyMath';

my $total = SPVM::MyMath->sum([3, 6, 8, 9]);

print "$total\n";

Run the Perl program.

# Run
perl sum.pl

Features

Tutorial

Documents

All SPVM Documents

Exchange APIs

Builder APIs

Commands

Modules

Examples

Wiki

Repository

SPVM - Github

Author

Yuki Kimoto <kimoto.yuki@gmail.com>

Core Developers

moti<motohiko.ave@gmail.com>

Contributors

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License