It was excellent last night - some really useful info about Hotwire Native, thanks Ste! Also nice to see our numbers are growing and there was some really interesting discussions afterwards.
So I've gone all in monkey patching JavaScript with some Ruby and Rails methods and I really like it. I think you can mitigate a lot of the issues with monkey patching and then it just comes down to whether adding more methods to native objects a good idea or not. Personally I like the fact that JavaScript is flexible enough to add let me add the methods I like using in Ruby. It was also a nice exercise in trying to recreate them and I found out about quite a few methods I didn't realise Ruby had!
Henrik - love that Elixir library, I was thinking of something similar but went one further and used 5 |> days |> ago
The pipe operator is definitely a great way to get a nice syntax without having to monkey patch, it would be great if it ever came to JS
I had a play around with doing it in JavaScript using polyfills for the new Temporal class and pipe operator:
// Number -> Duration
const days = n => Temporal.Duration.from({ days: n })
// Duration -> Date
const ago = duration => Temporal.Now.plainDateTimeISO().subtract(duration)
// Duration -> Date
const from_now = duration => Temporal.Now.plainDateTimeISO().add(duration)
// Number -> Date
const daysAgo = n => ago(days(n))
// All of these are the same
console.log(daysAgo(2))
console.log(2 |> daysAgo)
console.log(2 |> days |> ago)
You can see it here:
On the subject of JavaScript ruining the Internet, I thought this thread had some interesting opinions:
Last of all - Tekin pointed me to DHH's latest rant and I think it's his worst yet, horrible read.
Thanks to everyone for organising and to Fatsoma for the room and pizza!
DAZ