3 ms·
> Documentation: One criticism is that the documentation is somehow incomplete. I think https://www.ruby-lang.org/en/documentation/ https://www.ruby-lang.org/en
by philwelch 9y ago
> Documentation: One criticism is that the documentation is somehow incomplete. I think https://www.ruby-lang.org/en/documentation/ https://www.ruby-lang.org/en/documentation/ and http://ruby-doc.org/ http://ruby-doc.org/ neatly dissolve that.
The language itself is finally documented, but libraries are extremely hit-and-miss and the lack of features to support extracting documentation from code is a huge reason for this. Having used both Ruby and Python extensively (and Ruby for many more years), the difference is pretty staggering.
> The other criticisms appear to be things that would largely apply if one were trying to implement a Ruby interpreter, which is not the normal task of a Ruby programmer and are irrelevant, but also largely wrong. Most Ruby developers are not consulting the source code of the interpreter to determine what functions do on a regular basis.
But we do consult the source code of every library and framework we use.
As for the advantages of having a well-defined grammar or the ability to inspect the AST, those are things I don't think you appreciate the value of until you have the opportunity to use them. Linting and optional static typing are two things I've come to appreciate.
To name another example: I once worked on a Python project where we had to swap out database drivers across every Python codebase in the entire organization, and, as you point out, different libraries do things differently so we had to change the code around all our DB calls. One of our senior devs used astor--a Python library that supports loading Python code and transforming it at the AST level--to write a script to perform this transformation programmatically on our code repos. There was still lots of testing and review of the generated code changes, but it was a lot nicer than having to do it all by hand.
> Namespaces, compilation units, and modules: The explanation for this is tortured and simplistic. You can see confusion shining through when he calls a Ruby file a compilation unit. It just doesn't work that way. Multiple files can contribute to a Module or a Class.
I think you might have misunderstood the author here, because files are indeed "compilation units" in Ruby. If I have a running irb session where I've imported code from 20 different Ruby files, and I change the code in one of those files, I can just call load on that file again and it should fix anything up, even if that file is monkeypatching a class that's also defined in seven other files.
- mattmcknight 9y ago"because files are indeed "compilation units" in Ruby. If I have a running irb session where I've imported code from 20 different Ruby files, and I change the code in one of those files, I can just call load on that file again and it should fix anything up, even if that file is monkeypatching a class that's also defined in seven other files." I should have been more clear, Ruby is not compiled. It is interpreted. Compilation units are a concept from the Java Langauge Spec. That concept does not clearly map to Ruby.
- philwelch 9y agoThe Ruby interpreter compiles to bytecode, which is then passed to the VM, which isn’t that far off from classical Java. JRuby also seems to support ahead-of-time compilation. In any case, the fact that a single Ruby source file can be incrementally loaded into the runtime despite altering classes and modules defined elsewhere supports, rather than detracts, from the author’s notion of a “compilation unit”. Python, in contrast, tightly couples code files (“compilation units”) with modules.