3 ms·
It's a cool feature which enables some really nice APIs, but it also has the potential to break your mental model when reading code. For example: x <- f(a)
by one-more-minute 10y ago
It's a cool feature which enables some really nice APIs, but it also has the potential to break your mental model when reading code. For example:
x <- f(a)
y <- g(x, z)
vs
y <- g(f(a), z)
It would be extremely unexpected if the result `y` was different for these two expressions, but you can't know for sure without reading `f` – since it could be using NSE. This applies to any innocent-looking function in any library you use – imagine trying to debug an issue caused by something like this.
It's also awful for performance. Allowing functions to peek at their arguments at any time is one of the things that makes R virtually impossible to optimise effectively.
Of course, libraries like dplyr also show that it can be used to great effect in the right hands.
- GlennS 10y agoI think this is a big part of why R is such a success amongst data analysts. A lot of R libraries have a really good human interface which you can play around with and it will successfully DWIM a lot of the time. Once you start trying to drive R in a more automatic way with your own programs, though, it starts to get really messy. I wouldn't want to make even a medium-sized program in it (10,000 lines would be too, for example). Then it's time to switch to Python with numpy. I wonder if Julia will be able to cover both types of program effectively. There's definitely a niche for it if it can.