ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: eregontp@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99463] [Ruby master Feature#15752] A dedicated module for experimental features
Date: Mon, 03 Aug 2020 19:34:03 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-86920.20200803193402.772@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15752.20190407135631.772@ruby-lang.org

Issue #15752 has been updated by Eregon (Benoit Daloze).


Dan0042 (Daniel DeLorme) wrote in #note-18:
> Can I ask what would be so bad about having the `RubyVM` constant in other implementations? I mean, in itself the name is very general. Every implementation can be said to be a "Ruby VM".

It's a good question. My understanding is that `RubyVM` was really meant as the `JRuby` or `TruffleRuby` module of JRuby/TruffleRuby, i.e., a module specifically for CRuby-specific things.
I tried to rename it to CRuby for clarity in https://bugs.ruby-lang.org/issues/15743 but failed: https://bugs.ruby-lang.org/issues/15743#note-21

See also https://bugs.ruby-lang.org/issues/15743#note-7 which notes that about everything under `RubyVM` was meant to be CRuby-specific.
But since CRuby is the standard implementation, about any public API, including RubyVM will become used and depended on.
Even more so if the name doesn't imply "experimental/unstable".

I would like experimental APIs to be clearly marked as such, and RubyVM doesn't achieve that well at all.
In fact I would bet many users of RubyVM don't even know it's experimental, or don't even know it's CRuby-specific (I tried to document that, but people don't read the documentation all the time).

So if RubyVM becomes shared it will become clear it's no longer CRuby-specific experiments.
I'm fine with that, because RubyVM is already used in production by now (e.g., bootsnap).

I think as a result CRuby will no longer have a module for experimental features then.
Not necessarily a bad thing, as truly experimental APIs should probably be behind a `./configure` flag if developers are serious about not having gems depend on it.
And I think it's good that new APIs, even if experimental, consider about portability since we have more than 1 implementation in the Ruby ecosystem.


Adding `ExperimentalFeatures` would let CRuby and other implementations experiment in a shared namespace, which seems clearer for everybody.
It wouldn't prevent gems to depend on it, but at least the name clearly states the intention.

So, in summary I don't really mind either way.

I think if we make `RubyVM` a shared namespace then CRuby will need another module/way for experimental/CRuby-specific features.

----------------------------------------
Feature #15752: A dedicated module for experimental features
https://bugs.ruby-lang.org/issues/15752#change-86920

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
----------------------------------------
I believe we should introduce a module for experimental features portable across Ruby implementations.

An example of such a portable experimental feature is `RubyVM.resolve_feature_path`.
This feature has nothing MRI specific in it, it is a part of basic `require` functionality.
In the future, I would think more experimental features will be introduced, and I think `RubyVM` is not a good place for it.

Currently, `RubyVM` is sometimes used for experimental features, but I believe `RubyVM` should be defined only on MRI and contain only MRI-specific features.
This means it is *impossible* for other implementations such as JRuby and TruffleRuby to define `resolve_feature_path` (even though it's trivial and might be useful for some users),
and keeping `RubyVM` not defined for clearly marking MRI specific features are not available.

This is a problem that will only gets worse as portable experimental features are added to `RubyVM`.
Here is one example of adding an experimental feature but unfortunately there is no common place between Ruby implementations to add it:
https://github.com/jruby/jruby/issues/5206

If other implementations defined `RubyVM`, then only parts of it would be portable and other parts would be MRI specific,
which would be very confusing to both users and Ruby implementers.

Also, `RubyVM` doesn't really indicate by its name that it contains experimental features.

So I propose the obvious name `ExperimentalFeatures`.

I think such a long name is unlikely to clash with existing Object constants, is very clear,
and marks that any usage of it is by definition using not stable APIs that might be removed or changed.

In combination with #15743, this would mean we can very clearly see what kind of feature it is due to explicit naming:

* `ExperimentalFeatures.resolve_feature_path` is a portable experimental feature, which can be supported on other Ruby implementations too.
* `CRuby::InstructionSequence` is a CRuby/MRI-specific feature, which will only be supported on MRI.

OTOH, the `RubyVM` name doesn't indicate this important difference, and doesn't even indicate the features under it might experimental or not portable.

My main motivation here, is allowing other Ruby implementations to support some of these portable experimental features.
There is no reason for only MRI to be able to support code using portable experimental features.

cc @mame @headius



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2020-08-03 19:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15752.20190407135631.772@ruby-lang.org>
2020-08-01 13:25 ` [ruby-core:99436] [Ruby master Feature#15752] A dedicated module for experimental features eregontp
2020-08-01 13:29 ` [ruby-core:99438] " eregontp
2020-08-03 19:04 ` [ruby-core:99462] " daniel
2020-08-03 19:34 ` eregontp [this message]
2020-08-03 19:40 ` [ruby-core:99464] " eregontp
2020-08-04  0:19 ` [ruby-core:99467] " mame
2020-08-15 10:20 ` [ruby-core:99594] " eregontp
2020-09-01  8:06 ` [ruby-core:99814] " matz
2021-01-28 21:01 ` [ruby-core:102278] " eregontp
2021-01-29  4:14 ` [ruby-core:102281] " naruse
2021-02-16  6:54 ` [ruby-core:102520] " matz
2021-02-16 12:01 ` [ruby-core:102533] " eregontp
2021-03-17  4:38 ` [ruby-core:102898] " naruse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-86920.20200803193402.772@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).