Silo of Reusable Code (Contributors wanted)

Everything else that doesn't fall into one of the other PB categories.
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Silo of Reusable Code (Contributors wanted)

Post by akamicah »

Hi all,

I'm piecing together a library of reusable code to accelerate application development in Purebasic, as I've tinkered with PureBasic since the very early days and one thing that kinda held me back developing more ambitious projects with it was having to dig around my own mega repository of half baked projects for snippets and bits to incorporate into another project.

With that in mind, I've started this repository on GitHub with a mission to create/procure, refactor and adapt code I stumble across which I find useful and think others will too.

Just like everyone, my time isn't infinite with work and other projects I actively work on, so I'd love it if other members of the community can join me in this mission through posts here or through fork/pull requests.

You can find the repository here:

https://github.com/akamicah/puresilo

Code must be MIT compatible mind to be as friendly to others as possible, and I will refactor/modify/tidy up code if needed to produce a consistent style throughout the library - just something to keep in mind :)

So far I've added my logging library, also introduced Vector2, Vector3 (of 4 different types) with a bunch of methods, defined Vector4, Rectangle to be expanded too, and will be introducing more as time goes along.
User avatar
STARGÅTE
Addict
Addict
Posts: 1726
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by STARGÅTE »

I just looked over it quickly, but I want to mention some issues:
  • You define a function RSqr(Number.d), the reciprocal square root. However, the definition is wrong:

    Code: Select all

      Procedure.d RSqr(Number.d)
        ProcedureReturn 1.0 / Number ; << should be 1.0 / Sqr(Number)
      EndProcedure  
  • Similar issue in vector2.pbi, here your normalize procedure misses the square root as well:

    Code: Select all

        Procedure Vec2#Type#_Normalise(*Vec.sVec2#Type, *Result.sVec2#Type)
          Protected.d length = Vec2#Type#_LengthSq(*Vec)  ; << here you calculate the squared length
          If length = 0
            ProcedureReturn #False
          EndIf
          *Result\x = *Vec\x / length  ; << should be Sqr(length)
          *Result\y = *Vec\y / length  ; << should be Sqr(length)
        EndProcedure
  • It seems to be inconsistent to define methods for doubles and floats, but returning always a double in functions like Length, Dot, Distance, ... .
    They should return floats as well, when float-vectors are used, to avoid unnecessary type conversions.
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 5.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by akamicah »

STARGÅTE wrote: Sat May 14, 2022 3:05 pm I just looked over it quickly, but I want to mention some issues:
  • You define a function RSqr(Number.d), the reciprocal square root. However, the definition is wrong:

    Code: Select all

      Procedure.d RSqr(Number.d)
        ProcedureReturn 1.0 / Number ; << should be 1.0 / Sqr(Number)
      EndProcedure  
  • Similar issue in vector2.pbi, here your normalize procedure misses the square root as well:

    Code: Select all

        Procedure Vec2#Type#_Normalise(*Vec.sVec2#Type, *Result.sVec2#Type)
          Protected.d length = Vec2#Type#_LengthSq(*Vec)  ; << here you calculate the squared length
          If length = 0
            ProcedureReturn #False
          EndIf
          *Result\x = *Vec\x / length  ; << should be Sqr(length)
          *Result\y = *Vec\y / length  ; << should be Sqr(length)
        EndProcedure
  • It seems to be inconsistent to define methods for doubles and floats, but returning always a double in functions like Length, Dot, Distance, ... .
    They should return floats as well, when float-vectors are used, to avoid unnecessary type conversions.
Thanks! Will push up changes momentarily. There's probably a few other little things I missed as well rushing to put something initial together, so will fine-tooth comb it during the weekend
Axolotl
Enthusiast
Enthusiast
Posts: 153
Joined: Wed Dec 31, 2008 3:36 pm

Re: Silo of Reusable Code (Contributors wanted)

Post by Axolotl »

Hi akamicah,
I really wish you much success with your project. But, without demotivating you, I would like to point out that there are already several similar offers on github. What they all have in common is that after an initial phase of euphoria, the expansion and updating very quickly came to a standstill. Please do not misunderstand, it is not a criticism but only a statement on my part.
I have also played with the idea of joining the various github repositories. However, github is absolutely not my thing.... :oops:
So i will not (be able to) help.
Good luck.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by akamicah »

Axolotl wrote: Sat May 14, 2022 3:31 pm Hi akamicah,
I really wish you much success with your project. But, without demotivating you, I would like to point out that there are already several similar offers on github. What they all have in common is that after an initial phase of euphoria, the expansion and updating very quickly came to a standstill. Please do not misunderstand, it is not a criticism but only a statement on my part.
I have also played with the idea of joining the various github repositories. However, github is absolutely not my thing.... :oops:
So i will not (be able to) help.
Good luck.
No worries! The main motivator for this repo is that I would benefit from it so I shall continually contribute to it over time which hopefully avoids the trap others may have fallen in when starting something similar. A lot of code does exist in my own private git server which I do aim to tidy up, and if it's adapted from someone else's code then find the original code on the forums to correctly attribute the works before adding it to the silo library.

As for git - it's not at all a requirement to use git to contribute, and downloading a repository as a zip is always an option for those who don't want to touch git - the purpose of git is to manage the repository, keeping it in existence, and providing an advantage to people who do use git who'd find it easier to add it as a submodule to their own projects :)
User avatar
skywalk
Addict
Addict
Posts: 3657
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Silo of Reusable Code (Contributors wanted)

Post by skywalk »

I applaud your efforts. But, it would be more desirable to have a PB sponsored set of user libraries.
Each having a set of standard tests to avoid simple bug proliferation.
As these libs become more rugged, they could be added to the PB installer.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by akamicah »

STARGÅTE wrote: Sat May 14, 2022 3:05 pm [*]It seems to be inconsistent to define methods for doubles and floats, but returning always a double in functions like Length, Dot, Distance, ... .
They should return floats as well, when float-vectors are used, to avoid unnecessary type conversions.
[/list]
Merged an update breaking those methods out of the implementation macro - each will return float now unless a vector of double is being used
skywalk wrote: Sat May 14, 2022 4:12 pm I applaud your efforts. But, it would be more desirable to have a PB sponsored set of user libraries.
Each having a set of standard tests to avoid simple bug proliferation.
As these libs become more rugged, they could be added to the PB installer.
As nice as that would be, Fred and co I imagine are in the same boat of time being finite, and that would potentially also remove the open-source aspect which would be a shame
User avatar
skywalk
Addict
Addict
Posts: 3657
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Silo of Reusable Code (Contributors wanted)

Post by skywalk »

I'm suggesting something similar to the now open source IDE?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by akamicah »

skywalk wrote: Sat May 14, 2022 7:27 pm I'm suggesting something similar to the now open source IDE?
Ahhh gotcha. That'd be really good
User avatar
Thorsten1867
Addict
Addict
Posts: 1301
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: Silo of Reusable Code (Contributors wanted)

Post by Thorsten1867 »

I also have a small silo of PureBasic modules. ;-)

https://github.com/Hoeppner1867/PureBasic
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
akamicah
User
User
Posts: 17
Joined: Fri May 06, 2022 7:11 pm
Contact:

Re: Silo of Reusable Code (Contributors wanted)

Post by akamicah »

Thorsten1867 wrote: Sat May 14, 2022 7:57 pm I also have a small silo of PureBasic modules. ;-)

https://github.com/Hoeppner1867/PureBasic

Very nice :)
Post Reply