Live data from Hacker News

Static, Ahead of Time Compiled Julia

juliacomputing.com

21–30 of 87 posts

Re: Static, Ahead of Time Compiled Julia

#21
post #19

Earlier quoted context omitted.

Well, Julia is a language designed for mathematics, where indices starting at 1 is common (vectors, matrices). You can argue that polynomials have exponents starting at zero, but then you quickly get to Laurent polynomials, and what you really should be arguing is that the lower bound should be configurable, rather than being set at one specific value (which, of course, is still possible with custom types). Second, I…

Here are some tasks that are ugly with [1:n] indexing: - the 1D index of element (i,j) in a matrix is i+(j-1)*m instead of i+j*m - the i'th 3-element subvector of a vector is v[3*(i-1)+1:3*i] instead of v[3*i:3*(i+1)] - if you have vector of indices that partitions an vector into chunks, the i'th chunk is v[ind[i]:ind[i+1]-1] instead of v[ind[i]:ind[i+1]] Perhaps small issues, but these are all real examples from my…

You will find problematic examples no matter which option you choose (which is why I personally favor being able to set the lower bound freely).

With half-open ranges, for example, you will need different code to address a segment and the last element of a segment. E.g. if you have some structure with start_of(i) and end_of(i) expressions, then you can do a[start_of(i):end_of(i)] with closed indexing and a[end_of(i)] to access the last element, while with open intervals, you have to break the abstraction and use a[end_of(i)-1].

You can also iterate over start_of(i) .. end_of(i) in a for loop naturally if ranges are closed. (See how Python's iteration is defined in terms of half-open ranges and how iterating over closed ranges – which happens often enough when the values aren't indices – is a bit of a pain in Python.)

Re: Static, Ahead of Time Compiled Julia

#22
post #18

Earlier quoted context omitted.

This is kind of bike-shedding (since that's such a small part of the language), but I also think there are arguments for using 0-indexing with open upper bounds. Guido explains his choice best: https://plus.google.com/115212051037621986145/posts/YTUxbXYZ...

From the comments section of that G+ post I found this Dijkstra essay with really good arguments for zero-based indexing. Not only does it have sound mathematical reasoning but also some anecdotal evidence of problems caused by one-based indexing in programming languages. http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF

For statistics 1 based is much cleaner and less error prone in my opinion. R is 1 based and it drives me nuts to have to switch to Pandas.

Re: Static, Ahead of Time Compiled Julia

#23
post #19

Earlier quoted context omitted.

Well, Julia is a language designed for mathematics, where indices starting at 1 is common (vectors, matrices). You can argue that polynomials have exponents starting at zero, but then you quickly get to Laurent polynomials, and what you really should be arguing is that the lower bound should be configurable, rather than being set at one specific value (which, of course, is still possible with custom types). Second, I…

Here are some tasks that are ugly with [1:n] indexing: - the 1D index of element (i,j) in a matrix is i+(j-1)*m instead of i+j*m - the i'th 3-element subvector of a vector is v[3*(i-1)+1:3*i] instead of v[3*i:3*(i+1)] - if you have vector of indices that partitions an vector into chunks, the i'th chunk is v[ind[i]:ind[i+1]-1] instead of v[ind[i]:ind[i+1]] Perhaps small issues, but these are all real examples from my…

>I really, really wish they had dropped the 1-based indexing

>, my opinion on this topic is distorted because I spent a lot of time programming in C++

Mathematics-related programming[1] in MATLAB, R Language, Mathematica, SAS, etc all use 1-based indexing. Given that the originators of Julia are MATLAB users, it makes sense that they made a deliberate choice to keep 1-based indexing.

In other words, it was more important to grab mindshare from those previous math tools rather than appeal to C/C++/Java/etc programmers.

One outlier in the landscape of numerical programming is Python+NumPy/SciPy in the sense that it uses 0-based indices. While Julia also wants to be attractive to Python programmers, it still seems like the bigger motivation was programmers of MATLAB and other math software.

[1]https://www.youtube.com/watch?v=02U9AJMEWx0&feature=youtu.be...

Re: Static, Ahead of Time Compiled Julia

#24
post #3

I personally find the syntax of the language and quality of the current implementation (speed!) excellent. However, it doesn't experience the marketing languages like Rust or Golang receive. What I personally also find worrisome is the perception (at least for me) that Julia is confined to scientific computing whereas I find it should really be a general purpose language.

There is no technical reason that Julia can't be used for general purpose computing. (Well personally, I'd like nested namespaces, but) it is an amazing language. Just a matter of someone putting in the time to build the required libraries and glue code. Which will happen in time.

Re: Static, Ahead of Time Compiled Julia

#25
post #23
post #19

Earlier quoted context omitted.

Here are some tasks that are ugly with [1:n] indexing: - the 1D index of element (i,j) in a matrix is i+(j-1)*m instead of i+j*m - the i'th 3-element subvector of a vector is v[3*(i-1)+1:3*i] instead of v[3*i:3*(i+1)] - if you have vector of indices that partitions an vector into chunks, the i'th chunk is v[ind[i]:ind[i+1]-1] instead of v[ind[i]:ind[i+1]] Perhaps small issues, but these are all real examples from my…

>I really, really wish they had dropped the 1-based indexing >, my opinion on this topic is distorted because I spent a lot of time programming in C++ Mathematics-related programming[1] in MATLAB, R Language, Mathematica, SAS, etc all use 1-based indexing. Given that the originators of Julia are MATLAB users, it makes sense that they made a deliberate choice to keep 1-based indexing. In other words, it was more impor…

This, pretty much. Not to mention that, beyond languages, data is often 1-based indexed. I have never gotten a patient data set with ID=0 as the first entry. In my mind, compatibility with what users are expecting, and trying not to induce indexing errors, trumps most other concerns.

Re: Static, Ahead of Time Compiled Julia

#26
post #19

Earlier quoted context omitted.

Here are some tasks that are ugly with [1:n] indexing: - the 1D index of element (i,j) in a matrix is i+(j-1)*m instead of i+j*m - the i'th 3-element subvector of a vector is v[3*(i-1)+1:3*i] instead of v[3*i:3*(i+1)] - if you have vector of indices that partitions an vector into chunks, the i'th chunk is v[ind[i]:ind[i+1]-1] instead of v[ind[i]:ind[i+1]] Perhaps small issues, but these are all real examples from my…

You will find problematic examples no matter which option you choose (which is why I personally favor being able to set the lower bound freely). With half-open ranges, for example, you will need different code to address a segment and the last element of a segment. E.g. if you have some structure with start_of(i) and end_of(i) expressions, then you can do a[start_of(i):end_of(i)] with closed indexing and a[end_of(i)]…

See https://github.com/eschnett/FlexibleArrays.jl

(somewhat in jest, there's also https://github.com/simonster/TwoBasedIndexing.jl)

Re: Static, Ahead of Time Compiled Julia

#27
post #8

I think this [0] is worth reading before starting a project in julia (it's quite shocking). Does anyone know if anything has changed in julia's development process over the last year? [0] http://danluu.com/julialang/

The language works well for what is effectively still a beta. Sure I'd like more documentation and tests, but I'm happy to get features first. The alternative for me is trying to do some non trivial cluster computing in C or in python, either of which would suck.

What kind of cluster computing? I've had good experiences with Scala and Spark, though that might be for a different use case.

Re: Static, Ahead of Time Compiled Julia

#28
> For example, the Julia community seems to have coined the term “type-stability” to describe a concept that static / compiled languages have historically enforced and dynamic / scripting languages have historically disregarded.

I was not aware that this was a Julia neologism. It seems like such an appropriate term for discussing how to make code make the most out of JIT-compilation.

Re: Static, Ahead of Time Compiled Julia

#29
post #25
post #23

Earlier quoted context omitted.

>I really, really wish they had dropped the 1-based indexing >, my opinion on this topic is distorted because I spent a lot of time programming in C++ Mathematics-related programming[1] in MATLAB, R Language, Mathematica, SAS, etc all use 1-based indexing. Given that the originators of Julia are MATLAB users, it makes sense that they made a deliberate choice to keep 1-based indexing. In other words, it was more impor…

This, pretty much. Not to mention that, beyond languages, data is often 1-based indexed. I have never gotten a patient data set with ID=0 as the first entry. In my mind, compatibility with what users are expecting, and trying not to induce indexing errors, trumps most other concerns.

>, beyond languages, data is often 1-based indexed.

That's a good point. Probably the most widespread data example for non-programmers is spreadsheets (MS Excel, Google Sheets). The first row[1] in the spreadsheet is labeled as "1" instead of "0". The idiomatic Visual Basic programming code to loop through the rows would look something like:

  For Each cell In Range("a1:a25")  ' not "a0:a24"
      ' do work
  Next cell
[1]https://www.google.com/search?q=microsoft+excel+spreadsheet+...

Re: Static, Ahead of Time Compiled Julia

#30

> For example, the Julia community seems to have coined the term “type-stability” to describe a concept that static / compiled languages have historically enforced and dynamic / scripting languages have historically disregarded. I was not aware that this was a Julia neologism. It seems like such an appropriate term for discussing how to make code make the most out of JIT-compilation.

I thought that type stability was actually a crucial notion in real-world dynamic language implementations? Witness inline caches and polymorphic inline caches, for example.
Post reply on HN