Show HN: Arturo – REBOL-inspired programming language and VM written in Nim
github.com
github.com
Any chance you'll be adding something like the parse function? The ability to have domain-specific dialects was one of the best things about Rebol and would be great to see in a modern language.
And speaking of functions, could you make the "Function Reference" that's on the homepage, be available on a standalone page too? It's a very useful reference and would be great to access it easily. Thanks!
Regarding 'parse', it's absolutely in my to-do list. Although, already, the language by its very nature has the means to do it (even you, as a user, could) - but I have to prioritize things.
Regarding reference, it's obviously a work-in-progress. However, what you mean is probably already available @ GitHub Wiki: https://github.com/arturo-lang/arturo/wiki
Have a look :)
Looking forward to hearing your feedback. Anything is welcome, ideas or suggestions :)
Let me know what you think! :)
Another REBOL-inspired language is Red [0], which also looks interesting.
Maybe I'll actually sit down and have a proper look one of these days.
In any case, I'm all ears for feedback/ideas/suggestions. Code contributions are more than welcome as well - it's been just a one-guy thing so far, and I can honestly not find time for everything :)
Anyway, Arturo looks interesting and I'm looking forward to try it!
Even using it as an inspiration, it's obvious that I absolutely respect both projects.
Again, what I'm trying to do is take the good points and create something completely new.
Looking forward to hearing your feedback/ideas/suggestion/anything. I'm all ears! :)
(Code contributions are also 100% welcome!)
My attempt here is nothing too bloated. I just needed a super-flexible, easy to use (and tweak) programming language for me (automation, templates, typesetting, "quick" scripts and webview-based app publishing). So, I created it.
It's by no means "complete" - yet. Although, after months (to years) of hard work, I think it's ready to get a bit more known. At least, my personal goal has been achieved: Arturo is the language I personally use for my everyday scripting. :)
Besides, there are only a few active contributors helping the project, others, unfortunately, prefer to watch from afar and wait, or to pick Red apart feature-by-feature for other languages — and TBH I don't know if this is a historical problem with Rebol family or lack of goal-oriented communication from Red's side which would encourage people to participate (e.g. write a Postgres driver).
loop 1..10 'x [
if? even? x -> print [x "is even"]
else -> print [x "is odd"]
]
I can't find any reference for what the arrow is doing. It looks like a lambda in the first part (x -> print [x "is even"]), except that would mean that's getting passed to "even?" instead of "x". But that doesn't make sense for the second one, so is the arrow part of "if?"/"else" or is it an alternate way of wrapping the print in a block? Or something else?So...
The command "if?" takes two arguments: a boolean and a block.
Think of it like if? <something> [do something-else].
In this example, something is `even? x` and something-else is `print [x "is even"]`.
And yes, regarding the right-arrow symbol you are absolutely correct: it's syntactic sugar for wrapping a command in a block (provided that it's just ONE command - if there are more than one, you will have to use a block).
But it's still syntactic sugar as ALL symbols being used in Arturo. Pretty much like ".." is the symbol infix-alias of the command "range".
Was also going to note the "?" in "if?" didn't make sense, due to how it's used in rebol, before finding core has both "if" and "if?", and "if?" does indeed return a boolean. Since both are there though, that does make it unnecessary in this particular example.
However, there is one thing that could be done with "if": in arturo, it's documented to always return null, however in rebol it returns the value of the evaluated block, making "if/else" and "either" work as a ternary (and just "if" returns a none! if it was false).
Now, why the two "if"s:
Obviously, as you yourself mentioned, 'if? returns a boolean (the result of the condition) and 'if doesn't.
So that's one use.
The next use - which I will obviously have to make crystal clear in the Language Reference - is that if? (with the ?) is a must if you want to pair with an "else".
Think of it this way. If?-else may appear as a language construct, but in fact they are two separate commands. The if? is an if - that pushes the result of the condition of the stack. And "else" is actually a reversed-if: it checks what is at the top of the stack (see: returned by the if? above) and if that is false - that is: the above if-condition was not true - it executes its block.
So, in that case, you have to use an "if?" (and not a simple "if")
The same thing happens with a case/when? construct (only, in that case, the condition blocks are actually concatenated),e .g.
case [x] when? [<3] [print "it was less than 3"] when? [=3] [print "it was equal to 3"] else [ print "it was greater than 3"]
:)
:)
One idea would be to add an .attribute, e.g. if.get - and then have it return a value.
Or, use a different function altogether.
But then we'd have, 3-4 if's. That sounds like a bit of an overkill, I admit.
I'm absolutely open to ideas :)
Let me know what you think! :)
[0] https://stat.ethz.ch/R-manual/R-devel/library/utils/doc/Swea... I haven't used it in a while, so it's the best explanation link I could find.
I'm thinking of the same thing for LaTeX (and perhaps even more sophisticated). One of my main "businesses" is centered around typesetting and electronic publishing, hence I'm a heavy ... LaTeX user.
Feel free to ask anything else. All suggestions and contributions are welcome! :)
Let me know what you think! :)
Rebol has absolutely been an inspiration. But I'm just trying a different take on it - a bit more flexible, more dynamic and with more modern programming language features.
Any idea/comment/suggestion or even code contribution is more than welcome! :)
And that was a conscious choice. Having different forms of declaring literals, in my eyes simply "litters" the language.
What Arturo does instead is use simple strings... And the interpreter internally tries to make out what they are automatically.
For example: the 'do' function can take pretty much anything. If it is a block, it executes it. If it is a string, it executes it too - but depending on what it is. If it is a url, it executes the remote script. If it's a local file, it executes the file. If it's Arturo code, it executes it as Arturo code.
The interpreter identifies what it is automatically. Why have different data types for that, pre-built in the language?
And this is the way it works throughout, with different functions - 'do' aside, that is.
For example, there is the very powerful 'read' function.
This may take a simple string (text), a file location or a URL. You obviously know what it is and the interpreter will figure it out itself as well.
Now, let's say you want to read a file:
read "myfile.txt"
"Reading" a webpage:
read "http://somewebsite.com/somewebpage"
Parsing JSON from a remote source:
read.json "http://somewebsite.com/data.json"
Or parsing it from a string:
read.json "[1,2,3]"
And 'read' also can take different attributes, e.g. .csv (for parsing CSV files), .html etc etc...
Basically you pass a string with its options and the interpreter figures out where to get it from and what to do with it... :)
Let me know what you think! :)
The point is to keep the syntax clean. (Ok, that would be an argument of going all the way, like Tcl, where everything ends up being a string - but let's just get the best of every world without overdoing it :) )
@9214 Since you are knowledgeable about the topic (included but not limited to Rebol/Red), I would be glad if you joined the effort. Even testing bits here and there would be great. You're welcome :)
Let me know what you think! :)
if? even? x -> print [x "is even"]
but I couldn't find it in Arithmetic, Comparison, Core, Logic, or Numbers - I figured those were the most obvious places to look.
I was wondering specifically if this example
loop 1..10 'x [ if? even? x -> print [x "is even"] else -> print [x "is odd"] ]
could be rewritten
loop 1..10 'x [ even? x -> print [x "is even"] odd? x -> print [x "is odd"] ]
and what other number checking things one could do - like decimal?, positive? negative?
Regarding the syntax:
every "function" in Arturo takes a specific number of arguments. in that case: loop, if?, even? else are ALL functions (there are no special constructs in Arturo, nor reserved keywords).
Regarding your second example/question: you could have written it like that, but it wouldn't do as you expect.
What can be done though is using the 'case function.
For any other questions, doubts, ideas or even code contribution, you're welcome to post anything at Github or via our Gitter community: https://gitter.im/arturo-lang/community or Discord: https://discord.gg/YdVK2CB
Let me know what you think! :)
Let me put it like this:
- Just open the REPL (Arturo's terminal) - Write: webview "Hello World!"
Although super-minimal, you already have a Webview-based GUI app with something in it. It's a starting point :)
Btw, have you managed to compile it on NetBSD? (It should run fine, I think, though I haven't tried it yet...)
P.S. A little bit of trivia: my choice of the scorpion logo was no random selection at all. Arturo was my little (well, not so little) Black Emperor scorpion that passed away in February. Hence, the name. And the logo...
Let me know what you think! :)
Let me know what you think! :)
Rebol - Arturo's ideological grandparent - is a great language (albeit not as well-known as it should be). And Arturo attempts to get the best bits of it and make a modern take on programming.
In the website (and the GitHub repo) you will find more than enough information about it.
Also, have a look at the wiki!
That being said, as I've already mentioned, my goal was not to make a Rebol replica. Arturo is a new language.
Now, regarding the "inspiration" part, to anyone that is familiar with Rebol, I think it would be fair to say that Arturo does look more like the Rebol group, than an Algol-type language, or ML, or Python type of language. I don't know... (I would really be intrigued to hear what it reminds you of... :))
My understanding so far is that Arturo has VM-based interpreter (perhaps stack-based or even indirect-threaded, hence the mention of Forth as an inspiration) which operates on a syntax tree (either concrete or abstract, although Rebol uses the former) produced from textual source during lexing. Is that correct?
Regarding "homoiconicity", the way I would succintly put it is that: the line between what is considered code and what is data is super-fine. Basically, anything can be anything - depending on the context. Thus, an Arturo script can manipulate its own code, the way it can manipulate any other type of data.
Regarding Arturo's implementation: It's written in Nim (though I have written it in the past in almost every language you can think of... lol started with C++, went to D, then to Nim, back to C, and now in Nim again). Basically it's a Stack-based Bytecode Virtual Machine. And yes, Forth's influence is also important - although (intentionally) not that obvious at first sight.
The source text is parsed to an abstract structure/tree of words and symbols. That's the part that happens in translator/parse.
Then if it's an executable block, it is evaluated (as valid Arturo code) into Bytecode (this happens in translator/eval), and then this bytecode is executed by the virtual machine (in vm/exec).