TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

High Performance Numeric Programming with Swift: Explorations and Reflections

113 点作者 parrt超过 6 年前

4 条评论

Someone超过 6 年前
One thing to look out for is that Swift Arrays aren’t really arrays. <a href="https:&#x2F;&#x2F;www.raywenderlich.com&#x2F;1172-collection-data-structures-in-swift" rel="nofollow">https:&#x2F;&#x2F;www.raywenderlich.com&#x2F;1172-collection-data-structure...</a>:<p><i>”1. Accessing any value at a particular index in an array is at worst O(log n), but should usually be O(1).<p>2. Searching for an object at an unknown index is at worst O(n (log n)), but will generally be O(n).<p>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”</i><p>If you want a more traditional data structure, use ContiguousArray, which <i>is</i> an array. <a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;swift&#x2F;contiguousarray" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;swift&#x2F;contiguousar...</a>:<p><i>”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”</i>
评论 #18881080 未加载
评论 #18881046 未加载
byt143超过 6 年前
Thanks for writing up your thoughts!<p>I find Julia&#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&#x27;s type system and multiple dispatch.<p>It&#x27;s external program interop is also more pleasant than Python&#x27;s :<a href="https:&#x2F;&#x2F;docs.julialang.org&#x2F;en&#x2F;v1&#x2F;manual&#x2F;running-external-programs&#x2F;#Running-External-Programs-1" rel="nofollow">https:&#x2F;&#x2F;docs.julialang.org&#x2F;en&#x2F;v1&#x2F;manual&#x2F;running-external-pro...</a><p>Sure, it doesn&#x27;t have the same general library ecosystem, but even that is being remedied for core areas like web programming: <a href="http:&#x2F;&#x2F;genieframework.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;genieframework.com&#x2F;</a> (a full MVC framework), <a href="https:&#x2F;&#x2F;github.com&#x2F;JuliaGizmos&#x2F;WebIO.jl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;JuliaGizmos&#x2F;WebIO.jl</a> (write front end code without javascript) and I&#x27;m particularly excited for <a href="https:&#x2F;&#x2F;github.com&#x2F;Keno&#x2F;julia-wasm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Keno&#x2F;julia-wasm</a>, which will allow Julia programs to be compiled for the browser.<p>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.<p>With regards to numerical programming, it&#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&#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: <a href="https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2018&#x2F;12&#x2F;ml-language-compiler" rel="nofollow">https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2018&#x2F;12&#x2F;ml-language-compiler</a><p>In addition, it&#x27;s macro system, introspection, dynamic typing and value types through abstract typing approach allows for natural development of advanced probabilistic programming languages: <a href="https:&#x2F;&#x2F;github.com&#x2F;TuringLang&#x2F;Turing.jl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;TuringLang&#x2F;Turing.jl</a>, <a href="https:&#x2F;&#x2F;github.com&#x2F;probcomp&#x2F;Gen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;probcomp&#x2F;Gen</a>, <a href="https:&#x2F;&#x2F;github.com&#x2F;zenna&#x2F;Omega.jl&#x2F;pulse" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zenna&#x2F;Omega.jl&#x2F;pulse</a>
评论 #18879214 未加载
评论 #18881687 未加载
评论 #18881316 未加载
评论 #18879357 未加载
jph00超过 6 年前
Hello folks! I wrote this article - so if you have any questions, feel free to shoot them my way. :)
评论 #18878370 未加载
评论 #18879937 未加载
评论 #18879501 未加载
abalone超过 6 年前
Key point here is Chris Lattner is working on this stuff. He’s the creator of Swift and LLVM and one of the smartest minds in the industry. Pay atttention.