Dart
2011fragletwebimperativeobject-oriented.dart
docker run --rm --platform="linux/amd64" 100hellos/dart:latest
MCP + fragletc
MCPstdinargs
This language supports code execution via MCP and the fragletc CLI. Stdin piping and argument passing are both supported.
Install fragletc →Dart looks to do it all. On the server it can support JIT for it's VM or compile to machine code. It can be transcoded into javascript. It can compile languages for any platform, and it can be used to write web applications.
But it's SDK doesn't support musl-based linux distributions (like this image). So this uses an unofficial build of the Dart SDK for musl linux from dart-musl.
Hello World
// BEGIN_FRAGLET
void main() {
print("Hello World!");
}
// END_FRAGLETCoding Guide
Language Version
Dart 3.x
Execution Model
- Compiled to native code or JIT-compiled at runtime
- Runs via
dart runcommand - Top-level code executes when program runs
Key Characteristics
- Statically typed (with type inference)
- Object-oriented
- Case-sensitive
- Semicolons required for statements
Fragment Authoring
Write valid Dart statements. Your fragment becomes the main() function body, so code executes when the program runs. You can define functions, classes, and other constructs within the fragment scope.
Available Packages
Standard Dart SDK libraries are available. No additional packages are pre-installed.
Common Patterns
- Print:
print("message"); - Variables:
var name = "value";orString name = "value"; - Functions:
void functionName() { }orreturnType functionName() { } - Lists:
var list = [1, 2, 3]; - Maps:
var map = {"key": "value"}; - String interpolation:
"Hello, $name"or"Sum: ${a + b}" - Loops:
for (var i = 0; i < 10; i++) { }orfor (var item in list) { }
Examples
// Simple output
print("Hello, World!");
// Variables and calculations
var a = 5;
var b = 10;
print("Sum: ${a + b}");
// Function definition
String greet(String name) {
return "Hello, $name!";
}
print(greet("Alice"));
// List processing
var numbers = [1, 2, 3, 4, 5];
var squared = numbers.map((x) => x * x).toList();
var sum = squared.reduce((a, b) => a + b);
print("Sum of squares: $sum");
// Loops
for (var i = 1; i <= 5; i++) {
print("Count: $i");
}
// Maps
var person = {"name": "Bob", "age": 30};
print("${person["name"]} is ${person["age"]} years old");Fraglet Scripts
Echo Args
#!/usr/bin/env -S fragletc --vein=dart
void main(List<String> args) {
print("Args: ${args.join(" ")}");
}Stdin Echo
#!/usr/bin/env -S fragletc --vein=dart
import 'dart:io';
void main() {
while (true) {
var line = stdin.readLineSync();
if (line == null) break;
print(line.toUpperCase());
}
}Stdin Upper
#!/usr/bin/env -S fragletc --vein=dart
import 'dart:io';
void main() {
while (true) {
var line = stdin.readLineSync();
if (line == null) break;
print(line.toUpperCase());
}
}Test
#!/usr/bin/env -S fragletc --vein=dart
void main() {
print("Hello World!");
}Connections
influenced by