The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SPVM - Fast calculation, GC, static typing, VM with perlish syntax

SPVM is under development! I will change implementation and specification without warnings.

SYNOPSIS

  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.

If you want to know SPVM language, see solo/README.md

DESCRIPTION

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 Tutorial

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.

SPVM module

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.

You can define field by has keyword, and specify static type by : 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.

Extension is spvm. And you create SPVM directory.

lib is normal directory.

Call SPVM subroutine

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.

  my $total = SPVM::MyModule1::sum(3, 5);
  print $total . "\n";

Document

SPVM Language Specification

SPVM::Document::Spec - SPVM Language Specification

SPVM Native API

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 Cookbook

SPVM::Document::Cookbook - SPVM Cookbook, advanced technique and many examples.

SPVM FAQ

SPVM::Document::FAQ - Oftten asked question.

Functions

new_byte_array

Create new_byte array

  my $array = SPVM::new_byte_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;

new_short_array

Create short array

  my $array = SPVM::new_short_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;

new_int_array

Create int array

  my $array = SPVM::new_int_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;

new_long_array

Create long array

  my $array = SPVM::new_long_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;

new_float_array

Create float array

  my $array = SPVM::new_float_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;

new_double_array

Create double array

  my $array = SPVM::new_double_array([1, 2, 3]);

If you get perl values, you can use get_elements methods.

  my $values = $array->get_elements;
  

new_object_array_len

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.

  $array->set(1, SPVM::new_int_array([1, 2, 3]));
  my $element = $array->get(1);

new_string_raw

Create byte array from not decoded Perl string. This function is faster than SPVM::string because copy is not executed.

  my $array = SPVM::new_string_raw("AGTCAGTC");

new_string

Create byte array from decoded Perl string.

  my $array = SPVM::new_string("����������");

new_object

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');

DON'T PANIC!

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.

SUPPORT

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/

AUTHOR

Yuki Kimoto <kimoto.yuki@gmail.com<gt>

CONTRIBUTERS

COPYRIGHT AND LICENSE

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.