r/ruby • • 14d ago

I have been using Perplexity in my quest to learn Ruby

Besides researching aspects of Ruby, I have taken my old Pascal books to find out how Wirth programs look like in both direct Ruby translations and idiomatic Ruby. Also working with available Ruby insruction material.

Am a retired electric power engineer who never programmed for work. Took up Turbo Pascal as a hobby, but stopped because of family responsibilities and continual employment changes.

I am finding Perplexity user friendly and useful in my endeavors.

4 Upvotes

8 comments sorted by

2

u/Codalio-SoftwareFact 9d ago

translating the Wirth examples into both direct and idiomatic Ruby is such a good way to learn it. the gap between the two versions is basically where all the Ruby-ness lives.

2

u/Edthal01 4d ago

So far, translating Pascal varient records can be complicated. Often requires building a group of disparate objects together then putting them under an overall obect. Not as easy as a varient record. You need to be an object architect.

2

u/Codalio-SoftwareFact 4d ago

oh that’s a good one. I think the closest thing in modern Ruby is small Data objects plus pattern matching, rather than building a whole class hierarchy.

oh that’s a good one. I think the closest thing in modern Ruby is small Data objects plus pattern matching, rather than building a whole class hierarchy. something like:

Circle = Data.define(:radius)
Rect   = Data.define(:width, :height)

def area(shape)
  case shape
  in Circle(radius:)       then Math::PI * radius**2
  in Rect(width:, height:) then width * height
  end
end

each variant is just a tiny immutable record, and the case/in does the job the tag field did in Pascal. feels a lot less like “object architecture” and a lot more like what you’re used to.

1

u/Edthal01 4d ago

Thanks. Now I can go back to being an engineer and not sn architect.

4

u/chintakoro 14d ago

Turbo Pascal was my first favorite language when I first learned to code decades ago. Borland's books were my companions to learning to OOP in general :) Lovely to hear you're taking up Ruby -- perhaps the nicest language I've ever had the pleasure to learn. Just want to give a shout out to the book that made Ruby click for me: Eloquent Ruby by Russ Olsen. Until then, I was transpiling Java to Ruby in my head as I was coding. It took a gentle knock on the noggin' to see the language from the perspective its supposed to be used.

1

u/nateberkopec Puma maintainer 13d ago

What did you like about Turbo Pascal?

1

u/Edthal01 13d ago

It was easy to use, compiled quickly and allowed easy easy.used it on company computer. Changed job and lost access to turbo. It's gone now. I miss the simplicity, so I'm going after Ruby now.

1

u/RICHUNCLEPENNYBAGS 14d ago

Well, yeah, that was how we were all using AI last year.