<div>For the interpreter, it&#39;s acceptable since it&#39;s got the debugger in there; but for the scripting mode it&#39;s a real obstruction.</div><div><br><div class="gmail_quote"><div>Keith Smiley &lt;k@keith.so&gt; schrieb am Mo. 20. Feb. 2017 um 11:25:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A related issue that&#39;s worth mentioning is the overhead of running a<br class="gmail_msg">
Swift script in general. Here&#39;s the simplest of examples of Swift vs<br class="gmail_msg">
Python:<br class="gmail_msg">
<br class="gmail_msg">
```<br class="gmail_msg">
$ cat helloworld<br class="gmail_msg">
print(&quot;Hello World&quot;)<br class="gmail_msg">
<br class="gmail_msg">
Cold:<br class="gmail_msg">
<br class="gmail_msg">
$ time swift helloworld<br class="gmail_msg">
Hello World<br class="gmail_msg">
swift helloworld  0.06s user 0.44s system 67% cpu 0.746 total<br class="gmail_msg">
$ time python helloworld<br class="gmail_msg">
Hello World<br class="gmail_msg">
python helloworld  0.01s user 0.01s system 22% cpu 0.095 total<br class="gmail_msg">
<br class="gmail_msg">
Warm:<br class="gmail_msg">
<br class="gmail_msg">
$ time swift helloworld<br class="gmail_msg">
Hello World<br class="gmail_msg">
swift helloworld  0.04s user 0.01s system 22% cpu 0.212 total<br class="gmail_msg">
$ time python helloworld<br class="gmail_msg">
Hello World<br class="gmail_msg">
python helloworld  0.02s user 0.01s system 84% cpu 0.035 total<br class="gmail_msg">
```<br class="gmail_msg">
<br class="gmail_msg">
While we&#39;re thinking about this for scripting, I think it&#39;s tangentially<br class="gmail_msg">
related that the repl has a similar difference in overhead:<br class="gmail_msg">
<br class="gmail_msg">
```<br class="gmail_msg">
$ time swift &lt;&lt;&lt; &quot;:quit&quot;<br class="gmail_msg">
Welcome to Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1). Type :help for assistance.<br class="gmail_msg">
swift &lt;&lt;&lt; &quot;:quit&quot;  1.88s user 0.23s system 86% cpu 2.459 total<br class="gmail_msg">
<br class="gmail_msg">
$ time python &lt;&lt;&lt; &quot;quit()&quot;<br class="gmail_msg">
python &lt;&lt;&lt; &quot;quit()&quot;  0.01s user 0.01s system 81% cpu 0.030 total<br class="gmail_msg">
```<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Keith Smiley<br class="gmail_msg">
<br class="gmail_msg">
On 02/19, Jason Dusek via swift-build-dev wrote:<br class="gmail_msg">
&gt; One issue with compiling the dependencies is that script startup would be<br class="gmail_msg">
&gt; slow. Maybe there should be a per-user or system level cache? System level<br class="gmail_msg">
&gt; is better from a disk usage perspective but some thought must be given to<br class="gmail_msg">
&gt; security.<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; With Ruby and Python, it is not expected that a script&#39;s dependencies are<br class="gmail_msg">
&gt; installed when it is run but rather they have already been installed via<br class="gmail_msg">
&gt; the package manager, although it does seem useful for single files to<br class="gmail_msg">
&gt; contain all the relevant information.<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Here is another idea: a Swift script can be run from a project directory<br class="gmail_msg">
&gt; with Sources/, Packages/, &amp;c. In that environment, build products are<br class="gmail_msg">
&gt; already cached. If the script is symlinked into /usr/local/bin/ it will be<br class="gmail_msg">
&gt; on the path but xcrun will still be able to find the project. It is kind of<br class="gmail_msg">
&gt; like a source-level .app bundle.<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Maxim Veksler via swift-build-dev &lt;<a href="mailto:swift-build-dev@swift.org" class="gmail_msg" target="_blank">swift-build-dev@swift.org</a>&gt; schrieb am<br class="gmail_msg">
&gt; Sa. 18. Feb. 2017 um 11:28:<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; &gt; Hi,<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; Ayaka Nonaka gave a talk[1] about basic scripting[2] support in Swift.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; The gist of the idea is to use #!/usr/bin/env xcrun swift<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; Therefor it seems the basic building blocks for allowing a swift file to<br class="gmail_msg">
&gt; &gt; &quot;execute itself&quot; are always laid out and proved to be applicable.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; What&#39;s missing IMHO is a better support for dependencies, the suggested<br class="gmail_msg">
&gt; &gt; solutions in the talk are using the -F for including frameworks that were<br class="gmail_msg">
&gt; &gt; built using Carthage or CocoaPods. That&#39;s not idle because a script I think<br class="gmail_msg">
&gt; &gt; should be self contained, meaning that you can &quot;just run it&quot; and it works.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; So, I&#39;m wondering what if it was possible to include the dependencies<br class="gmail_msg">
&gt; &gt; inside the swift file itself? Probably using the same format as the<br class="gmail_msg">
&gt; &gt; Package.swift syntax. The the swift binary would &quot;detect&quot; that it&#39;s a self<br class="gmail_msg">
&gt; &gt; contained file, it could make this distinction because import<br class="gmail_msg">
&gt; &gt; PackageDescription is defined by the user.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; Then it would follow a 3 step process:<br class="gmail_msg">
&gt; &gt; 1. It should download and build the dependencies<br class="gmail_msg">
&gt; &gt; 2. then compile the code inside the file<br class="gmail_msg">
&gt; &gt; 3. and then run it.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; Having everything happening behind the scenes, so the &quot;script user&quot; simply<br class="gmail_msg">
&gt; &gt; calls ./MyScript.swift or swift MyScript.swift and it &quot;just works&quot;.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; Wondering what the community thinks.<br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
&gt; &gt; [1] <a href="https://realm.io/news/swift-scripting/" rel="noreferrer" class="gmail_msg" target="_blank">https://realm.io/news/swift-scripting/</a><br class="gmail_msg">
&gt; &gt; [2] <a href="https://github.com/ayanonagon/talks/tree/master/2015-swiftsummit/2" rel="noreferrer" class="gmail_msg" target="_blank">https://github.com/ayanonagon/talks/tree/master/2015-swiftsummit/2</a><br class="gmail_msg">
&gt; &gt; _______________________________________________<br class="gmail_msg">
&gt; &gt; swift-build-dev mailing list<br class="gmail_msg">
&gt; &gt; <a href="mailto:swift-build-dev@swift.org" class="gmail_msg" target="_blank">swift-build-dev@swift.org</a><br class="gmail_msg">
&gt; &gt; <a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br class="gmail_msg">
&gt; &gt;<br class="gmail_msg">
<br class="gmail_msg">
&gt; _______________________________________________<br class="gmail_msg">
&gt; swift-build-dev mailing list<br class="gmail_msg">
&gt; <a href="mailto:swift-build-dev@swift.org" class="gmail_msg" target="_blank">swift-build-dev@swift.org</a><br class="gmail_msg">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>