Hacker News new | past | comments | ask | show | jobs | submit login
Ruby for eBook Publishing (strzibny.name)
150 points by thunderbong on Sept 20, 2021 | hide | past | favorite | 51 comments



I've been using mdBook: https://github.com/rust-lang/mdBook for a personal knowledge base in an ebook format and it's been a joy. Not Ruby, it's written in Rust instead.

It's very easy to customize either via plugins with Rust or by overriding template files. While the linked article is cool, it seems like a lot of effort to maintain such a set up. Then again, if you're a Ruby expert I could see this being worth it.


Did not know about mdBook, will have a look!


Man, I love Ruby. I think it is much more elegant than Python and I really really wish Ruby would have taken the world instead of Python. That said, it's often the case where I want to do something where there's just no Ruby library for it (or at least not a maintained one) and there's a well known library for it in Python. Note: I do low level things, I don't do anything related to web or Rails.

Also, sometimes I start writing scripts for simple things, then they grow and at some point it's interesting to share them to my teammates, and they all immediately dismiss it since it's in Ruby. For that reason, I started doing all my work-related scripting in Python. But oh boy, it's always with that sad feeling of "I wish I was doing this in Ruby". Sometimes I think I should just not have learned Ruby and jumped straight to Python.


I feel very similarly! Ruby just feels like such a well designed system from the ground-up. The object model is so elegant and consistent. The standard library is feature-full and fun to use, and the docs are excellent. Ruby is a beautiful object-oriented language but also leans into the power of FP with a plethora of functions defined on the powerful base-classes like Enumerable. In comparison, Python feels way less thoughtful, more of an ad-hoc language constructed through independent decisions over a long period of time


Yes, exactly! Even Python's object orientation feels like a hack made on top of a procedural language.


It just shows how "cargo cult" driven our industry is. Ruby was in. Then it was out, because it "doesn't scale". Then suddenly Python is in, even though it is has the exact same performance characteristics, give or take some constant value, as Ruby.


Languages look similar, but Python value resides in the vast amount of libraries available to do data processing and ML. Most of them backed by C implementations under the hood.


There's nothing about Python, compared with Ruby, that gives it any advantage, numerics or otherwise. Ruby's C ffi is just as powerful as Python's. It's all just a first mover phenomenon. Python is the VHS of programming languages.


Community matters. In this case Python community around data science is huge.


PHP, JS and Python all have great communities but they're still crappy languages.


Exactly, and though Ruby has an FFI (Foreign Function Interface) similar libraries were not created and Ruby was pigeon holed as a language you build CRUD apps in.


There is a dev adding Ruby bindings via FFI to ML libs. Unfortunately it doesn't seem to be a large community (yet).

I don't do any ML and don't know much about it, but the Elixir / Phoenix people around José Valim now build ML software (nx, livebook) and I'm excited for this.


And those libraries can actually be used from any language with FFI capabilities.

So whatever headstart Python might have in machine learning, it is only a matter of time until all major languages support the same C, C++ and Fortran libraries.

The only things holding it, are having anyone that cares enough to write those bindings, and the culture of which languages are accepted when submiting papers.


Software, like anything with money involved, tends to suffer from cargo cultism, but I think there's much more to it. Language ecosystems tend to be self-reinforcing in a cycle between developers and supporting libraries/tools.

Once Python got the edge in certain areas - particularly data processing - it was an upward spiral. The same can be said of JavaScript for webdev over Ruby and Python, with its special place at the heart of every browser.

I'm not entirely sure why Python got its initial edge for data processing. I think Google probably played a big role by sponsoring Guido and making it one of the key languages used internally and on App Engine. Ruby also had its share of drama and not everyone appreciates its "More than one way" (TMTOWTDI) philosophy.


I have to admit I've had a similar reaction, at a previous company we were "forced" to use Ruby to be consistent.

I grew to love Ruby, though I admit I always approached it with half a mind pretending I was writing Perl.

These days I've sometimes fallen back into Ruby, but then had issues sharing it with colleagues - so I've largely switched to Go. While most people don't have a dev-environment setup I can give them binaries built via github/gitlab/jenkins, and so sharing tools & utilities is just that little bit less painful than with Ruby (and even Python).


I used to work somewhere where I got "forced" to use Perl but was more familiar with Ruby.

Obviously Perl came far earlier than Ruby and Ruby was heavily inspired by Perl (There's even a quick comparison on the official Ruby site here https://www.ruby-lang.org/en/documentation/ruby-from-other-l...) but it always felt like Ruby is such a nicer language to read and write and obviously due to age was just a more modern overall. You could define a class as a... class!

Whenever I wanted to make a quick script for myself for personal usage I'd always write it in Ruby.

I'm now in a C#/.NET role and love typed languages now but I'd never go back to Perl, but I still have a special spot for Ruby.


Perl got lost in arguments over whether to adopt a meta-object protocol (MOP) in the core and if so, which one. That and the endless variants of Moose just took TIMTOWTDI to ridiculous extremes. Meanwhile PHP and Rails were eating Perl's lunch.


ruby-packer worked for my little Ruby things in that regard https://nts.strzibny.name/making-a-ruby-executable-with-ruby...


why not docker?


I also think Ruby is so much cleaner and more productive than Python. I really miss it. The number of times I think "this is like a bad version of Ruby" while doing stuff in Python...


Perhaps we need a ruby <-> python transpiler so you can secretly program in ruby on python projects.


Especially with Python lambdas. Such a contrast with Ruby's elegantly-designed blocks, Procs and lambdas.


Another comment to piggy back off the ruby > python love. RSpec is a million times better than any testing library in python and bundler solved package management issues years ago that python still hasn’t solved. Glad to see I’m not alone!


I just the other day started working on an idea for a ruby based shell: https://github.com/seiferteric/rbshell . The idea is to try to write a ruby DSL that looks as similar as possible to regular CLI commands, but return ruby objects so you can more easily process the results. I would be interested in some help if others are interested. I haven't yet decided on the exact syntax yet but it is already looking kind of interesting I think.


I was just daydreaming about this the other day and would definitely give the finished project a spin. Depending on what you need (I'm a Rails dev, so pretty ok with Ruby in general but probably of not much help on the system end) I'd be happy to support you.


neat, I started a similar thing in 2014 but just didn't have the time it needed. I sincerely wish you well on your effort! I'd still love to have a shell based on ruby.


One of the major reasons Ruby didn't take off [outside of web] is because of the library availability. Ruby was pigeon holed by Rails while in Python I can reach for a library for pretty much any usecase and scenario from Genomics to Web.

The thing is that is an issue of community, because Ruby does have an FFI and there is really nothing stopping people from building libraries similar to how they're done in Python, calling out to C. They just didn't.


I think this is largely because academia adopted python as a teaching language, and given enough time college students and faculty write a lot of library code.


Indeed, it was also one of Python's original goals, to be the next Pascal/Basic.


Yeah I love ruby too... why do they dismiss it if docker is there for them to get running quickly? python is just so janky to me


I must be in the minority. I strongly dislike Python, and I loathe Ruby. Give me a statically typed language any day of the week.


Can you give me one or twoo examples for such missing low-level stuff Ruby libraries, please?


Two examples I remember researching Ruby for and ended up giving up: hardcore statistics stuff (I'm using using Python's scipy.stats now) and GUI toolkits (yes, there are some toolkits available, but nothing like Python's official bindings for gtk/qt).

It's hard to remember more examples. I remember having problems even with FastCGI on Ruby, but I ended up not writing the code at all so that won't count. Also something related to parsing emails.


Ruby was in my blood, once. Mountains of systems integration and backend parsing and business logic. Never any Rails though.

The older and more boring I got, the more I liked Python. Young me and old me both knew what they were doing.


>PDF publishing

I'm also a big fan of the HexaPDF library: https://hexapdf.gettalong.org/


It's mentioned! I used it to make all kind of previews.


Sounds like fun. However, I started using LaTeX instead of Markdown+pandoc for PDF creation because I needed more control over the layout than Markdown is capable of.


Asciidoc might be a reasonable middle ground, depending on what do you mean by layout.


I need precise control over columns, among other things.


I know this guy, he is a good worker and puts passion into this book. Help him out and give him a sale!


Thanks James ;)


I'm really liking this book. It almost seems like a light Unix administration handbook mixed with application deployment. I might just buy it to get some guidance with Podman.


Can it paint a PDF text between 2 pints in a color gradient?


Yep. It can also convert PDFs into nice PNGs


Are you referring to the color gradients in text made popular by BeeLine Reader?


Yes. The idea feels very nice but the implementation is unbearable. I want to imitate that without having to install a browser extension which is ridiculously slow and requires access to all the pages you visit. I would tolerate it if it would stay off until I actively invoke it when and where I want (mostly local disk/host documents) and if I could be sure it doesn't spy on me. So I am passively looking for an alternative. So far LaTeX was the only alternative I've found that can do that but it is otherwise too complex to use (I managed to achieve the effect but failed to build a book of specific structure I needed in reasonable time). Now I'm curious if Ruby can fill this gap between MarkDown/HTML+CSS and LaTeX.


Totally understandable. I'm the creator of BeeLine (and the concept), and permissions in Chrome extensions are tough. One possible solution for concerned users is to whitelist certain sites via the extension manager, so that the extension only has access to those domains, but I don't think there's a way to do that for local files.

If you want to just convert files, you might try the File Transformer[1] by Blackboard Ally. They've licensed the BeeLine technology and are temporarily making it available for free publicly through the File Transformer (it's also available to their university customers through their LMS interface).

Lastly, I know it probably won't put your mind at ease, but I am the solo founder who runs BeeLine Reader. I do not do anything with user data, and in fact I don't even gather data at the individual user level. This is partly because my tools are used in K12 schools, and partly because I can't imagine selling out my customers.

1: https://ally.ac/covid19/


I am happy to meet you. Thank you for the link (and for inventing the concept). I'll probably use it for some files but again this means uploading files to some untrusted server (I believe you when you say you don't gather data but uploading a file and being sure it won't be saved anywhere feels harder).

You probably know better as you have probably done some business modelling but just for my piece of feedback - I would buy it if you would offer a purely offline Linux+Windows+Mac app that outputs coloured (and structured) PDFs given a MarkDown (or some XML intermediary, perhaps FB2, for more complex structures) file and a paper format for input. At the moment I feel like the price I would pay could be something near $100. I wouldn't even mind paying if it's just a proprietary script on top of free software.

It would also be great if one day you would add an on-demand (on the extension button click) mode to the extension to save the users' CPUs and batteries.

I hope you don't feel insulted or discouraged by how do I speak about your creation's performance - I understand it can be hard to teach a browser's text rendering engine a totally new trick. Perhaps you have even improved it since the last time I tried (which was years ago).


I appreciate the candid feedback. We understand that different people want to use the extension in different ways, and some want more autorun whereas others want more manual control.

In our experience, the group that favors autorun tend to be the ones that get more benefit out of our software, and therefore are more likely to be paid users as opposed to people on the free trial. Because of limited resources (and the need to make the product simple), that means we've focused on optimizing for the autorun case instead of the manual activation case.

I should note that we do have a way to use the extension just as you describe, which is to use the Clean Mode. This is manually activated using a keyboard shortcut (which is hard-coded in Firefox and manually configured in Chrome). If you turn off autorun you can invoke BeeLine (in Clean Mode) using the shortcut.


This is great, but wouldn’t it be easier to use a LaTeX ebook transformer since many books are already set in TeX?


I used Pandoc + LaTex for https://deploymentfromscratch.com/ as mentioned in the post, but my brother is now taking the AsciiDoc approach and I think it's looking good. I will think hard next time and most likely give AsciiDoctor a chance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: