7 ms·
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 p
by mythz 5y ago
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 https://github.com/mame/quine-relay
- dwohnitmok 5y ago> 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/ https://docs.racket-lang.org/algol60/ There's two implementations of Javascript https://docs.racket-lang.org/ecmascript/index.html https://docs.racket-lang.org/ecmascript/index.html and https://docs.racket-lang.org/javascript/intro.html https://docs.racket-lang.org/javascript/intro.html, an implementation of Forth https://docs.racket-lang.org/forth/index.html https://docs.racket-lang.org/forth/index.html and a lot more.
- henryaj 5y agoIn 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.
- gopiandcode 5y agoI 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).
- dwohnitmok 5y agoYeah. 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/nqueen.a60 https://github.com/racket/algol60/blob/master/examples/nquee...
- forty 5y ago> 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.
- honkobonko 5y agoI think its a bit rude to put C macros in the same sentence as scala (not sure about it) and rust
- forty 5y agoHaha 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 ^^
- deleted 5y ago[deleted]
- robotmay 5y agoI'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.
- dnautics 5y agoYou should really look into the nerves platform.
- robotmay 5y agoOh 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.
- dnautics 5y agoLast 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.
- allcentury 5y agoCan you share the workshop?
- dnautics 5y agoSorry, 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 https://github.com/jjcarstens/nervesconf2021_training
- 5y ago
- specialp 5y agoIt 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.
- tmm84 5y agoThis 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.