Jump to content

Native shebang: Difference between revisions

m ({{header|Racket}} stub added)
Line 353:
=={{header|Racket}}==
 
Racket has [http://docs.racket-lang.org/raco/index.html?q=raco <tt>raco: Racket Command Line Tools</tt>]
which can be used to compile to bytecode or compile to standalone executables (along with a whole load of
other fun stuff to do with packages, unit testing and the likes).
 
To properly compile a file/program, one needs to invoke <tt>raco</tt> or go through invocations of racket
File `native-shebang.rkt` contains the following:
to see what needs to be done. Compilation is expensive. Dependency management is expensive and difficult
<lang racket>#! /home/tim/racket-6.1/bin/racket
to do. The only one who can probably be trusted to do this is <tt>raco</tt>. So (as with Python), if you
need to compile the program, do so with the compiler.
 
Once you have done this, however, racket (in the shebang) will use the 'compiled' version, not the source.
 
In this example:
 
File `<tt>native-shebang.rkt`</tt> contains the following:
<lang racket>#! /homeusr/timlocal/racket-6.1/bin/racket
#lang racket
(displayln "hello")</lang>
 
My directory contains only this:
<pre>-bash-3.2$ ls
native-shebang.rkt</pre>
Which runs:
<pre>-bash-3.2$ ./native-shebang.rkt
hello</pre>
But has not self-compiled or anything like that:
<pre>-bash-3.2$ ls
native-shebang.rkt</pre>
I run <tt>raco</tt> to compile it:
<pre>-bash-3.2$ raco make native-shebang.rkt
-bash-3.2$ ls -R
.:
compiled native-shebang.rkt
 
./compiled:
native-shebang_rkt.dep native-shebang_rkt.zo
</pre>
The dependency file and byte-code -- <tt>.zo</tt> -- file are in a <tt>compiled</tt> directory.
 
I still run <tt>native-shebang.rkt</tt> from the script (with the <tt>racket</tt> shebang). Racket will use the compiled code instead of the source in the script:
<pre>-bash-3.2$ ./native-shebang.rkt
hello</pre>
(although it's hard to prove)
 
=={{header|Ruby}}==
569

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.