Live data from Hacker News

Reducing Memory Usage in Ruby

tenderlovemaking.com

21–30 of 58 posts

Re: Reducing Memory Usage in Ruby

#21
post #17
post #13

Earlier quoted context omitted.

Until I can perform runtime define_method calls and dynamically construct classes, it doesn't matter what Crystal does. It's fundamentally antithetical to my needs. (JavaScript isn't, but JavaScript is kind of clunky.) I have Kotlin, C#, C++, and Rust if I need static typing. Ruby is for when I don't.

You can do all of that with really easy to write crystal macros.

You can dynamically build at runtime an HTTP client from an OpenAPI spec (unavailable until runtime, to be clear), method-by-method, using macros? Tell me more.

Re: Reducing Memory Usage in Ruby

#23

What I'd like to be able to do is load ActiveRecord (or any other v. heavy lib) asynchronously in non web-based apps so that I can paint the UI quicker. By the time the user will do/need anything db-related a proxy object should be swapped out for an actual ActiveRecord object. Using Rails' ORM is so nice and ergonomic but it kills start-up time with all the file requires, Bootsnap helps a bit but I'd prefer not to h…

I am actually facing a similar problem. I also find that Rails just creates a db connection everytime I do Model.new even though I have not yet saved it.

This is because active record models learn their attributes by querying the database scheme. I haven’t tried it but there appears to be a way to cache this information in the local file system which would likely avoid the early dB connect if you really needed to do that. Also avoids querying the scheme on processs boot entirely if you are willing to trust the cached scheme matches the. database scheme. See https://github.com/rails/rails/issues/24133 for discussion

Re: Reducing Memory Usage in Ruby

#25
What I'm really keen to see is truffleruby receiving a lot of community support.

The underlying JVM and the Truffle/Graal/SubstrateVM is the product of millions of man hours of research - and for the very first time, you have a compiler framework on top of that.

The Truffle framework also brings in a lot of support that all languages get for free, like zero overhead profiling https://twitter.com/nirvdrum/status/948333404122214401

Truffleruby is already in the running in benchmarks, and it will be awesome to see how far it can be pushed . http://nirvdrum.com/2017/02/15/truffleruby-on-the-substrate-...

Re: Reducing Memory Usage in Ruby

#26
post #24

Ruby seems to have a footprint on Hacker News disproportionate to its general popularity and TIOBE index. Why?

Ruby has one of the better communities among programming languages - disproportionate to its popularity. I wish more languages had that quality of discourse.

Re: Reducing Memory Usage in Ruby

#27
post #24

Ruby seems to have a footprint on Hacker News disproportionate to its general popularity and TIOBE index. Why?

Rails, and possibly 37signals, was very influential to many folks about a decade ago, especially in the startup community, where Rails was seen as especially useful for prototyping or rapid, test-driven web app development. https://www.quora.com/Why-do-so-many-startups-use-Ruby-on-Ra...

It’s popularity at this may have diminished with the rise of JavaScript, Go and alternatives but many folks still like and use Ruby, or at least would like to see it continue to improve and thrive.

Re: Reducing Memory Usage in Ruby

#28
post #21
post #17

Earlier quoted context omitted.

You can do all of that with really easy to write crystal macros.

You can dynamically build at runtime an HTTP client from an OpenAPI spec (unavailable until runtime, to be clear), method-by-method, using macros? Tell me more.

Got me there. First time I've ever in my life heard of a legitimate example where you really do need dynamic methods.

Re: Reducing Memory Usage in Ruby

#29
post #24

Ruby seems to have a footprint on Hacker News disproportionate to its general popularity and TIOBE index. Why?

From a different perspective, having worked on numerous Ruby projects for years across the private (startups to Fortune 500), nonprofit, and government sectors, spanning many locations with worldwide team members, I don’t see where Ruby/Rails isn't at this point—it’s seemingly all-pervasive.

Similar to general hiring/salary surveys, I’m not sure that the referenced index is accurate.

Re: Reducing Memory Usage in Ruby

#30
post #28
post #21

Earlier quoted context omitted.

You can dynamically build at runtime an HTTP client from an OpenAPI spec (unavailable until runtime, to be clear), method-by-method, using macros? Tell me more.

Got me there. First time I've ever in my life heard of a legitimate example where you really do need dynamic methods.

If you're doing stuff with OpenAPI (as I've been doing over the last few weeks), it becomes a pressing thing. =( Generated clients usually are pretty awful, you usually have to generate your own (because they don't publish gems when their APIs change, which is why I've written online-generated ones!), and once you've completed the bootstrap process for an HTTP client, it's as fast as any other Ruby thing. Which is not the fastest out there by a long shot--though JRuby helps--but is Fast Enough for most stuff.

I'm also not sure Crystal can implement an active record pattern off of a database? (Though I am not personally the type to go with that, I prefer row mappers.)

Post reply on HN