Slide 1

Slide 1 text

Back to the roots of date ODA Hirohito 2026-04-22

Slide 2

Slide 2 text

Copyright © BizteX Inc All Rights Reserved. 2 Do you know the date library?

Slide 3

Slide 3 text

Copyright © BizteX Inc All Rights Reserved. 3 Do you know issues of the date library?

Slide 4

Slide 4 text

Copyright © BizteX Inc All Rights Reserved. 4 2025-04-11 (UTC)

Slide 5

Slide 5 text

Copyright © BizteX Inc All Rights Reserved. 5 h tt ps://bugs.ruby-lang.org/issues/21264

Slide 6

Slide 6 text

Copyright © BizteX Inc All Rights Reserved. 6 h tt ps://bugs.ruby-lang.org/issues/21264 • There have been no primary maintainers for the date library and the datetime library for over 10 years. • Maintaining the date library and the datetime library are becoming a burden for Ruby commi tt ers.

Slide 7

Slide 7 text

Copyright © BizteX Inc All Rights Reserved. 7 Future proposals for the date library and the datetime library • The Date class will be deprecated. • Instead, a simpli fi ed The Date class will be created. • Move the Date class into a core class. • Keep the current situation.

Slide 8

Slide 8 text

Copyright © BizteX Inc All Rights Reserved. 8 Future proposals for the date library and the datetime library • The Date class will be deprecated. • Instead, a simpli fi ed The Date class will be created. • Move the Date class into a core class. • Currently, there are no major problems, so Ruby commi tt ers will continue with maintenance that only involves version updates. How did I approach this challenge?

Slide 9

Slide 9 text

Copyright © BizteX Inc All Rights Reserved. 9 Who are you? • Name: ODA Hirohito • X: jimlock • GitHub: jinroq • Community: Fukuoka.rb • Organization: BizteX Inc.

Slide 10

Slide 10 text

Copyright © BizteX Inc All Rights Reserved. 10 h tt ps://www.biztex.co.jp/ We are Hiring!

Slide 11

Slide 11 text

Copyright © BizteX Inc All Rights Reserved. 11 2025-04-18 (JST)

Slide 12

Slide 12 text

Copyright © BizteX Inc All Rights Reserved. 12 RubyKaigi 2025

Slide 13

Slide 13 text

Copyright © BizteX Inc All Rights Reserved. 13 #rubyriver

Slide 14

Slide 14 text

Copyright © BizteX Inc All Rights Reserved. 14 #rubyriver Me!!

Slide 15

Slide 15 text

Copyright © BizteX Inc All Rights Reserved. 15 #rubyriver

Slide 16

Slide 16 text

Copyright © BizteX Inc All Rights Reserved. 16 Ghost said… • Moving away from date library: • Decoupling DateTime from Date. • Moving `Time.parse` to the time library to decouple it from date library. • strptime issue.

Slide 17

Slide 17 text

Copyright © BizteX Inc All Rights Reserved. 17 Ghost said… • Moving away from date library: • Decoupling DateTime from Date. -> DateTime is already deprecated, so no major action is required. • Moving `Time.parse` to the time library to decouple it from date library. -> Since `Time.parse` internally calls `Date._parse`, we should port the equivalent of `Date._parse` into the time library. • strptime issue. -> The current implementation is slightly biased toward date, so it should be made more neutral and compact, assuming Time.

Slide 18

Slide 18 text

Copyright © BizteX Inc All Rights Reserved. 18 2025-09-25 (UTC)

Slide 19

Slide 19 text

Copyright © BizteX Inc All Rights Reserved. 19 h tt ps://bugs.ruby-lang.org/issues/21616

Slide 20

Slide 20 text

Copyright © BizteX Inc All Rights Reserved. 20 h tt ps://bugs.ruby-lang.org/issues/21616 • date library will be deprecated. • Porting `Date._parse` to time library. • Porting `Date.strptime` to time library.

Slide 21

Slide 21 text

Copyright © BizteX Inc All Rights Reserved. 21 h tt ps://github.com/ruby/time/compare/ master...jinroq:time:implement_parse_from_date

Slide 22

Slide 22 text

Copyright © BizteX Inc All Rights Reserved. 22 h tt ps://bugs.ruby-lang.org/issues/21616#note-1

Slide 23

Slide 23 text

Copyright © BizteX Inc All Rights Reserved. 23 h tt ps://bugs.ruby-lang.org/issues/21616#note-1 The overly heuristic `Time.parse` is what we want to abolish.

Slide 24

Slide 24 text

Copyright © BizteX Inc All Rights Reserved. 24 h tt ps://www.ruby.or.jp/en/news/20250819

Slide 25

Slide 25 text

Copyright © BizteX Inc All Rights Reserved. 25 h tt ps://www.ruby.or.jp/en/news/20250819 NOT accepted

Slide 26

Slide 26 text

Copyright © BizteX Inc All Rights Reserved. 26 Judges said… • That’s not features we want. • We’d like to stop using the current date implementation if possible.

Slide 27

Slide 27 text

Copyright © BizteX Inc All Rights Reserved. 27 Reconsider about the date library • Should we implement a part of Date's functionality (or a similar independent function) in Time? • If Time can handle dates, how does it di ff er from the already deprecated DateTime?

Slide 28

Slide 28 text

Copyright © BizteX Inc All Rights Reserved. 28 Reconsider about the date library • Should we implement a part of Date's functionality (or a similar independent function) in Time? • If Time can handle dates, how does it di ff er from the already deprecated DateTime? My thoughts are wandering in a labyrinth.

Slide 29

Slide 29 text

Copyright © BizteX Inc All Rights Reserved. 29 2025-12-18 (UTC)

Slide 30

Slide 30 text

Copyright © BizteX Inc All Rights Reserved. 30 h tt ps://github.com/ruby/date/pull/152

Slide 31

Slide 31 text

Copyright © BizteX Inc All Rights Reserved. 31 h tt ps://github.com/ruby/date/commits/master/

Slide 32

Slide 32 text

Copyright © BizteX Inc All Rights Reserved. 32 It's no probrem to incorporate new technologies into established technologies.

Slide 33

Slide 33 text

Copyright © BizteX Inc All Rights Reserved. 33 2025-12-20 (JST)

Slide 34

Slide 34 text

Copyright © BizteX Inc All Rights Reserved. 34 Ruby Release 30th Anniversary Party h tt ps://rubyassociation.doorkeeper.jp/events/190436

Slide 35

Slide 35 text

Copyright © BizteX Inc All Rights Reserved. 35 Ruby Release 30th Anniversary Party h tt ps://rubyassociation.doorkeeper.jp/events/190436

Slide 36

Slide 36 text

Copyright © BizteX Inc All Rights Reserved. 36 If C extension of date library were rewri tt en in pure Ruby, we would it be maintainable?

Slide 37

Slide 37 text

Copyright © BizteX Inc All Rights Reserved. 37 If C extension of date library were rewri tt en in pure Ruby, we would it be maintainable? If so, it seems possible.

Slide 38

Slide 38 text

Copyright © BizteX Inc All Rights Reserved. 38 Jinroq’s idea • The date library SHOULD NOT be deprecated. • I would like to ensure compatibility with date library.

Slide 39

Slide 39 text

Copyright © BizteX Inc All Rights Reserved. 39 RubyDate h tt ps://github.com/jinroq/ruby_date

Slide 40

Slide 40 text

Copyright © BizteX Inc All Rights Reserved. 40 What is RubyDate? • A project to rewrite the C extension of the date library in pure Ruby. • Only Date class will be rewri tt en.

Slide 41

Slide 41 text

Copyright © BizteX Inc All Rights Reserved. 41 2026-01-10 (JST)

Slide 42

Slide 42 text

Copyright © BizteX Inc All Rights Reserved. 42 fi rst commit

Slide 43

Slide 43 text

Copyright © BizteX Inc All Rights Reserved. 43 The day before the closing of the RubyKaigi 2026 CFP

Slide 44

Slide 44 text

Copyright © BizteX Inc All Rights Reserved. 44 The day before the closing of the RubyKaigi 2026 CFP

Slide 45

Slide 45 text

Copyright © BizteX Inc All Rights Reserved. 45 The day before the closing of the RubyKaigi 2026 CFP • Development of RubyDate is complete. • Until the end of March 2026 • Date rewriting complete. • Until the end of March 2027

Slide 46

Slide 46 text

Copyright © BizteX Inc All Rights Reserved. 46 RubyDate development plan • Used an AI agent • Started by porting ruby/date/ext/date/date_core.c. • Implemented it by referring to the behavior described in the usage comments. • Ported some of the tests from ruby/date/test/date/test_date.rb, and then had an AI agent write the rest of the tests. • Development environment • 4.1-dev • Ubuntu 24.04 LTS

Slide 47

Slide 47 text

Copyright © BizteX Inc All Rights Reserved. 47 First commit • Class Methods • jd • gregorian_leap? • julian_leap? • ordinal • Instance Methods • initialize • year • month/mon • day/mday • jd • start • <=> • == • eql? • hash? • +(n) • in fi nite?

Slide 48

Slide 48 text

Copyright © BizteX Inc All Rights Reserved. 48 Development of RubyDate • Together with an AI agent, I diligently implemented the Date methods into RubyDate.

Slide 49

Slide 49 text

Copyright © BizteX Inc All Rights Reserved. 49 2026-01-30 (JST)

Slide 50

Slide 50 text

Copyright © BizteX Inc All Rights Reserved. 50 The porting of date_core.c is complete!

Slide 51

Slide 51 text

Copyright © BizteX Inc All Rights Reserved. 51 Ported test_date.rb from the date library to ruby_date.

Slide 52

Slide 52 text

Copyright © BizteX Inc All Rights Reserved. 52 Ported test_date.rb from the date library to ruby_date. All RED😱

Slide 53

Slide 53 text

Copyright © BizteX Inc All Rights Reserved. 53 Investigation of causes • Tests that had been partially ported from test_date.rb were somehow deleted by the AI agent. • The AI ​​ agent was only adding tests that passed the logic it had implemented.

Slide 54

Slide 54 text

Copyright © BizteX Inc All Rights Reserved. 54 Investigation of causes • Tests that had been partially ported from test_date.rb were somehow deleted by the AI agent. • The AI ​​ agent was only adding tests that passed the logic it had implemented. • All test code under ruby/date/test/date has been moved to ruby_date. • Only the tests in test_date.rb have been fi xed to pass.

Slide 55

Slide 55 text

Copyright © BizteX Inc All Rights Reserved. 55 2026-02-11 (JST)

Slide 56

Slide 56 text

Copyright © BizteX Inc All Rights Reserved. 56 The ruby_date gem was complete!

Slide 57

Slide 57 text

Copyright © BizteX Inc All Rights Reserved. 57 The ruby_date gem was complete! • Development of RubyDate is complete. • Until the end of March 2026 • Date rewriting complete. • Until the end of March 2027

Slide 58

Slide 58 text

Copyright © BizteX Inc All Rights Reserved. 58 Shouldn't I rewrite the C extension of Date in pure Ruby?

Slide 59

Slide 59 text

Copyright © BizteX Inc All Rights Reserved. 59 Shouldn't I rewrite the C extension of Date in pure Ruby? I see no reason not to move forward.

Slide 60

Slide 60 text

Copyright © BizteX Inc All Rights Reserved. 60 RubyDate vs Date • Supported Ruby version • RubyDate: 3.0 or later • Date: 2.6 or later • Presence or absence of DateTime • RubyDate: absence • Date: presence

Slide 61

Slide 61 text

Copyright © BizteX Inc All Rights Reserved. 61 Pitfall #1 DateTime

Slide 62

Slide 62 text

Copyright © BizteX Inc All Rights Reserved. 62 h tt ps://docs.ruby-lang.org/en/4.0/DateTime.html

Slide 63

Slide 63 text

Copyright © BizteX Inc All Rights Reserved. 63 Pitfall #1 ruby/date/ext/date_core.c

Slide 64

Slide 64 text

Copyright © BizteX Inc All Rights Reserved. 64 Pitfall #1 ruby/date/ext/date_core.c

Slide 65

Slide 65 text

Copyright © BizteX Inc All Rights Reserved. 65 Pitfall #1 ruby/date/ext/date_core.c Tests don’t pass😇

Slide 66

Slide 66 text

Copyright © BizteX Inc All Rights Reserved. 66 Pitfall #1 • Cause • Date refers to the pure Ruby implementation. • DateTime's instance variables access the C extension implementation.

Slide 67

Slide 67 text

Copyright © BizteX Inc All Rights Reserved. 67 Pitfall #1 • Solution • date_core.c: Incorporate pure Ruby Date implementation into DateTime. • DateTime: Move toward a full pure Ruby implementation.

Slide 68

Slide 68 text

Copyright © BizteX Inc All Rights Reserved. 68 Pitfall #1 • Solution • date_core.c: Incorporate pure Ruby Date implementation into DateTime. • DateTime: Move toward a full pure Ruby implementation.

Slide 69

Slide 69 text

Copyright © BizteX Inc All Rights Reserved. 69 Pitfall #2 Regexp

Slide 70

Slide 70 text

Copyright © BizteX Inc All Rights Reserved. 70 Pitfall #2 ruby/date/test/date/test_date_parse.rb

Slide 71

Slide 71 text

Copyright © BizteX Inc All Rights Reserved. 71 Pitfall #2 ruby/date/test/date/test_date_parse.rb

Slide 72

Slide 72 text

Copyright © BizteX Inc All Rights Reserved. 72 Pitfall #2 ruby/date/test/date/test_date_parse.rb Failed tests on Ruby ≤ 3.2😇

Slide 73

Slide 73 text

Copyright © BizteX Inc All Rights Reserved. 73 Pitfall #2 • Cause • Historically, Ruby's Regexp processing has been relatively slow. • Ruby 3.3 introduced dramatic performance improvements for Regexp.

Slide 74

Slide 74 text

Copyright © BizteX Inc All Rights Reserved. 74 Pitfall #2 • Solution • Ruby 3.3+ → Use pure Ruby Date • Ruby 3.2 & below → Use C extension Date

Slide 75

Slide 75 text

Copyright © BizteX Inc All Rights Reserved. 75 2026-02-15 (JST)

Slide 76

Slide 76 text

Copyright © BizteX Inc All Rights Reserved. 76 h tt ps://github.com/ruby/date/pull/155

Slide 77

Slide 77 text

Copyright © BizteX Inc All Rights Reserved. 77 2026-02-17 (JST)

Slide 78

Slide 78 text

Copyright © BizteX Inc All Rights Reserved. 78

Slide 79

Slide 79 text

Copyright © BizteX Inc All Rights Reserved. 79 Seriously?😇

Slide 80

Slide 80 text

Copyright © BizteX Inc All Rights Reserved. 80 The game of chicken started: Will PR #155 be merged by my talk of RubyKaigi 2026?

Slide 81

Slide 81 text

Copyright © BizteX Inc All Rights Reserved. 81 First review comment

Slide 82

Slide 82 text

Copyright © BizteX Inc All Rights Reserved. 82 First review comment You need to provide comprehensive benchmarks showing that performance does not decrease signi fi cantly.

Slide 83

Slide 83 text

Copyright © BizteX Inc All Rights Reserved. 83 First review comment You need to provide comprehensive benchmarks showing that performance does not decrease signi fi cantly. I forget it…😇

Slide 84

Slide 84 text

Copyright © BizteX Inc All Rights Reserved. 84 Pure Ruby Date Benchmark .FUIPE $FYU JT 3VCZ JT 3VCZ$ %BUFKE . ,  %BUFPSEJOBM . ,  %BUFDPNNFSDJBM . , 

Slide 85

Slide 85 text

Copyright © BizteX Inc All Rights Reserved. 85 Pure Ruby Date Benchmark • Cause • Focused solely on rewriting the C implementation in pure Ruby.

Slide 86

Slide 86 text

Copyright © BizteX Inc All Rights Reserved. 86 Pure Ruby Date Benchmark • Solution

Slide 87

Slide 87 text

Copyright © BizteX Inc All Rights Reserved. 87 Pure Ruby Date Benchmark .FUIPE $FYU JT CFGPSF3VCZ JT BGUFS3VCZ JT BGUFS3VCZ$ %BUFUPEBZ ,  ,  %BUF@QBSTF JTP ,  ,  %BUFQBSTF JTP ,  ,  %BUFTUSQUJNF .  ,  %BUFTUSGUJNF .  .  %BUFDJWJM .  .  %BUFKE . , .  %BUFPSEJOBM . , ,  %BUFDPNNFSDJBM . , , 

Slide 88

Slide 88 text

Copyright © BizteX Inc All Rights Reserved. 88 Another review comment

Slide 89

Slide 89 text

Copyright © BizteX Inc All Rights Reserved. 89 Another review comment The current extension is line-by-line translation from Ruby to C and not optimized for C.

Slide 90

Slide 90 text

Copyright © BizteX Inc All Rights Reserved. 90 Another review comment The current extension is line-by-line translation from Ruby to C and not optimized for C. 💡

Slide 91

Slide 91 text

Copyright © BizteX Inc All Rights Reserved. 91 Another review comment The current extension is line-by-line translation from Ruby to C and not optimized for C. 💡 Burn it all down and build it again.

Slide 92

Slide 92 text

Copyright © BizteX Inc All Rights Reserved. 92 The Trigger for a Clean Slate • AI agents boosted development speed more than I ever imagined. • Working with AI agents gave me a much higher resolution of how date works.

Slide 93

Slide 93 text

Copyright © BizteX Inc All Rights Reserved. 93 Shift in Implementation Approach • The Rules for AI agent: • Zero changes to tests. (Maintain the ground truth) • Target: 85%+ performance of C extension. • The Process: • Identify bo tt lenecks method by method. • Apply micro-optimizations.

Slide 94

Slide 94 text

Copyright © BizteX Inc All Rights Reserved. 94 Shift in Implementation Approach • The Rules for AI agent: • Zero changes to tests. (Maintain the ground truth) • Target: 85%+ performance of C extension. • The Process: • Identify bo tt lenecks method by method. • Apply micro-optimizations. These optimizations didn't move the needle as much as I expected.

Slide 95

Slide 95 text

Copyright © BizteX Inc All Rights Reserved. 95 Shift in Implementation Approach • The Rules for AI agent: • Zero changes to tests. (Maintain the ground truth) • Target: 85%+ performance of C extension. • The Process: • Identify bo tt lenecks method by method. • Apply micro-optimizations. And then, I arrived at a single truth.

Slide 96

Slide 96 text

Copyright © BizteX Inc All Rights Reserved. 96 The truth is... YJIT was disabled the whole time.

Slide 97

Slide 97 text

Copyright © BizteX Inc All Rights Reserved. 97 Pure Ruby(+YJIT) Date Benchmark .FUIPE $FYU JT 3VCZ JT 3VCZ :+*5 JT 3VCZ :+*5$ %BUFUPEBZ , , ,  %BUF@QBSTF JTP , , .  %BUFQBSTF JTP , , .  %BUFTUSQUJNF . , .  %BUFTUSGUJNF . . .  %BUFDJWJM . . .  %BUFKE . . .  %BUFPSEJOBM . , .  %BUFDPNNFSDJBM . , . 

Slide 98

Slide 98 text

Copyright © BizteX Inc All Rights Reserved. 98 Pure Ruby(+YJIT) Date Benchmark .FUIPE $FYU JT 3VCZ JT 3VCZ :+*5 JT 3VCZ :+*5$ %BUFUPEBZ , , ,  %BUF@QBSTF JTP , , .  %BUFQBSTF JTP , , .  %BUFTUSQUJNF . , .  %BUFTUSGUJNF . . .  %BUFDJWJM . . .  %BUFKE . . .  %BUFPSEJOBM . , .  %BUFDPNNFSDJBM . , .  🙌

Slide 99

Slide 99 text

Copyright © BizteX Inc All Rights Reserved. 99

Slide 100

Slide 100 text

Copyright © BizteX Inc All Rights Reserved. 100 Is Jinroq prepared to maintain this source code for years to come?

Slide 101

Slide 101 text

Copyright © BizteX Inc All Rights Reserved. 101 Is Jinroq prepared to maintain this source code for years to come? 😇

Slide 102

Slide 102 text

Copyright © BizteX Inc All Rights Reserved. 102 Over-optimization • Abuse of `getbyte` • Excessive inlining

Slide 103

Slide 103 text

Copyright © BizteX Inc All Rights Reserved. 103 Restraining optimization • Improve readability and maintainability • Eliminated `getbyte` byte-level manipulation. • Switched to StringScanner and regex for clearer logic.

Slide 104

Slide 104 text

Copyright © BizteX Inc All Rights Reserved. 104 Pure Ruby(+YJIT) Date Benchmark .FUIPE $FYU :+*5 JT 3VCZ :+*5 JT 3VCZ$ %BUF@TUSQUJNF . .  %BUFTUSQUJNF . .  %BUFTUSQUJNF DPNQMFY . . 

Slide 105

Slide 105 text

Copyright © BizteX Inc All Rights Reserved. 105 2026-03-03 (JST)

Slide 106

Slide 106 text

Copyright © BizteX Inc All Rights Reserved. 106 Ruby O ff ice Hour

Slide 107

Slide 107 text

Copyright © BizteX Inc All Rights Reserved. 107

Slide 108

Slide 108 text

Copyright © BizteX Inc All Rights Reserved. 108 Approaches to refactor Date._strptime • `$~.get_int(1)`

Slide 109

Slide 109 text

Copyright © BizteX Inc All Rights Reserved. 109 h tt ps://bugs.ruby-lang.org/issues/21932

Slide 110

Slide 110 text

Copyright © BizteX Inc All Rights Reserved. 110 h tt ps://github.com/ruby/ruby/pull/16300 get_int -> integer_at

Slide 111

Slide 111 text

Copyright © BizteX Inc All Rights Reserved. 111 h tt ps://bugs.ruby-lang.org/issues/21943

Slide 112

Slide 112 text

Copyright © BizteX Inc All Rights Reserved. 112 h tt ps://github.com/ruby/strscan/pull/193

Slide 113

Slide 113 text

Copyright © BizteX Inc All Rights Reserved. 113 MatchData#integer_at VS StringScanner#integer_at .FUIPE 3VCZ :+*5 JT .BUDI%BUBJOUFHFS@BU 4USJOH4DBOOFSJOUFHF S@BU %BUF@TUSQUJNF    %BUFTUSQUJNF    %BUFTUSQUJNF DPNQMFY   

Slide 114

Slide 114 text

Copyright © BizteX Inc All Rights Reserved. 114 2026-04-21 (JST)

Slide 115

Slide 115 text

Copyright © BizteX Inc All Rights Reserved. 115 Latest review comment

Slide 116

Slide 116 text

Copyright © BizteX Inc All Rights Reserved. 116 To Be Continued…

Slide 117

Slide 117 text

Copyright © BizteX Inc All Rights Reserved. 117 Conclusion • Jinroq would like to avoid deprecating the date library. • However, it's easier said than done. • AI agents enable us to build products with incredible speed. • Therefore, there is no compelling reason to wait. • AI agents are powerful partners, but NEVER our masters. • We MUST remain accountable for what we build.

Slide 118

Slide 118 text

Copyright © BizteX Inc All Rights Reserved. 118 Special Thanks • narse, znz • nobu, jeremyevans • tompng • and more…

Slide 119

Slide 119 text

Have a nice RubyKaigi💎