Skip to content

Releases: dphfox/Fusion

Fusion 0.3

30 Aug 01:23
Compare
Choose a tag to compare

A year and a half on from 0.2, we're finally ready to solidify Fusion 0.3 in place. This is a new, forward-looking vision for Fusion, introducing new ideas around memory management, contextual value sharing, and dependency traceability.

A lot has changed, so feel free to take some time and revisit the Fusion documentation. We've rewritten a whole lot of it together!

Here's a quick summary of the highlights... at least, I tried to make it quick, there's too much to mention!


Use functions: flexible trace-able dependencies

Starting in Fusion 0.3, we've introduced a better way of writing your logic, so you always know how Fusion is connecting your code together, and you can freely mix and match state objects with plain values throughout your codebase.

The old StateObject:get() method has been replaced with new "use functions". These functions grab the value for you, but can also do other things in the meantime.

  • The most basic use function is Fusion.peek(). It grabs the value without doing anything, no matter what.
  • Every Computed and For object exposes their own use function, which grabs the value and adds a dependency, no matter what.
  • Future use functions could do a whole lot more, from flattening deeply nested objects, to aiding constant optimisations, to performing complex observation tasks!

Plus, something exciting. Uniquely, use functions let you mix in regular values in your code, too! With the UsedAs type, your code can easily accept both plain values and state objects. What's, all use functions will recognise plain values and pass them straight through to you, letting you write truly generic code.

Check out the dedicated discussion to learn more about this new way of writing computations, and how you can port your code.


Scopes: rigorous, time-travelling memory management

Fusion 0.3 introduces a brand new way of preventing memory leaks, explicitly organising your code, and even performing time travel to warn you about errors your code will run into in the future.

Scopes are like Maids, but more general, more powerful, and coupled with more expressive tools. All the while, your code stays syntactically clean, with minimal impact on every line you write.

Internally, scopes lay an exciting groundwork for deterministic, debuggable memory management. Future development tools will be able to inspect and show you exactly what your program is holding on to, and detect memory leaks with much more accuracy and precision than what similar garbage collection-based tools could offer.

And today, Fusion already performs automatic time travelling analysis, predicting how your code will clean itself up and warning you right away when your code could destroy itself incorrectly in the future.

This is a massive paradigm shift, and we're not done yet. This is the first expression of the idea, and there's plenty to get on with!

Check out the dedicated discussion to learn more about how scopes work, and what you need to do to port your code over.

And, check out the companion video over on the Studio Elttob channel, introducing scopes and the new possiblyOutlives warning, to see how your code can be cleanly structured to avoid memory leaks and destruction errors.


Contextuals: pass common props through space and time

Ever had to pass something down through layers and layers of components? We know the feeling.

That's why Fusion 0.3 introduces contextual values. These values can be modified for the duration of a single callback, letting you pass different values to different parts of your codebase, all controlled by code higher up for truly flexible long-distance communication.

Contextuals are very useful for sharing values that aren't quite global. One popular choice is theme colour - you might want to show both light and dark themes at the same time when you're building your UI in Studio, but don't want to pass theme into every component. Not to worry - contextuals give you the ergonomics of global values and the flexibility of props, all in one.

And best of all, contextuals are a generic Luau construct, meaning they're useful outside of Fusion too. Use them anywhere throughout your game, plugin or project - they'll just work.

Check out the Sharing Values tutorial in the Fusion 0.3 docs to learn all about contextuals and what they can do for your code.


Safe expressions: error safety that just works anywhere

Code can fail unexpectedly for many reasons. While Fusion tries to prevent many errors by design, Fusion can't stop you from trying to access data that doesn't exist, or taking actions that don't make sense to the computer.

That's where all-new safe expressions come in, Fusion 0.3's novel construct for ensuring your code runs flawlessly, even at the worst of times.

With safe expressions, you can write any error-prone logic as a plain function, and embed it directly into any other expression such as a Fusion instance template. If your code runs fine, your values are passed straight through.

But should something go wrong, the safe expression lets you divert to a separate error handling expression to return any backup values of your choice! You get full information about the error, and access to debug functions like traceback right in your own code.

Check out Fusion's brand new error safety guide. to learn how to make the most of safe expressions.


Hybrid execution: efficient and more correct than ever

Fusion 0.3 introduces a new hybrid execution model based on pioneering work in the functional reactive programming world.

With hybrid execution, Fusion now completely skips calculations that go nowhere. With this key optimisation, your code can be written more flexibly than ever before without worrying about phantom performance drains from dead-end chains of computation.

But it gets better. Hybrid execution uses pull-based evaluation, meaning we can now guarantee that every state object you read is up to date immediately and on-demand. What's more, hybrid execution will naturally run your computations in the correct order, guaranteeing correct order of operations without running any sorting algorithm. Your code naturally organises itself.

That's all combined with new push-based, deterministic eager execution for observers. That means your code behaves less randomly, letting you safely predict how it runs across a variety of devices. Plus, it enforces correct order of operations for complex nested subgraphs of objects, meaning your code is run less spuriously when re-evaluating complex dynamic graphs of objects.

The cherry on top is Fusion's new similarity algorithm, which is now fully compatible with NaN, userdatas, metatables, OOP objects and frozen tables. The new algorithm runs quickly for common values, while producing accurate results for the vast majority of user code, all without deep checks that bog your computer down.

With all these foundational changes, we can pursue new feature requests with confidence that we're not closing performance options in the future, so expect to see more adventurous and convenient API designs into the future!

Check out the supporting discussion around computed object update timings, to see if your code will need adjustment to run on Fusion 0.3's new hybrid model.

And make sure to read through our new optimisation guide, to see how you can get the most out of Fusion on every CPU.


Fusion @ RDC - featuring the top UI experts from the community!

We're proudly making a showing on-stage at Roblox's largest worldwide developer conference!

Make sure to tune into our UI frameworks panel, featuring the brightest sparks in the UI community. From Clip It to classrooms, and Reclass to Roblox itself, we've assembled a star-studded team of Frame fanatics - you'll be able to directly ask us the most difficult, thought-provoking questions about UI.

Plus, we'll be freely distributing a working demonstration of Fusion side by side with React, so you can see just how much Fusion can do, and what real code looks and behaves like - all open source for your education and expansion!

Tune in for the "Using UI Frameworks to Conquer Code Complexity" panel at RDC 2024, whether you're attending virtually or in person. Be there or be square 🤠


With every year that goes by, Fusion continues to grow into a more powerful and expressive library. I'm personally looking forward to the next few years - with established fundamentals in place, we have a lot of feature requests to get to.

This is the most exciting project I've had the privilege of leading, and I can't wait to see where we will go.

Onwards!

- Dan


Pull requests

Read more

Fusion v0.2

31 Jan 04:02
Compare
Choose a tag to compare
Fusion v0.2 Pre-release
Pre-release

Well over a year on from Fusion's initial release, we're happy to officially release Fusion's second beta version! v0.2 aims to backfill a lot of what was originally missing with v0.1 and address a few shortcomings of the original API and codebase.

You can watch the v0.2 keynote to learn more about all of the new features in this version.


videoplayer


If you're currently using v0.1, it's strongly recommended you migrate to v0.2 for a more complete development experience with fewer issues and greater flexibility. If you are currently using Fusion via the Wally package, an updated package will be made available soon.

Outside of library changes (of which there are so, so many), we have also taken the time to improve the documentation website. All of the tutorials have been rearchitected from the ground up to ensure that Fusion is easy to learn and understand. Visit our lovely new home: https://elttob.uk/Fusion/0.2/

We hope you enjoy this update, and onwards to v0.3 - hopefully expeditiously!


Thank you, sponsors <3

These wonderful people help keep Fusion alive by donating. Thank you so much!
If you would like your name here in future, you can sponsor here: https://github.com/sponsors/Elttob

  • ChooShu-Cho
  • foxydevloper
  • Korky5000
  • TreehouseFalcon
  • railworks2
  • Haydz6
  • noblereign

Fusion v0.1

20 Aug 22:59
Compare
Choose a tag to compare
Fusion v0.1 Pre-release
Pre-release

Fusion is highly work-in-progress right now. There are a lot of features that don't work, aren't implemented, aren't documented fully or which may be tweaked or removed. We don't recommend using Fusion for any major project right now unless you're willing to take on the extra work of following these changes.

More stable, long-term-supported Fusion versions will be available once Fusion exits beta testing.