DEV Community

Yuki Kimoto
Yuki Kimoto

Posted on

SPVM supported self Compiler in 0.9683.

SPVM now supports self-compilers.

What is a self-compiler? It means that SPVM's own source code can be compiled using SPVM.

SPVM has a goal of implementing a browser within 5 years.

The browser downloads the SPVM source code from the web and executes it. In other words, the browser executable generated by SPVM can execute SPVM's source code.

This allows SPVM to be the code of the browser itself, the client code interpreted by the browser, and the code executed on the server side.

This may seem like a distant dream, since browsers require the implementation of a large amount of source code. But the way forward is clear.

Borrow the Web GPU specification, create a rendering engine, and run all applications on top of it. Instead of building applications on top of HTML and CSS, HTML and CSS rendering will be done on top of an engine written in SPVM.

Examples

  use Compiler;

  my $compiler = Compiler->new;

  $compiler->add_module_dir("lib");

  $compiler->set_start_file(__FILE__);

  {
    my $class_name = "Foo";
    $compiler->set_start_line(__LINE__ + 1);
    my $success = $compiler->compile($class_name);
    unless ($success) {
      my $error_messages = $compiler->get_error_messages;
      for my $error_message (@$error_messages) {
        warn "$error_message";
      }
      die "Can't compile the \"$class_name\" class";
    }
  }

  {
    my $class_name = "Bar";
    $compiler->set_start_line(__LINE__ + 1);
    my $success = $compiler->compile($class_name);
    unless ($success) {
      my $error_messages = $compiler->get_error_messages;
      for my $error_message (@$error_messages) {
        warn "$error_message";
      }
      die "Can't compile the \"$class_name\" class";
    }
  }

  my $runtime = $compiler->build_runtime;
  my $env = $runtime->build_env;
  my $stack = $env->build_stack;
Enter fullscreen mode Exit fullscreen mode

SPVM 0.9683 is released.

New Features and Enhancement

Changes

0.9683 2022-01-21
  [New Features]
    * Added the Compiler class.
    * Added the Runtime class.
    * Added the Env class.
    * Added the Stack class.
  [Exception Message Improvement]
    * Exception messages are improved.
      - "SPVM_BUILD_DIR environment variable must be set to build a $category method at runtime";
      + "The \"build_dir\" field must be defined to build a $category method at runtime. Perhaps the setting of the SPVM_BUILD_DIR environment variable is forgotten";      [After]
      - "SPVM_BUILD_DIR environment variable must be set for link";
      + "The \"build_dir\" field must be defined to build the native module for the $category methods. Perhaps the setting of the SPVM_BUILD_DIR environment variable is forgotten";
  [Changes]
    The document of the module file that is generated by the spvmdist command is changed.

    [Before]
    =head1 Name

    SPVM::$class_name - foo

    =head1 Description

    C<SPVM::$class_name> is the L<SPVM>'s C<$class_name> class.

    [After]
    =head1 Name

    SPVM::$class_name - Short Description

    =head1 Description

    C<SPVM::$class_name> is the C<$class_name> class in L<SPVM> language.
  [Document Changes]
    * Added the "Executable Envrionment" heading to SPVM::Document::NativeAPI.
    * Renamed the "Stack" heading to SPVM::Document::NativeAPI to "Call Stack".
Enter fullscreen mode Exit fullscreen mode

For Programming Beginners

What Is SPVM?

SPVM is a static typed programming language that can be installed from Perl/CPAN.

How potential dose SPVM have?

Growth is expected in the fields of Bio Tech, AI/ML, Apple/iPhone/iPad Apps, Google/Android Apps, IoT Device, Connected Car, Smart Device, Smart Home, etc.

This is because SPVM can produce an executable file that supports cross platforms and make easy to calculate arrays and bind C/C++

Top comments (0)