Virtual Meetup: Beads, a programming language to build every kind of application

I am happy to announce our next Virtual Meetup, this Thursday, the 8th of October.

This time Edward De Jong will present Beads, a programming language he created.

Beads is a programming language intended to be used to write all sorts of applications. In a sense, this is the opposite of a Domain Specific Language. You can find some examples on GitHub: https://github.com/magicmouse/beads-examples

The main focus of the author is to make the language as reliable as possible, capturing most errors at compile time.

Edward is an experienced developer, who is currently a VP of Engineering at Silicon Valley VOIP company.

Regarding futture meetings, please do not be shy and write to me at federico@strumenta.com to volunteer to present something at the next meetups. You can share an idea, a prototype, a topic for a discussion, a project you worked on. If it is related to Language Engineering we are interest to hear about it.

How to connect

After the summer we moved the meetup one hour earlier! From now on we will host them at this time.

If this is your first meetup you will find all the instructions to connect here:

(Long story short: click here https://zoom.us/j/278156178)

It is hosted on Zoom at 6PM GMT+2/CEST (you can use this link to figure out which time is in your timezone: https://www.thetimezoneconverter.com/?t=6%3A00%20PM&tz=Roma&).

My questions on a compiler tried to connect the dots: You mentioned an IDE should be written in Beads itself. Even if the actual compiler is stand-alone, a good IDE needs an almost compiler-like understanding of the language. You also mentioned that you chose not to focus on compatibility with another language. How would an IDE in Beads work then?

I started on an IDE, wrote a few thousand lines, and saw that it was quite straightforward, but it is a lot of work. Beads has a wonderful reflection system, whereby the compiler generates a big tree structure describing the data structures and code chunks that were written in the code, so it is a matter of grinding out all the visualizations of different value types, and making nice scrolling lists, etc. and trying to make the UI compact so that you can see your product and the IDE at the same time. A complex graph schema is difficult to pack in a small space. It would be great if you could mandate dual monitors.

Fragments of the toolchain have been written already, such as the “cycler” tool which allows you to cycle through how your program will look when run on a variety of machines, and orientations. That is a just a few hundred lines.

Another component that is shipping is the localizer, which is a translation management tool that lets you manage internationalized string tables. Thats about 1k LOC. It works great, and i used it to translate the Beads website into Amharic and Japanese as a test.

The tools i built so far are what you must have to ship a useful, localized product, and the IDE is not an essential tool, it would be fun to have, and would improve productivity somewhat, but at this point i need shipping products to validate the entire language. Even if i made programming fun, and convenient, i would still hear the same refrains, about how it doesn’t connect to C libraries, and that Google is going to win with Flutter, etc. Other on-the-up languages like Julia and Rust have all their proponents evangelizing.

So i am building a commercial product with Beads. It only takes one successful commercial product to support a language. I have a chart showing the 60 improvements over Python and Java, but one cannot appreciate all the many subtle improvements and error avoidances until one uses Beads for a little bit. The declarative model is so different than OOP, its like only having to write half your code, and the other half doesn’t need to be written any more, because the runtime does it for you. That’s the real secret weapon of the declarative model; what you don’t have to specify (and thus could make a mistake in specifying), is the big improvement. The part you do specify is just as hard as it was before. But half of the code doesn’t have to be written. That cannot be perceived looking at syntax or examples. You have to write something to sense this.

1 Like

Here you can find the slides from the presentation

Slides from the presentation

For those who did not attend:

  • Beads is a language intended to write applications with a GUI. It works to write web applications, mobile apps or desktop apps. In a way it is a replacement for multiple languages: forget HTML, CSS, and JS and just use Beads
  • It has an interesting feature: the possibility of using “time travel”. Every action is recorded and one can go back to a certain instant and use this feature to debug. When going back the screen is redrawn. The system knows which functions are “calculations” and which are “drawing”, so it can safely re-invoke the drawing one to get the picture that was displayed at a certain time
  • It contains support for localization
  • It contains support for advanced types like timeslots and physical units
  • It is a competitor/inspired by Flutter, Elm, Smalltalk, Modula-2 for different aspects
1 Like

@CodingFiend When I searched for ‘flags’ in the manual I found nothing, so it doesn’t support flags enums?

So Beads is implemented in ActionScript/Haxe? There’s a conversion of a WASM output class (from the Lobster language implementation) to ActionScript: https://github.com/recoyx/WASMOutput (original BinaryWriter by @aardappel, reference and example).

I am not sure what you mean by flags enums. If you mean booleans by flags, Beads has a yesno primitive type, which is similar to Boolean in some languages, however, in C Boolean has only 2 states (as it is 1 bit), in JS the Boolean has 3 values (true, false, undefined), and in Beads the boolean has 4 states as all primitive types include the base U state, and support an error state ERR. It is hard for people to accept that fourth state sometimes, but it is needed for symmetry across all data types.

The enum in Beads is similar to what Lisp called an atom, or JS calls a “symbol”. It is a unique value, determined by a hash of the letters, an it will map to a repeatable unique value across all compilations, and can be used as a numeric value (as it has a hidden from view unique value that will cannot be mistaken for an arithmetic-compatible value). The only operations that are valid on an enum are assignment and comparison. Any attempt to add or subtract to a value that is an enum will result in ERR. Beads uses the arithmetic style of Excel, which has a base value of #UNDEF and a universal error value of #ERROR. The enum thus allows arithmetic to be extended, so that you can avoid giving regular numbers some special meaning like -1 for “NOT SPECIFIED” or some such encoding which is so common in older languages.

There is a preprocessor in the spec for compile time #if, #then #else type of conditional code inclusion, etc.

If you mean by flags semaphores for multiprocessing, with the current focus being JS, they don’t have semaphores or conventional multiprocessing in JS. they worker threads but that isn’t full support for threads.

At present Beads exists as a transpiler mostly used to emit JS.

@CodingFiend Only C# so far supports flags enums. I meant constants internally implemented with bitwise operations, where constants are power of two (in C#, you use them in the form Enum.CONST_A | Enum.CONST_B; and e & Enum.CONST_A != 0; in ShockScript they appear as ['constA', 'constB'] and 'constA' in e).

Every language has idiomatic patterns.; In C to pack 4 different flags that could each be independently ON or OFF, you would use const FLAG1 = 0x01, FLAG2 = 0x02, FLAG3 = 0x04, FLAG4 = 0x08, and then you would typically combine these all into one integer quantity, and thus myval = FLAG1 | FLAG2, and would use various bitwise AND and OR operations.

I suspect C# is automatically generating power of 2 values for the enum constants.

However, in a language like Beads which uses sparse matrices/trees, there is zero cost for storing a 0 bit, so one would instead make a separate field name for each field. You would not try to pack them in tight; this is an artifact of a time when size was critical, and one was willing to sacrifice the two states which always exist anyway, namely “undefined” and “error” condition. In order to prove your system is correct, you must account for missing and erroneous data; you can’t properly classify error as either true or false, and this sloppiness pervades almost all languages. One of the reasons people can’t prove their programs correct, or more importantly guarantee their robustness, is that missing or erroneous information in most programs causes undefined/unpredictable behavior. To make a program rock solid, as i indend to, you have to track this small amount of information. I am arguing that a boolean cannot have less than 2 bits of storage. So one could do flag enums in a binary way if you wanted, by using up 2 bits for each flag.

2 Likes

I have just found this language, that reminded me of Beads:

It says you don’t have to use CSS, HTML, Javascript, just as you do in Beads.

If you are interested in Vaadin, you may be interested in this interview I did with Ben Wilson, from Vaadin https://tomassetti.me/application-modernization-an-interview-with-ben-wilson/