Preskoči na glavno vsebino

Objave

Prikaz objav, dodanih na april, 2021

Html parsing dialect demo

In the last post I said that I will focus on data (pre)processing with Rye next and gradually try to make Rye a useful tool in this smaller niche. I already made few demos in this area previously. The first step will be making a HTML parsing / scraping functionality in a form of a custom dialect . The dialect will share most of the traits with other tree navigation dialects (XML, JSON, ...). It's a "streaming" parser, Sax (not DOM) like. This means it doesn't load document into memory and then you navigate it, but it "streams" the document and you can react to events of finding specific nodes. This way you can parse huge files, it's very memory efficient and documents can be parsed as they are loaded. Below is an image of the Rye repl that shows few examples. I will write a tutorial about the dialect soon. New code will be pushed to github in next few days.  

Rye's html parsing dialect

In the past I experimented with plenty of libraries, to see how Rye behaves in different scenarios. Now is the time to touch the ground a little. To make any impact I decided to focus on a niche that is interesting to me and where I think Rye's features can be effective.  I will focus on data/information retrieval, (pre)processing and also exporting and try to make Rye usable in this smaller niche. I stared by adding a html parsing dialect. It's based on Go's "golang.org/x/net/html" library. The dialect so far looks the same as the one I made for (SAX) XML parser. More examples to follow.

Rye meets Raylib #2 (more namespacing)

This is a continuation from the previous post . When we communicate, which programming is, we try to be not overly verbose and redundant. Communication between people usually happens inside some context hierarchy. A fork when two programmers chat is a different thing than when two chefs do. One of the goals of Rye is to enable succinct, well flowing code and use of short words for functions helps with that. That's why generic methods are an important part of the language. Many times the first argument providing the context works well. But sometimes this is redundant also. Given that the contexts/scopes are first class Rye values, we can construct a context that holds all words of our Raylib game engine. Contexts can link to parent context, so Raylib words have a priority, but everything else works as normal. Let's create this context: And use it. Comparable Go code is on the left: Because we can create custom "looping constructs" in Rye, I just replaced for loop and

Rye meets Raylib (and namespacing)

To start things again I decided to make a minimal Raylib integration and see what it teaches me/us about the language. Raylib is a very interesting project on it's own, it's a " simple and easy-to-use library to enjoy videogames programming ". It works on an unusual number of platforms (also Linux, rPi and Android), has bindings for many programming languages (in Rye we use golang of course) and has a nice straight-forward API, with good support for graphical primitives that could also be good for quick immediate UI/visualisation experiments, similar to (imho legendary) Processing . One question I asked myself was how to best "namespace" the raylib related words. I had one more unusual idea that I might try later, but for now I made words generic, dispatch on the first argument which is raylib native. The screenshot shows really minimal example using two styles of coding. A more usual one with variables and the one using the pipe/op words and so called &q