Try the dewy development environment: https://dewy.run
My daughter started learning coding basics with code.org (which is now only AI focused it seems) and Scratch. After some time, she wanted to learn to write "real" code like her dad, which these days is mostly Dart. She wanted to jump into writing little apps with Flutter, but Flutter is too complex for someone just starting out, and I would end up writing most of the code for her. The obvious starting point is to write command line applications.
So she wrote a "hello world" app, a calculator, and a quiz. She was having fun, though CLI applications are not the most visually interesting thing, especially for a kid. She mentioned terminal applications were similar to a chat: the program outputted some text and the user would respond with their own text input, back and forth. This gave me an idea to convert the pure terminal application into a chat UI. I created my own terminal program called dewy which was a drop-in replacement of the dart compiler command. So instead of executing the command dart hello.dart to run her programs, she would run dewy hello.dart. dewy = dart + GUI, a small wrapper around the dart compiler to convert it to a simple chat-like UI.
dewy compiles the given dart code to Javascript via dart compile js, then injects that JS into an HTML template. The dart code uses the dewy API to print text and accept input, which in turn adds elements to the HTML DOM rather than as terminal output. The HTML page output is fully self contained, and is opened automatically after the compilation is complete.
Here is an example dewy program:
@DewyApp(title: 'Hello! Example App', author: 'somebody')
void main() async {
say('Hello!');
var name = await ask('What is your name?');
say('Hello, $name!');
var answer = await choice('What is your favorite animal?', {
1: 'Turtle',
2: 'Dog',
3: 'Cat',
}, shuffle: true);
say('${answer.text} is a good choice!');
}
Which outputs to a web app:
Unlike a terminal application, the dewy output HTML file can be shared easily with others, either on a web hosting site or directly as a file.
I thought about open-sourcing the dewy wrapper for other beginner coders who want to experiment with dart, though the setup requried is still fairly daunting for a newbie. You have to install the Dart SDK, which requires Homebrew, then install dewy from wherever it'll live, then a code editor like VS Code. On top of that, you'll need a MacBook/Windows/Linux laptop, this won't work on a Chromebook or iPad. So instead, I decided to release a dewy development environment on the web: https://dewy.run. Similar to dartpad.dev it includes a code editor in the left pane and a run button to see its output on the right pane. It's also a PWA that can be installed and run entirely offline; file storage and compilation happen all in the browser. The HTML page output can be shared and downloaded. HTML output files also include the code, so you can open the dewy HTML sent from a friend and see how it works, and make your own remix. If images are included, they two are also embedded in the HTML file so these dewy mini web apps require no network or additional permissions. On a separate note, I'm pretty excited about self-contained HTML as an app container format; though I'll get more into that some other time.
dewy is currently still in an experimental phase, and I probably will make additions to the API if there is interest, as currently is fairly rudimentary with say, ask, choice, and show.
Give it a try: https://dewy.run