2sxc 17 introduces HotBuild, which will let you build 5x bigger Apps. Welcome to the 5th Day.
Important: This is still experimental.
In v17.00 we used the term ThisApp for the main folder and namespace.
In v17.02 we're switching to AppCode. The Blog is updated to use that term.
2sxc HotBuild WTF?
A limiting factor when creating large apps is managing and reusing lots of code. Previously it was possible to create helper CSharp files like FileHelper.cs, which would be accessed using CreateInstance(...). Typically you would then write things such as:
var fileHelper = CreateInstance("FileHelper.cs");
var size = fileHelper.GetSize("abc.jpg");
Despite being practical, it didn't scale well. Everything was dynamic and there was no type safety. And return values were also untyped, making it difficult to build sophisticated solutions.
Our goal was to introduce the classic dev-experience where you would use var fileHelper = new FileHelper(); - just like in compiled DLLs. But way better - so it's compiled on the fly without restarting a server or anything.
This is now possible! 💃 🎉
Thanks to the dedicated work of Tonci - who spent around 3 months in the depths of compilers, Roslyn, Assembly-Providers and really crazy 💩, we made magic happen.
How HotBuild works
- It all starts with a namespace AppCode and a folder AppCode
- Any .cs files placed in this folder will get compiled into a DLL on the fly - and served steaming hot directly to your Razor and other .cs files outside of this folder.
- So any other file which has a using AppCode will automatically get that DLL with all the classes, types and everything coded there.
HotBuild is Steaming Hot
Basically this allows you to have live (hot) compiled, shared DLLs in an App. But there's more:
- Each App is isolated in it's own Hot Tub - so the code will only be available and work inside that App.
- This allows you to have many sites with the same app (eg. the Blog) with different modifications as needed, and the DLLs will be different for each App!
- The moment you change a file in AppCode, the DLL will get recompiled on the fly, and previously compiled Razor files will get flushed from the cache, so that they can pick up any changes made.
AND it works in ☢️ Dnn (.net Framework 4.7+) and 🩸 Oqtane (.net Core 8)!
Scale Up like Crazy 🚀
This will allow you to create type-safe applications which are easily 10x more sophisticated than before (we just write 5* because it's the fifth day of Christmas 😉). Because:
- You can split your code into as many files as you like (eg. place some classes with properties in one file, helper code in others...)
- VS Code can give you intellisense when you work with objects in other files (also new in v17)
- Return values can be typed using complex objects or tuples, and both VS Code and the compiler know this.
This allows you to create way more complex solutions than ever before. On the fly. Without restarting DNN / Oqtane at every step.
HotBuild will get even Better
This is just the beginning. In the coming months we'll gather some experience, monitor memory usage and performance and do various improvements.
It's important to note that this feature is still not perfect. When bugs prevent your code from compiling, the errors are still very cryptic and the line numbers don't seem to match the source. But we'll get that improved in January.
After that we'll go the next steps:
- Add Polymorphism to allow open-heart surgery. This lets you develop enhancements on a production system, without affecting the users.
- Hot-Compile content-types based on the data, so that you can then work with typed BlogPost or RealEstate objects in your code.
- ...and we have some more ideas 😉
Imagine What You Can Build 💡
Did you know that our company name 2SIC stands for 2serve, 2inspire, 2create? With this, we really hope 2serve you even more, 2inspire you 2create amazing things.
We hope that you're mind is already racing with ideas what you can build with this new technology.
Love from Switzerland and Croatia
iJungleboy & Tonci
Special Thanks to Tonci of Sistemi
A BIIIIIIG shoutout to Tonci 🙏 - he spent hundreds of hours figuring out how Roslyn works internally to make it work in both Dnn and Oqtane. What he did is really magic at the highest levels.