Live data from Hacker News

Rubish: A Unix shell written in pure Ruby

github.com

101–110 of 111 posts

Re: Rubish: A Unix shell written in pure Ruby

#101

Earlier quoted context omitted.

Yeah. I will probably join their ranks at some point. Bash maintainer actually implemented the library feature I suggested and it's already dramatically cut down the amount of unsightly bash code I need to keep around and maintain. I'm getting pretty tired of coping with old stuff just because it's there though. Went through this phase with GNU make too.

Sorry, which library feature?

I proposed adding an import builtin to bash on the mailing list. Sent patches too. Didn't go very well, to say the least.

Nevertheless, a version of the feature landed in bash 5.3.

  source -p "${HOME}/.local/lib/bash" file
You can use that to implement the library import function yourself.

  import() {
    local f
    for f in "$@"; do
      [[ -v loaded[$f] ]] && continue
      loaded[$f]=1
      source -p "${HOME}/.local/lib/bash" "${f}"
    done
  }

  import arguments terminal

Re: Rubish: A Unix shell written in pure Ruby

#102

Earlier quoted context omitted.

There is a big difference between JIT compiled _dynamic_ language and ahead of time compiled static language. While modern JS engines show that difference sometimes can be narrowed down with sophisticated JIT and runtime, it is still there.

Ruby's YJIT compiler does compile ahead of time, the details are in the link provided. On the first run it will, if feasible, compile blocks of frequently executed code and stow it away for when it's needed next. So only on the first run is it interpreting everything.

Many interpreted languages have this feature, including PHP these days. But they're still quite slow, because dynamic languages are just slow. Dynamic typing is very suboptimal because generally you have to box A LOT of stuff and burn a lot of memory. That matters because then cache lines get evicted more often, and the performance grinds to a halt.

It used to be in PHP that every array element took 96 bytes (!!!) of booking overhead. That was/is why PHP is slow. That was reduced and performance basically quadrupled for PHP 7.4.

EDIT: sorry just wanted to add I'm being a bit hyperbolic. These languages are fast enough for their use cases, both PHP and Ruby. But compared to even something like C#, this is where the performance gap comes from, despite both being garbage collected.

Re: Rubish: A Unix shell written in pure Ruby

#103

Earlier quoted context omitted.

Honestly I don't know why would you choose ruby for vibecoding. This is a language that explicitly sacrifices important stuff like the strength of automatic checks possible and performance in lieu of developer ergonomics. Even if you support that particular choice, chosing the language when you won't be writing or reading most of the code is a pretty poor tradeoff.

There is a study that reported ruby as the best language for LLM over something like 15 languages

Link?

Re: Rubish: A Unix shell written in pure Ruby

#105

Earlier quoted context omitted.

There is a study that reported ruby as the best language for LLM over something like 15 languages

Link?

Looks like I misremember, it's not a study but just a blogpost with some benchmarking. And it's not first, but third: https://news.ycombinator.com/item?id=46582728

Re: Rubish: A Unix shell written in pure Ruby

#106
post #85

People think Ruby is a slow language, but little do they know Ruby is a slower language than Go. But ruby these days is faster than Python.

Heavy lifting Python libraries are in C and C++

What’s your point?

Those same C and C++ libraries can be just as easily be called from other languages like ruby.

Re: Rubish: A Unix shell written in pure Ruby

#107
post #90

Earlier quoted context omitted.

> Rails is also ancient already. I think Rails both boosted Ruby and killed it. When I ask people about why they dislike Ruby it's usually due to something specific to Rails (plus some comments around syntax which are easily dismissed or accepted). I used to be a pretty heavy Ruby user and I still love the language, though I have only used Rails sparsely and not by choice. I had the opportunity to work on a Ruby proj…

just yesterday i was searching for CMS alternatives. i found dozens in php, but only a single one in ruby. i found that disappointing. python did no better. i found two. there is really no reason for php to be dominating this space. can't find ruby skills? they are searching for the wrong thing. they should hire an experienced programmer who could learn ruby in a week and not expect someone who has been working exclu…

I don’t disagree with you but they were a small, struggling startup, with a team already formed. Perhaps they made a few wrong calls along the way, it wouldn’t be for me to say as I was there simply to help them tighten their security.

They had a good team, everybody was knowledgeable, approachable and curious. I wish them all the best, and I imagine they’ve been recovering as they’re still alive and kicking years later!

Re: Rubish: A Unix shell written in pure Ruby

#108
post #34

Earlier quoted context omitted.

Not sure if this is related, but i'd love to see more scripting languages (mostly Python) offer facilities which let them take over from shell script for more scripts and one-liners. Think about what it would take to write this in Python right now: for wmv_file in $(find $1 -name '*.wmv'); do echo -n "${wmv_file} " ffmpeg -i $wmv_file ${wmv_file%.wmv}.mpg 2>&1 | grep kb/s: || echo "ERROR $?" done With a few handy var…

How about for wmv in Path(sys.argv[1]).rglob("\*.wmv"): print(wmv, end=" ") r = subprocess.run( ["ffmpeg", "-i", wmv, wmv.with_suffix(".mpg")], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) lines = [l for l in r.stdout.decode().splitlines() if "kb/s:" in l] print("\n".join(lines) if lines else f"ERROR {r.returncode}") ? If you go outside stdlib you can use the sh library instead of subprocess.run.

Not bad, but the subprocess invocation is too verbose given this is a staple of shell script type work, and the string mangling is a bit painful.

Re: Rubish: A Unix shell written in pure Ruby

#109
post #34

Earlier quoted context omitted.

Not sure if this is related, but i'd love to see more scripting languages (mostly Python) offer facilities which let them take over from shell script for more scripts and one-liners. Think about what it would take to write this in Python right now: for wmv_file in $(find $1 -name '*.wmv'); do echo -n "${wmv_file} " ffmpeg -i $wmv_file ${wmv_file%.wmv}.mpg 2>&1 | grep kb/s: || echo "ERROR $?" done With a few handy var…

I think Perl is what you're looking for!

Perl is what I've spent the last thirty years running away from.

Re: Rubish: A Unix shell written in pure Ruby

#110

Earlier quoted context omitted.

Link?

Looks like I misremember, it's not a study but just a blogpost with some benchmarking. And it's not first, but third: https://news.ycombinator.com/item?id=46582728

I see Clojure actually tops the list! It seems this lines up with what one would've guessed even pre-LLM: the most token-efficient languages are highly expressive languages where concision is also a requirement for idiomicity.
Post reply on HN