News for hackers. Stuff that matters.
Re:What's wrong with statistics in Julia? by nyir on Saturday November 29, 2014 @06:25PM (#8675415)
Isn't the rather big flexibility of R to not eagerly evaluate, or to rewrite function arguments entirely (and apparently scope manipulation, that's a new one for me) one of the major points of critic? It always seemed to me that having "proper" macros is a selling point rather than only an approximation/emulation.
Re:What's wrong with statistics in Julia? by jacobolus on Saturday November 29, 2014 @07:05PM (#8675482)
> Isn't the rather big flexibility of R to not eagerly evaluate, or to rewrite function arguments entirely (and apparently scope manipulation, that's a new one for me) one of the major points of critic [sic]?

For anyone coming from a programming background, the way R deals with scope and function arguments is incredibly confusing and frustrating, and causes all kinds of nasty bugs. It seems pathological.

For several of the academic statisticians I’ve talked to though, R seems to be their first programming language, and they learn (in a slightly fuzzy way, but enough to do their work) the behavior of its APIs without thinking too deeply about issues of scope or eager vs. lazy argument evaluation, etc. However it works is “just the way it is.” When their expectations about what it should do are violated, they futz with the code until it starts working again and call it a day. People are typically using R to solve narrow concrete problems instead of building systems out of it, so most end-users don’t really have practice with thinking about API design. (R is similar to Matlab in this way.)

Personally I think many of R’s idioms are net negative for the language because they make the abstractions much less simple/clean, and make it more difficult to solve problems in general/adaptable ways. But for someone who already has substantial amounts of time invested in learning R’s API quirks, and doesn’t know any other way, it might not seem like a big deal.

Re:What's wrong with statistics in Julia? by stewbrew on Sunday November 30, 2014 @03:00AM (#8676323)
R (or rather S) wasn't intended to be a general purpose programming language. It was written as a glue language (or rather a DSL) for low-level code for _interactive_ use in the domain of statistics. The goal to have a language that should be used interactively in a REPL IMHO explains many of those "quirks". You should take R for what it is.
Re:What's wrong with statistics in Julia? by johnmyleswhite on Saturday November 29, 2014 @07:14PM (#8675505)
A fun test to see if R users understand how R works is to ask them to predict the behavior of the following snippet of code:

foo <- function(a, b) { if (a == 0) { return(1) } else { return(2) } }

foo(0, stop("Error!"))

foo(1, stop("Error!"))

Re:What's wrong with statistics in Julia? by Hansi on Saturday November 29, 2014 @07:22PM (#8675530)
Why? Seems to simple. I normally go straight for drop=FALSE the most evil default issue of the language.
Re:What's wrong with statistics in Julia? by jghn on Saturday November 29, 2014 @08:01PM (#8675610)
Agreed. There are many WTF things I can think of in R, this is absolutely not one of them.
Re:What's wrong with statistics in Julia? by johnmyleswhite on Saturday November 29, 2014 @08:32PM (#8675665)
My experience asking people about that snippet is that very few people can correctly predict the results of that function without actually executing the code. What interests me about the question is that many people's mental model of how R programs are evaluated is often too vague to enable them to produce sharp predictions about program behavior prior to executing code.
Re:What's wrong with statistics in Julia? by RA_Fisher on Saturday November 29, 2014 @09:44PM (#8675800)
This is funny because I was heavily skeptical yet completely reversed my opinion within 10 minutes. I correctly predicted the results, but I program R professionally. Then I asked my partner who's a non-programmer to read the snippet and her prediction was that the program would stop. That led me to reflect back on your statement. I think the key word is "sharp". I correctly predicted the result, but that's only because I trust lazy-eval heavily. Even then, it's hard to really cement trust in lazy-eval (for me) as it's difficult to mentally map. That's not exactly sharp after all!
Re:What's wrong with statistics in Julia? by jghn on Saturday November 29, 2014 @10:04PM (#8675834)
"but I program R professionally"

To be fair to JMW, I used to as well - and perhaps more importantly I was writing end user software in R and not doing my own data wrangling.

Re:What's wrong with statistics in Julia? by coldtea on Sunday November 30, 2014 @02:49AM (#8676312)
>My experience asking people about that snippet is that very few people can correctly predict the results of that function without actually executing the code.

Which is still not any serious barrier in using R succesfully.

Re:What's wrong with statistics in Julia? by stewbrew on Sunday November 30, 2014 @03:03AM (#8676326)
Lazy evaluation in R isn't that difficult to grasp once you accept the fact and don't superimpose an evaluation model dominant in most other languages. It turns out, this kind of lazy evaluation can actually be quite useful.
Re:What's wrong with statistics in Julia? by jghn on Saturday November 29, 2014 @10:01PM (#8675830)
My first answer was correct, although i'll admit to having run the snippet afterwards as I figured there was some trick in there that I couldn't see.
Re:What's wrong with statistics in Julia? by johnmyleswhite on Saturday November 29, 2014 @10:23PM (#8675868)
I didn't mean to imply I thought you would guess the wrong answer, but rather that most R users do not understand delayed evaluation well enough to understand how it will impact their code. Sorry if my comment seemed rude.
Re:What's wrong with statistics in Julia? by jghn on Sunday November 30, 2014 @12:09AM (#8676051)
I didn't find it rude, I just have trouble seeing it as a snippet which would really cause confusion. If you have seen people get confused by it though, I suppose it is.
Re:What's wrong with statistics in Julia? by johnmyleswhite on Saturday November 29, 2014 @06:34PM (#8675431)
I fully share that viewpoint, but there are many R users who believe that R's idiosyncratic evaluation rules are essential to writing "readable" code.
Re:What's wrong with statistics in Julia? by stewbrew on Sunday November 30, 2014 @03:14AM (#8676343)
They sometimes allow to write functions for which you would have to use macros in other languages.