3 ms·
I really don't think R the language is poorly designed. Sure the implementation isn't great, and the standard library is patch and inconsistent, but the core of
by hadley 13y ago
I really don't think R the language is poorly designed. Sure the implementation isn't great, and the standard library is patch and inconsistent, but the core of the language is elegant and well-suited to its domain (which is not just programming, but also interactive data analysis).
I'm interested to hear dissenting opinions, but you'll need to back them up with specifics.
- noelwelsh 13y agoOk, here is one I remember from my R days: the save and load functions. First some preamble. One of the fundamental design features of Scheme is lexical scoping, at the time a relatively unusual feature. Lexical scoping greatly simplifies program comprehension and compilation. In a lexically scoped language, a binding -- that is, an association between a name and a value -- is only visible in the scope in which it is defined, and any scopes within that scope. This means the textual source of the language determines which bindings are visible -- simple and no surprises. The save function in R doesn't save a value, it saves a binding. When you call load you actually add a binding into your scope (local or global scope? I'm not sure and the docs don't say.) This is absolute madness. It means you need to know the name that was bound to the value when it was saved, coupling the code that uses the saved value to the code that produces it. Imagine programmer A writes the code that calls save and programmer B loads values. They agree on a name, but then programmer A changes that name ... and breaks programmer B's code! Now you might argue this is a standard library issue, not a language issue, but I argue the two are so tightly coupled you can't consider one in isolation.
- hadley 13y agoYes, save and load suck, and I never use them (and encourage others to avoid them too). Use saveRDS and readRDS instead (and yes those are their totally inconsistent names). (Also the documentation for load does tell you where the objects get bound) Language and standard library are tightly coupled, but problems with the standard library are _much_ easier to fix than problems with the language.
- alsocasey 13y agoAlternately, load() to an environment other than the global one and ls() to figure out what you just loaded... But since attending one of your talks that mentioned saveRDS/readRDS in passing, I've switched over entirely to those.
- hadley 13y agoAlso load returns (invisibly) the names of the objects it loaded, so `(load(...))` will print them out.