6

I have a Go Script which complied to Windows and Linux where i provide it to my customers.

I started exploring Perl6 and want to write the new version with perl 6 , does anyone know if Perl 6 have any option like :

Go build , GOOS AND GOARCH where the user can set the OS and ARCH and create new executable where it will be used by the end user?

raiph
  • 31,607
  • 3
  • 62
  • 111
jsor
  • 637
  • 4
  • 10

2 Answers2

3

Perl 6 compiles to its own virtual machine, but from the outside it looks like an interpreted language. You don't need to set different compiling options, it will all compile to MoarVM (or Java VM) adapting to the operating system it's in.

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
  • 1
    thanks for the answer i want the step that compile MoarVM code adapting to the OS could you help and give an example? , i want to provide the customer a file that run directly on the OS without let him install any additonal issue . – jsor Oct 07 '18 at 20:28
  • Well, as I said, you don't need to do anything. For instance, paths do use internally different classes such as [`IO::Path::Win32`](https://docs.perl6.org/type/IO::Path::Win32) to generate path names, in the case you mention. – jjmerelo Oct 08 '18 at 05:27
2

In contrast to Go, which by default compiles to a native executable, the current Perl 6 implementation requires a virtual machine to run. This is similar to other scripting languages like Python or PHP. The virtual machine is itself an executable that is dependent on OS and ARCH.

So Perl 6 currently does not offer an option to build native executable files from scripts.

However there is a tool called Perl 6 WiX Installer Maker that can create Windows MSI installers for Perl 6 scripts. Such installers bundle everything needed to run (virtual machine, compiler and runtime) in addition to the script itself. It's still a young project, so expect some bumps on the road.

Patrick Böker
  • 3,173
  • 1
  • 18
  • 24
  • Thanks for sharing the link for the WIX Installer i will try it , do you know if such feature is planned on Perl 6 MoarVM ? , such feature will make the process of distributing Perl 6 scripts with customer/clients more flat and easy. – jsor Oct 17 '18 at 13:26
  • I think it's in the nature of p6 to use a VM. So supporting native compilation will probably never happen. Tools that create exe files by binding together the VM and program tend to crop up at some point. (e.g. [this SO answer with sometools to do this for Python](https://stackoverflow.com/a/49155/1975049). Though most often installers or folders are used to put software together instead because of the limitations of the .exe approach. – Patrick Böker Oct 18 '18 at 06:58