Live data from Hacker News

Some Insights from a Julia Developer

stochasticlifestyle.com

221–230 of 241 posts

Re: Some Insights from a Julia Developer

#221

Earlier quoted context omitted.

Just a response for a few comments, since you talk with confidence but could maybe do with a closer look: 1. You end with `end` in julia. 2. You can use indexing with any base, not just 1 - no performance penalty. 3. The julia repl comes with latex completions making it very easy to just type e.g. \sigma and get the sigma sign. 4. The package system is moving both directions - functionality is split into modules for…

Re 2: Yes, but most of the language is geared towards 1-based indexing, e.g. ranges like a:b being inclusive at the right. Hence, using a zero-based variant of array makes only sense if your code really really profits from zero-indexing. Btw, the question should not be "is zero-based slower"; I know that julia has zero-cost abstractions. The question is whether is is faster, because of the avoided decrement instructi…

>Sure, heaps exist, e.g. in datastructures.jl. But there is no canonical documentation / default choice in the base language, like e.g. heapq in python. And if you want to figure out how to use custom orderings for your heap you end up reading the source code of all 2-3 heap implementations in datastructures.jl (which use different incompatible APIs), because the documentation fails at providing examples. Older julia versions came with heaps included.

If you watch Stefan's 1.0 talk (https://www.youtube.com/watch?v=qHpaztMu_Uw) you'll see that one of the reasons we want 1.0 out is so that way this kind of non-breaking work can get priority. 1.0 is about doing all of the breaking changes to the language. 1.x releases, and package work, are about actually using it. It's known that DataStructures.jl needs work which is why it's even mentioned in the talk as a 1.x improvement goal.

Re: Some Insights from a Julia Developer

#222

Earlier quoted context omitted.

I greatly prefer Julia syntax. `end` makes the code blocks stand out more easily than }. I find it easier to see the indentation at a glance than when just dealing with a single thin character. Also I like that Julia prefers shorts words over special characters. C/C++ use far too many special characters. That might run counter to my delight at unicode support. I think it is quite nice to be able to write mathematical…

Re unicode: When writing latex, you don't want to encounter unicode greek sigma. You want \sigma, as 6 7bit-ascii chars. Same in julia; sure, define a display mode that translates certain things into unicode for people like you, but keep compatibility with code-editors/people/tools who do not understand unicode. In short: I want to it to be possible to use a dumb text-editor, not an IDE/word-processor. (ok, the text…

The convention in Julia is to not have unicode in user-facing APIs. That way you're not forcing unicode on anyone. All of the big libraries and the Base module do this. So you can use unicode for your variables to match your paper if you want, but no library (that I know of) is going to force you to have unicode support in your terminal.

Re: Some Insights from a Julia Developer

#223

"is a good generic type-stable function for any number which has zero and + defined. That's quite unique: I can put floating point numbers in here, symbolic expressions from SymEngine.jl, ArbFloats from the user-defined ArbFloats.jl fast arbitrary precision library, etc." Is it really unique? Isn't that just a Monoid (e.g. in Haskell, Scala, ...) or am I wrong?

I think that unique is an overstatement there, but in the context it's a comparison to other numerical computing systems, where this kind of support for generic code is less common.

Yes,i it was an overstatement. But, while I do see it can be done with these Monoids, I haven't come across these kinds of numerical linear algebra libraries that allow generic code in other languages (here's an example of what I find in Haskell that requires double: https://hackage.haskell.org/package/hmatrix-0.14.0.1/docs/Nu...)

Re: Some Insights from a Julia Developer

#224

Earlier quoted context omitted.

That's what I was told about 0.4 -> 0.5 last year.

By who? Someone who isn't part of the development team? There was an issue set for v0.5 called "Arraypocolypse" that was meant to change a ton of things related to arrays, and that was known months (a year?) before v0.5 was out. Semvar is used for a reason: pre-1.0 is all breaking.

People on gitter, IIRC... I'm sure there's a record of it somewhere. Half the packages I wanted to use were still on 0.4, half were on 0.5, and the combination was incompatible.

Re: Some Insights from a Julia Developer

#225
post #154

Earlier quoted context omitted.

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

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…

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

#226
post #195

Earlier quoted context omitted.

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.

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

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

#227
post #195

Earlier quoted context omitted.

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.

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

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

#228

Earlier quoted context omitted.

I don't use R, so I thought you were referring to dynamic scoping, which I do think it's horrifying. But it seems R uses lexical scoping - that is, the y is captured at function definition time. That's extremely common and quite useful, in my opinion.

R documentation and users SAY that R has lexical scoping, which can be really confusing for people reading about the topic. But if you're coming from something like Common Lisp (which is my point of reference), you soon discover that "Lexical Scoping" as implemented there and "Lexical Scoping" as implemented in R are two different things. In R (paraphrasing) you generally have a search path of environments, and at ru…

A search through linked environment objects corresponding to nested lexical scopes is a valid, correct implementation of lexical scoping.

It could be that R somehow gets some aspect of it wrong but you haven't so far presented evidence of that. (Maybe it's something you know a lot about and so it's obvious to you.)

Re: Some Insights from a Julia Developer

#229

Earlier quoted context omitted.

I don't use R, so I thought you were referring to dynamic scoping, which I do think it's horrifying. But it seems R uses lexical scoping - that is, the y is captured at function definition time. That's extremely common and quite useful, in my opinion.

R uses a "sort of" lexical scoping which causes some "interesting" things. Eg a symbol may be simultaneously in global and local scope within the same function, which can be (ab)used to create a variable that's randomly scoped[0]. I'd say this is sort of a "dynamically lexical scope". [0] http://andrewgelman.com/2014/01/29/stupid-r-tricks-random-sc...

The article is not convicing me that the language is obeying any poorly designed requirements.

The function f contains a free reference to a variable called a. This is satisfied in some sort of global environment.

Later, f is called from a function in which there is a local a bound to 100. Of course, this a which is local to that function is invisible to the free reference in f which continues to refers to the global a that contains 10.

It could be there is some problem in R, but whatever that is, this article isn't exposing it in a convincing way.

Same thing in Common Lisp (using CLISP):

  [1]> (defun f (x) (* a x))
  F
  [2]> (setf a 10)
  10
  [3]> (f 3)
  30
  [4]> (defun g (y) (let ((a 100)) (f y)))
  G
  [5]> (g 3)
  30
The surprise is supposed to be that `(g 3)` doesn't produce 100. Why should it?

(It could produce 100 if the symbol a were marked for binding as a special variable; but it isn't. Thus it's just a free variable in f resolved in the global environment, and a lexical binding in g).

Re: Some Insights from a Julia Developer

#230

Earlier quoted context omitted.

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…

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…

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.
Post reply on HN