Re:Swift: Google’s Bet on Differentiable Programming
by lalord on Thursday April 09, 2020 @02:38PM
(#22825759)
Hi, author here, thanks for taking the time to read the article!
The objective of the demo was not to see which language could sum up a bunch of numbers the fastest. You could keep optimizing that until you are left with just `print(<the resulting number>)`. The objective was to have a simple example of looping over an array a bunch of times. The only reason I ended up summing the numbers in the array and printing them was so that LLVM wouldn't optimize it away and be unfair towards python. I actually wrote it first in Python tbh.
Re:Swift: Google’s Bet on Differentiable Programming
by BiteCode_dev on Thursday April 09, 2020 @02:44PM
(#22825817)
Make sense, thanks.
Re:Swift: Google’s Bet on Differentiable Programming
by favorited on Thursday April 09, 2020 @06:12PM
(#22827744)
The `CFAbsoluteTimeGetCurrent()` is just a call to a system library. There are libraries which implement APIs like:
let clock = Clock.system
let now = clock.thisInstant()
there just isn't a nice core library interface yet.
But the python example doesn't make me trust the rest of the article. It is clearly a swift example, translated verbatim to python.
Idiomatic Python would be this:
Which is shorter, and way faster.Now of course, Python is slower than swift (although a numpy version would not be, but I get it's not relevant in general purpose machine learning). But misrepresenting a language is not a good way to make a point.