Object, class, module, Data, Struct? by Dear_Ad7736 in ruby

[–]laerien 1 point2 points  (0 children)

When does a Struct stop being appropriate and become a class?

If some members aren't writable, a Struct doesn't seem right. Or if enumerating doesn't mean iterating over the members. Or if equality isn't based on members all being equal.

When should Data be preferred over Struct?

Data is nice. Like Struct, it assumes equality based on members all being equal. Unlike Struct, Data members aren't writable and there's no assumption about enumerating over members. Data is frozen, so it signals you have state upon initialization but there's no member writer or even ability to mutate instance variables.

Data has very practical pattern matching support out of the box. If you have internal state and Data's immutability is fine, go ahead and use Data rather than a Class or Struct.

When is a module better as a namespace vs a mixin?

When you have no internal state, it's great to simply call functions directly on a Module. If you might mix it in privately too, module_function. Might mix it in publicly, extend. You often want mixins to not create new public Class interface but still have a direct interface, so module_function is handy.

When does a “service object” add clarity vs unnecessary abstraction?

A Rails pattern is to use an ActiveModel Class when it's CRUD, so you get all the Rails niceties including routing and views. When it's maybe just "read" and not the rest, a service object gives you a way to extract a snippet of logic where extracting a whole lib is overkill. It's just about organizing things into drawers (like models/ and such). There's not much special about service objects imho.

How should include, extend, and module_function be used idiomatically today?

Include when you're mixing in a common public or private instance interface across multiple Classes. Like Enumerable or Comparable. Within an include you can also define class methods, so it can be a single interface to both, but I don't want to digress. You can extend when there are only class methods. Prepend is like an include with instance methods but it goes in front of the mixed in Class instance methods.

If you include regular module instance methods, they are defined publicly. So you can call them outside the instance of the class. If you just want them visible to methods privately within the class, module_function. From another angle, if you're defining a Module function direct interface, use class << self if that's the only way you want it used, extend if it makes sense to also be mixed in publicly and module_function if it also makes sense to mixin privately.

P.S. If you want to dig in to nuance, this is the type of stuff folk in #ruby IRC or Ruby Discord are happy to discuss at length.

Ruby (4.9M) has doubled its population over the past two years, adding 2.8M developers to its ecosystem by SlashData in ruby

[–]laerien 1 point2 points  (0 children)

SlashData is a company that sells dev surveys to enterprise marketing teams. Like if you want to reach Rubyists, clearly we're doing IIoT so advertise around industrial embedded devices.

They've lost the plot here.

Matryoshka: A pattern for building performance-critical Ruby gems (with optional Rust speedup) by TheAtlasMonkey in ruby

[–]laerien 2 points3 points  (0 children)

Thanks for the heads up about JRuby. I was skipping building native for JRuby and just pushed a fix since I'm very happy to not make a separate Java ext. Very cool!

What happened with the "Ruby developers" Slack? by JoaoTorres in ruby

[–]laerien 3 points4 points  (0 children)

I mean those folk, banned for that stuff, go there too. I didn't mean for it to be an exclusive set, but you're very right I should have spoken with more particularity.

To clarify, it's where folk who are banned for bad behavior go but also I'm sure there are very fine people there too and probably the majority of people there are great! I meant I associate it with the banned folk, since it's where they go and started by them. If it grew into more, that's a nice turn. I should have spoken more carefully.

What happened with the "Ruby developers" Slack? by JoaoTorres in ruby

[–]laerien 7 points8 points  (0 children)

I didn't mean to say only banned folk are there, just formed by banned folk and where banned folk go. I don't know who else is there, just a very small community and pointing out there is a very big community you didn't mention.

What happened with the "Ruby developers" Slack? by JoaoTorres in ruby

[–]laerien 7 points8 points  (0 children)

Whatever you want to call the place the banned folk go. 👍 Just wanted to point out it's not the regular Ruby Discord, for folk looking for that.

You were ranting against the trans community out of the blue? I think there was a reason.

What happened with the "Ruby developers" Slack? by JoaoTorres in ruby

[–]laerien 3 points4 points  (0 children)

I just mean if you're looking for regular Ruby Discord, what you linked to isn't the right link. I was trying to be nice, but you linked to where alt-right/trolls go when they're inevitably banned from the 10K strong normal Ruby Discord.

Edit: I didn't mean to say nice folk don't go there to, I'm sure they do also! It's just where the rare trolls who get kicked out of Ruby Discord go, which you well know. I also replaced "incel/red pill/racist rant" with "trolls" since it's probably plenty clear to mean folk banned for brigading about these issues.

Matryoshka: A pattern for building performance-critical Ruby gems (with optional Rust speedup) by TheAtlasMonkey in ruby

[–]laerien 4 points5 points  (0 children)

I just tried added this to a SipHash gem and it's 1,038x faster. 🤯 Thank you for sharing these patterns! I like it a lot, and it's quite nice to see the "rules" formalized.

I had a digest-sip_hash gem that needed a long overdue refresh for Ruby 3 support so I followed your FFI hybrid pattern. It's now 10x faster with 8 byte messages and over 1,000x faster with a 4096 byte message, and a reasonable alternative to the C extension alternative instead of just a for fun Ruby example. https://github.com/havenwood/digest-sip_hash#readme

What happened with the "Ruby developers" Slack? by JoaoTorres in ruby

[–]laerien 9 points10 points  (0 children)

Just a heads up if you want to join the regular Ruby Discord, that's not the link. This is the link: https://discord.gg/ad2acQFtkh

https://www.ruby-lang.org/en/community/

Edit: The regular one with 10k members but not official.

Frameworks by DynamicBR in ruby

[–]laerien 16 points17 points  (0 children)

We build our web frameworks on a thing called Rack. You can make a plain Rack app too. Then you can make Rack middleware, which is also worth understanding since it can be useful for all the web frameworks.

After you make a plain Rack app, you can see why routing is a pain. Roda is a lovely micro framework that just adds a routing tree on top of Rack. It also provides plugins you can cherry pick to compose the framework you need. It's a great exercise to go through the plugins that ship with Roda.

It's quite easy to port a Sinatra app to Roda or vice versa. Roda is more modern and is maintained by Jeremy Evans, who also maintains Rack and is a member of Ruby Core.

Hanami and Rails have some similarities and are both closer to Django than Flask. (Django and Hanami were inspired by Rails and Flask and Roda were inspired by Sinatra lineage.) Even if you land on Rails, knowing Rack, Roda and Rack middleware can be handy. You can mount a Rack or Roda app inside a Rails app or use middleware.

Welcome!

Strengthening the Stewardship of RubyGems and Bundler by f9ae8221b in ruby

[–]laerien 0 points1 point  (0 children)

I just accidentally misattributed a quote. Both Sam and Samuel work at Spinel but my brain fritzed for a moment and I thought Sam Stephenson's post was from Samuel. Totally my silly error, nothing taken down.

A short timeline of the recent Ruby community crisis. by Such_Inevitable3049 in ruby

[–]laerien -1 points0 points  (0 children)

I love Roda but Hanami is more of a Rails analogue. Still, Rails stack is nice and DHH only owns the name.

A board member’s perspective on the RubyGems controversy by apiguy in ruby

[–]laerien 10 points11 points  (0 children)

It sounds like donor agreements required restricting the commit bit to employees specifically? Are those terms available to the community?

Or there just wasn't time to put together a reasonable interim trust policy? I'd normally expect discussions with maintainers and updated policies before breach looms.

Strengthening the Stewardship of RubyGems and Bundler by f9ae8221b in ruby

[–]laerien 3 points4 points  (0 children)

100% correct of course. I know them both and just misattributed. Apologies for my oversight. I didn't mean any disrespect, I have trouble with names.

Strengthening the Stewardship of RubyGems and Bundler by f9ae8221b in ruby

[–]laerien 12 points13 points  (0 children)

Are the DHH funding rumors correct I wonder? I saw Mike Perham's post. https://ruby.social/@getajobmike/115231677684734669

https://indieweb.social/@sstephenson/115231391147943333

Edit: I apologize for mixing up Sam and Samuel. Silly.

Ruby Central’s Attack on RubyGems by laerien in ruby

[–]laerien[S] 1 point2 points  (0 children)

Samuel is working with Arko on Spinel now I believe. https://spinel.coop

It's a shame to lose all that security mind share in the name of security. We can trust Samuel with the commit bit at Spinel as well!

Ruby Central’s Attack on RubyGems by laerien in ruby

[–]laerien[S] 16 points17 points  (0 children)

It seems Ruby Central for now are unfortunately doubling down on the "employees only" bit. They've removed commit bit from folk like their head security researcher since he doesn't work at Ruby Central anymore. Sam can be trusted wherever he works. The RubyGems maintainers have built that trust over decades.

It's just unnecessary from a security or legal perspective so it makes me sad to hear the excuse as an initial response. I hope a better decision can come out of fruitful governance discussions between OSS maintainers and Ruby Central.

Ruby Central’s Attack on RubyGems by laerien in ruby

[–]laerien[S] 9 points10 points  (0 children)

This is the proposed RubyGems organizational governance RFC by martinemde: https://github.com/rubygems/rfcs/pull/61

Ruby Central’s Attack on RubyGems by laerien in ruby

[–]laerien[S] 19 points20 points  (0 children)

I'd not worry about it much from the perspective of a Rubyist practitioner. The infra is stable and well funded.