Ruby Icon

Ruby

Ruby is a scripting language designed for simplified object-oriented programming.
329 Stories
All Topics

Ruby rubyonjets.com

Ruby and Lambda had a baby and that child's name is Jets

Ruby on Jets allows you to create and deploy serverless services with ease, and to seamlessly glue AWS services together with the most beautiful dynamic language: Ruby. It includes everything you need to build an API and deploy it to AWS Lambda. Jets leverages the power of Ruby to make serverless joyful for everyone.

I’m not (yet) big on serverless things, but if I were, I’d love to run some Ruby code there.

Ruby phlex.fun

A framework for building fast, reusable, testable views in pure Ruby

Phlex views are “plain old Ruby objects” — templates are methods and HTML tags are method calls. If you know how to define a class with a method that calls another method, you know how to use Phlex.

When it comes to API usability, Ruby is so tough to beat. This looks actually fun to use!

class Nav < Phlex::HTML
  def template
    nav(class: "main-nav") {
      ul {
        li { a(href: "/") { "Home" } }
        li { a(href: "/about") { "About" } }
        li { a(href: "/contact") { "Contact" } }
      }
    }
  end
end

Ruby blog.saeloun.com

Ruby adds a new core Data class to represent immutable value objects

Ruby 3.1 adds a new core class called Data to represent simple immutable value objects. The Data class helps define simple classes for value-alike objects that can be extended with custom methods.

While the Data class is not meant to be used directly, it can be used as a base class for creating custom value objects. The Data class is similar to Struct, but the key difference being that it is immutable.

In its heyday, most Rubyists wouldn’t touch immutability with a ten-foot pole. Times, they are a changin’…

Bill Prin billprin.com

Why I ditched Django for NextJS

If you’re feeling the FOMO of JavaScript or you’re writing “spaghetti code” just to do something a NextJS component would do out of the box, then read this post from Bill Prin on why he moved from Django to NextJS.

The summary is that using a language like Python or Ruby for a significant web project has increasingly gotten less reasonable over time to the point where now, in 2022, it’s getting hard to justify. By not keeping your web stack in pure Javascript, you are making your life unnecessarily difficult (as usual, we’ll include languages like TypeScript as part of the JavaScript ecosystem). You will almost certainly invest a bunch of time-solving problems that would be automatically solved for you if you just stuck with JavaScript.

I will provide specific examples of solving problems using Django that would have been trivially solved in NextJS.

He goes on to share two reasons why you should use Python or Ruby for web projects in 2022.

You’re working on an existing project that hasn’t been migrated yet or is not worth migrating.
You are already a master of a Python or Ruby web stack, and you need to implement a new project as soon as possible, and you don’t have time to learn a better stack.

Culture whytheluckystiff.net

_why's Estate

whytheluckystiff.net is back online and now hosts links and mirrors to everything the man published on the internet during his illustrious career.

It works sort of like a museum that sells maps.

If you’ve never heard of why the lucky stiff, click through to get acquainted. If you were fortunate enough (like myself) to be around when he was actively creating things, click through for some top notch nostalgia.

JSON github.com

An interactive wrapper around `jq`

Nick Nisi shared this with me recently and it’s cool, so I thought I’d pass it along. Here’s Nick describing it:

And it is a visual wrapper around jq, that kind of does the fzf type thing where as you’re writing out your query, it’s live showing you a preview in virtual text of exactly what would get returned by what you’re querying as you go. So you can use that as a nice tool to build out your jq syntax, or your jq query, and in real time get that feedback.

The only bummer is that it’s written in Ruby. Don’t get me wrong, I love Ruby. But it requires you to have Ruby tooling on your machine to use jqq, which many people don’t have or want. BUT it’s a mere 241 lines of code, so porting it to something a little more portable shouldn’t be too much work…

Gui Heurich code-anth.xyz

Chunky Bacon

Gui Heurich on one of the legends of the Ruby community, _why the lucky stiff.

Through the things that he built, the way he performed, and the books that he wrote, _why makes us think about code and also about ourselves. It makes us think about ourselves as programmers. In a sense, _why was the meta-programmer, the one that generates other programmers by promoting reflexivity.

Ruby dmitrytsepelev.dev

Why Ruby has symbols

Most Ruby engineers know the difference between symbols and strings from a usage perspective. So, in this article I look at them from a different angle.

You’ll learn about a cool compiler optimization called “string interning”, which is used in many languages. Also, you will understand what happens when (almost any) interpreter runs your code, take a look at the AST and take a peak at the symbols interpretation at the low level.

David Heinemeier Hansson rubyonrails.org

Rails 7.0: fulfilling a vision

DHH announcing the 7th major release of Ruby on Rails:

This version of Rails has been years in the conceptual making. It’s the fulfillment of a vision to present a truly full-stack approach to web development that tackles both the front- and back-end challenges with equal vigor. An omakase menu that includes everything from the aperitif to the dessert.

There’s a lot to like about the new Node-free approach to the frontend, at-work encryption added to Active Record, a new auto-loading strategy, and more. Congrats to the hundreds of contributors who worked on this major milestone!

Ruby softwaredoug.com

Ruby vs Python comes down to the for loop

Doug Turnbull breaks down a major difference between two beloved programming languages in how they handle iteration.

Python embraces for. Objects tell for how to work with them, and the for loop’s body processes what’s given back by the object. Ruby does the opposite. In Ruby, for itself (via each) is a method of the Object. The caller passes the body of the for loop to this method.

He goes on to give examples and explain why each approach might map to different developers’ brains… differently. Here’s a succinct summary, if you don’t have time for the deeper discussion:

In Ruby, the objects control the affordances. In Python, the language does.

Evil Martians Icon Evil Martians

A no-go fantasy: writing Go in Ruby with Ruby Next

Svyatoslav Kryukov on the Evil Martian blog:

Ruby is awesome. We love its readability, flexibility, and developer-centric nature. Still, here at Mars, we also love Go because it has its own sense of simplicity and magic, too. Simply put, Go holds advantages over Ruby in some aspects: it’s faster, statically typed, and comes with cool concurrency primitives out of the box. This being said, some intrepid readers might find themselves grappling with a seemingly reasonable question: if Go is so darn good, why don’t we just write everything with it?

Read this tale and learn to write Go in Ruby, gaining the ability to modify Ruby exactly as you desire.

Emma Hyde Medium (via Scribe)

Ruby is still a diamond

Emma Hyde:

I have seen a staggering amount of Ruby is Dead missives in the last few years, and a decline, or at least, an often discussed decline, of the language’s popularity and ranking. But what makes Ruby so much worse than other languages?

She goes on to discuss how Ruby 3.0 addresses two of the most criticized elements of Ruby: its ability to handle processes simultaneously and and its overall performance.

RSS github.com

A GitHub Action to create single-show feeds from your Changelog++ feed

One of our awesome Changelog++ members scratched their own itch:

When you upgrade to Changelog++ you’re given access to ad-free versions of episodes however they’re only available in one giant bucket feed instead of through individual show feeds. Though only around 5 new podcast episodes are published weekly, if you’re coming in as a new listener you’ll have a long backlog list with over one thousand shows. It’s easier to sift through older episodes when they’re organized by show, so that’s what this project provides: individual show feeds.

I love grassroots initiatives like this, but it’s motivating me to bring Changelog++ onsite so we can bake the functionality right in to our platform…

Ruby github.com

A pure-Ruby JIT compiler for Ruby (read it, don't use it!)

This project is no longer actively developed, but it looks like an excellent resource for anyone who is interested in compilers. Ruby is an easy language to grok, so it should make for (relatively) easy reading!

Rhizome is a paedagogical just-in-time compiler (JIT) for Ruby, implemented in pure Ruby. It’s not really designed to be used. It’s designed to show you how JITs work and why perhaps a JIT for Ruby should be written in Ruby. It’s also designed to try to go beyond the trivial aspects of a simple template compiler that introductions to JITs often show - instead it has a proper intermediate representation (IR) and shows how more advanced parts of compilers such as lowering and schedulers work, that people don’t usually cover.

Ruby fastruby.io

Why wasn't Ruby 3 faster?

Noah Gibbs tries to reason through why some folks are disappointed in Ruby 3’s lack of speed improvements:

I think some of the problem was misplaced expectations. People didn’t understand what “three times faster” was supposed to mean. I don’t think people thought it through, but I also don’t think it was communicated very clearly.

So: some people understood what was promised, and some people didn’t.

What was promised?

I think Noah hits on a lot of solid points here.

Ruby github.com

Higher-level Ruby data structures built on Redis

Kredis (Keyed Redis) comes from the Rails team and lets you interact with Redis-backed keys as coherent Ruby objects rather than isolated procedural commands. Here’s what that might look like when dealing with strings, integers, and JSON:

string = Kredis.string "mystring"
string.value = "hello world!"  # => SET mystring "hello world"
"hello world!" == string.value # => GET mystring

integer = Kredis.integer "myinteger"
integer.value = 5  # => SET myinteger "5"
5 == integer.value # => GET myinteger

json = Kredis.json "myjson"
json.value = { "one" => 1, "two" => "2" }  # => SET myjson "{\"one\":1,\"two\":\"2\"}"
{ "one" => 1, "two" => "2" } == json.value  # => GET myjson

(There are also Redis-backed data structures for counters, enums, flags, lists, unique lists, sets, and slots.)

I love the idea of being able to think at the layer of objects instead of database record manipulation. Dark is doing something similar with its persistence engine, which we discuss on an upcoming episode of The Changelog.

The GitHub Blog Icon The GitHub Blog

Bringing React's ideas to server-rendered Rails views

We didn’t do too much coverage of Rails 6.1 release last week, but here’s a great write-up on the GitHub blog about how they landed a couple small PRs into the framework that dramatically changed how the company is building views with ViewComponent.

This comment was particularly noteworthy, methinks:

Inspired by our experience building component-based UI with React, we set off to build a framework to bring these ideas to server-rendered Rails views.

Good ideas propagate. Regardless of what comes next in the web UI world (or React goes from here), this single idea is so profound for building frontends that it will be React’s lasting legacy.

Ruby learnbyexample.github.io

Ruby one-liners cookbook

Ruby is my favorite tool for slightly-longer-than-one-liners, but I don’t often reach for it directly from the command line. This little cookbook might change my mind on that:

A shell utility like bash provides built-in commands and scripting features to make it easier to solve and automate various tasks. External *nix commands like grep, sed, awk, sort, find, parallel etc can be combined to work with each other. Depending upon your familiarity with those tools, you can either use ruby as a single replacement or complement them for specific use cases.

Shopify Engineering Icon Shopify Engineering

Shopify rewrites away from their Rails monolith

Maxime Vaillancourt shared the background and details of how Shopify reduced their storefront response times with a rewrite.

The Rails monolith still handles checkout, admin, and API traffic, but storefront traffic is handled by the new implementation.

Designing the new storefront implementation from the ground up allowed us to think about the guarantees we could provide: we took the opportunity of this evergreen project to set us up on strong primitives that can be extended in the future, which would have been much more difficult to retrofit in the legacy implementation. An example of these foundations is the decision to design the new implementation on top of an active-active replication setup. As a result, the new implementation always reads from dedicated read replicas, improving performance and reducing load on the primary writers.

Similarly, by rebuilding and extracting the storefront-related code in a dedicated application, we took the opportunity to think about building the best developer experience possible: great debugging tools, simple onboarding setup, welcoming documentation, and so on.

Shopify rewrites away from their Rails monolith

David Heinemeier Hansson gist.github.com

A peek inside HEY's Gemfile 👀

DHH posted a gist sharing HEY’s Ruby dependencies for the curious. It’s a pretty stock Rails app with MySQL (?!) and Redis stores, Elasticsearch, and a few other niceties. One line that caught my eye was:

gem 'turbo', github: 'basecamp/turbo'

That points to a private repo, so there will probably be some new open source turbolinks stuff here real soon. Anything else in this Gemfile catch your interest?

  0:00 / 0:00