Settings

Theme

The Web Pipe Programming Language

github.com

2 points by williamcotton 14 days ago · 1 comment

Reader

williamcottonOP 14 days ago

Technically this is a DSL and not a general purpose language!

Here's an example of the latest thing I was playing around with:

  GET /:city/weather.svg
    |> fetch("https://geocoding-api.open-meteo.com/v1/search?name=" + .params.city + "&count=10&language=en&format=json", {method: "GET"})
    |> jq: `{
      latitude: .data.response.results[0].latitude | tostring,
      longitude: .data.response.results[0].longitude | tostring
    }`
    |> fetch("https://api.open-meteo.com/v1/forecast?latitude=" + .latitude + "&longitude=" + .longitude + "&hourly=temperature_2m", {method: "GET"})
    |> jq: `
      .data.response.hourly as $h |
      [$h.time, $h.temperature_2m] | transpose | map({time: .[0], temp: .[1]})
    `
    |> gg({ "type": "svg", "width": 800, "height": 400} ): `
      aes(x: time, y: temp)
        | line()
        | point()
    `
That "gg" middleware is another project I started very recently: https://github.com/williamcotton/gramgraph

The language is polyglot in nature. Pipelines and DSLs all the way down.

I do a lot of data analysis and typically write bash scripts that query a database, return csv, pipe, plot with ggplot2, etc, and I wanted a similar sort of environment for writing web applications and whatnot.

Here's an introduction: https://williamcotton.com/articles/basic-introduction-to-web...

Here's an article on the the GraphQL implementation, complete with Data Loader pattern baked in: https://williamcotton.com/articles/graphql-dataloader-patter...

Personally my favorite bit is how the the BDD-testing framework is baked right into the language and runtime, which allows for some cool interactions with the LSP: https://github.com/williamcotton/webpipe/blob/main/todos.wp#...

Oh, and here's the LSP (with GIFs showing some features), which also integrates with a full DAP step debugger: https://github.com/williamcotton/webpipe-lsp

And of course my blog is written using this language:

https://github.com/williamcotton/williamcotton.com/blob/main...

I would love some feedback!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection