DEV Community

Sylwia Vargas
Sylwia Vargas

Posted on

Talk Notes: "Implicit to Explicit: Decoding Ruby's Magical Syntax" (RailsConf 2021)

What is this post about: As a part of my professional growth, I make time to watch conference talks on Ruby, Rails, JS, React, tech writing, and tech trivia. Previously, I'd just watch them but now I will take and publish notes for future reference. This talk was a part of RailsConf 2021 that I'm participating in at the time of writing.

Talk: 'Implicit to Explicit: Decoding Ruby's Magical Syntax' by Justin Gordon

One-paragraph summary: Ruby's implicitness makes it great for readability and DSLs. But that also gives Ruby a "magical" syntax compared to JavaScript. In this talk, let's convert the implicit to explicit in some familiar Rails code. What was "magic" will become simple, understandable code.

Impression: I feel this talk was much more about pry and I am blown away by Justin's 🔥 ~/.pryrc 🔥 (see below ) and the ease it introduces into debugging 💕 I loved this talk, and Justin's way of calm and kind explaining complex concepts.


Table of contents:


Notes

  • DSL: Domain-Specific Language
  • Rails leverages Ruby's implicitness:
    • self
    • variable declarations
    • parentheses
    • much more
  • Can we learn to read Ruby code like the Ruby interpreter?
    • ideally, you should understand the code, not just copy-paste
  • 🔥 🔥 🔥 OMG Justin's pry demo is a must-watch! I need to re-watch it and code along 🔥 🔥 🔥

JS vs Ruby

  • JS is very explicit:
    • you need the parentheses for function invocations;
    • this is rarely implicit;
    • explicit return in standard functions;
  • Ruby is often implicit:
    • parentheses are optional and so zero arg method calls are the same as object values (user.first can be a method invocation or just a call for the attribute);
    • self can be implicit or explicit (it's explicit for writer methods because otherwise, Ruby's trying to declare a new local var)
    • implicit returns;

Read more

Top comments (1)

Collapse
 
yechielk profile image
Yechiel Kalmenson

I loved this one as well!

His pry game is next level!!