Preskoči na glavno vsebino

Objave

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 .  

A new way to work with Rye - Project local Rye binaries

When you are working on an "wide" project, like a language is, you have to limit your scope somehow. One self-imposed limit for Rye < 1.0 was, that I will not think about modules. Go compiler is known to produce single statically linked binaries. That means that a single file just works , no need for additional installations of any other Go runtime dependencies. This is very nice for distribution. Rye interpreter is also such single binary, and although Go, from version 1.5 supports use of shared libraries, I don't plan to make Rye's bindings dynamic for now. This is a limitation. If you have one global Rye, it has to be compiled in with all the bindings you need on your system. Tags to the go compiler define the modules, so defining them is not hard, but not something you want a Rye programmer to think about. Solving limitations often offers new avenues for innovation. Having a global programming language and global modules is problematic also in dynamic/shared s...

Spreadsheet in action - Transit data demo

I visit news.ycombinator.com - the Hacker News - at least few times a day. It often features interesting news items and intelligent comments. Last week I found a language comparison post by losvedir . Author thought of an interesting and compact problem around serving merged data from two CSV files over HTTP. Author so far tested idea only with static/compiled programming languages. Since Rye is focused on data/information processing and also on "the backend", this sounded like a perfect job for it. Rye also has this very high-level datatype called Spreadsheet (more about the reasoning in the previous blog-post ). This datatype, with some powerful functions, elegant setup for a HTTP server and easy loading of CSV files made whole Rye code very simple. While Go's solution used 180 lines of code and Rust 200 , Rye (which is a dynamic language) took just 38 lines . The problem Program needs to load two CSV files. First (trips) features 72k lines, second (stop_times) 1....