4 ms·
I don't really know much about python, but how is the C API? Because as nice as Ruby may be as a language, I wouldn't want to touch the C API with a laser point
by DarkWiiPlayer 7y ago
I don't really know much about python, but how is the C API? Because as nice as Ruby may be as a language, I wouldn't want to touch the C API with a laser pointer.
Maybe python just has a nicer API, leading to more people writing fast C libs for it instead of Ruby; and ultimately many people will just use the language with the fastest libraries for their domain (specially the kind of people that have some influence on their community).
Again, no idea if this is the case, but comparing the C APIs of Ruby and Lua, it's a huge difference.
- roryrjb 7y agoThis is a big use case for me. I really want to use Perl but I favour Python because the CPython API vs XS, it's a no brainer. I haven't really looked into the Ruby C API but if it's sane I would use it as well.
- AdieuToLogic 7y ago> I really want to use Perl but I favour Python because the CPython API vs XS, it's a no brainer. As I just mentioned in this thread, there is a project called SWIG[0] which might be something you'd want to check out. 0 - http://swig.org/ http://swig.org/
- roryrjb 7y agoThank you. I've heard of it and read about it a few times but haven't seriously considered it, but I will.
- lizmat 7y agoPerhaps Raku is an alternative for you with its Perl roots and its NativeCall support: https://docs.raku.org/language/nativecall https://docs.raku.org/language/nativecall Also see this recent blog post for interfacing with C++ and Fortran from Raku: https://andrewshitov.com/2020/01/08/calling-cpp-and-fortran-functions-from-raku-using-the-nativecall-interface/ https://andrewshitov.com/2020/01/08/calling-cpp-and-fortran-...
- roryrjb 7y agoNice thank you. The last time I looked at Raku a few years ago when it was still called Perl 6 I hadn't considered native bindings. Will take a look.
- brigandish 7y agoI wouldn't say I'm a C programmer at all though I did manage to struggle through producing a very simple C-extension for Ruby once. Recently, I had to debug one that wouldn't install. Could I find well written, up to date documents? No. I found bits and pieces scattered in blog posts and gists, and wildly different ways of making extensions. It was incredibly vexing and I would've happily used Python - or anything else - at that moment. The number of times I find hardcoded paths in Ruby extensions is mind boggling. I guess "it works on my computer" is okay for some but to me it seems amateurish. I don't blame the library authors as much as the core team for this because the documentation and examples are so bad. Not a good look for a mature language. I'm looking at learning Crystal and Elixir because they'll (hopefully in Crystal's case) fix a lot of the glaring-but-never-fixed problems in the Ruby ecosystem for me. Ironically enough I've spent my afternoon fighting with a Ruby C-extension that won't install!
- AdieuToLogic 7y ago> I don't really know much about python, but how is the C API? Because as nice as Ruby may be as a language, I wouldn't want to touch the C API with a laser pointer. You might want to check out SWIG[0] then. It can definitely help integrate C/C++ libraries into Ruby (as well as a dozen other languages) without having to work directly with the host language's C API. HTH 0 - http://swig.org/ http://swig.org/
- deleted 7y ago[deleted]
- Buttons840 7y agoAs one of my favorite HN comments of all time said: > Ruby's C implementation is a mess of support for language-level flexibility. Python's C implementation is so clean you get the unsettling thought that you could probably write Python using C macros. https://news.ycombinator.com/item?id=682364 https://news.ycombinator.com/item?id=682364