Low Code examples from other languages

One of the potential myths of Xojo is that it is low code. In some places, this may be true, but in t’other thread, I highlighted some examples of where this is false.

What I’d like to do is to share some more examples that have impressed me, and I encourage others to do the same in their languages.

This is the code that de-serializes my data model from JSON. By including it in this method, it doesn’t matter how the file is opened in the app, even from using the “Versions” option in the file menu.

    init(configuration: ReadConfiguration) throws {
        guard let data = configuration.file.regularFileContents
        else { throw CocoaError(.fileReadCorruptFile) }
        self.items = try JSONDecoder().decode( [MRAFunctionalityItem].self, from: data )

If the de-serialization fails for what ever reason, the app auto displays the error message to the customer. I don’t have to do anything to get that.

In the opposite direction, this code serializes my data model, and again, by putting the code in this method, it can be called when the user saves, when the OS auto saves document etc.

    func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
        let data = try JSONEncoder().encode( self.items )
        return .init(regularFileWithContents: data)

This code below is one of the latest I’ve learned and I think it’s pretty incredible. It not only displays a list of objects in an array, it also manages that list. If the customer rearranges the data in the list view, the data is updated to match, same with using the swipe action to delete data. This list will auto update if I change the data from anywhere else in the application. The list is fully native for each platform. In a document based app, all these actions auto generate an Undo and auto update when the customer performs an Undo.

List( $document.data.app.features, editActions:.all, selection: $multiSelection ) { $item in
    TextField( "Field Hint", text: $item.title )
        .focused( $focusedField, equals: item.id )
        .tag( item.id )

Those dollar signs in front of variable names, indicate that I want a binding, which means the view can update the property and if the property changes, the view should auto update.

That .focused modifier allows to me set focus on that field by simply setting a property called focusedField to the id of the item.

This next one is one of my favorites, code in-between these braces will now run as a pre-emptive thread on the efficiency core of the Apple Silicon processor, with full access to the object’s properties.

Task( priority: .background ) {

This code allows me to store temporary scene specific data, it is preserved between application re-launches, but is disposed of when the customer closes the window.

@SceneStorage( "editMode" ) var editMode: Bool = false

If I want to store a variable in the application preferences…

@AppStorage( "editMode" ) var editMode: Bool = false

While I like to annotate my variables with the defined type, it is not needed in Swift. I could just write var editMode = false.

Lastly, if I want to animate a view change (adding a row to a list or more), it can be done by simply wrapping that code in a withAnimation closure.

withAnimation( .bouncy ) { document.data.app.features.append( newItem ) }

Or I can attach animation modifiers to views that react on a property change.


8th can easily import JSON data:

"config.json" f:slurp json>

Naturally you can also encode data as JSON string:


JSONPath accessories are also supported, as is MessagePack.

Multithreading is also simple. Sample code below fetches and outputs ‘Hacker News’ top stories in order using 16 tasks:

needs net/http
needs array/parallel

"https://hacker-news.firebaseio.com/v0/topstories.json" constant STORIES_URL
"https://hacker-news.firebaseio.com/v0/item/" constant ITEM_URL_BASE

16 constant NUMTASKS

: get-ids  \ -- a
  STORIES_URL net:get if
    nip json>
    drop "Error retrieving data" throw
  then ;

: item  \ n -- s | null
  ITEM_URL_BASE "%s%d.json" s:strfmt net:get if
    nip json> null? if
      "Failed get." log
      "title" m:_@
    "Error retrieving data." log
  then ;

: get-top-stories \ a -- a'
  ' item NUMTASKS a:map-par ;

: print-top-stories  \ a --
  ( "*Error: failed get*" ?: . "\n" . ) a:each! drop ;

: app:main
  "Trying to fetch the 'Hacker News' top stories...\n\n" .
  get-ids get-top-stories print-top-stories ;

B4X Json parsing to a dictionary (map in B4X):

Dim m As Map = SomeJsonString.As(JSON).ToMap

And back to a Json String:

Dim SomeJsonString As String = m.As(JSON).ToString

yepp, inherited from java.

var root as new ItemPackage()


(Xojo Serializing from JSON to a complex and nested Entity object, showing here that Xojo can be low code too…of course this is using plugin but still…)

Sorry, no, but this is not the same as standard provided by the language syntax.

1 Like

What does self.items end up being ?
A dictionary ? A set of objects ?
Somehow I expect that what others are deserializing doesnt end up with the same or similar results

1 Like

I fail to see the difference, for such you would in C# grab nuget package (=> under the hood) and then deserialize in one line in same way. Most of the languages work like that link to some package and then do things.

1 Like

ok, so every language is low code… :roll_eyes:


Java didnt start out with json; and I suspect many other languages didnt either
It got added by some intrepid folks who wrote various implementations
And improved over time
Then adopted into the common runtimes that now ship with it
Thats not an uncommon pattern

COULD Xojo also follow such a path ? sure
WILL it ? entirely different question

8th uses JSON syntax for datatypes and JSON support is builtin including JSONPath accessors. I find it a really nice feature!

Is 8th DEAD??? Reading about it in this forum make me curious about BUT… The (maybe) oficial youtube channel videos are from 9 years ago. A channel from an “evangelist”, last video is 7 years old. In the forum for windows, the last post was from 2 years ago.

It is suposed to be a great multiplatform tool with GUI capabilities but, not a single screenshot, showcase or any real world app using it… Does it have an IDE? A Designer? They have listed 7 suposed proyects using it, only one has a link… and is DEAD… WTF?

The site has little info, the “FAQ” is mostly for purchasing questions but, purchasing what? lol. Looks like the 8th team really want to keep the product as a secret. :face_with_raised_eyebrow:

Do you have a real world app made with 8th to showcase?

I :heart: Python

import json

# from a json file to a dictionary ...
with open("config.json") as json_data:
    python_dict = json.load(json_data)
# from a dictionary to json string ...
json_string = json.dumps(python_dict)

# from a json string to a dictionary ...
python_dict = json.loads(json_string)
1 Like

No, it’s not dead and is actively maintained by it’s developer, Ron Aaron. There have been a new release in about every two months. Official forum is also quite active for it’s user base. There are no official IDE or designer. I am writing a GUI builder myself but it’s at very early stage and very different than usual GUI-editors. I know Ron uses 8th for commercial projects but about others, I don’t know.

I have my home automation software written fully using the 8th, including secure Pub/Sub-server and GUI for desktop and mobile platforms.

I have also written some programs just for fun, like morphing/warping program.

Sure but did 8th start out with it or add it some time later ?

Maybe it did as Forth, which its derived from has been around for a long time & maybe 8th is a new enough derivative that it did

Just saying that additional libraries & such initially start out as add ons & eventually become “standard”

The C++ std lib was definitely that way


isnt much different from adding a json plugin to Xojo in terms of usage

An array of MRAFunctionalityItem structures. [MRAFunctionalityItem].self is where you specify what and because the structure name is wrapped in square brackets, it indicates an array.

Ah ok so that one liner is NOT just cranking out a dictionary !
Nice !

1 Like

Correct, that’s what’s really cool about it, it is de-serializing the entire data model, no matter how complex. In a larger project, it’s the root structure that contains sub structures, arrays etc… One line of code and boom, you’ve got JSON data (or XML) and t’other way also.

Which is why I think it is a prime example of how Xojo advertises Low Code, but other tools are actually low code (because someone actually approved quality of life improvements).

1 Like

Just learned a new one this morning. This code, takes an array of objects, returns an String array of the object’s .title property, where the object’s .tag property contains the bitwise key of kMRAFunctionalityTagIsHeader.

func featureGroupNames() -> [String] {
    return features
        .filter { $0.tags & kMRAFunctionalityTagIsHeader == kMRAFunctionalityTagIsHeader }
        .map { $0.title }

I could even put this all one line and avoid the method entirely.

let groups:[String] = features.filter{ $0.tags & kMRAFunctionalityTagIsHeader == kMRAFunctionalityTagIsHeader }.map{ $0.title }