[ruby-core:117508] [Ruby master Feature#18576] Rename `ASCII-8BIT` encoding to `BINARY`

Issue #18576 has been updated by alexander-s (Alexander S). matz (Yukihiro Matsumoto) wrote in #note-14:
I don't object to the proposal itself. But as @ko1 searched, there are so many gems that compare `Encoding#name` and `ASCII-8BIT`. So I don't accept the proposal for the sake of compatibility.
Matz.
I've been developing with Ruby for some 10+ years now, and overall I really like the language. However, I also feel that Ruby sometimes seems too focused on being backwards compatible, to a point where it risk hurting the ecosystem. I think this thread is a good example, because it seems like such a small and benign change, yet it's taken several years and lots of back and forth, and in the end the proposed change wasn't even applied(!?). At the same time, several parts of the standard library feels outdated (Net::HTTP for example), and others misplaced (OLE-automation anyone?). On the other hand, new "cool features" are sometimes introduced that I don't really see any value in. For example 'endless ranges' and 'single line end-less method definition'. In short, I share much of Bbatsov's (RuboCop author) sentiment from this article (https://metaredux.com/posts/2019/04/02/ruby-s-creed.html). There is good progress too, I'll happily admit. A few examples that comes to mind are 'keyword params', 'unifying Integer/Fixnum', 'UTF-8 encoding by default', the Prism parser and the focus on performance. All these seemed like sensible improvements, in alignment with development in other modern languages. Others probably have a much better ideas on what old stuff could be improved, but it could be for example: - Remove or deprecate globals - Update the Rubydoc system (many other languages have better documentation systems) - Continue cleaning up the stdlib (some progress has been made in recent Ruby releases, which is good) - Look at popular rules in RuboCop etc, for stuff that people are frequently disabling with linting, and consider deprecating them. - Take it easy with new syntax, ruby already have 'many ways to solve the same problem'. Something like end-less method definition seems like a pointless addition. On our team, we just disabled it with linting on day one. To summarize, obviously backwards compatibility is important. But progress is inevitable and a language that doesn't development at a reasonable pace will eventually stagnate and die. I don't think ruby is there yet, but I'd hate to see it go down that path. I also think think much of this can be managed with deprecation messages and the like. ---------------------------------------- Feature #18576: Rename `ASCII-8BIT` encoding to `BINARY` https://bugs.ruby-lang.org/issues/18576#change-107895 * Author: byroot (Jean Boussier) * Status: Open * Target version: 3.4 ---------------------------------------- ### Context I'm now used to it, but something that confused me for years was errors such as: ```ruby
"fée" + "\xFF".b (irb):3:in `+': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
When you aren't that familiar with Ruby, it's really not evident that `ASCII-8BIT` basically means "no encoding" or "binary".
And even when you know it, if you don't read carefully it's very easily confused with `US-ASCII`.
The `Encoding::BINARY` alias is much more telling IMHO.
### Proposal
Since `Encoding::ASCII_8BIT` has been aliased as `Encoding::BINARY` for years, I think renaming it to `BINARY` and then making asking `ASCII_8BIT` the alias would significantly improve usability without backward compatibility concerns.
The only concern I could see would be the consistency with a handful of C API functions:
- `rb_encoding *rb_ascii8bit_encoding(void)`
- `int rb_ascii8bit_encindex(void)`
- `VALUE rb_io_ascii8bit_binmode(VALUE io)`
But that's for much more advanced users, so I don't think it's much of a concern.
--
https://bugs.ruby-lang.org/
participants (1)
-
alexander-s (Alexander S)