[Swift-user] Questions

Ben Clifford benc at hawaga.org.uk
Tue May 13 11:09:07 CDT 2008


> > > > 2.  Can i call other code (written in another language) from swift?

> > Swift calls out to unix executables; if you can compile your code into a
> > unix executable, then you can call your code that way.

> > It will not be a JNI / function level link. It will be using Swift's file
> > transfer+execute mechanism for calling executables:
> >   input data files are copied to whichever machine you will run on
> >   your code is executed
> >   output data files are copied back

> Does any one have an example on how to do item # 2 below?

In section 3.4 of the tutorial at 
http://www.ci.uchicago.edu/swift/guides/tutorial.php there is an example 
of one procedure, greeting(), outputing some data (a text message) to a 
file and another procedure, countwords(), reading that data in and 
counting the words.

If you are familiar with shell, the example is basically doing:

 echo hello from swift > q13greeting.txt
 wc -w q13greeting.txt

Each of those two command lines can be run in different places and at 
different times by swift (and, if they didn't have a data dependency of 
q13greeting.txt between them, potentially in parallel).

So all the pieces of your code that you want Swift to be able to execute 
separately, you need to make into its own separate command line program, 
like echo or wc above (but presumably much larger - for example, minutes 
of computation).

-- 



More information about the Swift-user mailing list