fusionlanguage/fut

Thoughts on expanding the standard lib

caesay opened this issue · 3 comments

HAXE has quite a rich std lib, but unfortunately it's type system and runtime make it a poor choice for library authors. Fusion's approach is much cleaner.

I'm giving fusion a try right now to implement a rather small library, but a lot of the very common tasks are not possible. eg.

  • starting processes
  • parsing xml/json
  • HTTP requests
  • and so forth.

For C/C++, there are header-only libs which can solve these problems in a cross-platform way (eg. json.hpp, subprocess.h), and for most higher level languages there is native support for things like these (eg. system.text.json, httpclient, System.diagnostics.process in C#).

It would be great if some common functionality could start getting exposed, leveraging the built in capabilities of our target languages, and possibly even pulling in libs where possible.

As an example, a Json parsing implementation could utilise the following API's:

For something like json, we could write a pure fusion implementation and have it work in all languages, but for something like Process.Start we would be better off leveraging language features (and something like subprocess.h on C/C++)

Curious to hear your thoughts on how we might expand in this area, and if you can give me some tips on how to implement and test a change like this I would be willing to give it a go.

Thank you for sharing your ideas! In addition to "Issues", there are also "Discussions". But let's continue this topic here.

I fully support this direction. I would definitely need help in implementing these. It's not the actual implementation that's most time consuming, but a design of the API in a way that can be transpiled to the target languages. Browsing through all the standard libraries (and external libraries in case of C/C++) takes time. What you already mentioned for JSON is probably already 20% of progress.

It is tempting to list all the missing features, but I'd suggest to start with one and see how it goes. Please pick one of the above that you're most familiar with, need most or think would be easiest. Then just list the classes, methods and translations (preferrably with documentation links) as a GitHub issue. Then write a Fusion test for it and I can help with the actual implementation.

Is there a way to just run specific tests, eg. if I write a new test for string.ToLower(), right now trying to run make test -j20 -k takes a long time and has a lot of errors for tests I'm not concerned with

Of course! For example, to run the Basic.fu test, use:

make -j20 test-Basic.fu

I have configured a key shortcut in my editor (SciTE) to run the test for the current file:

command.3.*=make -C PATH-TO-FUT-REPO -j7 test-$(FileNameExt)