Better HN
topnewbestaskshowjobs
Log inSign up

mitghi

69 karma · joined Nov 5, 2014 (12y ago) · 36 submissions

Submissions

comment 6mo ago · link · parent

I see the point you mention, in that case, I think a language like Haskell is the better choice, so it could be marketed as an "agents" language that hit the market three decades before today’s agents :)

comment 6mo ago · link · parent

Why Zero when there are countless alternatives?

comment 6mo ago · link · parent

I believe there are currently some efforts underway as part of projects like jaq ( https://github.com/01mf02/jq-lang-spec ), though I’m not familiar with the current status. It is true, however, that many implementations introduce some minor changes.

comment 6mo ago · link · parent

Hey everyone,

I’ve been building Jetro, a Rust JSON query language inspired by functional language paradigm.

The project started about three years ago, but recently went through a serious design overhaul. The newer direction is planner-driven, and focused on being expressive without becoming overwhelming.

It aims to cover much of the everyday usefulness of jq, but with a smaller, more approachable query language and a Rust embeddable engine. Jetro uses simd-json as its primary JSON parser and tries hard not to do unnecessary work on top.

One fun part is demand propagation:

    use jetro::Jetro;

    let j = Jetro::from_bytes(bytes)?;
    let out = j.collect(
      "$.orders
        .map({ id: @.id, total: @.items.map(@.price * @.qty).sum() })
        .filter(@.total > 100)
        .map(@.id)
        .first()"
    )?;

In many query languages, this kind of chain naturally becomes:

    parse/materialize all orders
    compute totals for every order
    filter all shaped orders
    extract all ids
    then take the first one
Jetro tries to read the chain from the end backward and ask what is actually needed. Then elements stream through the pipeline only until that need is satisfied:

    need one id
    <- need one matching order
    <- pull orders one at a time
    <- compute total for the current candidate
    <- if it matches, emit the id and stop
So the pipeline is not "finish every stage, then move to the next." It is more like: pull one item, shape it, test it, maybe emit it, and stop as soon as the query has enough.

The same idea works for richer object-shaping queries too:

    let out = j.collect(
      "{
        errors: $.events
          .drop_while(@.level != 'error')
          .filter(@.service == 'checkout')
          .map(match @ with {
            { level: 'error', message: msg, timestamp: ts } -> {
              kind: 'error',
              ts: ts,
              msg: msg
            },
            { level: 'warn', message: msg } -> {
              kind: 'warning',
              msg: msg
            },
            _ -> {
              kind: 'other'
            }
          })
          .take(20),
    
        slow_orders: $.orders
          .filter(@.latency_ms > 500)
          .map({ id: @.id, latency: @.latency_ms })
          .take(10),
    
        first_vip: $.customers
          .filter(@.tier == 'vip')
          .map({ id: @.id, region: @.region })
          .first()
      }"
    )?;

There’s also jetrocli for terminal, a book for learning the language.

Would love get some feedbacks, or ideas for what would make this useful to you.

Thanks

Jetro CLI: https://github.com/mitghi/jetrocli Book: https://github.com/mitghi/jetro-book

5.

Jetro – JSON query engine for Rust (jq-like DSL with compilation and VM)(github.com ↗)

15 points · by mitghi · 6mo ago · 3 comments

6.

Show HN: Parse Prometheus Exposition Format in Rust Using Pest(medium.com ↗)

1 points · by mitghi · 3y ago · discuss

7.

Show HN: Jetro – transform and query JSON format(crates.io ↗)

1 points · by mitghi · 3y ago · discuss

comment 4y ago · link · parent

Do you mean Source Engine?

9.

Show HN: Concurrent Sharded HashMap for Rust(github.com ↗)

2 points · by mitghi · 4y ago · discuss

10.

Show HN: Quartz.rs Minimalistic scheduling library for Rust(github.com ↗)

1 points · by mitghi · 4y ago · discuss

comment 4y ago · link · parent

How is this called a Buffer Overflow and not a logic error? you are not overflowing the buffer and rewriting the registers, but taking the user input in the same buffer that holds the password and writing the user input from beginning of the buffer. It is not overflowing anything, only wrong bound check for user input. You can't write past the buffer, Rust will halt the program and throw an error.

It could be more interesting to have another buffer holding user input and then overflow it and corrupt the password buffer.

I am curious if that is possible without using unsafe?

comment 5y ago · link · parent

Singularity is near

comment 5y ago · link · parent

Nice article. Have you tried to compile the program with '--release' flag? Because Cargo builds for debug by default. If you build the program for debug then its slower.

comment 5y ago · link · parent

Its possible to use partial function to simulate method calls in C by memoizing the first argument which is always a pointer to the struct that method is getting called from. It requires little assembly. Check this: https://github.com/sharow/experiments/tree/master/partial

15.

Show HN: Lock Free MRMW Ring in Go(github.com ↗)

2 points · by mitghi · 6y ago · discuss

16.

Show HN: Protox client generator(github.com ↗)

2 points · by mitghi · 7y ago · discuss

17.

Show HN: Go X Utilities: Double CAS, Atomic Slice, Pointer Tagging and More(github.com ↗)

2 points · by mitghi · 7y ago · discuss

18.

Show HN: Protox high performance message broker(github.com ↗)

3 points · by mitghi · 7y ago · discuss

19.

Show HN: Lock-Free MRMW Ring Buffer for Go(github.com ↗)

1 points · by mitghi · 9y ago · discuss

20.

Show HN: BuffPool, a recycling pool with lock-free context(github.com ↗)

2 points · by mitghi · 9y ago · discuss

21.

Show HN: Python client for Tile38(github.com ↗)

7 points · by mitghi · 9y ago · discuss

22.

Show HN: Routers. simple, dynamic routing for django(github.com ↗)

2 points · by mitghi · 10y ago · discuss

comment 10y ago · link · parent

No, i suggest to check lthread.

24.

Show HN: Libconcurrent – Coroutines in C(github.com ↗)

91 points · by mitghi · 10y ago · 24 comments

25.

Show HN: CSpider – Scalable Webcrawling framework in C(github.com ↗)

2 points · by mitghi · 10y ago · discuss

26.

Show HN: Cyuri – Python wrapper for uriparser(github.com ↗)

2 points · by mitghi · 10y ago · discuss

27.

Show HN: Thread Safe Priority Queue in C(github.com ↗)

2 points · by mitghi · 10y ago · discuss

28.

Show HN: Simple Lock-Free Queue in C(github.com ↗)

5 points · by mitghi · 10y ago · 2 comments

12