8 ms·
Why data scientists should start learning Swift
- curiousgal 8y ago>engineers need a language that treats machine learning as a “first class citizen” Machine/Deep Learning are not some novel application, we've been multiplying matrices since forever.
- goatlover 8y agoLike with Fortran, APL, J/K, R and for at least a decade, Numpy.
- acmecorps 8y agoDoes Swift have the libraries that Python/Matlab has? My wife is doing some kind of fMRI analysis/research for her PhD and she's using Matlab. I'm an iOS developer, so I'd love it if I can get her to use Swift!
- msravi 8y agoNot sure about Swift libraries, but you should definitely try Julia. It's incredibly easy to move from MATLAB to Julia. https://julialang.org/ https://julialang.org/
- therealmarv 8y agoI know companies like e.g. Airbus which replaced Matlab with Python.
- Bukhmanizer 8y agoMost fMRI toolboxes are written in Matlab or Python unfortunately. You don't really want to go down the path of trying to rewrite (most of them) too.
- thefilth 8y agoIf you mean the matlab toolboxes (eg, image processing toolbox), which are proprietary libraries that you pay like $1k per year to use, no. Honestly, as someone who wrote matlab professionally for a couple years, the price is a joke, and the performance is jokier. The only reason that matlab still exists is that they use the same marketing tactics as drug dealers- it's free to universities, and super easy to use.
- lucas_membrane 8y ago>> A clean, automated way of compiling code for specialized hardware from TPUs to mobile chips If it is so good at that, why are we waiting so long for expeditiousness on run-of-the-mill industry-standard non-specialized non-Apple linux machines?
- laughfactory 8y agoSwift? Um, okay... Good language, yes, but it's still very iOS-centric. I generally agree with the assessment of Python, but I'll stick with R for everything it can do. I use Python for everything else. If Swift breaks out of the iOS box then maybe I'll think about learning it.
- therealmarv 8y agohm, no! data scientist are not using only Tensorflow... in the article libraries like Numpy, Scipy, Pandas are mentioned and swift does not have it or not in that maturity at all. It's not only about the beauty of a language, especially for data scientiest it's the variety and maturity of third party packages designed for data scientist and Tensorflow is only ONE part. Don't get me wrong... swift is beautiful and it is great to have Tensorflow natively running on it for certain scenarios but I don't see swift as a bright and good language outside the apple ecosystem (look at C#, great language, still mostly Windows). If you are starting with Python definitely start with Python 3 and you are future safe...
- SwiftKickInThe 8y agoHonestly I don't even use Swift for serious iOS apps, just for 'throwaway' apps for lack of a better word. Swift would need to stabilize for at least 5-10 years before I would consider building anything with Swift as the foundation. I strongly believe in backwards compatibility, the Swift team does not.
- nielsbot 8y agoYes and no... They did a ton if work to be backwards compatible with ObjC, while making breaking changes to Swift syntax/libraries with each new release. Although it is stabilizing.
- goatlover 8y agoWhy would you use Swift as your new data science language when Julia was made for that purpose and Swift was not? Julia's data structures, functions, syntax and libraries were all designed with scientific computing in mind. Swift was designed for general purpose app development.
- civility 8y agoHeh, because 1-based arrays are gross. I'm poking fun of course, but you really shouldn't underestimate how many people are turned off of Julia by this.
- goatlover 8y agoIt's not like it's the first. Doesn't Fortran default to 1-based? R and Matlab are also 1-based. Julia like those two are aimed at a mathematical domain, not zero-based offsets. Anyway, it's not hard to get used to.
- civility 8y agoA bunch of wrongs don't make a right :-) And honestly, it's because I do numerical programming that I value zero-based offsets. In addition to subscripting arrays (which I could do in any base), I use those subscripts in the math itself. For instance, the zeroth bin of an FFT indicates the zero frequency. I also choose the zeroth array element to represent the constant term (zeroth power) of a polynomial, and so on. The common places where math notation uses 1-based subscripts (matrix notation) have more to do with people saying "first", "second", etc... With a few exceptions (the Hilbert matrix comes to mind), the base of the subscript isn't actually relevant to the math itself.
- dnautics 8y agoGenerally math formulae are one based, the fft and the Taylor expansions being the major exception. Natural numbers, by convention, unless you're bourbaki, start at one. I do appreciate that zero is easier because of offset caluculations, but you really do get used to it and in most cases the compiler figures it out with almost no penalty.
- 2RTZZSro 8y agoPlease stop balkanizing the scientific software development community. Python has excellent wrappers for many other excellent scientific libraries which in turn leverage C and Fortran for high performance computing.
- natch 8y agoWhen people say Python, I never know if they mean 2.7, 3.x, or both, or are unaware that there's a difference, or don't realize how much it matters in practice... so a language that has clear forward momentum, focuses on the latest version, and quickly deprecates old versions is pretty welcome.
- andybak 8y agoIt's a lot easy to "quickly deprecate" when the ecosystem is small and breakage is acceptable. Let's see how Swift handles the situation at a similar point in it's life cycle. Bear in mind that most criticisms of the Python2/3 situation came from people that wanted less breakage - not more.
- 2RTZZSro 8y agoThe Python community focuses on stability and maintains each major and minor release for a long time so applications built with a particular version of Python continue to work with updates for a long time
- okket 8y agoCorrect title: Why TensorFlow developers should start learning Swift Why on earth should data scientists ditch the IPython/Jupyter/SciPy/etc. ecosystem?
- MR4D 8y agoI think there is a subtlety you missed in the article. He didn’t say ditch Python, he said learn Swift. He simply states that 10 years from now people will be using Swift, not Python. Obviously he may be wrong, but it’s certainly reasonable prediction.
- nielsbot 8y agoPython seems a lot more "fun" than Swift IMO
- DonaldPShimoda 8y agoHow do you mean? I'm a big fan of Python, so I'm just curious what you mean here. Swift has a lot of great language features that Python lacks, in my opinion. (My first favorite: native option types. Second favorite: internal and external function parameter names. There are more, but these are my top two.)
- nielsbot 8y agoi like Swift, i think, but prefer something more dynamically typed i guess. Swift gives me that “i’m using C++” feeling.
- PeterisP 8y agoWhile the author says "Don’t mistake Swift for TensorFlow as a simple wrapper around TensorFlow to make it easier to use on iOS devices." , the only thing Python is missing from his wishlislist of features is "6. Native execution on mobile". "7. Performance closer to C" is a non-issue - all the parts where performance matters are going to run on CUDA anyway and there's no performance hit there, and very little computing time is spent in the actual python code.
- throwaway84742 8y agoStill an issue, just not where you think. For recent, more efficient CNN architectures _data augmentation_ is a bottleneck when done on a single thread. So Python has to resort to either queues and async (TF approach, worse perf than PyTorch in practice), or use multiprocessing (PyTorch approach, works better but ugly AF under the covers). I would absolutely love to use a multi core-capable language there. The machine does have several dozen cores after all.
- breatheoften 8y agoI hope swift gets serious about serving the needs of data scientists tool — it would not take that much work to improve swift playgrounds to the point to enable a far better dx than can be had with Jupyter notebooks or matlab ...
- MR4D 8y agoAgreed. I monitor this page [1]. So far, no Swift. :( [1] https://github.com/jupyter/jupyter/wiki/Jupyter-kernels https://github.com/jupyter/jupyter/wiki/Jupyter-kernels
- MR4D 8y agoJust found this. Not sure how good it is, but it’s a start.... https://repl.it/languages/swift https://repl.it/languages/swift
- blt 8y agoI don't know anything about Swift, but I really wish ML had settled on a language with higher performance. Interpreter speed doesn't bottleneck vision stuff but reinforcement learning really suffers.
- sriku 8y agoThe end to end application building aspect of python is not yet there with swift (swift for servers?). Also if folks keep sticking to tools well tuned for their jobs, maybe something like graalvm may provide enough interoperability and performance eventually ... in the "good enough is the competitor to the best" sense.
- mikkelam 8y agoSwift runs on Linux and there are also plenty of web frameworks, so it’s definitely possible to run on a server
- kreetx 8y agoHonest question: isn't python just glue over the well-performamt c++ tensorflow library? I thought it was, but given this article does python do more then? There wouldn't be much to gain by swappinge the wrapper.
- edem 8y agoMaybe you should use Kotlin instead. It runs native on IoS, on the server, and on Android as well.
- acqq 8y agoI haven't followed the news about Chris Lattner. For those who like me who haven't seen that he's in Google now: http://nondot.org/sabre/ http://nondot.org/sabre/ "I worked for Apple from July 2005 to January 2017, holding a number of different positions over the years" "This included managing the Developer Tools department, which was responsible for Swift Playgrounds for the iPad, Xcode, and Instruments, as well as compilers, debuggers, and related tools. In early 2017, I briefly ran the Tesla Autopilot team. We built a lot of great things, but Tesla wasn't the right fit for me." Joined "Google Brain" in August 2017. https://techcrunch.com/2017/08/14/swift-creator-chris-lattner-joins-google-brain-after-tesla-autopilot-stint/ https://techcrunch.com/2017/08/14/swift-creator-chris-lattne...
- jwilbs 8y agoIt may sound weird, but I believe if any data scientists switch to a ‘nontypical’ language for the domain, it should be JavaScript. What’s required for data science is a healthy ecosystem of scientific computing tools. While js obviously isn’t as mature as python (anaconda stack + Jupiter, etc) or R (tidyverse etc) in this aspect, it has made great strides recently: - tensorflow.js - observable notebooks - mathjs - simple-statistics / jstat Furthermore, with tools like d3 + leaflet, js has very little competition when it comes to data visualiation. A big thing holding js back is a mature library for data manipulation, hopefully this changes in the future (anybody know of any potential fills for this gap?).
- ktpsns 8y agoJust to give an example why a "domain specific" language like Julia is more appealing then a "general purpose" language like Swift: I would like to demonstrate this on the old and classy Fortran vs C++ discussion in numerical computing. In Fortran, you can write linear algebra on n-dimensional arrays (similar as in numpy and julia) very compactly, i.e. d(i) = TRANSPOSE(MATMUL(B(i,:),c)) Writing something like this in C++ is absolutely possible and elegant with modern templates libraries such as `eigen`. However, the compilation will be slower, the compiler errors will be hard to read and it is hard to beat Fortrans runtime efficiency of such code. But it get's more interesting. Think of tensor contractions. This is something where you probably want to implement your own algebra (say for relativistic quantum mechanics or for general relativity) -- or you just stick to the n-dimensional array again and use index-wise loops: DO i=1,4 DO j=1,4 DO k=1,4 DO l=1,4 A(i,j) = B(k,l)*C(i,k)*D(l,j) ! note: compe up with better examples END DO END DO END DO END DO I maintain a templated C++ library to write such expressions in one line instead of 4 loops. But contrary to this Fortran code, in order to understand my code, you first have to learn this library. Means you need to learn C++, then the library. In Fortran, it is just Fortran. Nothing more. Believe it or not: Many scientists are no good programmers. Cut-down domain specific languages are perfect to avoid them to loose time on weird compiler features such as "const", templates and all that overhead which is hard to regain in time.
- jcelerier 8y ago> But contrary to this Fortran code, in order to understand my code, you first have to learn this library Do you ? I've used Eigen and boost a lot of times and didn't ever need to "learn how the sausage is made", just looking at examples is enough to get stuff to work.
- ktpsns 8y agoWhether you look up examples or a reference documentation does not change the fact that ontop of a given language, you learn new concepts of a library. In contrast, domain specific languages have exclusive support for certain data types built right into the heart. There is a need for that.
- diskandar27 8y agoGoogle just release tensorflow support javascript and swift. I don't understand why would somebody go with swift for this, if javascript is the language for the web. with javascript you could not just make a web app but also potentially like almost native app using frameworks. so, where is the use case for swift? probably running on IOT devices? or is swift is faster than javascript? Javascript should just upgraded its syntax to be more swift syntax in the near future, that would be a game changer.