SPVM - Fast calculation, GC, static typing, VM with perlish syntax
SPVM is under development! I will change implementation and specification without warnings.
use FindBin; use lib "$FindBin::Bin/lib"; use SPVM 'MyModule2'; my $total = SPVM::MyModule2::foo(3, 5); print $total . "\n";
Module file
# lib/SPVM/MyModule1.spvm package MyModule1 { has x : int; has y : int; sub sum ($x : int, $y : int) : int { my $total = $x + $y; return $total; } } # lib/SPVM/MyModule2.spvm use MyModule1; package MyModule2 { sub foo ($x : int, $y : int) : int { my $total = ($x * $y) + MyModule1::sum(2, 4); return $total; } }
If you want to know more syntax, see solo/SPVM/Test.spvm.
solo/SPVM/Test.spvm
If you want to know SPVM language, see solo/README.md
solo/README.md
Do you need faster Perl? SPVM provides fast calculation to Perl.
Fast calculation - The Perl's biggest weak point is the calculation performance. SPVM provides fast calculations.
GC - You don't need to care about freeing memory
Static typing - Static typing for performance
VM - Byte codes are generated so that you can run them on SPVM language
Perlish syntax - SPVM syntax is very similar to Perl
Perl module - SPVM function can be called from Perl itself.
SPVM is a language which is similar with Perl. SPVM is very similar to Perl, and you can write same syntax of Perl in most part.
SPVM communicate with Perl. You can call SPVM function directory from Perl.
SPVM is very fast and provide array data structure. Now SPVM array operation is about 6x faster.
At first, you can write SPVM module.
# lib/SPVM/MyModule1.spvm package MyModule1 { has x : int; has y : int; sub sum ($x : int, $y : int) : int { my $total = $x + $y; return $total; } }
This is same as Perl except SPVM have static type and has keyword.
has
You can define field by has keyword, and specify static type by : type.
: type
has x : int;
You can specify argument types and return type to subroutine by : type.
sub sum ($x : int, $y : int) : int { my $total = $x + $y; return $total; }
Let's save this file by the following name
lib/SPVM/MyModule1.spvm
If package name is MyModule1, file name must be SPVM/MyModule1.spvm.
MyModule1
SPVM/MyModule1.spvm
Extension is spvm. And you create SPVM directory.
spvm
SPVM
lib is normal directory.
lib
Next you can use SPVM subroutine from Perl.
use FindBin; use lib "$FindBin::Bin/lib"; use SPVM 'MyModule1'; my $total = SPVM::MyModule1::sum(3, 5); print $total . "\n";
At first, you add library path by FindBin and lib module.
use FindBin; use lib "$FindBin::Bin/lib";
Next, use SPVM module. MyModule1 is loaded.
use SPVM 'MyModule1';
And call SPVM subroutine. If SPVM subroutine absolute name is MyModule1::sum, you can call this subroutine by SPVM::MyModule1::sum.
MyModule1::sum
SPVM::MyModule1::sum
my $total = SPVM::MyModule1::sum(3, 5); print $total . "\n";
SPVM::Document::Spec - SPVM Language Specification
SPVM::Document::NativeAPI - SPVM Native API.
Native API is C level API. You can write programing logic using C language and SPVM Native API.
SPVM::Document::Cookbook - SPVM Cookbook, advanced technique and many examples.
SPVM::Document::FAQ - Oftten asked question.
Create new_byte array
my $array = SPVM::new_byte_array([1, 2, 3]);
If you get perl values, you can use get_elements methods.
get_elements
my $values = $array->get_elements;
Create short array
my $array = SPVM::new_short_array([1, 2, 3]);
Create int array
my $array = SPVM::new_int_array([1, 2, 3]);
Create long array
my $array = SPVM::new_long_array([1, 2, 3]);
Create float array
my $array = SPVM::new_float_array([1, 2, 3]);
Create double array
my $array = SPVM::new_double_array([1, 2, 3]);
Create object array with type name and length.
my $array = SPVM::new_object_array_len("int[]", 3);
You can set and get elements by set and get method.
set
get
$array->set(1, SPVM::new_int_array([1, 2, 3])); my $element = $array->get(1);
Create byte array from not decoded Perl string. This function is faster than SPVM::string because copy is not executed.
SPVM::string
my $array = SPVM::new_string_raw("AGTCAGTC");
Create byte array from decoded Perl string.
my $array = SPVM::new_string("����������");
Create object.
my $object = SPVM::new_object("Point");
You can set and get value by set and get method.
$object->set(x => 1); my $x = $object->get('x');
We are constantly working on new documentation. Follow us on GitHub or join the official IRC channel #perl11 on irc.perl.org to get all the latest updates.
#perl11
irc.perl.org
If you have any questions the documentation might not yet answer, don't hesitate to ask on the the official IRC channel #perl11 on irc.perl.org (chat now!).
You can see #perl11 log.
http://irclog.perlgeek.de/perl11/
Yuki Kimoto <kimoto.yuki@gmail.com<gt>
akinomyoga (Koichi Murase)
[NAGAYASU Shinya
Reini Urban
chromatic
Kazutake Hiramatsu
Copyright (C) 2017 by Yuki Kimoto
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.3 or, at your option, any later version of Perl 5 you may have available.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.