<story><title>High Performance Numeric Programming with Swift: Explorations and Reflections</title><url>https://www.fast.ai/2019/01/10/swift-numerics/</url></story><parent_chain></parent_chain><comment><author>Someone</author><text>One thing to look out for is that Swift Arrays aren’t really arrays. &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.raywenderlich.com&amp;#x2F;1172-collection-data-structures-in-swift&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.raywenderlich.com&amp;#x2F;1172-collection-data-structure...&lt;/a&gt;:&lt;p&gt;&lt;i&gt;”1. Accessing any value at a particular index in an array is at worst O(log n), but should usually be O(1).&lt;p&gt;2. Searching for an object at an unknown index is at worst O(n (log n)), but will generally be O(n).&lt;p&gt;3. Inserting or deleting an object is at worst O(n (log n)) but will often be O(1).
These guarantees subtly deviate from the simple “ideal” array that you might expect from a computer science textbook or the C language, where an array is always a sequence of items laid out contiguously in memory”&lt;/i&gt;&lt;p&gt;If you want a more traditional data structure, use ContiguousArray, which &lt;i&gt;is&lt;/i&gt; an array. &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;developer.apple.com&amp;#x2F;documentation&amp;#x2F;swift&amp;#x2F;contiguousarray&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;developer.apple.com&amp;#x2F;documentation&amp;#x2F;swift&amp;#x2F;contiguousar...&lt;/a&gt;:&lt;p&gt;&lt;i&gt;”The ContiguousArray type is a specialized array that always stores its elements in a contiguous region of memory. This contrasts with Array, which can store its elements in either a contiguous region of memory or an NSArray instance if its Element type is a class or @objc protocol”&lt;/i&gt;</text></comment>
<story><title>High Performance Numeric Programming with Swift: Explorations and Reflections</title><url>https://www.fast.ai/2019/01/10/swift-numerics/</url></story><parent_chain></parent_chain><comment><author>byt143</author><text>Thanks for writing up your thoughts!&lt;p&gt;I find Julia&amp;#x27;s core design to be excellent for general purpose programming, better than python in fact since it essentially solves the expression problem with it&amp;#x27;s type system and multiple dispatch.&lt;p&gt;It&amp;#x27;s external program interop is also more pleasant than Python&amp;#x27;s :&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.julialang.org&amp;#x2F;en&amp;#x2F;v1&amp;#x2F;manual&amp;#x2F;running-external-programs&amp;#x2F;#Running-External-Programs-1&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.julialang.org&amp;#x2F;en&amp;#x2F;v1&amp;#x2F;manual&amp;#x2F;running-external-pro...&lt;/a&gt;&lt;p&gt;Sure, it doesn&amp;#x27;t have the same general library ecosystem, but even that is being remedied for  core areas  like web programming: &lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;genieframework.com&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;genieframework.com&amp;#x2F;&lt;/a&gt; (a full MVC framework), &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;JuliaGizmos&amp;#x2F;WebIO.jl&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;JuliaGizmos&amp;#x2F;WebIO.jl&lt;/a&gt; (write front end code without javascript)  and 
 I&amp;#x27;m particularly excited for &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;Keno&amp;#x2F;julia-wasm&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;Keno&amp;#x2F;julia-wasm&lt;/a&gt;, which will allow Julia programs to be compiled for the browser.&lt;p&gt;For any packages than are python only, it has excellent python interop using the pycall.jl package, which even allows users to write custom python classes in Julia.&lt;p&gt;With regards to numerical programming, it&amp;#x27;s obviously already far ahead of swift, and IMO much better placed to beat it in the long run. For example the  WIP zyogte package is able to hook into Julia&amp;#x27;s compiler to zero overhead  diff  arbitrary code. Using Cassette.jl, package authors can write custom compiler passes outside the main repo and in pure Julia: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;julialang.org&amp;#x2F;blog&amp;#x2F;2018&amp;#x2F;12&amp;#x2F;ml-language-compiler&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;julialang.org&amp;#x2F;blog&amp;#x2F;2018&amp;#x2F;12&amp;#x2F;ml-language-compiler&lt;/a&gt;&lt;p&gt;In addition, it&amp;#x27;s macro system, introspection, dynamic typing and value types through abstract typing  approach allows for natural development of advanced  probabilistic programming languages: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;TuringLang&amp;#x2F;Turing.jl&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;TuringLang&amp;#x2F;Turing.jl&lt;/a&gt;, &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;probcomp&amp;#x2F;Gen&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;probcomp&amp;#x2F;Gen&lt;/a&gt;, &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;zenna&amp;#x2F;Omega.jl&amp;#x2F;pulse&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;zenna&amp;#x2F;Omega.jl&amp;#x2F;pulse&lt;/a&gt;</text></comment>