can someone explain to me what userlib is ?

Everything else that doesn't fall into one of the other PB categories.
marc_256
Addict
Addict
Posts: 842
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

can someone explain to me what userlib is ?

Post by marc_256 »

Hi,

I see we can now [PB6.20x] create userlibs.

I'm only a designer so, :oops: :?
can someone explain to me,

- What is a userlib ?
- Where is it used ?
- Where is used for ?
- What are the benefits ?


Thanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
STARGÅTE
Addict
Addict
Posts: 2232
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: can someone explain to me what userlib is ?

Post by STARGÅTE »

marc_256 wrote: Tue Dec 24, 2024 2:45 pm - What is a userlib ?
- Where is it used ?
- Where is used for ?
- What are the benefits ?
A user library is a pre-compiled version of a bunch of procedure, like the libraries of pure basic.
You can use it in your own codes, when you want to have a faster compiling time or no use of includes.
It is similar to a Module, but already compiled.

Here is my example for additional random functions: PB 6.20 - UserLibrary - Random extension
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
skywalk
Addict
Addict
Posts: 4218
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: can someone explain to me what userlib is ?

Post by skywalk »

Pros:
+ Compile time reduced by lib code amount.
+ Statically loaded instead of shipping and loading external dll.

Cons:
- You cannot debug an error within your user created lib.
- Complicated compilerifs required to allow user lib code to be used as both inline and lib. Else you have to maintain duplicate code.
- User lib code must be flat, not module based.
- All functions are loaded into memory, even if never called.
- Unsure if lib code is backward and forward compatible?
- Unsure where lib constants and structures are created?
- Sharing lib as binary opens potential threats.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
mk-soft
Always Here
Always Here
Posts: 6245
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: can someone explain to me what userlib is ?

Post by mk-soft »

Never use third-party user libraries without source code !!!
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: can someone explain to me what userlib is ?

Post by Fred »

Yes source code is mandatory, a userlib must be compiled with the same PB version to work flawlessly. I will made be a check to disallow the loading of a lib not compiled with the same version to enforce that.
User avatar
mk-soft
Always Here
Always Here
Posts: 6245
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: can someone explain to me what userlib is ?

Post by mk-soft »

Fred wrote: Tue Dec 24, 2024 6:38 pm Yes source code is mandatory, a userlib must be compiled with the same PB version to work flawlessly. I will made be a check to disallow the loading of a lib not compiled with the same version to enforce that.
But please not with every small change ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: can someone explain to me what userlib is ?

Post by Little John »

In normal PureBasic code, procedure parameters must be of a specific type. For instance, when I want to write a routine which does something with arrays, I have to write a separate procedure for each array type that I want to handle:

Code: Select all

Procedure HandleArrayI (Array foo.i(1))
EndProcedure

Procedure HandleArrayF (Array foo.f(1))
EndProcedure

Procedure HandleArrayD (Array foo.d(1))
EndProcedure

Procedure HandleArrayS (Array foo.s(1))
EndProcedure
In contrast, built-in PureBasic functions for arrays can handle arrays of any data type or at least of any basic data type.

My question is:
Can I write a user library with a procedure that can take arrays of different types as parameter, like the built-in PureBasic functions do?
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: can someone explain to me what userlib is ?

Post by jacdelad »

mk-soft wrote: Tue Dec 24, 2024 8:19 pm
Fred wrote: Tue Dec 24, 2024 6:38 pm Yes source code is mandatory, a userlib must be compiled with the same PB version to work flawlessly. I will made be a check to disallow the loading of a lib not compiled with the same version to enforce that.
But please not with every small change ...
How about an automate regeneration process, like you put all your userlibs in a defined folder and there's an option in the ide "create userlibs", which automatically creates them for/with the desired compiler? With more than one compiler you need some version handling anyway.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: can someone explain to me what userlib is ?

Post by Denis »

Fred wrote: Tue Dec 24, 2024 6:38 pm Yes source code is mandatory, a userlib must be compiled with the same PB version to work flawlessly. I will made be a check to disallow the loading of a lib not compiled with the same version to enforce that.
It will be easier not to have PB lib but rather to have includefile, won't it?

I have several personnal asm PB lib i wrote a while ago, and all is correct (x86-x64 windows only).
Am I going to have to recompile everything, knowing that it's in asm ?

mk-soft wrote: Tue Dec 24, 2024 8:19 pm
Fred wrote: Tue Dec 24, 2024 6:38 pm Yes source code is mandatory, a userlib must be compiled with the same PB version to work flawlessly. I will made be a check to disallow the loading of a lib not compiled with the same version to enforce that.
But please not with every small change ...
+1
A+
Denis
marc_256
Addict
Addict
Posts: 842
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: can someone explain to me what userlib is ?

Post by marc_256 »

WOW,
thanks for the tips and the reactions.

I learn from this, as long I use it in my own program it will be OK.

Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: can someone explain to me what userlib is ?

Post by Bisonte »

marc_256 wrote: Thu Dec 26, 2024 12:07 am WOW,
thanks for the tips and the reactions.

I learn from this, as long I use it in my own program it will be OK.

Marc
it only means: If you don't have the source, you are fixed to the current
version of the compiler as long as the author does not make updates available!
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Caronte3D
Addict
Addict
Posts: 1361
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: can someone explain to me what userlib is ?

Post by Caronte3D »

Also... if you don't have the code, it can cause a security hole if the author is someone with malicious intentions.
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: can someone explain to me what userlib is ?

Post by threedslider »

*Edit : Ok I have seen userlib from PB and it is a part in PB itself so now I understand that :D

Happy coding !
Post Reply