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

From Curiosity To Confusion

Keshav Biswa
November 29, 2024
1

From Curiosity To Confusion

This talk will take you on a journey through the creation of a simple programming language using Ruby. We’ll explore:

The motivation behind Confuscript: Why create a language that intentionally confuses programmers?
Key features of Confuscript: From reversed operators to counter-intuitive keyword behaviors
The technical process of building a language in Ruby: Leveraging libraries like Treetop for grammar construction
Lessons learned from creating a language: Language design, Parser implementation, traversing ASTs and the nature of programming itself.
The unexpected benefits of working with an intentionally confusing language: Enhancing problem-solving skills and deepening understanding of conventional languages
Whether you’re an expert programmer or just starting to code, this talk will offer a fresh perspective on language design, Ruby’s ecosystem and how easy it is to build anything and the fun side of coding. Join me in embracing the confusion and discovering new ways to think about programming!

Keshav Biswa

November 29, 2024
Tweet

Transcript

  1. From Curiosity to Confusion Turning Programming Rules Upside Down for

    Fun and... Mostly Fun Keshav Biswa Senior Software Engineer Saeloun
  2. ▣ Journey of Confuscript ▣ Mind bending features ▣ Building

    a language in Ruby ▣ My experience with Ruby and Confuscript Why This Talk? 2
  3. Senior Software Engineer at Saeloun Ruby Enthusiast and creator of

    multiple gems I’m from Guwahati, Assam Hello! I am Keshav Biswa
  4. 8 ▣ Fascinated by Esoteric languages ▣ Experiment with Ruby

    ▣ Making a programming language is challenging! ▣ Confu-conf 2025?? Why Confuscript?
  5. ▣ Confuscript = Confusing JavaScript ▣ Built on Ruby ▣

    Parsing Expression Grammar 9 What is Confuscript?
  6. 01 02 03 04 Technical Parts Anatomy of a programming

    language A look at the code Some more Examples Building in Ruby
  7. ▣ Lexer (Tokenizer) ▣ Parser ▣ Semantic Analyzer ▣ Intermediate

    Representation (IR) ▣ Optimizer ▣ Code Generator ▣ Runtime System ▣ Standard Library Parts of a Programming Language 20
  8. Journey of a program 21 Compiled Code OCT SEP Machine

    Dependent Code Optimizer Code Optimizer MAY Intermediate Code Generator Semantic Analyzer Syntax Analyzer Lexical Analyzer Character Stream Syntax Tree Intermediate Representation Target Machine Code Token Stream Intermediate Representation Target Machine Code
  9. Treetop to the Rescue! 24 ▣ Define syntax with PEG

    ▣ Generate Ruby Parsers to create ASTs ▣ Implement semantics by adding methods to SyntaxTrees
  10. PEGs and ASTs?? 25 ▣ Additive Rule □ Combines multitive

    terms with `+` (e.g., 1 + 2). ▣ Multitive Rule □ Combines primary terms with `*`,` /`, or `%` (e.g., 2 * 3) ▣ Primary Rule □ Matches primary followed by zero or more *, /, or % primary □ Example: 1, (1 + 2)). ▣ Number Rule □ Matches integers, optionally negative (e.g., 1, -5).
  11. 26

  12. 27

  13. 28

  14. Grammar for Confuscript 31 ▣ Program is on top ▣

    action defines all actions ▣ Assignment details all assignments ▣ Conditional Logics ▣ Loops ▣ Operators ▣ Initializations ▣ I/O ▣ Functions
  15. 33