News for hackers. Stuff that matters.
Re:Some Insights from a Julia Developer by 88e282102ae2e5b on Saturday October 14, 2017 @10:32AM (#15472317)
It's great and all, but I can't justify switching languages for minor improvements over Python + numpy/scipy. I'd be abandoning:

  * My deep knowledge and experience with Python
  * My entire codebase
  * The ability to work on projects with colleagues who don't also switch
  * The certainty that when I leave my current job, someone will be able to pick up after me
  * Zero-based indexing
I've started to do some work in Rust when it makes sense, since there's occasionally a compelling case and it's substantially different than Python. Incremental advances in programming languages just aren't worth it, and knowing that other people are probably coming to the same conclusion means I can't expect a serious community to ever arise around Julia.
Re:Some Insights from a Julia Developer by 3JPLW on Saturday October 14, 2017 @12:36PM (#15472929)
Honest question: did you read the post at all? Even the quick summary addresses this.

Chris' whole point is that the biggest benefits of switching to Julia will be felt by the folks that are developing the packages and libraries for others to use. He's advocating that the best way to get you to want to switch isn't incremental language-level features, but rather it's first-in-class domain-specific packages.

This is something that will take time, but Julia's language-level features are uniquely positioned to enable the development of such packages. Chris is extremely productive (and definitely an outlier), but in less than two years he managed to coordinate and build a first-in-class ecosystem for differential equations.

So he's not advocating for you to switch at all — he's advocating for folks to build the packages (like his) that will get you to want to switch.

Re:Some Insights from a Julia Developer by rattray on Saturday October 14, 2017 @01:07PM (#15473069)
Agreed. A relevant excerpt:

> But for end users throwing together a 100 line script for a data analysis? I don't think that this crowd will actually see as much of a difference between other scripting languages if the packages in the other languages they are using are sufficiently performant (this isn't always true, but let's assume it is). To people who aren't "pros" in the language, it will probably look like it just has a different syntax. It will be a little faster than vectorized code in other languages if code is in type-stable functions, but most of the differences a user will notice will come from the mixture of features and performance of packages. Because of this, I am not sure if marketing the features of the language is actually the best way to approach the general audience. The general audience will be convinced Julia is worthwhile only by the package offering.

(For context, this was after several hundred words of compelling, detailed examples of Julia's language-level advantages).

EDIT: the author then goes on to claim

> that "lack of packages" isn't really a problem with the ecosystem: you can find a great package that does what you're looking for.

with several examples, pointing to poor discoverability, uniqueness, distribution and branding.

He also recommends more practical, use-case-specific how-to guides.

Re:Some Insights from a Julia Developer by sgt101 on Saturday October 14, 2017 @01:53PM (#15473300)
My experience is that Julia promotes lucid and error free code vs R (especially) and Python. For me this matters more and more due in part to the business impact of my 100 line scripts but more significantly due to the impact of other people's 100 line scripts.
Re:Some Insights from a Julia Developer by Certhas on Saturday October 14, 2017 @02:28PM (#15473465)
This is now happening. The DifferentialEquations Library in Julia seems to be best in class.

More importantly: I can imagine writing algorithmic improvements to it for my use case, which is where I hit a wall with python + scipy/numpy/numba.

I can't go and use my python skill to teach a scipy routine about some feature I need.

Re:Some Insights from a Julia Developer by elcritch on Saturday October 14, 2017 @03:02PM (#15473644)
This is where Julia really shines. Hopefully as more researcher's realize they can quickly make customized/specialized implementations for their projects it'll help reinforce momentum. It's awesome being able to quickly dig into a library, grok the algorithm and tweak it. Actually could make for some fun hackathons!
Re:Some Insights from a Julia Developer by 88e282102ae2e5b on Saturday October 14, 2017 @01:12PM (#15473094)
I did read the post.

> but rather it's first-in-class domain-specific packages.

You'll note I didn't cite lack of libraries as a reason I'm reluctant to use Julia. I agree that a solid ecosystem is critical for adoption, but my point is that, for me, it's not sufficient to overcome the human/time/cost factors.

Re:Some Insights from a Julia Developer by ViralBShah on Saturday October 14, 2017 @12:28PM (#15472879)
In my opinion, this is not about abandoning, but supplementing. Python is good at many things, as is Rust, as is Julia.

Stuff like the ODE library that Chris has, or JuMP (for mathematical programming) that Miles Lubin, Iain Dunning and Joey Huechette wrote, or a number of other packages are simply not available elsewhere. The Celeste project, for example, achieved 1.6 PetaFlop/sec of compute rate on half a million cores.

Programming languages are abstractions. Some abstractions are better for certain kind of problems. Many of the amazing libraries that are available in Julia would simply not be easy to do otherwise.

Think about it - if these were incremental advances and no serious community would ever form - then Chris would have never written his packages. Julia has seen over a million downloads. In my biased opinion, it is more than an incremental advance. I think the right approach is to understand where those advances are and apply it to the right kind of problems.

There is a balance to be struck between the two extremes of nothing new will ever get adopted, and everything should adopt anything new and shiny that comes out.

Re:Some Insights from a Julia Developer by throwaway7645 on Saturday October 14, 2017 @12:51PM (#15472989)
Python's PULP & Pyomo are pretty similar to JUMP.
Re:Some Insights from a Julia Developer by StefanKarpinski on Saturday October 14, 2017 @04:08PM (#15473981)
The JuMP paper [1] compares JuMP with all the major commercial and open source options in this area, including Pyomo. Pyomo is orders of magnitude slower than JuMP and doesn't scale as well so the comparison gets worse as problems get larger. (Pyomo had the worst performance of all the systems compared.) JuMP is the only open source option that has performance like commercial systems. Throw in JuMP's improved expressiveness and usability over Pyomo and JuMP's incredibly broad solver support [2] and there's really no contest. These days, your best option in Python is probably to call JuMP via pyjulia.

[1] https://arxiv.org/pdf/1508.01982.pdf

[2] http://jump.readthedocs.io/en/latest/installation.html#getti...

Re:Some Insights from a Julia Developer by throwaway7645 on Saturday October 14, 2017 @04:22PM (#15474063)
Not sure how much performance matters here. You're just farming it off to CPLEX or Gurobi anyway. If performance really matters, you'll do this part in C++ anyway.
Re:Some Insights from a Julia Developer by StefanKarpinski on Saturday October 14, 2017 @04:41PM (#15474164)
Unless you're solving toy problems, it matters quite a bit. In mathematical optimization, constructing the problem tends to be just as expensive as solving the problem is – sometimes more so. The existence of expensive commercial systems like AMPL and GAMS that only exist to express optimization problems demonstrates that this is a non-trivial issue that people are willing to pay money for. Using C++ APIs to solvers is extremely painful, inflexible, error-prone, and completely locks you into a specific solver.
Re:Some Insights from a Julia Developer by _dps on Saturday October 14, 2017 @08:54PM (#15475228)
> Unless you're solving toy problems, it matters quite a bit. In mathematical optimization, constructing the problem tends to be just as expensive as solving the problem is – sometimes more so.

With all due respect, this is just false. I can construct a million dimensional linear program for a large network problem in a few seconds in python. Solving it with cplex can take minutes.

I have a Ph.D. in computational mathematics and do this for a living. I write lots of C, and still almost exclusively use Python or Lua for problem formulation because the performance just doesn't matter.

I'm certain there are some cases where it's true. One I've encountered is doing real-time solution of MILP for adaptive path planning. Here the problems are of moderate size and you want to reconstruct them from geometry data every 10ms or so. Here Python will indeed bite you in the problem formulation stage.

Re:Some Insights from a Julia Developer by throwaway7645 on Saturday October 14, 2017 @08:21PM (#15475103)
Solver licenses are extremely expensive (~100k in production), so switching solvers isn't very common. Going to C++ helps a bit with I/O before it gets to the solver if you really need it, but a lot of people do just fine with things like AIMMS which is a proprietary high level modeling language similar in performance to Python. Maybe Julia + JUMP is nice if you want to remove I/O performance barriers, but don't want C++ pain & more flexibility, but I don't see JUMP being talked about much in the industry currently. If you don't mind me asking, what is your experience in this area and what domain are you working in?
Re:Some Insights from a Julia Developer by tavert on Monday October 16, 2017 @01:51AM (#15481134)
Stefan is one of the co-creators of the Julia language, not really an operations research person. He must have misread the results in the JuMP paper where Pyomo outperforms CVX and Yalmip on several problem classes.
Re:Some Insights from a Julia Developer by StefanKarpinski on Monday October 16, 2017 @09:51AM (#15483173)
You're right, I was looking at the lqcp results and misread the other results. Still, the main takeaway is that of the open source options for expressing OR problems, JuMP is the only one in the same class as the commercial tools. If you've got a problem where problem construction isn't hard, cool; often that's not the case.
Re:Some Insights from a Julia Developer by throwaway543219 on Saturday October 14, 2017 @04:50PM (#15474218)
Can you share an example of calling JuMP directly via pyjulia? I was under the impression that Julia macros are not currently callable from Python via pyjulia.
Re:Some Insights from a Julia Developer by ssivark on Saturday October 14, 2017 @12:37PM (#15472933)
Any time 1-based indexing is mentioned as a shortcoming of Julia reminds me of PG's 'Blub paradox' [1].

> As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub.

Julia has offset array indexing (for essentially no additional cost) which is an amazingly useful feature! See eg. [2] Think of this feature as blurring the distinction between data (accessing an array) and computation (calling a function). The fact is that arrays as they are used (contiguous memory location collection) often carry more information than being just a dumb list of arbitrary data, and it's very convenient to expose that in their interface.

[1]: http://www.paulgraham.com/avg.html [2]: https://julialang.org/blog/2017/04/offset-arrays

Re:Some Insights from a Julia Developer by ACow_Adonis on Saturday October 14, 2017 @06:08PM (#15474600)
I've seen the claim that Julia has offest-arrays at essentially no additional cost a few times now, and I'm just not buying it.

As in, I don't see how its possible without stretching the meaning of "no additional cost". I'm familiar with displaced arrays and the like in Common Lisp, so i get that you can do offsets and things without using much additional memory, and i feel its a small jump from that to arbitrary indexing.

I mean, sure, if you're programming with constants or common patterns or things like that, a compiler could theoretically figure out and adjust the references itself. Or you can use macrology (I presume, since julia is so close to being lisp in matlab clothing, there's no issues with this in theory). Or you can come up with some kind of functional wrapper to adjust offset indexes back to the base case...

But if you're actually using run-time calculations using returned numbers from a calculation to index N-quadrillion times into various arrays and you're swapping between a standard and arbitrary/offset index measure, which is about the only time I can see you'd actually care about the relative efficiency of repeated arbitrary indexing, then it can't be a pre-compiled thing. The offsets between the actual numbers you're getting back and the actual index into the arrays have to be calculated in an additional step at run time.

Now its true that's likely to be only an addition or multiplication operation for each one, (and if it isn't, the run time application of another transformation just cements my point) but perhaps my notion of "essentially no additional cost" is more strict...

Re:Some Insights from a Julia Developer by 3JPLW on Saturday October 14, 2017 @07:20PM (#15474883)
This is easily testable:

    julia> using BenchmarkTools
           using OffsetArrays
           A = rand(1000)
           O = OffsetArray(A, 0:999)
           function naive_sum(A)
               s = zero(eltype(A))
               @unsafe for i in eachindex(A) # @unsafe will eventually be folded into @inbounds
                   s += A[i]
               end
               return s
           end
    naive_sum (generic function with 1 method)
    
    julia> @btime naive_sum($A)
      1.025 μs (0 allocations: 0 bytes)
    514.0960505118594
    
    julia> @btime naive_sum($O)
      1.023 μs (0 allocations: 0 bytes)
    514.0960505118594
Yes, there's an extra operation or two in there, but it's effectively free on modern CPUs due to caching/op latencies/pipelining/etc.
Re:Some Insights from a Julia Developer by StefanKarpinski on Sunday October 15, 2017 @06:02PM (#15479574)
The performance is the same because the core loop in both cases is identical:

    loop:
        vaddsd	(%rcx), %xmm0, %xmm0
        addq	$8, %rcx
        addq	$-1, %rax
        jne	loop
There's more setup required for offset arrays, but otherwise there's no difference. I'm not sure why arrays having an offset would be any more work: array indexing in general involves adding an index to a base pointer; having an offset effectively just changes what the base pointer value is.
Re:Some Insights from a Julia Developer by 88e282102ae2e5b on Saturday October 14, 2017 @01:14PM (#15473110)
I didn't mean to seem petty, it's just that going back and forth between zero-based and one-based languages just added extra mental overhead (admittedly this was with Fortran, so there may have been other issues).
Re:Some Insights from a Julia Developer by ssivark on Saturday October 14, 2017 @01:27PM (#15473169)
The way I think of it is that different indexing schemes suit different problems. I want to think carefully about the problem domain and use the most convenient convention. For example, when my array stores a time series, I would like the index to correspond to timestamps (and still be performant, so long as my timestamps can be efficiently mapped to memory locations, which is true for affine transformations, for example). When another array stores the Fourier transform of that time series, I would like to access elements by the frequency they correspond to. That stops me from making annoying indexing errors (eg: off-by-1), because the data structure's interface maps nicely to the problem domain. I find that much easier than the cognitive cost that comes with trying to shoehorn a single convention on every situation. But it's difficult to appreciate that when thinking of language constructs divorced from specific problem domains, as one tends to do when typically studying data structures and/or algorithms.
Re:Some Insights from a Julia Developer by simonbyrne on Saturday October 14, 2017 @11:51PM (#15475794)
Fourier transforms are a great example: when I started with Julia, this was the only time I missed 0-based indexing.

Now there is the awesome FFTViews.jl package which goes one better with wrap-around indexing: https://github.com/JuliaArrays/FFTViews.jl

Re:Some Insights from a Julia Developer by iamed2 on Saturday October 14, 2017 @03:52PM (#15473862)
Re:Some Insights from a Julia Developer by tlarkworthy on Saturday October 14, 2017 @03:11PM (#15473694)
I am so sold I want to learn right now.
Re:Some Insights from a Julia Developer by chrispeel on Saturday October 14, 2017 @01:23PM (#15473148)
I think it crucial to offer at this point the important Julia package TwoBasedIndexing.jl :-)

https://github.com/simonster/TwoBasedIndexing.jl

Re:Some Insights from a Julia Developer by Fomite on Saturday October 14, 2017 @09:41PM (#15475408)
Honestly, given how much work I do in R, and how much the assumption of 1-based indexing is in my field, this is a massive Julia selling point for the exact same mental overhead reasons you mention.
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @10:41PM (#15475589)
Wait a minute. Having an arbitrary offset is one thing. Settling on 1 as a standard is another one!
Re:Some Insights from a Julia Developer by jernfrost on Saturday October 14, 2017 @11:15AM (#15472520)
The improvements are not minor they are massive. Citing rust shows that the advantage of Julia has not been explained well enough. Julia allows you to write as performant code as Rust with a much smaller investment in learning. You cite your concern for spending time learning something new. That makes no sense considering the high learning curve and complexity of Rust compared to Julia. Julia is quite fast to learn and has far more overlap with Python than Rust to make the transition easy. You can call python code from Julia and ise many of the same tools like the notebook.
Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @12:13PM (#15472785)
Have a citation on the performance vs Rust?

I'm skeptical any GC'd language can approach C/Rust unless they have explicit mechanisms to do data layout for using the cache/prefetcher to the fullest degree.

Re:Some Insights from a Julia Developer by ViralBShah on Saturday October 14, 2017 @12:31PM (#15472901)
The point around Julia's performance is often in the context of mathematical computing. The two languages are designed for very different use cases.

Julia is designed to make it extremely easy to write high performance mathematical programs with ease. Rust is designed to make it easy to do systems programming. Both are high performance for the things they are designed to do. Just like I wouldn't do systems programming in Julia (although I am certain KenoFischer would), I wouldn't want to do mathematical computing in Rust.

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @12:41PM (#15472953)
Sure but mathematical problems don't exist in isolation. I used to do a ton of 3D graphics work with matrices, vectors, etc. We definitely couldn't use something that didn't have the right support for data layout and good runtime semantics.

C/Rust/C++ fit that very well so I wanted to understand how similar claims were made for a GC'd language. C# for instance can work with value types and was wondering is Julia has similar constructs.

Re:Some Insights from a Julia Developer by andyferris on Saturday October 14, 2017 @06:56PM (#15474777)
Just thought I'd chime in that there is a StaticArrays.jl package that lets you make arrays which are stack allocated like value types in other languages, and you can make arrays of static arrays that layout exactly like arrays of structs in C/C++, and can be memory mapped from disk and so-on. (Such arrays of static arrays do eventually get GC'd, but that is not necessarily very frequent). They also support the same set of abstractions as other arrays including performant (SIMD) math/linear algebra that in my (biased) opinion is perfect for 3D graphics.

(As an aside, we also take this further with abstractions of 3x3 rotation matrices using a variety of internal representations such as quaternions in Rotations.jl, and allow composing coordinate transformations in CoordianteTransformations.jl, etc, etc).

Touching on the original authors post about the package ecosystem, I feel it can't be understated enough how easily different packages can compose and be used together in Julia. I like to say there is a product rule here where functionality/productivity grows as the square of the number of packages/features you can use together naturally (regardless of programming language). We can use static arrays, rotations, coordinate transformations, etc in combination with differential equation packages to simulate a system or with an optimization package to optimize a coordinate transformation for SLAM given certain measurements, and so-on, at full run-time speed but comparatively little user effort.

Re:Some Insights from a Julia Developer by omginternets on Saturday October 14, 2017 @04:27PM (#15474086)
In the case of research, data-science and -- generally speaking -- "scientific computing", mathematical problems pretty much do exist in isolation.

This is the niche that Julia wants to occupy.

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @05:08PM (#15474313)
If that were the case I wouldn't have an adjacent subthread telling me that they are pretty much the same ;).

To be clear, I have no beef with Julia, I'm sure it's a fantastic language. I take issue with people thinking they can get the same level of performance without explicitly controlling their memory access patterns/allocations.

98% of developers will never need it in their careers but when you do there is no substitute.

Re:Some Insights from a Julia Developer by CyberDildonics on Saturday October 14, 2017 @09:49PM (#15475436)
Why don't you think you can control those things? Make an array, loop through linearly, just like C. Avoid allocations in inner loops, just like C.
Re:Some Insights from a Julia Developer by xfer on Sunday October 15, 2017 @12:44AM (#15475930)
I agree, a lot of the performance problems have to with allocation in any language, gc'd or not. I still can't believe people making the same argument against gc'd languages even when highly performant jvm exists.
Re:Some Insights from a Julia Developer by vvanders on Sunday October 15, 2017 @12:22PM (#15477799)
It's not an issue of allocation, it's an issue of allocation location to get better cache locality.

Take the JVM, a good majority of ORM databases uses Sun.misc.unsafe to do manual native memory allocation. Not because it's faster(because it isn't faster than bumping the nursery pointer).

They do it so they can control where disparate datatypes live in memory so that as a cache line is read in the prefetcher is already pulling in the next cache line.

Things like this will get you a 10-50x performance increase, which in some cases you absolutely need it.

Re:Some Insights from a Julia Developer by xfer on Sunday October 15, 2017 @06:25PM (#15479682)
Sure, but like you said, 98% don't need it and there is indeed a substitute when you need it.
Re:Some Insights from a Julia Developer by CyberDildonics on Sunday October 15, 2017 @07:33AM (#15476725)
I don't see too many reasonable arguments that garbage collection is slower. Taking up more memory, having pauses and requiring the same amount of thought as modern C++ are all arguments I've heard, which is my experience with Julia (sans the pauses since I haven't done something interactive yet).
Re:Some Insights from a Julia Developer by xfer on Sunday October 15, 2017 @06:23PM (#15479677)
Requiring same amount of thought as modern C++ is not simply true, as soon as you start dealing with cyclic data structures/shared data(reference counting takes more memory and slower than a well implemented gc), that model breaks down.

Pauses is indeed a problem, which then requires you to manually tune the gc to your settings.

Re:Some Insights from a Julia Developer by CyberDildonics on Tuesday October 17, 2017 @09:58AM (#15490904)
That's not my experience and I have dealt with all of those things to a fairly heavy degree.

> reference counting takes more memory and slower than a well implemented gc

This is a ridiculous cliche at this point. It might be true if every memory allocation was reference counted, but in C++ (and julia) almost everything winds up on the stack. What doesn't wind of up on the stack is usually being dealt with using ownership and move semantics. The number of reference counted variables in my C++ programs is usually 0 unless they are being shared across threads. Not only that, but within a thread, move semantics means that the reference count doesn't need to be touched.

While there may be 'conventional wisdom' I have implemented non-trivial software in both C++11 and Julia, and optimizing memory allocations happens in both and Julia required more thought. Julia made data structures and general functions easier to write so it wasn't as if it was a net negative, but memory allocation wise I don't feel the garbage collector made things any easier.

Then on top of that you have the myth of the 'well implemented GC'. Java, C#, D, Go and Julia are all languages where this seems to be a constant struggle. After significant R+D some are there, but if you look at D and Julia, it is a constant user complaint.

As for cyclic data structures, I'm not sure why I would do that in the first place and I'm doubly unsure why I would do it with pointers and fragmented memory allocations.

Re:Some Insights from a Julia Developer by ballenarosada on Saturday October 14, 2017 @12:51PM (#15472991)
Value types are also addressed in the article
Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @03:28PM (#15473753)
From what I can find[1] it looks like while Julia has compact values it doesn't have what I'd traditionally call value types. Specifically value types that live on the stack unless they are a member of a reference type(which is what C# does).

Looking at the performance docs[2] this is pretty clear in that array types(which looks like how Julia does Matrices) get allocated on the heap. You can clearly see the performance impact in the docs(1.95s vs 0.08s) that this type of behavior has.

While you can preallocate(which the docs suggest and is the only path for GC'd languages) it's not an ideal solution. If your type is smaller than a single cache line, like in the example above, you've just flushed a whole cache line just to bring in that one pre-allocated value. You also run into the issue if you don't know exactly how many values you need upfront which leads to pooling. In that scenario your pool may be large enough that you're bouncing between cache lines on different pooled objects.

This is the type of thing that you really need control over if you want performance "as good as C". Anything less will be a compromise. There's also the whole class of zero-cost abstractions that can get from C++/Rust which leverage all the above to great effect. That lets you get things like nom[3] which gives you high level semantics + productivity while maintaining parity with C.

None of this is academic, these are all optimizations I've used on shipping products that went out to millions of users. In each case we had fixed hardware with a limited execution budget and the 5-20x improvements we made were critical to us shipping a product that people wanted to use.

[1] https://discourse.julialang.org/t/how-to-know-if-object-memo...

[2] https://docs.julialang.org/en/release-0.4/manual/performance...

[3] https://github.com/Geal/nom_benchmarks/tree/master/http / https://github.com/Geal/nom

Re:Some Insights from a Julia Developer by StefanKarpinski on Saturday October 14, 2017 @03:49PM (#15473846)
The distinction in Julia isn't between value versus reference types (which have fundamentally incompatible semantics), it's immutable types (declared using `struct`) versus mutable types (declared using `mutable struct`). Immutable types are generally stack allocated and need not even be fully materialized, whereas mutable types are typically heap allocated and fully materialized. The built-in array-type is mutable and can change size. As you say, these can be preallocated and modified in place with a rich collection of in-place, mutating algorithms in the standard library, but sometimes that's not quite enough. If you want fixed-size, stack-allocated arrays, you can use the StaticArrays package [1], which provides precisely such types. Aside from immutability, stack allocation and amazing performance, StaticArrays look and behave just like built-in arrays: one of the basic premises of Julia is to allow you to implement types like this and get the exact feature/performance tradeoff you need.

[1] https://github.com/JuliaArrays/StaticArrays.jl

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @04:04PM (#15473955)
Uf, I really don't like intermixing mutability with allocation location. Those seem like two completely separate concerns.

One thing that was really common for us to do was to instance a weighted graph(something like this[1]) per-actor. This means that you might have 10-300 floating point values in a block indexed by the node they interact with. It was really common to see one, maybe two values change on a per-frame basis. With the constraint above I'm now copying 300 floating point values every time any node changes which would be brutal for performance. Or I'd take a potential cache miss each time I touched the array which could be even worse if it was a reference type.

To be clear, I'm not saying Julia isn't really good at what it does. My complaint stems from the fact that you can't claim performance good as/better than C without having all these tools at your disposal.

We haven't even gotten into things like restrict[2] where things like Rust's ownership model let you get it for free[3].

[1] https://docs.unrealengine.com/latest/INT/Engine/Rendering/Ma...

[2] https://en.wikipedia.org/wiki/Restrict

[3] https://doc.rust-lang.org/nomicon/aliasing.html

Re:Some Insights from a Julia Developer by StefanKarpinski on Saturday October 14, 2017 @04:21PM (#15474056)
> I really don't like intermixing mutability with allocation location. Those seem like two completely separate concerns.

They're not. The semantics of value types and reference types are different in the presence of mutation. So if you want uniform object semantics in a language, then objects that can be implemented as values must be immutable. There are many languages that have kept these independent and bifurcated their type system instead (Java, C#), but it's been a source a great deal of pain and frustration (e.g. Java's `int` versus `Integer` awkwardness).

Fortunately, there's nothing you can do with mutation that you can't do just as well by modifying and replacing an immutable value in a mutable cell – the compiler implements them the same way. Wrap an immutable in a mutable `Ref` and voila, you've got something equivalent to a mutable value type without exposing completely incompatible semantics in the language.

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @04:54PM (#15474245)
> They're not. The semantics of value types and reference types are different in the presence of mutation.

I think C#'s overloaded term for "value-types" may have caused you to misinterpret the above. Let me be more clear, if a value lives on the stack or the heap is completely separable from if it is mutable or not, that's my objection.

> ... just as well by modifying and replacing an immutable value in a mutable cell

In terms of "correctness", sure. In terms of performance see my 300+ float block example above. I shouldn't have to copy, modify, copy when I can just mutate in-place(and be explicit about that rather than relying on language semantics).

Also I can seem to find any mention in the docs about Ref's semantics aside from a passing mention in the FFI section.

Re:Some Insights from a Julia Developer by anon_342njlkesr on Sunday October 15, 2017 @11:35AM (#15477558)
I had the same problem; my problem was not the giant number of reads, but rather that a naive replacement needs a read and has a dependency on the write-back; hence, a scatter where you modify immutable structures by replacing certain fields induces a stall on cache-miss.

In my case, julia/llvm was smart enough to figure out that the read and write can be eliminated. Hence, the julia code that replaces an immutable with a copy where only few fields are changed generates the same @code_native as the obvious evil construction (figure out where the field is stored; unsafe_store! to the pointer).

But I guess this optimization is unreliable, or at least it is not well documented when this optimization is guaranteed to happen. So the situation is not optimal, but also not as catastrophic as you would have guessed without reading the generated native code.

Re:Some Insights from a Julia Developer by StefanKarpinski on Tuesday October 17, 2017 @11:14AM (#15491600)
Right, so the way to address this is to provide guarantees that this kind of optimization /will/ occur and providing syntax for making writing "pseudo-mutating" code more convenient. There's a PR [1] for the latter, but it's been shelved while we focus on getting 1.0 out the door instead of adding new features. Optimization guarantees + convenient syntax provides everything you need without trashing the semantics of the language by bifurcating the type system into two incompatible kinds of values.

[1] https://github.com/JuliaLang/julia/pull/21912

Re:Some Insights from a Julia Developer by KenoFischer on Saturday October 14, 2017 @03:49PM (#15473843)
For values with compiler-visible scoped lifetime, the compiler will automatically promote them to stack variables. There is currently no way to enforce this happening, but it would be perfectly possible to add such an annotation.

Regarding preallocation, you tend to want to avoid dynamic memory allocation in high performance applications anyway, so whether you do that in C++ or in Julia, doesn't really make too much of a difference. It is true this is a little harder to control in GC'ed languages than in languages where you have to do memory management manually, but the effect is about the same. Julia provides tools to figure out where you're using dynamic memory allocation and those tools will certainly improve in the future.

One thing I think is under appreciated from the performance perspective though is how easily julia lets you express data layout transformation to take better advantage of the cache hierarchy. I touched on this a bit in my JuliaCon presentation [1].

[1] https://youtu.be/uecdcADM3hY?t=32m19s

Re:Some Insights from a Julia Developer by bjourne on Saturday October 14, 2017 @06:08PM (#15474598)
> For values with compiler-visible scoped lifetime, the compiler will automatically promote them to stack variables. There is currently no way to enforce this happening, but it would be perfectly possible to add such an annotation.

Other languages such as Java have that optimization too. But it is quite limited because it can only be applied to data whose size is known at compile-time. There is also the problem that if some data allocated in a procedure is passed to another procedure, it can't be allocated on the stack because it can escape.

A programmer working in a low-level language can be smart and choose the best locations (stack or heap) for each piece of data. A language that does not allow explicit stack access (like C does), can never make as optimal decisions.

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @04:09PM (#15473988)
> Regarding preallocation, you tend to want to avoid dynamic memory allocation in high performance applications anyway, so whether you do that in C++ or in Julia, doesn't really make too much of a difference.

Yes! Which is why it shouldn't take me digging through 3 different documents and still getting it partly wrong!

C/C++/Rust make this easy by annotating the type modifiers(&/*/Box/etc) with how the object lives in my runtime system. Rust even gets bonus points for giving me aliasing information as well(&mut vs &).

Re:Some Insights from a Julia Developer by ChrisRackauckas on Saturday October 14, 2017 @09:36PM (#15475387)
You just do @. and you're done?
Re:Some Insights from a Julia Developer by KenoFischer on Saturday October 14, 2017 @12:59PM (#15473018)
> although I am certain KenoFischer would

Sure would.

Re:Some Insights from a Julia Developer by jernfrost on Saturday October 14, 2017 @07:40PM (#15474941)
The language page shows micro benchmarks that Julia is comparable to C in performance, when optimized. I've seen various users of the language report similar experience for packages they've built. Since C and Rust are similar in performance I would assume Julia is close to Rust in performance.

You can also easily verify this yourself by looking at assembly code dumps for JITed Julia functions. You can see that the amount of code would be comparable to that of C for many common scenarios.

As for cache and data layout. That GC'd language can't control data layout and cache usage is simply wrong. Best known example is probably Go. You can nest structs to create contiguous blocks of memory in Go, just like in C. You can also create arrays of structs as contiguous blocks of memory.

Just because Java and C# doesn't work that way, doesn't mean all GC'd languages are like that.

A struct of concrete types in Julia is just like a struct in C in the way it is packed in memory. An array of structs in Julia or a nesting of structs will have similar memory layout as in C.

So I know this sounds really odd, but Julia despite being a dynamic language thus allows more optimal memory layout than a statically typed languages such as Java.

What is frustrating with promoting Julia, is that it simply sounds way too good to be true, so people dismiss the language before they have actually read up on it. I advice you to read up a bit more on the details of how the language works. It will then become clear why it can pull off stuff which seems far too good to be true.

Re:Some Insights from a Julia Developer by faitswulff on Saturday October 14, 2017 @12:20PM (#15472834)
Julia's website has some benchmarks: https://julialang.org/benchmarks/

C is the leftmost dot, Julia is just to the right.

Re:Some Insights from a Julia Developer by pollitos on Saturday October 14, 2017 @01:07PM (#15473066)
Just to note, these benchmarks are biased. This is a competition between highly-tuned-to-the-processor Julia with tuned BLAS vs other languages out-of-the-box binaries. Additionally, the benchmarks tests are written inefficiently in the comparison languages. But even then Javascript comes out on top on some benchmark tests.
Re:Some Insights from a Julia Developer by dnautics on Saturday October 14, 2017 @02:42PM (#15473543)
That's because the jit compiler in the Julia standard library selects the blas for you. As a programmer you don't have to optimize beyond using idiomatic type strategies. You could, say write a galois field type and use the \ solve operator to solve a Reed Solomon Erasure using old fashioned lu decomposition (automatically without pivoting, even), and then turn around and use the same \ operator with floats one line down and it will give you highly optimized blas.
Re:Some Insights from a Julia Developer by 3JPLW on Saturday October 14, 2017 @03:34PM (#15473783)
Yes, these benchmarks do tend to be a lightning-rod for controversy. You have two complaints:

1. Yes, some languages do not make it easy to install and link against a well-tuned BLAS. The benchmarks were very recently updated, and you can see the level of effort required to get everything installed and working properly. This was all done in the open on the discourse message board.

2. Yes, the benchmarks involve testing very specific language-level features like iteration, recursion, and IO. And they're testing the ability of specific languages to do these things. Yes, of course in Python you'd look towards a vectorized library call instead of a `for` loop, but then you're not testing Python itself anymore.

Re:Some Insights from a Julia Developer by bjourne on Saturday October 14, 2017 @06:14PM (#15474619)
How come there are no entries for Julia on the Benchmarks Game? http://benchmarksgame.alioth.debian.org/ Given Julia's good performance, it is a little strange. :)
Re:Some Insights from a Julia Developer by ihnorton on Saturday October 14, 2017 @10:32PM (#15475557)
Inclusion is by selection of the admin [1,2]. There are Julia implementations available for most of the benchmarks [3] so perhaps eventually they will be included.

[1] https://alioth.debian.org/forum/message.php?msg_id=182495&gr...

[2] http://benchmarksgame.alioth.debian.org/play.html#languagex

[3] https://github.com/JuliaLang/julia/tree/master/test/perf/sho...

Re:Some Insights from a Julia Developer by bjourne on Sunday October 15, 2017 @08:00AM (#15476788)
Interesting! Does that mean the Benchmarks Game is not open for new languages? The faq entry is kind of ambiguous.
Re:Some Insights from a Julia Developer by igouy on Monday October 16, 2017 @12:39PM (#15484539)
It means -- "If you're interested in something not shown on the benchmarks game website then please take the program source code and the measurement scripts and publish your own measurements."

Like this guy did -- https://pybenchmarks.org/

Re:Some Insights from a Julia Developer by ViralBShah on Saturday October 14, 2017 @03:28PM (#15473756)
Only one of the benchmarks is BLAS dependent and the point is to make sure that it is easy to get a tuned BLAS in that system.

If these benchmarks have resulted in all the languages focusing on a fast BLAS, I think that is fantastic.

Re:Some Insights from a Julia Developer by vvanders on Saturday October 14, 2017 @12:24PM (#15472858)
According to that JavaScript is faster than both Julia and C by a significant margin in iter_mandelbrot ;).
Re:Some Insights from a Julia Developer by 3JPLW on Saturday October 14, 2017 @12:39PM (#15472945)
Yup, it's really amazing what millions of hours of development time will do! That benchmark in particular is a little deceiving — and we take those benchmarks very seriously! See this issue for more details: https://github.com/JuliaLang/julia/issues/24097
Re:Some Insights from a Julia Developer by Thaxll on Saturday October 14, 2017 @12:27PM (#15472873)
Performance is not everything, people are obsessed with it and it's a mistake.

- libraries

- community

- tools

Are much more important.

Re:Some Insights from a Julia Developer by astrobe_ on Saturday October 14, 2017 @01:56PM (#15473312)
You're overlooking the context, that's a bigger mistake.
Re:Some Insights from a Julia Developer by 88e282102ae2e5b on Saturday October 14, 2017 @12:05PM (#15472741)
Is Julia really that much more performant than numpy?
Re:Some Insights from a Julia Developer by wallnuss on Saturday October 14, 2017 @12:24PM (#15472860)
In my opinion that is the wrong question to ask. The right question is: How fast will my code be. Numpy has been heavily optimised and is written in C and not Python.

Take a look at the link below, comparing a simple sum in different languages (among them Python and Numpy). The power of Julia is that there is no privileged code. Your code will be as fast as the base library.

http://nbviewer.jupyter.org/github/alanedelman/18.337_2017/b...

Re:Some Insights from a Julia Developer by improbable22 on Saturday October 14, 2017 @01:47PM (#15473271)
Yes to this. When you're calling some big fast package (be it some field-specific thing, or just matrix algebra) the language you're in doesn't matter that much. In terms of speed, but also in terms of effort -- you spend most of your time reading this field-specific package's manual.

What's liberating is that for the things which aren't covered by such packages, there's no huge penalty for just writing it yourself. In speed but in effort too -- it's quicker to write the loop than to figure out how to make np.einsum do what you have in mind.

Re:Some Insights from a Julia Developer by 81212w1 on Saturday October 14, 2017 @12:44PM (#15472963)
I find this benchmark a bit disorganized, but it seems that the "hand-written" Julia function is as slow as the "hand-written" C function.

The C function is of course naive. I'm pretty sure that a hand-unrolled loop would be faster.

Re:Some Insights from a Julia Developer by wallnuss on Saturday October 14, 2017 @09:50PM (#15475438)
You are absolutely right, an optimised C Programn would be as fast or faster than the Numpy implementation.
Re:Some Insights from a Julia Developer by quintessex on Saturday October 14, 2017 @09:19PM (#15475324)
I've been using Julia for a year or two now, and over that time my enthusiasm for the language has waned, not grown.

Here's the standard pitch for Julia: C-like performance with R/Python/MATLAB-like expressivity.

This is undeniably true. For someone coming from R/Python/MATLAB, you will be able to program as easily in Julia, if not more easily and more cleanly, and get much better speed.

However, what I've come to realize now is that you can get something similar from Kotlin, Nim, and Crystal, but those are much more general-purpose, and often are more consistent in their performance. They don't have the same numerical libraries at the moment, but they have a much bigger use-case target, and for something like Kotlin, a lot more leverage from the community.

Rust is a lot lower-level, but as the numerical resources grow (and they inevitably will) and layers of abstraction are added, what you will probably get is something very similar to Julia in expressivity but more extensible downward, and probably more performant. Rust has a ton of room to grow, and has many good role models from C (e.g., Eigen).

This also isn't even touching on PyPy and things of that sort.

I like Julia and still reach for it when I'm starting a project. Often it's worked great, but other times I have to go back to R or Python for some library that calls C, because the Julia library, while usable in a way that pure R or Python isn't, is still not actually as fast as C. Sometimes "on the order of magnitude of C" is not actually good enough, and you need C. Also, if you poke around for benchmarks that aren't posted by the Julia developers themselves, you'll see different conclusions about the real-world performance of Julia, so there's that.

I guess I read articles like the linked post, and I end up feeling like they're misleading. Is Julia better for data analysis than R or Python? Yes, almost certainly if you were starting from scratch and not calling any products of outside languages. Is Julia better than R or Python + C as it is in the real world? Not sure, because you still have to call C anyway at some point if you're being honest. Is it better than Kotlin, Nim, or Rust? I'm even less sure. If Julia wants to maintain long-term competitiveness, it has to reach out in the opposite direction of those languages, from numerics -> general purpose computing, because they are inevitably moving from general purpose computing -> numerics, and they are bringing a lot with them.

Re:Some Insights from a Julia Developer by chubot on Sunday October 15, 2017 @02:13PM (#15478299)
What problems are you solving with Julia? The way I see it, Kotlin, Nim, and Crystal are completely different languages aimed at a different space.

e.g. Kotlin is being used for Android apps, which is worlds away from what MATLAB and R users do.

Re:Some Insights from a Julia Developer by srean on Saturday October 14, 2017 @01:08PM (#15473075)
The same argument applied to the numpy/scipy stack when it was new. R, SAS and a whole slew of other offerings were available at that time.

This view of yours as applied to something new is as old as the woods, progress and shifts take place regardless of that. Small mercies actually but some are still writing and maintaining COBOL applications and earning extremely respectable salaries from it.

All you are really saying is you will not be an early adopter. That's OK, there will be others. Your non-adoption is unlikely to be a shattering loss for you or for Julia.

Regarding whether improvements are minor or significant that's a matter of opinion.

Re:Some Insights from a Julia Developer by wallnuss on Saturday October 14, 2017 @11:13AM (#15472510)
* My entire codebase

Julia has great interoperability between Python (checkout PyCall.jl) and many other languages. You don't need to abandon your old codebase.

With regards to your other points, a lot of that is subjective and hard to argue about, but for me Julia has drastically changed the way I approach writing scientific code and is not just an incremental improvement upon the status quo.

Re:Some Insights from a Julia Developer by rattray on Saturday October 14, 2017 @12:11PM (#15472769)
Interesting. How has it changed your approach?
Re:Some Insights from a Julia Developer by dnautics on Saturday October 14, 2017 @02:35PM (#15473500)
At work, we had some code that was written in Python. We needed it to exercise a drive (and had to be I/o bound for the metrics to make sense). I couldn't believe it when after several weeks of coworkers using it I noticed the CPU was pegged at 100%... I rewrote in Julia (which was much more terse and debuggable) and the CPU load dropped to 30%.
Re:Some Insights from a Julia Developer by BeetleB on Saturday October 14, 2017 @02:21PM (#15473433)
All of the above were arguments for not switching away from MATLAB 10 years ago, when I switched to Python + NumPy.
Re:Some Insights from a Julia Developer by mkborregaard on Saturday October 14, 2017 @11:11AM (#15472501)
Julia supports indexing with arbitrary bases, and it generally works ecosystem-wide.
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @11:47AM (#15472653)
Oh, it does? I've taken to saying that "zero-based indexing – that's how Julia broke my heart", because at the time, I didn't get the impression that there was anything else in sight. How do I index based on zero?
Re:Some Insights from a Julia Developer by wallnuss on Saturday October 14, 2017 @12:29PM (#15472888)
If you have a particular algorithm that is better expressed using 0-based indexing use https://github.com/JuliaArrays/OffsetArrays.jl
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @01:32PM (#15473194)
It's not just something particular I need it for; it's everything.
Re:Some Insights from a Julia Developer by SolarNet on Saturday October 14, 2017 @02:56PM (#15473610)
If you read the OP again carefully, you'll see that you can use offset arrays for every array you make and suffer no performance penalty, because the offset is compiled away. And the development overhead is a single library import call; I replace core language data-structures all the time in any language for features I want, this is no different.
Re:Some Insights from a Julia Developer by ACow_Adonis on Saturday October 14, 2017 @06:16PM (#15474637)
See my other comment in the thread for the thing I've always wondered: How can you compile away an arbitrary calculation that might need to be made at run time?

(assuming we're not just arguing over arbitrary-array indexing to input predefined constants at the REPL/code level).

Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @07:18PM (#15474870)
Could it be that the offset calculation to find the start of the array is needed in any case?
Re:Some Insights from a Julia Developer by ACow_Adonis on Sunday October 15, 2017 @03:16AM (#15476233)
My thinking is this:

To access an array via index, you basically have to take the reference to the array, the index (i), and generally multiply (i) by the space set aside for each element (e).

i * e

If you've offset the array, you have to take the offset index (o), and call a mapping function (m) that maps (o) to (i), so the result can be multiplied by (e). Though it should be said there is another theoretical alternative: you can figure out a way to map (o) directly to (i * e) without the intermediate operation or mapping (o) to (i).

Where (i) and (o), and the relationship between them, is known at compile time, you can theoretically get the compiler to magic that operation away.

But where (o) is only known at run time, you have to first fetch/generate (o), apply (m) to map it back to (i), then multiply (i) by (e) before knowing how to access an array.

If you know fetch/generate (i) at run-time, you don't need the map operation (m), you just multiple (i) by (e) and there's your array reference. But otherwise there's an operation (m) sitting around whose cost must be paid.

You can't handwave it away via reliance on cpu parallel instructions or anything like that because its by definition a serial operation: you can't multiply by (e) until after you've got (i), you can't get (i) until you've applied (m), and you can't apply (m) until after you've fetched (o).

Now where the cost of (m) is sufficiently low relative to other operations, or where the number of array accesses are low, the two may appear sufficiently similar and offset array access might appear practically costless. But the point where we generally care about these things is because we're doing them a very very large number of times on a sufficiently large number of indexes that can't be known or optimised away ahead of time.

And it is worth pointing out that addition operations and things are remarkably cheap in general. But if you're accessing these arrays themselves in order to do addition operations or something similar on their contents, then it may still take up a relatively high proportional amount of time relative to the entirety of the program/operation.

Avoiding theoretical discussion on the possibility of functions (m) that map (o) directly to (i * e) while being equal or cheaper than (i * e) in cost, there is another possibility that might appear in practice...

If the original array access operations are not optimal, (or slowed down due to other issues, such as in-optimal caching or memory access, then it may be possible for both offsets and array access to be equal in practice. If indexing by both (i) and indexing by (o) are both seeing an additional step between the getting of the index and multiplying by element size, or if there is sufficient lag because the CPU isn't doing work optimally, then in profiling and practice, both would appear to be running to the same speed. But this wouldn't imply you've optimised offset indexes, it implies your regular indexes and operations aren'y optimised enough already....that's why it appears you can get something for free.

Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @11:50AM (#15477624)
Instead of storing the start address of the array, store a suitably offset address, right? That amounts to an addition that has to be performed when memory is allocated to the data structure, which may be at compile-time or at run-time.
Re:Some Insights from a Julia Developer by omginternets on Saturday October 14, 2017 @04:30PM (#15474099)
Yeeesh, that sounds like a maintenance nightmare...
Re:Some Insights from a Julia Developer by ChrisRackauckas on Monday October 16, 2017 @05:01AM (#15481797)
Why? You don't have to write a package any differently to make it work with arbitrary indices.
Re:Some Insights from a Julia Developer by omginternets on Wednesday October 18, 2017 @05:01AM (#15497761)
Because it's inconsistent.
Re:Some Insights from a Julia Developer by strictfp on Saturday October 14, 2017 @04:16PM (#15474031)
I also found this effect super annoying when I switched to using a car - having to sell my carriage, get rid of my stable, sell or rent all my horses. All my connections in remote stables were suddenly useless. And I had to sell of all that hay! And oil, I had to get lots of oil! And it's nowhere to be found! Outrageous, I say.
Re:Some Insights from a Julia Developer by throwaway7645 on Saturday October 14, 2017 @12:50PM (#15472984)
Zero based indexing? I find it not too bad to switch between languages that use zero & one based indexing.
Re:Some Insights from a Julia Developer by goatlover on Saturday October 14, 2017 @09:29PM (#15475357)
I don't have problems with it, but I also never had an issue with Python's whitespace, or languages without semicolons, or languages which prefer to use begin/end blocks. I don't get why it's a big deal.

The one exception to that is when switching between languages. Sometimes one forgets which language one is in and a syntax error will result. Like using the dot operator to concatenate strings in Python or leaving semicolons off the end of PHP statements.

Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @09:28PM (#15475353)
It's not that one is incapable of doing it. It's that one way is wrong and the other is right!
Re:Some Insights from a Julia Developer by btschaegg on Sunday October 15, 2017 @07:08AM (#15476663)
The argument of zero vs one-based offset is not very new, and since there's a record of musings from Dijkstra on the topic[1], I feel obliged to mention it.

Note: Although I'd side with EWD on this one (for now, at least), I don't intend to reference it as an "appeal to authority", but as an example of someone producing a reasonable, properly worded and thought-through argument on the topic, which I've not really seen since. I'd be very interested in what similar arguments would look like from the other perspective. If someone would like to convince me, feel free give me a link to some reasoning :)

Also: I personally find "it's always been like this" to be a terrible argument in either case. Those are the reason we weren't able to standardize for one system of units, for example. In the Swiss army, there's a saying that is used to explain the various idiotic decisions and the bogus explications thereof a soldier has to endure:

  Ist so weil ist so, bleibt so weil war so.
Liberally translated:

  Things are like that because they are like that.
  All stays that way because it was that way.
[1]: EWD831, https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
Re:Some Insights from a Julia Developer by goatlover on Saturday October 14, 2017 @09:30PM (#15475361)
Right, so zero-based is wrong unless one is using a language close to assembly.
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @10:39PM (#15475580)
Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion.

I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

Re:Some Insights from a Julia Developer by goatlover on Sunday October 15, 2017 @12:31AM (#15475896)
Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

Everyone starts counting objects at 1. Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages, although maybe there are some mathematicians who think otherwise?

Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @01:14AM (#15476005)
> Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

I don't take programming languages as a reference point. It's the other way around. I try to figure out what the most natural, principled, and elegant way would be, and I would base my programming language on that, if I were to design one.

> Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

We should distinguish between two uses of the natural numbers, I think:

0. _Ordinal numbers_, for assigning labels to things. "This is car 3." 1. _Cardinal numbers_, for saying how many things there are. "There are 7 cars."

The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars.

> Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages

What is the most common isn't what determines, for me, what is the most proper. I will play along and use 1-based indexing when I have too, but in my heart I know how I think it should _really_ be.

> maybe there are some mathematicians who think otherwise?

Yes, though starting numberings on 1 is still common (maybe the most common). Zero is at least recognised as a natural number nowadays. Historically, this wasn't the case. Apparently, Peano started on 1 in his axioms for the natural numbers [0], and zero, as far as I understand, hardly had the status of being a number at all during much of Greek and Roman antiquity [1].

[0] https://en.wikipedia.org/wiki/Peano_axioms#Formulation [1] https://en.wikipedia.org/wiki/0#Classical_antiquity

Re:Some Insights from a Julia Developer by goatlover on Sunday October 15, 2017 @01:55AM (#15476091)
> The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars.

But who thinks that way? I just see 7 cars, not an indexed listing. And anyway, the 0 indexed car doesn't exist.

Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @11:47AM (#15477616)
He who finds zero-based indexing to be the proper way and wants to shape his thinking thereafter!
Re:Some Insights from a Julia Developer by rrock on Sunday October 15, 2017 @12:39AM (#15475914)
No, zero is the right number to start an offset, not an enumeration. No one starts counting from zero in real life.
Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @01:15AM (#15476010)
> No one starts counting from zero in real life.

The question for me is what one _should_ do, not what is usually done.

Re:Some Insights from a Julia Developer by flavio81 on Saturday October 14, 2017 @03:33PM (#15473782)
You will want to switch as soon as you have to confront the Global Interpreter Lock (GIL)
Re:Some Insights from a Julia Developer by 88e282102ae2e5b on Saturday October 14, 2017 @09:04PM (#15475265)
I've confronted it plenty of times, and for my use cases it's not really an issue. Many numpy functions release the GIL, so by keeping my performance-critical stuff in numpy it's just not an issue for me. I sometimes split tasks up with multiprocessing, which is a GIL workaround to be sure, but the memory footprint of extra interpreters is negligible compared to the data I work with.