Live data from Hacker News

Why data scientists should start learning Swift

heartbeat.fritz.ai

51–60 of 67 posts

Re: Why data scientists should start learning Swift

#51

Earlier quoted context omitted.

> A bunch of wrongs don't make a right :-) Funny how I always thought zero-based numbering[0] was a hack. Just in computer science a hack will become the right way? Any other fields where hacks became the new norm due to technical restrictions? Your statement is a opinion. To add to the list of languages using arrays in a "gross" way: pgsql, pascal, lua. [1]: https://en.wikipedia.org/wiki/Zero-based_numbering#Origin

I always thought it neatly mimicked the way we think of age. When you are born you start at 0. You only turn 1 after you have lived a year.

That's an argument for starting at 1, not at 0.

At age 0, you have no elements in your array of years. So the first year is also element 1.

If you want code to reflect the way you've done counting and arithmetic your whole life, you'd want it to start at 1.

Re: Why data scientists should start learning Swift

#52
Google 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.

Re: Why data scientists should start learning Swift

#53
post #36

Why 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.

> Julia's [was] designed with scientific computing in mind. Swift was designed for general purpose app development. General purpose always wins. Or should always win. Because in reality nobody has any idea what "the purpose" is in the grand scheme of things. Python succeeded because it was general-purpose enough. Javascript too. We don't want more narrow purpose languages that force us to change the language every ti…

I don't think that's necessarily true but can't help but still agree with you. There are tons of wonderful DSLs and niche languages out there, but with terrible interfaces to other languages that want to do more with it. In my case that's mostly R and Minizinc, but I know there's plenty more with the same problem.

But it doesn't have to be that way. SQL is a domain specific language. Regex is a domain specific language. They take different API strategies: one goes for ubiquitous and standardized interfaces, the other goes for direct embedding. But they both prove that it's not necessary to write everything in a general purpose language.

Re: Why data scientists should start learning Swift

#54

Earlier quoted context omitted.

It'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.

A 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.…

Originally, FFTs were the only time I missed 0-based indexing in Julia. But the neat FFTViews.jl package (https://github.com/JuliaArrays/FFTViews.jl) addresses this, and even improves on it by letting you use periodic indices avoiding the need for functions like fftshift.

Re: Why data scientists should start learning Swift

#55

Earlier quoted context omitted.

A 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.…

Generally 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.

> Generally math formulae are one based, the fft and the Taylor expansions being the major exception.

What formulas do you regularly use which benefit from being 1-based? Note, I'm not asking for instances where the index doesn't really matter and the author of a paper simply chose base-1.

There are clearly cases where zero based is more natural. But I don't regularly use any cases where one based is an improvement.

I will admit that zero-based adds a lot of confusion when communicating to other people.

Re: Why data scientists should start learning Swift

#56

Earlier quoted context omitted.

A 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.…

> A bunch of wrongs don't make a right :-) Funny how I always thought zero-based numbering[0] was a hack. Just in computer science a hack will become the right way? Any other fields where hacks became the new norm due to technical restrictions? Your statement is a opinion. To add to the list of languages using arrays in a "gross" way: pgsql, pascal, lua. [1]: https://en.wikipedia.org/wiki/Zero-based_numbering#Origin

> Your statement is a [sic] opinion.

Yeah, that's why put a smiley there. :-)

Re: Why data scientists should start learning Swift

#57
post #43
post #36

Earlier quoted context omitted.

> Julia's [was] designed with scientific computing in mind. Swift was designed for general purpose app development. General purpose always wins. Or should always win. Because in reality nobody has any idea what "the purpose" is in the grand scheme of things. Python succeeded because it was general-purpose enough. Javascript too. We don't want more narrow purpose languages that force us to change the language every ti…

You really should give Julia a go. It's as or more expressive in the general purpose sense of things as Python. It's the best of MATLAB and Python in one neat package. Edit: Plus, you can pass your data structures out to Python or C for processing. And you can use a whole host of visualization tools.

And Just came across link to new Julia article thanks to HN: https://increment.com/programming-languages/goldilocks-langu...

Re: Why data scientists should start learning Swift

#58
post #51

Earlier quoted context omitted.

I always thought it neatly mimicked the way we think of age. When you are born you start at 0. You only turn 1 after you have lived a year.

That's an argument for starting at 1, not at 0. At age 0, you have no elements in your array of years. So the first year is also element 1. If you want code to reflect the way you've done counting and arithmetic your whole life, you'd want it to start at 1.

That would be defining it as a time span and using the time since start as index.

Which to me is one step away from using the timepoint as the index iteself (zero as start), verus (1 year from zero).

How would you index the time before the first birthday?

Re: Why data scientists should start learning Swift

#59
post #36

Why 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.

> Julia's [was] designed with scientific computing in mind. Swift was designed for general purpose app development. General purpose always wins. Or should always win. Because in reality nobody has any idea what "the purpose" is in the grand scheme of things. Python succeeded because it was general-purpose enough. Javascript too. We don't want more narrow purpose languages that force us to change the language every ti…

All programming languages have a limited scope of applicability that is a natural product of the design choices that went into them. The idea of a general purpose language that is exactly the right fit for every task at hand is a myth.

There's nothing wrong with designing a language that is particularly good at data analysis, and which emphasises those features at the expense of others.

Re: Why data scientists should start learning Swift

#60
post #49

Just 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…

> 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.

Whether 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.

Post reply on HN