Solved-Import vs Framework?Use Framework Assistant

BlitzMax Forums/BlitzMax Beginners Area/Solved-Import vs Framework?Use Framework Assistant

RustyKristi(Posted 2016) [#1]
Import BRL.Max2D
Framework Some.Framework

For some reason Framework throws errors but when I used Import on Some.Framework it just works.

Are they the same? the example on some mod uses Framework.


xlsior(Posted 2016) [#2]
If you use import, it adds something on top of the default libraries that already get loaded.

If you use framework you're telling it that you only want to load that particular module (plus whatever others you import afterwards)

The catch is that if you DON'T use framework, you're probably loading a lot of unnecessary modules which can (greatly) increase the sizer of your compiled .exe.
If you DFO use framework, you need to make sure that you load ALL of the modules which define all the command your program uses: image loaders, sound loaders, memory access, etc.

I'd recommend searching the forums for Framework Assistant, it is a program that can analyze your source and create the framework/import statements for you, telling you exactly which modules are necessary while leaving out the extra ones that you do not use.


RustyKristi(Posted 2016) [#3]
Thanks xlsior, I'll check out the framework assistant.


Brucey(Posted 2016) [#4]
The catch is that if you DON'T use framework, you're probably loading a lot of unnecessary modules

That depends if you consider loading *all* modules from pub and brl is unnecessary :-)


dw817(Posted 2016) [#5]
Just started using Framework yesterday, Rusty. It's really quite nice. For what I need, I currently have:
Framework pub.glew ... (special, for virtual screens)
Import brl.pngloader ... (so you can load PNG images)
Import brl.jpgloader ... (so you can load JPG images)
Import brl.glmax2d ... (to do simple graphics like line, oval, plot)
Import maxgui.drivers ... (to develop CreateWindow and CreateCanvas)
Import brl.retro ... (if you want MID$, LEFT$, and all other oldie functions)
Import brl.eventqueue ... (needed for using PollEvent() and company)
If you don't use events, CreateWindow, virtual screens, or loading JPGs, you can likely break it down for yourself to compile much quicker with just:
Framework brl.glmax2d
Import brl.pngloader
Import brl.retro
If some command doesn't work with that particular Framework, let me know and I will find for you the library you need to include in your code.


BlitzMan(Posted 2016) [#6]
Been looking at this,i have a module i have done,with modules called from Brl.Do i still need to call so called modules in my code startup or leave it.Or can i just call Framework.


RustyKristi(Posted 2016) [#7]
If some command doesn't work with that particular Framework, let me know and I will find for you the library you need to include in your code.


Thanks dw817. I'm still trying to figure out how Framework assistant works. Do you have to omit the all imports then feed and let the assistant create a new file with all the import/framework?


xlsior(Posted 2016) [#8]
Thanks dw817. I'm still trying to figure out how Framework assistant works. Do you have to omit the all imports then feed and let the assistant create a new file with all the import/framework?


Framework assistant will analyze your code and figure out what the dependencies are.

If you already framework/import modules yourself, you can remove that part from your original code, and replace it with the code generated by Framework Assistant.

Sometimes you may be able to cut it down a bit further -- e.g. if I suggests brl.pngloader and brl.jpgloader and you know for sure that your program will never need to load PNG's, you can remove the pngloader import statement as well.


dw817(Posted 2016) [#9]
Ah, thanks, Xlsior. Perhaps that is what is causing the analyzer to select slightly larger Frames than my select. I rarely use JPGs in any of my code - the analyzer suggested I add it - but in my own estimate, I don't.

FA is a good program - certainly one to get the noodle going. :)


Bobysait(Posted 2016) [#10]
Framework is also used to control the size of the ".Exe"

When you import every basic stuff to the project (generally by just not using a Framework), you get an exe with at least 1500 Ko size. While a simple print with Framework brl.retro will just output something around 100 Ko that can later be compressed to 30-40 ko with 7zip.

So, this is 1500 Ko
Print "Hello"


and This is 100 ko
Framework brl.retro
Print "Hello World, I'm bigger but smaaaaaller !"



RustyKristi(Posted 2016) [#11]
Thanks for that tip Bobysait. It really makes a difference.


RustyKristi(Posted 2016) [#12]
I already got around with framework assistant so thank you all for the tips and xlsior for pointing out this handy tool!