logoalt Hacker News

shevy-javatoday at 12:35 PM3 repliesview on HN

    fn contains(range: &AddrRange, addr: &IpAddr) -> bool {
      range.min <= addr && addr <= range.max
Looks ugly as fudge.

Syntax is not everything, but it also shows that people too easily think they are great at language design when they really aren't. It's fascinating to watch how people continue with such an approach. How many people are going to use that over, say, python?


Replies

tertstoday at 3:56 PM

Hi! Author here. You're looking at Rust code there. Roto is very similar but without `&`. I wont pretend to be good at language design, but being similar to Rust has many advantages.

ModernMechtoday at 1:19 PM

  def contains(range_: AddrRange, addr: IpAddr) -> bool:
    return range_.min <= addr <= range_.max
I don't get it, how is that much better?
hellzbellz123today at 1:49 PM

you missed the closing bracket.

glad you like python, but a good reason to use this is setup being easier, also for people using rust, chances are the syntax is better compared to python. (also for what its worth, i picked up rust MUCH faster than i ever did with python)

the main reason i like rust is its explicitness in typing along with its syntax choices. memory safety means little imo, outside of being difficult to do strange stuff (which could be good or bad depending on your approach)

cargo add roto

code main.rs

-FILE- main.rs use roto::*;

fn main(){ roto::init_runtime() roto::load_script("hello.roto") }

-FILE-END-

code hello.roto

-FILE- hello.roto fn main() { print("Hello, world!"); } -FILE-END-

cargo run