Name
SPVM - The SPVM Language
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 to print "Hello World!" using the say operator.
# lib/SPVM/HelloWorld.spvm
class HelloWorld {
static method main : void () {
say "Hello World!";
}
}
Run the SPVM program using spvm command.
spvm -I lib/SPVM HelloWorld
Generating An Executable File
Generate an executable file using spvmcc command.
spvmcc -B ~/.spvm_build -o ./hello --no-config -I lib/SPVM HelloWorld
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
Native threads and goroutines.
AOT(Ahead-of-time compilation) and JIT(Just-in-time compilation).
Static types, type inference and static analysis.
C and C++ binding and resource system for C and C++ libraries.
Perl-like syntax with class syntax.
Tutorial
Documents
Exchange APIs
Builder APIs
Commands
Modules
Examples
Wiki
Repository
Author
Yuki Kimoto <kimoto.yuki@gmail.com>
Core Developers
moti<motohiko.ave@gmail.com>
Contributors
Mohammad S Anwar
akinomyoga
NAGAYASU Shinya
Reini Urban
chromatic
Kazutake Hiramatsu
Yasuaki Omokawa
Suman Khanal
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License