3 ms·
The Web Pipe Programming Language
- williamcotton 9mo agoTechnically 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 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-pipe 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-pattern-in-custom-dsl 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#L309-L347 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 https://github.com/williamcotton/webpipe-lsp And of course my blog is written using this language: https://github.com/williamcotton/williamcotton.com/blob/main/app.wp https://github.com/williamcotton/williamcotton.com/blob/main... I would love some feedback!