Hacker News new | ask | show | jobs
by goatlover 2981 days ago
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.
4 comments

> 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 time we change the fragment of the stack we work on.

We need an ultra-general purpose language with good support for both OOP and FP, non-retarded type-system, decent performance, and a good "compile to readable JS" story... to unify this damn mess of "diversity" that forces us to over-specialize in narrow niches and drowns us in complexity.

(No, otoh, I don't think "general purpose" should mean "infinite power" or "maximum expressivity". There's are reason why we're not all using Common Lisp and Scala...)

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.

I did. And it seems awesome.

I just dont see people with "software engineering" background taking any serious liking to it. So it creates DIVIDE between the "software engineering folks" (that want regular-looking-OOP-and-basic-FP architecting feature for APIs and stuff) and "data science folks" who just want to focus on the algorithms.

The litmus test for a "truly general purpose language" to me would be:

(1) write some algorithmic code in it (with not much concurrency and parallelism)

(2) write some (purposefully heavily overengineered) GUI or web-app (full-stack) code in it in a team of 3+ including at least one guy who's both really junior and another guy who's really sloppy

(3) write something making heavy use of networking, concurrency and parallelism

If all three feel EQUALLY natural in a language, than you've got a truly general purpose language. If not, look for something else.

And I know, people hate general purpose solutions just as much as they hate "expert generalist" people, and they have good reasons too, as we've all (or most) been burnt bad by contact with both such "solutions" and with such self-labeled people in the past. But just because we generally suck at "general purpose" doesn't mean we should stop trying!

> Python succeeded because it was general-purpose enough.

> I just dont see people with "software engineering" background taking any serious liking to it.

I guess my point is that if you found Python general purpose enough, you'd likely find Julia general purpose enough too. If people with "software engineering background" take a serious liking to Python but not to Julia, then the reason probably isn't the language itself, but a combination of lack of popularity and a pre-conceived notion that the language is meant to be "scientific" not "general-purpose", that there aren't enough libraries, that the language might not survive, etc.

And Just came across link to new Julia article thanks to HN: https://increment.com/programming-languages/goldilocks-langu...
Expressiveness of the language is one thing. Does it have the vast numbers of quality and well tried and tested libraries that Python does? That's generally more important than expressiveness.
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.

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.

> Swift was designed for general purpose app development.

Swift is a general-purpose language, but I would say that its first purpose is for mobile development. (Or, at least, that's where it started.)

> Why would you use Swift as your new data science language when Julia was made for that purpose and Swift was not?

The author calls out Swift as being good because (1) TensorFlow is now supported for it specifically and (2) it is optimized for mobile development. The author seems to feel that being able to deploy machine learning applications to mobile devices (and optimized) is a great boon, and Python is not well-suited to this.

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

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.

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.

> 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

The way I've thought about this is that it's about whether an index is the name or the offset of an element of an array. Indices have a torsor-like structure, where you can subtract indices i and j to get an offset j-i from index i, and there is the relationship a[j] == a[i + (j-i)]. Zero-indexing is the special case that the name is the offset from the first element.

Because of this, I figure any language that supports 1-indexing should also support arbitrary ranges for the indexing, like in Ada. (Basically, what's so special about 1?)

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.

> Your statement is a [sic] opinion.

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

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.
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." -- Stan Kelly-Bootle
Also:

  $[ = 1;
(Yes, I'm _old_...)
And don't forget the venerable:

   $| = 1;
I think it’s addressed in the article. He wants one language that spans many domains, including mobile. He even addresses Go in the comments section as not being available on Android.

Personally, I’m not aware of the ability to write mobile apps in Julia.

If I’m wrong, please post links, as that would certainly open up the conversation.