| ▲ | Lisp's Influence on Ruby(blog.tacoda.dev) |
| 177 points by tacoda 3 days ago | 26 comments |
| |
|
| ▲ | jksmith 2 hours ago | parent | next [-] |
| Now that I'm out of the corporate tyranny and have my own company, I use lisp for everything. There's certain satisfaction in writing config files and persisting data directly in s-expressions. Any json requirements are triggered by exports to foreign systems. |
| |
| ▲ | atcol 2 hours ago | parent | next [-] | | Which Lisp, out of interest? | |
| ▲ | Blikkentrekker an hour ago | parent | prev [-] | | That JSON prohibits trailing commata makes it an absolute pain to work with in practice. I also like how in Haskell: something =
{ element
, element1
, element2
, element3
}
Is an actually idiomatic way to deal with the lack of trailing commata. | | |
| ▲ | kazinator 17 minutes ago | parent [-] | | I did something like that in C++ circa 1998, before seeing it anywhere else: MyClass::MyClass(foo bar, int arg1, int arg2)
: Base(bar)
, member1(arg1)
, member2(arg2)
{
}
|
|
|
|
| ▲ | hyperrail 2 hours ago | parent | prev | next [-] |
| One way I find traditional Lisp style more painful for functional code than Ruby is that fully functional-style Lisp pushes me to read and write code the opposite way from how I think about it. In the author's example: orders
.select { |o| o.placed_at > 1.week.ago }
.group_by(&:customer_id)
.transform_values { |group| group.sum(&:total) }
the equivalent Lisp code would either be written in imperative style as multiple statements that each write to a temporary variable or (let) binding, or would look like this: (reduce #'+
(map (lambda (o) (getf o 'total))
; this group_by replacement function
; might be written as hash-table code
(my-group-by 'customer-id
(remove-if-not
(lambda (o)
(>
(getf o 'placed-at)
(- (my-now) (* 60 60 24 7))))
orders))))
where I now have to read from bottom to top to understand the order of operations on the `orders` record set, even though when I wrote the code earlier, I "logically" thought from first operation to last when deciding which high-level operations to use in which order.Other imperative languages that support functional code either make you do things imperatively to get the "logical" ordering of functional operations like I feel Lisp pushes you to do, or they do something like Ruby where things can be chained left to right in a "single" statement even for operations that were not thought of ahead of time by the creators of opaque data structures you later need to operate on. (Everything is a user-extensible object like Ruby, unified function call syntax in D, extension methods in C#, or pipelines of structured objects in PowerShell.) |
| |
|
| ▲ | evw 3 hours ago | parent | prev | next [-] |
| For folks that want all of this plus macros (and a lot of other great things), check out Elixir. |
| |
|
| ▲ | danlitt 4 hours ago | parent | prev | next [-] |
| > He’s described Ruby’s design as starting from a simple Lisp, stripping out macros and s-expressions Put the macros back! It would be so cool! |
| |
| ▲ | KerrAvon 3 hours ago | parent [-] | | You kind of don't need them in Ruby, because everything is a method or an object or a closure and you can dynamically create and alter those at runtime. That's why Ruby is really good for ad-hoc DSLs in ways that Rust and Swift really are not. |
|
|
| ▲ | dismalaf 4 hours ago | parent | prev | next [-] |
| I love Ruby, use it for most of my projects that don't require performance. Nothing I would love more than a Ruby with a Common-Lisp like compiler and runtime. Unboxed types, native compilation, partial compilation, live image (Ruby has this but "faster Rubies" like Crystal don't), etc... |
| |
| ▲ | Syzygies 40 minutes ago | parent | next [-] | | I came close to adopting Scala, many parallels to Ruby with vastly better performance. I'm Ruby or Lean 4. | |
| ▲ | rjsw 4 hours ago | parent | prev [-] | | ... or just use Common Lisp. | | |
| ▲ | dismalaf 3 hours ago | parent [-] | | Which is what I do. One can dream though right? Of a world where Ruby stayed just a tad more Lisp-y and less Perl/C/Smalltalk/Unix-y. Also I'm working on a DSL/Macros that give me more Ruby-esque quality of life things in Lisp. | | |
| ▲ | ralphc an hour ago | parent [-] | | Common Lisp, and even more so Racket, has reader macros. With a little help from LLMs you might be able to get a Ruby-like language that translates into Lisp. As a last resort look at Racket's "Rhombus" language, it's basically an infix, Python-like syntax on top of Racket. You can use that or see how they pull it off and add Ruby constructs to it. |
|
|
|
|
| ▲ | pjmlp 5 hours ago | parent | prev | next [-] |
| That is actually Lisp influence on Smalltalk, and Perl, that eventually influenced Ruby. |
| |
| ▲ | 0xpgm 4 hours ago | parent | next [-] | | From the article > Matz has said as much. He’s described Ruby’s design as starting from a simple Lisp, stripping out macros and s-expressions, then adding an object system, blocks, and Smalltalk-style methods. The features most Rubyists fall in love with aren’t the object-oriented ones. They’re the functional ones, dressed in friendlier clothes. | | |
| ▲ | wglb 4 hours ago | parent [-] | | But macros and s-expressions are two of my favorites parts of lisp! | | |
| ▲ | dismalaf 4 hours ago | parent [-] | | Funny enough Lisp was originally meant to be written in a higher level syntax (with infix operators and everything). But yeah, macros and S-expressions make it easier to write your own DSLs. | | |
| ▲ | pjmlp 3 hours ago | parent [-] | | With decades later, Dylan and Julia becoming the only ones that kind of managed to get some adoption doing it. For better or worse, parenthesis aren't that bad with the proper IDE tooling. |
|
|
| |
| ▲ | Smalltalker-80 4 hours ago | parent | prev | next [-] | | Totalle agree, I just googled it:
"Yukihiro 'Matz' Matsumoto heavily credits Smalltalk as the deepest structural inspiration behind Ruby’s object model. He combined Smalltalk’s beautiful object-oriented architecture and message-passing system with features from other languages to create a tool designed primarily for developer happiness."
Including the closures and collection operations. | | |
| ▲ | riffraff 4 hours ago | parent [-] | | "Some may say Ruby is a bad rip-off of Lisp or Smalltalk, and I admit that. But it is nicer to ordinary people." (Matz speaking at the LL2 conference some 20+ years ago) |
| |
| ▲ | dragonwriter 4 hours ago | parent | prev [-] | | No, its actual influence from Lisp-family languages (including Scheme). Yes, Lisp also influenced Perl and Smalltalk, but Matz was not ignorant of Lisp with the only influence om Ruby from Lisp being indirect through those other languages. |
|
|
| ▲ | DonHopkins 4 hours ago | parent | prev [-] |
| What have the Lisps ever done for us? https://www.youtube.com/watch?v=Qc7HmhrgTuQ |
| |