Re:Why Ruby Is More Readable Than Python
by dzsekijo on Friday July 22, 2022 @06:20AM
(#32190425)
What I enjoy about Ruby over Python the most is not intricacies of the OO implementation or delicacies of metaprogramming, but a good support for functional style. In ruby, statements are expression-like, they have a return value. Also, with Ruby it's easy to break down code to consecutive pure blocks.
Condiser the following task: take /proc/kallsyms in Linux, that lists symbols in kernel, in an '<address> <type> <name>' format, like:
0000000000000000 A fixed_percpu_data
0000000000000000 A __per_cpu_start
0000000000001000 A cpu_debug_store
0000000000002000 A irq_stack_backing_store
0000000000006000 A cpu_tss_rw
000000000000b000 A gdt_page
...
let's make stats on it -- how much of each type is present? Wanna get the result ordered by number of occurrence.
Condiser the following task: take /proc/kallsyms in Linux, that lists symbols in kernel, in an '<address> <type> <name>' format, like:
let's make stats on it -- how much of each type is present? Wanna get the result ordered by number of occurrence.In Ruby:
Of this method call chain, first and last are impure (as they do I/O), the intermediate ones are pure.In Python you'll have to grind through it procedurally. (Unless you use reach out to some advanced libs... https://gist.github.com/richardbann/5b363096de6b3de2e8178cce...)