3 ms·
The best Ruby always surpasses the elegance of the best Python... Unfortunately for practical means at this point I go for Python: more libraries, less problems
by antirez 2y ago
The best Ruby always surpasses the elegance of the best Python... Unfortunately for practical means at this point I go for Python: more libraries, less problems with the C implementation of the interpreter (had issues with the GC in the past), better LLMs understanding of the code.
- deleted 2y ago[deleted]
- drdaeman 2y agoSurely you can have the same API elegancy and overall semantics in Python? chat = python_llm.Chat() _ = chat.ask"What's the best way to learn Python?") # Analyze images _ = chat.ask("What's in this image?", image="python_conf.jpg") # Generate images _ = python_llm.paint("a sunset over mountains in watercolor style") # Stream responses for chunk in chat.ask("Tell me a story about a Python programmer"): print(chunk.content) # Can be a class if necessary, but for this weather thingy we can probably do with a simple callable # Requires Python 3.9+ for typing.Annotated def get_weather( latitude: Annotated[Decimal, "Latitude of the location"], longitude: Annotated[Decimal, "Longitude of the location"] ) -> str: """ Gets current weather for a location. """ ... _ = chat.with_tool(get_weather).ask("What's the weather in Berlin? (52.5200, 13.4050)") (The `_ =` bits are mine, to emphasize we have a meaningful result and we're knowingly and willingly discarding it. Just a habit, I hope it doesn't bug people.) Ruby has significantly more capable metaprogramming facilities, but they aren't used in RubyLLM, it's all just objects and methods (biggest difference being use of iterable in Python vs providing a block in Ruby, as I felt an iterable would be more Pythonic here), which is nothing Ruby-specific. And IMHO advanced metaprogramming should be used carefully, as it may make code pretty but really hard to comprehend and analyze. My largest issue with Rails is difficulty to tell where things are coming from and what's available (lack of implicit imports and ability to re-open any class or module and inject more stuff in there so there's no single place that defines it is a double-edged sword that may lead to chaos if wielded carelessly - YMMV, of course, I'm merely stating my personal preferences here).