[stack] Joy and code readability
"fabio_cevasco" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone, This is my first post here, so I thought I'd introduce myself a little bit: I'm a Ruby programmer (I program for fun, not for profit), and I recently became interested of the Joy language, especially of its minimalism. I also developed a small Ruby DSL <http://www.h3rald.com/concatenative> which implements some of Joy's combinators, just to see what's it like to work with a concatenative language <http://www.h3rald.com/articles/concatenative-programming-in-ruby> . After playing around a little bit, I just wanted to ask you guys how you cope with the (generally speaking) lack of readability of concatenative (but I'm referring mainly to Joy here) code. Although I really like everything concatenative programming offers, I'm somehow overwhelmened by it, in the sense that I find it more difficult to read (and mentally execute) concatenative code without local variables. How do you cope with that? Example (the famous quicksort in Joy): [small] [] [uncons [>] split] [[swap] dip cons concat] binrec To improve readability, the only thing I can think of is labeling each quoted program, using definitions, so: DEFINE remove_pivot_and_split_list == uncons [>] split insert_pivot_and_merge_lists == [swap] dip cons concat So we have: [small] [] [remove_pivot_and_split_list] [insert_pivot_and_merge_lists] binrec Definitely more descriptive and closer to a black box: each name identifies, roughly, how many items the program pops from the stack at the start and how many items pushes back at the end. Is there anything better than this? How do you keep track of what's going on the stack in a language with no variable assignments? Thanks, Fabio [Non-text portions of this message have been removed]