4 ms·
Many languages disagree on that rule (2 or 3 operators not worth factoring). Or rather, there are very many different approaches to this problem in various lang
by klibertp 11y ago
Many languages disagree on that rule (2 or 3 operators not worth factoring). Or rather, there are very many different approaches to this problem in various languages. Take a look at Forth, APL, J and possibly Factor to see something radically different than anything you've ever seen (and yes, people do use these).
Personally I find well-chosen names to help readability and may help avoid code duplication. There are 2 or 3 operator long things very much worth naming (see for example https://gist.github.com/piotrklibert/a0849f26523cad3d594e#file-refactoring-py-L44 https://gist.github.com/piotrklibert/a0849f26523cad3d594e#fi...).
It's a style I call "modern literate," which tries to emulate "literate programming" without extra-language tools. Jeremy Ashkenas uses it in his works, most notably Underscore.js and Backbone.js: the code is simultaneously a manual and a tutorial. See: http://backbonejs.org/docs/backbone.html http://backbonejs.org/docs/backbone.html
- asgard1024 11y agoI am aware of that, that's why I mention it (and I would add Perl and many Lisp-like languages to your list). I appreciate the path that Python took, though, because it keeps language small and orthogonal. There is lot of value in this approach, especially if you share code with someone outside of the project. > There are 2 or 3 operator long things very much worth naming I don't understand your example. But I am talking about functions that are part of the libraries (especially standard ones). How you refactor your code is a different matter.