Hacker News new | ask | show | jobs
by nestorD 2341 days ago
I love the idea of Swift for Tensorflow : powerful automatic differentiation and a solid type system in a single language. That's something that is not seen elsewhere and that would make it a perfect fit to write deep learning code targeting production systems.

Now the language needs two things in order to be safe from an hypothetical abandon from Google : - running smoothly on linux (I though it was already there but your post seem to imply that it is not the case) - getting the auto-diff out of the alpha stage where people can build framework on top of it (fastai seem to be ready to jump on that ball which is nice)

2 comments

Here,

https://swift.org/getting-started/#using-the-repl

> On macOS

    1> import Darwin
    2> arc4random_uniform(10)
    $R0: UInt32 = 4
> On Linux

    1> import Glibc
    2> random() % 10
    $R0: Int32 = 4
Any of the languages that Swift is competing against, doesn't need to have OS specific imports for basic stuff.
Having distinct Darwin or Glibc imports seems a little crazy for these examples. When you code in c, libc is just there. It has minor variations from platform to platform, but you always think of it as libc. (Even if Darwin calls it libsystem etc. Or if Microsoft's is mscvrt and it kind of sucks.) It would be more reasonable to call it libc. (If I run on BSD do I still call it "glibc" with no actual GNU present? And if the arc4random APIs present in libc there look a lot like Darwin's because they actually share code? Maybe they have not considered porting to non-linux?)

Basically they set a portability boundary in the wrong place.

But for context, the previous sentence on that page is: “You can also import any available system modules, such as Darwin on macOS and Glibc on Linux”

The random number examples aren’t saying that’s the right way to generate random numbers in a platform-independent way, it is specifically demonstrating how to import system libraries on your local platform.

Swift 4.2 (2018) introduced a cross platform random number API.

    (0..<10).randomElement()
Yet they didn't bother to update the example on the introduction to Swift.

There are plenty of other examples I can look for, like file handling.

File handling can be done using Foundation, which I believe has API parity between Darwin and Linux at least.

I think the point of the example was to demonstrate importing platform-specific modules, not random number generation per se. But you're right, it should probably be updated to do something else.

>Yet they didn't bother to update the example on the introduction to Swift.

There are widely popular FOSS languages with much much less documentation...

Such as?
Golang has terser and worse documentation than Swift, for one...
Dude you’re literally illustrating Swifts strength here. The whole point is to have a safe easy to use language that reuses existing system libraries.
Any mainstream programming language can do that.
Not many use an actual c/c++ compiler (clang) to generate language native calling convention wrappers for calling into C/ObjC code (not sure how well c++ interop works these days).
Few as elegant, as safe, or as performant combined...
Delphi, D, .NET, Eiffel, Ada, Rust, Nim.

And lets not put Swift and performance on the same sentence, they still need to catch up a bit.

https://github.com/ixy-languages/ixy-languages

What is this, a cabinet of curiosities?

Aside from .NET and Rust, all the others are not players in 2020.

for what it is worth: a few days ago I installed the latest Swift and TensorFlow in Swift on both my little MacBook and my Linux laptop (1070 GPU, i7, fast laptop).

I had to manually set LD_LOAD_PATH on macOS, but then everything worked on macOS and Linux.