Preskoči na glavno vsebino

Objave

Chat-like interface for the terminal in Rye

Rye is at this point focused on becoming a useful tool for use in Linux shell (the server/back-end tasks). So I integrate it with the libraries that make sense there and I also like to improve the whole terminal capability of Rye.   I got some idea (one of many of this kind, we will see how this one goes :P) that I could make a set of interactive tasks, that could teach my two kids (and others potentially) about how the computer works, and how you can work with a computer through Linux shell. For this I would need some sort of interactive terminal based user interface, I imagined something chat like. See how the "game" looks in action with asciinema . Above is a small demo of the idea after a day of work on it. It's in form o a very very small text based adventure game :). To make this work I needed to create basically 2 functions, chat (and chat-lines for now) and choice. I wanted to use short, context specific words to do all this so I created it inside a chat-tui co...

Ryelang Reddit group and Ryelang org domain, focus ...

Reddit After a motivating email by my unofficial handler :) (@otobrglez), I decided to move Rye up another step again. In the past, he also pushed me to put Rye on github , make it more orderly and presentable, able to run on docker, and other such bad things :). A reddit group was created /r/ryelang . You are welcome to check it out, join, like and comment on things: reddit.com/r/ryelang/ To kick things off, I've re-posted few more interesting examples from this blog there (with new accompanying text, mind you). And I've also created few original posts that might be of interest to you: Rye basics: a gentle introduction trough Python examples #1 Rye basics: a gentle introduction trough Python examples #2 Rye basics: a gentle introduction trough Python examples #3 Domain I also bought the domain, which will be the main hub around Rye language: ryelang.org There is not much there yet, just a few lines of Rye that run the webserver. I've never yet tested Rye on a long run...

Interactively displaying Rye values in Console

Still in the theme of blurring the line between programming languages and user interfaces , I improved the display function. It interactively displays Rye values. Enter returns the selected value as you would return it with code, escape returns Void. Blocks, Dicts, Spreadsheets and SpreadsheetRows now work with display . Next I need to make it work with contexts, then adding an option to recursively enter and exit sub-values (I am not sure how I would make that visually yet), add search, select ... This is also a stepping stone towards more interesting and not yet fully developed ideas, so I hope I will work on this more soon. It this sounds interesting you can follow further development on Github or our absolutely new Reddit group !  

Function docstrings, sub-contexts, language as an UI

In the last blog-post I showed a simple utility script that de-duplicates some information. I made a quick interactive solution by using just Rye console to interact with the functionality. I still keep to the idea of language as an user interface , which this simple example was sort of.  For it to be a little better user interface, the ls function mentioned upon entering the console should only display relevant functions, not all Rye's builtin functions. This can be achieved easily with contexts. Normally, when a file evaluates, it's context is the same as the root context of the language. But I now added a --subc flag to Rye executable, which runs code in a sub-context of the root context. So ls just shows what was defined in current code. It also makes sense for ls to show more than just word names, but also descriptions of functions. I added a "docstring" option to Rye function syntax. Both can be seen below. We could very simply create a context for the con...

Simple example of de-duplicating contacts (SQLite)

I must first excuse myself. I haven't been working on Rye for a while. It's not that I forgot about it, far from it, but my regular projects took over for a while. I needed to make major updates at the end of the year at some project, and also re-started a SaaS project for compact support teams that I created in Rebol more than 10 years ago, used ever since, but haven't found time to finalize and offer to others yet. I was also struck a little by ChatGPT demos, and took some time to familiarize myself with GPT, BERT and similar techologies. This was all Python based, so I had no chance to inject it with Rye. This period is unfortunately not over yet, but last week I needed to make a simple script on one of the servers, to de-duplicate some data. Users entered the same contacts multiple times and assigned tasks to them. Script needed to find the duplicates (triplicates, etc.), assign all tasks from the older one to the newer one, and remove the older contact. For the simp...

Advent of Code 2022 - Day 3 - reduce, fold, add-up

This is the Day 3 puzzle for #AoC2022 with Rye. Rye has reduce and fold functions. The difference is, that reduce doesn't accept initial value, so it can be less verbose in some situations, but you need an initial value many times, like when you are adding things up. Initial solution used fold to sum the priorities up, hence it needed initial zero and also an accumulator word (priority, priority1). You don't need to define a word for current value as usually with reduce/fold, because it's injected into code block.     I don't particularly like fold name, because it sounds like CS (computer science) "speak", not something that a person would intuitively name this functionality.  I'm not sure I will find any better name thou, but I thought today it would make sense to make a specialized function for summing/joining things up. That way I can get rid of the initial value (it can be inferred from the type of first returned value) and the accumulator word as...

Advent of Code 2022 - Day 1 & 2 with Rye

Yesterday @pkese and @otobrglez from Twitter made me aware of the Advent of Code 2022 . Oto made his solution in Scala and ZIO and Peter used F#. Both looked cool. I had very little time last two weeks, so almost none for Rye. I was planning for a blogpost about failure handling next.  Well today I couldn't help myself and made a solution for Day 1: "Calorie Counting":     It's really fun, try for yourself: https:// adventofcode.com/2022/day/1   If you just want to watch and compare the languages, there is this reddit megathread for Day 1. I also added my Rye solution :). Update I also solved Day 2. challenge "Rock Paper Scissors". I added two functions to Rye: reverse! and read\lines, others were already there. Star an follow Rye/me on Github .