3 ms·
Side-note: I do not understand the inclusion of "N lines of X". You import a library, which presumably consists of many lines. I do not see the point. It would
by johnisgood 1y ago
Side-note: I do not understand the inclusion of "N lines of X". You import a library, which presumably consists of many lines. I do not see the point. It would be true that this is only 94 lines of Ruby if and only if there was no "require "ruby_llm/tool"" at the top.
- monooso 1y agoGiven that this post is a response to an article about achieving the same in "N lines of Go" (also using a library), it seems like an appropriate title.
- johnisgood 1y agoThe original post uses "github.com/anthropics/anthropic-sdk-go", the Ruby uses a different library, does it not? If they are two different libraries, then the comparison does not make too much sense.
- radanskoric 1y agoI didn't put the number into the title to make it a competition. LoC is a poor metric. I put it to communicate to the reader that they won't have to spend a lot of time reading the article to get a full understanding. I always put extra effort into trying to make my blog posts shorter without sacrificing the quality. I think good technical writing should transfer the knowledge while requesting the least amount of time possible from the reader.
- johnisgood 1y agoI know, I was only responding to the comment, I was not trying to claim that you are attempting to make it a competition, my bad if it came across as such.
- radanskoric 1y agoIt's good that you commented. I see more than a few people are getting caught up on the number of lines so it's good that I clarify.
- monooso 1y agoI simply meant that I don't consider the title misleading; it's in keeping with the format of the original title and both solutions use third-party libraries to communicate with the external service.
- johnisgood 1y agoFair enough. :)
- zoky 1y agoThat actually is exactly the point. It has to do with the expressiveness of the language as well as how much you can do with the available toolset. If I showed you a 200-line program to play hangman written in C and a 2000-line equivalent program written in assembly, it wouldn’t really be useful to take into account the 15 million lines of code in the C compiler when trying to compare the two languages.
- johnisgood 1y agoI do not think it is any meaningful. If you have such a library in C, or Common Lisp, or Forth, then using that library is probably always going to be just a few lines of code. The library just has to have a good enough API.
- radanskoric 1y agoIt depends on the flexibility of the API. If you're making an API for just one specific use case, you can make it a one liner in any language, even assembler: just push the exact specific functionality into the one function. Language expressiveness is more about making the interface support more use case while still being as concise. And Ruby is really good at this, better than most languages.
- johnisgood 1y agoI don't disagree, I do find Ruby readable, and it was the first language that caught my eye back when I was a kid, precisely because of its readability and expressiveness. I suppose we have to define expressiveness (conciseness, abstraction power, readability, flexibility?), because Ruby, for example, has human-readable expressiveness, Common Lisp has programmable expressiveness, and Forth has low-level expressiveness, so they all have some form of expressiveness. I think Ruby, Crystal, Rebol 3, and even Nim and Lua have a similar form or type of expressiveness.
- radanskoric 1y agoYes, exactly, Ruby has the human readability expressiveness. If you say that expressivity is the ability to implement a program in less lines of code then Ruby is more expressive than most but less than for example Clojure. Well written Clojure can be incredibly expressive. However, you can argue that for most people it's going to be less readable than a comparable Ruby program. It's hard to talk about these qualities as there's a fair amount of subjectivity involved.
- radanskoric 1y agoI put the lines of code into the title to communicate to the reader that they can get a good understanding just by reading this article. Basically, what I wanted to say was: "Here is an article on building a prototype coding agent in Ruby that explains how it works and the code is just 94 lines so you'll really be able to get a good understanding just by reading this article." But that's a bit too long for a title. :) When understanding a certain concept, it's very useful to be able to see just the code that's relevant to the concept. Ruby language design enables that really well. Also, Ruby community in general puts a lot of value on readability. Which is why with Ruby it's often possible to eliminate almost all of the boilerplate while still keeping the code relatively flexible.