News for hackers. Stuff that matters.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by mythz on Wednesday November 10, 2021 @01:30AM (#29171717)
This is a beautiful feat showcasing Ruby's expressive power, don't know of any other language that could be molded to accomplish the same feat.

As a non Ruby programmer I still appreciate its culture whose community best seems to explore code as art. One of Ruby's contributors @mame (also a talented #1 IOCCC winner) does this a lot who's famous for quine-relay [1] but has lots of other interesting art code projects in their repos.

[1] https://github.com/mame/quine-relay

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by dwohnitmok on Wednesday November 10, 2021 @02:33AM (#29172063)
> don't know of any other language that could be molded to accomplish the same feat.

This kind of stuff is the bread and butter of Racket. For example Racket comes bundled with an implementation of Algol 60 that lets you write Algol in your Racket programs. https://docs.racket-lang.org/algol60/

There's two implementations of Javascript https://docs.racket-lang.org/ecmascript/index.html and https://docs.racket-lang.org/javascript/intro.html, an implementation of Forth https://docs.racket-lang.org/forth/index.html and a lot more.

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by henryaj on Wednesday November 10, 2021 @04:57AM (#29172956)
In e.g. the Algol example, it seems like you just get a function which can accept an Algol program as a string and run it. Seems quite different from what's been done in this case.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by gopiandcode on Wednesday November 10, 2021 @07:31AM (#29173933)
I think the process is exactly the same as the ruby example, except for the fact that while in ruby it was a hack, in racket, a programming-language programming language, is explicitly designed to allow for this kind of process. The linked website just mentions that the algol60 package also provides additional functions that allow executing over strings. The default mode of usage is to place a "#lang algol60" at the start of your files, and that configures the lexer/parser to allow the rest of the file to be parsed and interpreted as ALGOL code (just check out the examples in the packages's git forge page).
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by dwohnitmok on Wednesday November 10, 2021 @11:37AM (#29176696)
Yeah. Here's an example. It's exactly the same as any other Algol file except for the lang declaration at the top.

https://github.com/racket/algol60/blob/master/examples/nquee...

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by robotmay on Wednesday November 10, 2021 @06:33AM (#29173555)
I've always thought it a bit of a shame that Ruby isn't more popular for Raspberry Pi projects. I mean, I use it, but the standard is still Python. And Python is great, don't get me wrong, but Ruby is just so much fun for hobby projects.

I used to try to write things in the most popular language for those things, like writing Prometheus exporters in Go. But I eventually realised I just didn't care that much, and now I write them in Ruby, and everything is sunshine and happiness again.

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by antifa on Thursday November 11, 2021 @08:24PM (#29195342)
Have you checked if crystal has enough raspberry Pi momentum?
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by dnautics on Wednesday November 10, 2021 @08:06AM (#29174210)
You should really look into the nerves platform.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by robotmay on Wednesday November 10, 2021 @08:07AM (#29174220)
Oh I totally forgot about that - I think I played around with it a few years back. I should check in and see what has changed, it was rather cool.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by dnautics on Wednesday November 10, 2021 @08:10AM (#29174245)
Last month I participated in a workshop with nerves + livebook and it was insane.

At the end we did a demo where we clustered all of our pis and we could send messages to each other's lcd screens.

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by allcentury on Wednesday November 10, 2021 @08:24AM (#29174348)
Can you share the workshop?
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by dnautics on Wednesday November 10, 2021 @08:35AM (#29174433)
Sorry, I looked for it but I couldn't find it. But the conference was nervesconf.

Edit: protip go to the GitHub of the training person: https://github.com/jjcarstens/nervesconf2021_training

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by specialp on Wednesday November 10, 2021 @10:08AM (#29175378)
It is both one of Ruby's greatest strengths and weakness. I found that metaprogramming was overused in Ruby with an obsession for clean syntax. This then made many projects very hard to debug, and many runtime errors that have traces like "in method_missing at line 68". Like you can't even grep where the code is being called or what was being called.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by tmm84 on Wednesday November 10, 2021 @08:57PM (#29183592)
This has been my personal frustration with Ruby projects. Basic Ruby is easy to understand but metaprogrammed Ruby requires mastery of the Ruby REPL and a mental model to see where something could be going wrong. Save a few lines for an implementation but spend hours trying to modify/debug it.
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by forty on Wednesday November 10, 2021 @03:14AM (#29172304)
> don't know of any other language that could be molded to accomplish the same feat.

I guess any languages that have some kind of macros, like C, scala or rust.

Re:A no-go fantasy: writing Go in Ruby with Ruby Next by honkobonko on Wednesday November 10, 2021 @04:22AM (#29172702)
I think its a bit rude to put C macros in the same sentence as scala (not sure about it) and rust
Re:A no-go fantasy: writing Go in Ruby with Ruby Next by forty on Wednesday November 10, 2021 @07:30AM (#29173925)
Haha as a scala and rust lover I can only agree with you, though one thing you cannot deny to C macros is that they are pretty flexible ^^