Live data from Hacker News

Rye: Homoiconic dynamic programming language with some new ideas

github.com

51–60 of 86 posts

Re: Rye: Homoiconic dynamic programming language with some new ideas

#51

The blog entry titled "Less variables, more flows example vs Python" is strange. ( https://ryelang.blogspot.com/2021/11/less-variables-more-flo... ) The Python version uses intermediate variables so the author of the code is to blame for verbosity, not the language.

ISTM the big difference is that the Python code is doing CGI essentially from scratch, but the rye code appears to be using a CGI library.

Re: Rye: Homoiconic dynamic programming language with some new ideas

#52

Earlier quoted context omitted.

This took me a minute to get, even after looking at the page about if : https://ryelang.org/meet_rye/basics/if_either/ The tricky thing about if , and , and or --- the reason you can't implement them as functions in most languages --- is that they need to not evaluate all their arguments immediately. Otherwise: // Would print! if(false, print("oops!")) // Would throw an error if the key is not present and(my_hashmap.…

As done in Smalltalk.

Smalltalk may be influential, but is now rarely used.

The code block approach is widely applied in two massively used industrial languages though: Ruby and Kotlin. In Kotlin specifically it's one of the very central features.

Re: Rye: Homoiconic dynamic programming language with some new ideas

#53

Earlier quoted context omitted.

Yeah I did notice in the examples fac: fn { x } { either x = 1 { 1 } { x * fac x - 1 } } ; function that calculates factorial So presumably "either" is the "if" expression.

"if" is the "if" expression - https://ryelang.org/meet_rye/basics/if_either/

Yeah, but "either" is the if-else construct, so the person you replied to isn't really wrong.

Re: Rye: Homoiconic dynamic programming language with some new ideas

#54
post #40

Earlier quoted context omitted.

This took me a minute to get, even after looking at the page about if : https://ryelang.org/meet_rye/basics/if_either/ The tricky thing about if , and , and or --- the reason you can't implement them as functions in most languages --- is that they need to not evaluate all their arguments immediately. Otherwise: // Would print! if(false, print("oops!")) // Would throw an error if the key is not present and(my_hashmap.…

> The way that ryelang gets around this is that you pass the arguments in a "code block" surrounded by "{}" Like Lisp’s QUOTE which has to be a special form.

In the maxima computer algebra system[1] which was ancestrally based on lisp it has a single quote operator[2] which delays evaluation of something and a "double quote" (which acually two single quotes rather than an actual double quote) operator[3] which asks maxima to evaluate some expression immediately rather than leaving it in symbolic form.[4]

[1] https://maxima.sourceforge.io/

[2] https://feb.kuleuven.be/public/u0003131/WBT23/wxMaxima/wxM_i...

[3] https://feb.kuleuven.be/public/u0003131/WBT23/wxMaxima/wxM_i...

[4] although (in my limited experience) maxima sometimes refuses to evaluate anyway even if you do the double quote thing

Re: Rye: Homoiconic dynamic programming language with some new ideas

#55
post #33
post #31

Earlier quoted context omitted.

Likewise in Tcl where blocks can either be sent quoted (using {}) or unquoted (using “”). In the latter, variables and procs will have a round of substitution performed before being passed to the proc.

Rebol (where Rye took this from) is many times associated with Tcl. I've heard good things about it, but haven't really tried it yet.

TCL is kinda similar to Rebol in some ways but in other ways it's the opposite of Rebol, because in TCL everything is a string (although it can ALSO have another type, thanks to clever shenanigans). (You probably knew this!)

Re: Rye: Homoiconic dynamic programming language with some new ideas

#56
post #51

The blog entry titled "Less variables, more flows example vs Python" is strange. ( https://ryelang.blogspot.com/2021/11/less-variables-more-flo... ) The Python version uses intermediate variables so the author of the code is to blame for verbosity, not the language.

ISTM the big difference is that the Python code is doing CGI essentially from scratch, but the rye code appears to be using a CGI library.

The Pyhton side does have import cgi. It also uses req library for request parsing and making a post request. Only for cookies it uses os.environ which is maybe a little unusual, but I didn't specify in fiverr request what libraries to use or not use.

Re: Rye: Homoiconic dynamic programming language with some new ideas

#57
post #2

> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?

In a eagerly evaluating functional language you could always wrap the arguments in a thunk:

So if your built-in functions were implemented in Python, you'd use:

  def if_(cond, t, e):
    if cond:
      return t()
    else:
      return e()

Re: Rye: Homoiconic dynamic programming language with some new ideas

#58
post #55
post #33

Earlier quoted context omitted.

Rebol (where Rye took this from) is many times associated with Tcl. I've heard good things about it, but haven't really tried it yet.

TCL is kinda similar to Rebol in some ways but in other ways it's the opposite of Rebol, because in TCL everything is a string (although it can ALSO have another type, thanks to clever shenanigans). (You probably knew this!)

I heard this "everything is a string" line many times abot Tcl and it sounded a little unusual, but I havent delved deep enogh in tcl to see what it really meant and brought. I will.

Re: Rye: Homoiconic dynamic programming language with some new ideas

#59
post #4
post #2

> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?

Presumably as functions, the same way as excel? and(x, y) -> bool or(x, y) -> bool if(cond, funcTrue, funcFalse) -> void

    if(and(or(cond1, cond2), cond3), effect1(), effect2())
In most languages, if `cond1` evaluates to true, you would not evaluate `cond2`. If `cond1` and `cond2` evaluate to false, you would not evaluate `cond3`. If all conds evaluate to false, you would not evaluate `effect1()`, and if `cond3` and either `cond1` or `cond2` are true, you would not evaluate `effect2()`

They're not functions because they don't evaluate their arguments before evaluating their body. Their operands are passed verbatim and evaluated explicitly by the body on demand.

In Kernel, for example, we can define these as operatives, which don't evaluate their operands. Assuming we have some primitive operatives `$cond`, `$define!` and `$vau` (the constructor of operatives), and an applicative `eval`:

    ($define! and
        ($vau (lhs rhs) env
            ($cond ((eval lhs env) (eval rhs env)
                   (#t #f)))))
                   
    ($define! or
        ($vau (lhs rhs) env
            ($cond ((eval lhs env) #t)
                   (#t (eval rhs env)))))
                   
    ($define! if
        ($vau (condition consequent antecedent) env
            ($cond ((eval condition env) (eval consequent env))
                   (#t (eval antecedent env)))))
These aren't the definitions Kernel uses in its standard environment. It uses recursive definitions of `$and?` and `$or?` which take arbitrary number of operands, and `$cond` is defined in terms of `$if`, which is primitive:

    ($define! $cond
        ($vau clauses env
            ($if (null? clauses) #inert
                 ($let ((((test . body) . rest) clauses))
                    ($if (eval test env)
                         (apply (wrap $sequence) body env)
                         (apply (wrap $cond) rest env))))))

    ($define! $and?
        ($vau x env
            ($cond ((null? x) #t)
                   ((null? (cdr x)) (eval (car x) env))
                   ((eval (car x) env) (apply (wrap $and?) (cdr x) env))
                   (#t #f))))
                   
    ($define! $or?
        ($vau x env
            ($cond ((null? x) #f)
                   ((null? (cdr x)) (eval (car x) env))
                   ((eval (car x) env) #t)
                   (#t (apply (wrap $or?) (cdr x) env)))))

Re: Rye: Homoiconic dynamic programming language with some new ideas

#60
post #57
post #2

> Rye is homoiconic, it has no keywords or special forms (everything is a function call, everything is a value) How does it implement and , or , or if ?

In a eagerly evaluating functional language you could always wrap the arguments in a thunk: So if your built-in functions were implemented in Python, you'd use: def if_(cond, t, e): if cond: return t() else: return e()

[deleted]
Post reply on HN