Live data from Hacker News

RubyLLM: A delightful Ruby way to work with AI

github.com

131–140 of 182 posts

Re: RubyLLM: A delightful Ruby way to work with AI

#131

Earlier quoted context omitted.

What do you mean by 'assignment or creating a new object'? It assigns chat to ... whatever RubyLLM.chat returns. Do you mean the function could have a clearer name?

It's unclear whether `chat` is a field/property/member of `RubyLLM` or a method being called.

Ruby only has methods and everything is an object. So… that solves that.

Re: RubyLLM: A delightful Ruby way to work with AI

#133
post #13
post #4

Wow. So thoughtful. Ruby: late to the party, brought a keg.

been using https://github.com/alexrudall/ruby-openai for years with no issues which is a fine gem and works great.

aw thanks, glad you like it! more good Ruby AI libraries is a good thing IMO

Re: RubyLLM: A delightful Ruby way to work with AI

#134

Saw this gem of a gem on reddit earlier today and there were some trollish comments about no one using ruby anymore blah blah blah which quietly bummed me out. Surprised and Delighted to see it as #1 here on HN tonight!

> some trollish comments about no one using ruby anymore It is somewhat objectively true: https://octoverse.github.com/2022/top-programming-languages https://github.blog/wp-content/uploads/2024/10/GitHub-Octove... It doesn't mean much, and this library can be reproduced in any of those top 10 languages from what I can tell.

Over the last 10 years the number of programmers has grown enormously. So ruby dropping in position does not necessarily imply the absolute number of ruby programmers went down.

Re: RubyLLM: A delightful Ruby way to work with AI

#135
post #37

Earlier quoted context omitted.

Go ecosystem is generally good. However, given that Go as a language doesn't have any "fancy" (for the lack of a better word) syntactical features you can't create DSL's like this though Ruby's expressiveness comes at a cost and I'd personally stick with Go in a team but use something like RubyLLM for personal projects

I'm wary of equating "ability to create dsls like this" with "prioritizing developer experience". Ruby and go each prioritize different parts of the developer experience. Ruby prioritizes the experience of the author of the initial code at the expense of the experience of the maintainer who comes later. Go prioritizes the experience of a maintainer over the experience of the initial author. Both prioritize a develope…

I disagree with the idea that Go prioritizes the maintainer. More lines of code typically makes maintenance more difficult. Go is easy to read line by line, but the verbosity makes it more challenging to understand the bigger picture.

I find changes in existing Go software often end up spreading far deeper into the app than you'd expect.

The runtime is fantastic, though, so I don't see it losing it's popularity anytime soon.

Re: RubyLLM: A delightful Ruby way to work with AI

#136

Earlier quoted context omitted.

It's the extra parens, semi-colons, keywords and type annotations. Ruby makes the tradeoff for legibility above all else. Yes, you can obviously read the TypeScript, but there's an argument to be made that it takes more effort to scan the syntax as well as to write the code. Also: const chat: Chat = LLM.chat; ...is not instantiating a class, where Ruby is doing so behind the scenes. You'd need yet another pair of par…

chat = RubyLLM.chat Is ambiguous, though. You can't know if it's an assignment or creating a new object. I don't think that's more readable.

Rubyists understand it perfectly. It's common practice for us.

Re: RubyLLM: A delightful Ruby way to work with AI

#138
I am really impressed and delighted how simple this library is.

I agree that waiting for response can be an issue. I don't think this is meant to be for such purposes, but for tools that would process and create artifacts based on inputs.

I love Mistral and local LLMs, so this would probably the thing I would like to add.

Re: RubyLLM: A delightful Ruby way to work with AI

#139
post #135

Earlier quoted context omitted.

I'm wary of equating "ability to create dsls like this" with "prioritizing developer experience". Ruby and go each prioritize different parts of the developer experience. Ruby prioritizes the experience of the author of the initial code at the expense of the experience of the maintainer who comes later. Go prioritizes the experience of a maintainer over the experience of the initial author. Both prioritize a develope…

I disagree with the idea that Go prioritizes the maintainer. More lines of code typically makes maintenance more difficult. Go is easy to read line by line, but the verbosity makes it more challenging to understand the bigger picture. I find changes in existing Go software often end up spreading far deeper into the app than you'd expect. The runtime is fantastic, though, so I don't see it losing it's popularity anyti…

> More lines of code typically makes maintenance more difficult.

That’s kind of just the surface level of maintenance though. Go is not so much focused on making it easy to read a single file, but on minimizing the chains of abstraction and indirection you need to follow to understand exactly how things work.

It’s much more likely that all the logic and config to do something is right there in that file, or else just one or two “Go to definition” clicks away. You end up with way more boilerplate and repetition, but also looser coupling between files, functions, and components.

Contrast that to a beautiful DSL in Ruby. It’s lovely until it breaks or you need to extend it, and you realize that a small change will require refactoring call sites across a dozen different files. Oh and now this other thing that reused that logic is broken, and we’ve got to update most of the test suite, and so on.

Re: RubyLLM: A delightful Ruby way to work with AI

#140
post #2

Such a breath of fresh air compared to poor DX libraries like langchain

I’ve found the Ruby community really cares about DUX. Not sure why it’s not in other language communities

Every language prioritizes something (or somethings) because every language was made by a person (or people) with a reason; python and correctness; Java and splitting up work; Go and something like "simplicity" (not that these are the only priorities for each language). As another comment points out, Matz prioritized developer happiness.

My favorite example of this is the amazing useful and amazing whack Ruby array arithmetic; subtraction (`arr1 - arr2`) is element-wise removal, but addition (`arr1 + arr2`) is a simple append. These are almost always exactly what you want to do when you reach for them, but they're completely "incorrect" mathematically.

Post reply on HN