Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Philosophy of Static Typing -Ruby vs. TypeScript-

Avatar for Hayato Ishida Hayato Ishida
June 06, 2025
23

Philosophy of Static Typing -Ruby vs. TypeScript-

"Comparing objects is a mean to know what they are."
This is the saying I learned when I majored in English linguistics in university.
It applies to programming languages, too.
This time, I discuss the differences in histories, ecosystems and philosophy of static typing between Ruby and TypeScript.
"He who knows no foreign language knows nothing of his mother tongue." by Johann Wolfgang von Goethe, the greatest writer in the Germanic language.

Avatar for Hayato Ishida

Hayato Ishida

June 06, 2025
Tweet

More Decks by Hayato Ishida

Transcript

  1. Philosophy of Static Typing Composed By: Hayato Ishida Updated On:

    06 June 2025 For Japanese version, click here 1 -Ruby vs. TypeScript-
  2. About Me • Accounts • GitHub: @hayat01sh1da • X: @hayat01sh1da

    • Linkedin: @hayat01sh1da • Speaker Deck: @hayat01sh1da • Docswell: @hayat01sh1da • Occupation: Software Engineer • Things I Am Into • Linguistics • Singing at Karaoke • Listening to Music • Watching Movies • Cat Feeding 2
  3. Licences / Certifications • English • TOEIC® Listening & Reading

    915: Certified on December 2019 • Engineering • Information Security Management: Certified on November 2017 • Applied Information Technology Engineer: Certified on June 2017 • Fundamental Information Technology Engineer: Certified on November 2016 • IT Passport: Certified on April 2016 • Others • Abacus 2nd Class: Certified on June 2002 • Mental Arithmetic 3rd Class: Certified on February 2001 3
  4. Skills • Languages • Japanese: Native Proficiency • English: Full

    professional Proficiency • Development • Ruby: Upper-Intermediate(FW: Ruby on Rails) • Python: Intermediate • TypeScript: Intermediate(Library: React.js) • HTML: Intermediate(Library: Bootstrap) • CSS: Intermediate(Library: Bootstrap) • SQL: Intermediate • Others • Documentation: Advanced 4
  5. Work Experiences 1. System Engineer @System Engineering Service Firm •

    Maintenance of Legacy Windows Servers • Management of Corporate Employees’ Accounts • Promotion of Cooperate Security • English Translator for Video Conferences, Vendor Control and Host of International Staff Member 2. Software Engineer @System Development Firm on Contract Basis • Server-Side Development(Ruby on Rails, RSpec) • Front-End Development(HTML / CSS, JavaScript) • Quality Assurance(Native iOS / Android Apps) • Composer of In-House Technical Blog 3. Software Engineer @Chatbot Platform Development Firm • Development and Maintenance of Existing Chatbot Platform(Ruby on Rails, RSpec) • Inspection of an Alternative Chatbot Engine(Ruby, Ruby on Rails, RSpec, Python) 4. Software Engineer @Educational Service Development Division of a Mega Venture Firm • Server-Side Development for Academic Career Supporting Features(Ruby on Rails, RSpec, Minitest, TypeScript + React.js) • Annual Maintenance of Master School Data Migration(Ruby on Rails, RSpec) • Technical Debt Resolution Activities(Ruby, Python, GitHub Actions etc.) 5
  6. International-Exchange Activities • Activities in University • English Linguistics Seminar(Focusing

    on Mass Media English) • International-Exchange Clubs(The 2nd Year) • International-Exchange Programmes conducted by Japan Cabinet Office(2013 - 2016) • Japanese Linguistics Course(The Final Year) • Overseas Life Experience • Working Holiday in Australia(April 2014 - March 2015) • Language School for 1 month in Sydney • Work for 6 Months in Hamilton Island Resort • Volunteering for 1 Month as Assistant Teacher of Japanese Language at St Ives High School in NSW • Other Activities • Keep Everyday Journal in English (April 2014 - Present) • Sunrise Toastmasters Club(February 2017 - March 2018) • Vital Japan(January 2018 - July 2019, October 2022 - February 2023) • Self Learning and Training of English Language • Participation Ruby-Related Tech Conferences 6
  7. Prior to Lightening Talk… The chief organiser of RubyKaigi, Mr.

    Akira Matsuda, allows me to use the official logo of RubyKaigi 2025 as the background image. No offence to its copyright. Ref) https://x.com/a_matsuda/status/1918612709169672210 7
  8. Agenda 1. The Basics of Static Typing 2. The Typing

    Ecosystem 3. The Typing Philosophy 4. Summary 5. References 8
  9. 1. The Basics of Static Typing Trade-offs • Protects a

    system and/or program from ABEND(Abnormal End) and security holes caused by Undefined Behaviours • Detects TypeError prior to a code execution • Guards large-scale codebase more efficiently from such Nasal Demons as bugs, type inconsistency and unsafe refactoring • Worsens performance due to a huge overhead because it checks the type of a receiver every time in some processing system(e.g., JavaScript), such as `x.foo()` • Forces developers to maintain not just codes but type declarations • Brings developers another learning costs to master how to make it work 10
  10. 1. The Basics of Static Typing 11 Category Timing of

    Type Inspection Language Static Typing Prior to code execution • TypeScript • C • Rust • Java • Swift etc. Dynamic Typing During the code execution • Ruby • JaveScript • Java • Swift etc.
  11. Ruby 2. The Typing Ecosystem 13 System Gem Description RBS

    RBS(Ruby Signature) An official gem of which language to describe the structure of Ruby programs. Not DSL of Ruby but another language. Steep Checks types according to definitions on RBS TypeProf Infers definitions in RBS according to Ruby codes rbs-inline Generates RBS by inline comments on Ruby codes RBI RBI(Ruby Interface) Provides a Ruby API to compose Ruby I/F files for Sorbet Sorbet Provides existing Ruby codes with gradual typing and quick response with errors and suggestions Tapioca Compiles RBI files via not just Ruby source codes but Gems, Rails and other DSLs
  12. Ruby: RBS + Steep e.g. RBS + Steep 2. The

    Typing Ecosystem 14 person.rb sig/person.rbs $ steep check # Type checking files: ... No type error detected. $ rbs prototype rb person.rb
  13. Ruby: RBS + Steep e.g. rbs-inline + Steep 2. The

    Typing Ecosystem 15 person.rb sig/generated/person.rbs $ rbs-inline --output person.rb Generated 1 RBS files under sig/generated $ steep check # Type checking files: ... No type error detected.
  14. TypeScript On one hand, Ruby has not embraced another ecosystem

    than RBS yet in order to keep backward compatibility in terms of its syntax. On the other hand, TypeScript dynamically changed JavaScript's ecosystem by introducing Generics, Object Types and Interfaces. The drastic update broke an implicit assumption that we must introduce type check without making any differences in existing code, mentioned Mr. Sotaro Matsumoto(@sotaro), a Ruby Committer, in a blog article. He also referred to the fact that it was because JavaScript had already been well- organised in terms of its rich libraries and development environment with high functionality, which made it possible to change existing JavaScript codebase to that of TypeScript. 2. The Typing Ecosystem 16
  15. Ruby In a blog article posted by a Developer Advocate

    at Heroku Mr. Jonan Scheffler, the creator of Ruby Mr. Yukihiro Matsumoto, generally called Matz, mentioned the introduction of static typing to Ruby as follows. It proves his philosophy of Ruby which thinks highly of rich coding experience leading to developer's happiness and backward compatibilities. Jonan) So, along with the JIT, you've also talked about some type changes to coming to Ruby 3 and the optional static types. Can you tell us about that? Matz) Yeah, the third major goal of the Ruby 3 is adding some kind of static typing while keeping the duck typing, so some kind of structure for soft-typing or something like that. The main goal of the type system is to detect errors early. So adding this kind of static type check or type interfaces does not affect runtime. 3. The Typing Philosophy 18
  16. Ruby In fact, RBS is independent ecosystem of Ruby itself

    and the signature is a different language from it. `xxx.rbs` is separate from the corresponding `xxx.rb` and rbs-inline treats type definitions as comment so does not affect existing Ruby codes while it provides more meanings than semantic description. In my opinion, the concept of rbs-inline is very developer-friendly as follows. • Static typing plays a role in a document • The type of return value should be articulated especially on an app used as a web API • Inline comments of rbs-inline is literally "get two for the price of one" 3. The Typing Philosophy 19
  17. TypeScript On p.3 of his book型システムのしくみ - TypeScript で実装しながら学ぶ型とプ ログラミング言語,

    Mr. Yusuke Endo, a Ruby committer, mentions the philosophy that TypeScript focuses only on detection of undesirable behaviours as long as it is reasonable and does not drastically change the traditional JavaScript coding experiences. For example, Both of afterword variable definition below raise no error in type checking, but the latter raises ReferenceError in execution. 3. The Typing Philosophy 20 a.ts b.ts WSL
  18. TypeScript This phenomenon illustrates uninitialized variables can be referred to

    by already defined functions. Such a type unsafety should be detected in type-check system, but TypeScript is willing to ignore it. Why? According to the author, JavaScript has traditionally allowed this kind of implementation, so restriction on uninitialized variables in TypeScript can ruin of backward compatibilities with JavaScript. It proves TypeScript values traditional coding experiences as well as Ruby. 3. The Typing Philosophy 21
  19. 4. Summary • Both Ruby and TypeScript try hard to

    guarantee traditional coding experiences by keeping backward compatibilities • TypeScript succeeded in integration of static typing ecosystem by dynamic introduction of Generics, Object Types and Interfaces • Ruby has 2 big streams of static typing system, RBS(Ruby Signature) and RBI(Ruby Interface) ecosystems. No winner of Natural Selection and Survival of the Fittest yet • In any case, developers can enjoy a lot more benefits by static typing than they expect, so it is highly worth of installation 23
  20. 5. References • いかにして動的型付けの Ruby に静的な型検査を持ち込むか? Steep と RBS が目指すもの

    • Last Accessed On: 06 June 2025 • RubyKaigi 2025 初参加エンジニアのための Ruby 静的型付けガイド • Last Accessed On: 06 June 2025 • The State of Static Typing in Ruby in 2025 • Last Accessed On: 06 June 2025 • Why Static Typing is Essential for Efficient Ruby and Rails Development • Last Accessed On: 06 June 2025 • Static Typing in Ruby: It's Not a Cult, It's a Choice (You Should Probably Make) • Last Accessed On: 06 June 2025 25
  21. 5. References • Ruby 3×3: Matz, Koichi, and Tenderlove on

    the future of Ruby Performance • Last Accessed On: 06 June 2025 • RBS(Ruby Signature) • Last Accessed On: 06 June 2025 • Steep • Last Accessed On: 06 June 2025 • TypeProf • Last Accessed On: 06 June 2025 • rbs-inline • Last Accessed On: 06 June 2025 • RBI(Ruby Interface) • Last Accessed On: 06 June 2025 26
  22. 5. References • Sorbet • Last Accessed On: 06 June

    2025 • Tapioca • Last Accessed On: 06 June 2025 • TypeScript Official Documents • Last Accessed On: 06 June 2025 • 10 Must-Know TypeScript Features to Improve Your Coding Efficiency • Last Accessed On: 06 June 2025 • Yusuke Endo, 型システムのしくみ - TypeScript で実装しながら学ぶ型とプロ グラミング言語, Tokyo, Lambda Note Ltd., 2025 27