Slide 1

Slide 1 text

Satoshi Tagomori, a.k.a. tagomoris TokyuRubyձٞ14 - Jul 29, 2023 Avoid Collisions, Desire Co-existence Names, Modules, Versions, and NameSpaces

Slide 2

Slide 2 text

Satoshi Tagomori (@tagomoris) Independent developer Technical Consultant OSS Maintainer • Fluentd • MessagePack / msgpack-ruby • Norikra, Woothee, … tagomoris

Slide 3

Slide 3 text

https://www. fl ickr.com/photos/takkanm/3978417669 Asakusa.rb

Slide 4

Slide 4 text

10൪ ϛχνϡΞ͓ͰΜ 11൪ ϩʔετϏʔϑΘ͞ͼϚϦω

Slide 5

Slide 5 text

Collisions in Ruby programs, processes

Slide 6

Slide 6 text

Collisions Names, Modules, Versions Name Collisions: No one can use a name in two ways. Module Collisions: Modules can be modified, globally, from anywhere. Version Collisions: Two different versions of a module can’t be loaded.

Slide 7

Slide 7 text

Name Collisions Two “Tagomori” Problem 😃 Tagomori module Tagomori

Slide 8

Slide 8 text

Name Collisions Two “Tagomori” Problem 😃 Tagomori 🤪 Tagomori module Tagomori

Slide 9

Slide 9 text

Name Collisions Many “Matsumoto” Problem module Matsumoto 🙂 Matsumoto

Slide 10

Slide 10 text

Name Collisions Many “Matsumoto” Problem module Matsumoto 🙂 Matsumoto (papa) 😀 Matsumoto (type) 😝 Matsumoto (katsyoshi)

Slide 11

Slide 11 text

Name Collisions In Fact: App vs Gem, App vs App, Gem vs Gem • RoR app classes vs Gem library module names • RoR app classes vs RoR app classes • “Con fi guration”

Slide 12

Slide 12 text

Module Collisions Module global con fi guration changes module Tagomoris (@black_magic:false) User App code Dependency library .method_call {result}

Slide 13

Slide 13 text

Module Collisions Module global con fi guration changes module Tagomoris (@black_magic:true) User App code Dependency library .enable_black_magic!

Slide 14

Slide 14 text

Module Collisions Module global con fi guration changes module Tagomoris (@black_magic:true) User App code Dependency library .method_call {result}

Slide 15

Slide 15 text

Module Collisions In Fact: Oj

Slide 16

Slide 16 text

Version Collisions Tagomoris v2 vs v1 User App code module Joker1007 VERSION: 3.1.4 module Tagomoris VERSION: 1.y.z

Slide 17

Slide 17 text

Version Collisions Tagomoris v2 vs v1 module Tagomoris VERSION: 2.0.x User App code module Joker1007 VERSION: 3.1.4 module Tagomoris VERSION: 1.y.z 😱

Slide 18

Slide 18 text

Version Collisions In Fact: Gem Dependency Hell https://www.activestate.com/blog/dealing-ruby-dependency-con fl icts/

Slide 19

Slide 19 text

Avoid Collisions

Slide 20

Slide 20 text

Desire Co-existence

Slide 21

Slide 21 text

NameSpaces In other words: “Multiverse Ruby” https://rubykaigi.org/2023/presentations/shioyama.html#day2

Slide 22

Slide 22 text

NameSpaces in languages Many ways, Many hells… • JavaScript/TypeScript (npm) • Copy everything, import one-by-one “in past” (download/copy cost …) • Install once, symbolic links, import one-by-one • Java (classes w/ FQDN) • Write once, install once, import locally (name collisions, dependency hell) • Class loaders (oops….) • Python (pip) • Install once, import one-by-one (dependency hell) • Go • Install once, import locally (name collisions)

Slide 23

Slide 23 text

NameSpace Requirements What is it? • One native extension libraries of two versions at a time Ruby Process LibraryX version: a.b.c “x.so” LibraryX version: x.y.z “x.so”

Slide 24

Slide 24 text

“དྷͨ, ݟͨ, …” “Veni, vidi, vici”

Slide 25

Slide 25 text

উͬͨο! ୈ1෦׬!

Slide 26

Slide 26 text

No, Still on the Way Native Extensions, Top-level References, Open classes, and… • Calling C-functions of di ff erent gem • Top-level references • Enforcing use of ‘::NAME’ to access top-level names • Silent failures of open class accesses • Automatic namespace adoptions • Accessing modules in namespaces without any source code updates • To be implemented in PoC

Slide 27

Slide 27 text

Next Step More Concerns, More Features, and Agreements • https://bugs.ruby-lang.org/issues/19744 • “[WIP] Namespace on Read PoC” https://github.com/tagomoris/ruby/pull/1 • and
 
 দߐRubyձٞ10
 https://matsue.rubyist.net/matrk10/