NAME

SPVM - Fast Calculation and Easy C/C++ Binding with perlish syntax and static typing

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

SYNOPSIS

Fast Array Operation using SPVM.

SPVM Module:

# lib/SPVM/MyMath.spvm
package MyMath {
  
  # Sub Declaration
  sub sum ($nums : int[]) : int {
    
    # Culcurate total
    my $total = 0;
    for (my $i = 0; $i < @$nums; $i++) {
      $total += $nums->[$i];
    }
    
    return $total;
  }
}

Use SPVM Module from Perl

use FindBin;
use lib "$FindBin::Bin/lib";

# Use SPVM module
use SPVM 'MyMath';

# New SPVM int array
my $sp_nums = SPVM::new_int_array([3, 6, 8, 9]);

# Call SPVM subroutine
my $total = SPVM::MyMath::sum($sp_nums);

print $total . "\n";

If you know more SPVM syntax, see SPVM::Document::Specification.

If you know more Functions to convert Perl Data to SPVM Data, see SPVM::Document::Functions.

C Extension using SPVM

SPVM Module:

# lib/SPVM/MyMathNative.spvm
package MyMathNative {
  
  # Sub Declaration
  sub sum ($nums : int[]) : native int;
}

C Source File;

// lib/SPVM/MyMathNative.native/MyMathNative.c
#include <spvm_api.h>

int32_t SPVM__MyMathNative__sum(SPVM_API* api, SPVM_API_VALUE* args) {
  
  // First argument
  SPVM_API_OBJECT* sp_nums = args[0].object_value;
  
  // Array length
  int32_t length = api->get_array_length(api, sp_nums);
  
  // Elements pointer
  int32_t* nums = api->get_int_array_elements(api, sp_nums);
  
  // Culcurate total
  int32_t total = 0;
  {
    int32_t i;
    for (i = 0; i < length; i++) {
      total += nums[i];
    }
  }
  
  return total;
}

Use Extension Module from Perl:

use FindBin;
use lib "$FindBin::Bin/lib";

# Use SPVM module
use SPVM 'MyMathNative';

# New SPVM int array
my $sp_nums = SPVM::new_int_array([3, 6, 8, 9]);

# Call SPVM subroutine
my $total = SPVM::MyMathNative::sum($sp_nums);

print $total . "\n";

If you know more SPVM Extension, see SPVM::Document::Extension.

If you know the APIs to manipulate SPVM data, see SPVM::Document::NativeAPI.

DESCRIPTION

SPVM provide Fast Culcuration and Easy way to Bind C/C++ Language 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.

If you learn more SPVM, see SPVM Documentation.

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.