Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

152 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyd-blue Floral - A Parallel Scripting Language

  • Fully compiled (C++ backend)
  • Any function can be called normally, spawned onto a new thread, or spawned with a timeout (no marking sync vs. async)
  • Floral warns you about discontinuities across calling and spawning, and unsafe variable access
  • Easy spawn/await (No need to wrap return types in futures)
  • Message passing to and from children and unrelated threads (send, receive, Signal)
  • JS-like methods (map, filter, slice, etc.)
  • Documentation

codye

✔ Compiled
waiting for notifications...
from a: About to do some more work...
from b: About to do some more work...
Worker Nico is done!
Worker Rio is done!
Nico: 155 | Rio: 190 | Total: 345
See Generated C++
module;
#include <runtime/runtime.hpp>
#include <cstdint>
#include <cstdio>
#include <string>

export module showcase3;


export struct Report {
            Daisy::String name;
Daisy::LocalList<Daisy::String> expenses;
            };
DAISY_FUNCTION(Daisy::Integer, calculator, Daisy::_Local<Report> report, Daisy::SharedInteger total)
auto nums = Daisy::LocalList<Daisy::Integer>(Daisy::util::listmap(report.get().expenses.get(), Daisy::util::toInteger).get());
auto sum = Daisy::util::listreduce(nums.get(), [&](auto acc, auto x){ return acc + x; });
total->modify([&](auto __v){ return __v + sum; });
__DAISY_channel.send("About to do some more work...");
Daisy::Timing::sleep_ms(static_cast<Daisy::Integer>(50));
Daisy::builtin::io::print("Worker", report.get().name, "is done!");
return sum;

}
export Daisy::SharedInteger household = {};
export Daisy::Threads::Handler<Daisy::Integer> a = {};
export Daisy::Threads::Handler<Daisy::Integer> b = {};
export Daisy::Integer ra = {};
export Daisy::Integer rb = {};


extern "C++" {
int main() {
Daisy::builtin::file::_exe_path = "/Users/nico/Documents/DaisyLang/examples/showcase3.bud";

household = Daisy::NewShared(static_cast<Daisy::Integer>(0));
a = Daisy::Threads::spawn(calculator, Daisy::_Local<Report>(((Report){.name = "Nico",.expenses = Daisy::LocalList<Daisy::String>(Daisy::List<Daisy::String>{"100", "20", "35"})})), household);
b = Daisy::Threads::spawn(calculator, Daisy::_Local<Report>(((Report){.name = "Rio",.expenses = Daisy::LocalList<Daisy::String>(Daisy::List<Daisy::String>{"15", "150", "25"})})), household);
Daisy::builtin::io::print("waiting for notifications...");
Daisy::builtin::io::print("from a:", a.receive());
Daisy::builtin::io::print("from b:", b.receive());
ra = a.await();
rb = b.await();
Daisy::builtin::io::print(("Nico: " + Daisy::util::toString(ra) + " | Rio: " + Daisy::util::toString(rb) + " | Total: " + Daisy::util::toString(household)));


Daisy::Threads::join_all();
return 0;
}
}


Usage

  • install: npm install -g && npm run build
  • run: bud --run examples/showcase.bud
  • compile: bud examples/showcase.bud -o a.out
  • see generated code: bud examples/showcase.bud --generate

Status

  • variables: let, shared, restricted, const
  • control flow: if, elif, else
  • looping: while, repeat
  • functions
  • types
    • primitives: Integer, String, Bool, Float, Byte, Complex, None
    • templates: Handler, List, Timeout, Signal
    • custom structs: type
    • string interpolation: "my name is ${name}"
  • threading: spawn, await, timeout_ms, Signals
  • spawned handler methods .send, .receive, .done, .pending, ...etc
  • js-like methods: .split, .join, .map, ...etc
  • type conversions: .toInteger(), .toString(), ...etc (first class versions too)
  • built-in libraries: web, io, file, process
  • import/export: export def fn: ..., import "module" as myModule

Plans

  • classes
  • auto templating with untyped parameters
  • more utility methods on primitives
  • more builtin libraries

About

Parallel scripting language

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages