PureBasic 6.40 alpha 3 is ready, surprise inside !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
mk-soft
Always Here
Always Here
Posts: 6529
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by mk-soft »

Len + String is alignment 16 byte . So String address is alignment 16 byte + offset 8
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
User avatar
idle
Always Here
Always Here
Posts: 6188
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by idle »

mk-soft wrote: Sat Jan 31, 2026 1:23 am Len + String is alignment 16 byte . So String address is alignment 16 byte + offset 8
Yes the string is unaligned.
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by Fred »

2026-01-31: alpha 3 is available for Windows x64 ! A few more bugs has been fixed, and a new StringBuilder library has been added for very fast string concatenation ! Here is a small example:

Code: Select all

a$ = "Hello, World !"
CreateStringBuilder(0, 64000)
For l = 1 To 2000
  AppendStringBuilderString(0, a$)
Next
b$ = FinishStringBuilder(0)
Don't hesitate to test this version if you can as we believe it's ready for larger tests.
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by ChrisR »

I just compared the new StringBuilder library with the string builder here and with a$ = ReplaceString(Space(50), " ", "Hello World !") ; Len =13*50=650
Wow! It's really super fast, with PB_Any and the cache size. Well done 8)

Code: Select all

StringBuilder Large concat Size(1300000) 2 ms
ExString Large concat Size(1300000) 18 ms

I just looked at what I'm currently using in my app for the code generation,
The only thing I'm missing is Right, which can be very useful, to do for ex:

Code: Select all

If RightStringBuilder(0, 4) <> #CRLF$+#CRLF$
  AppendStringBuilderString(0, #CRLF$)
EndIf
AppendStringBuilderString(0, a$)

Wouldn't it be better with AppendStringBuilder(A, a$) only rather than AppendStringBuilderString(A, a$)
Thanks for adding it :)
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by ChrisR »

More Result:

Code: Select all

PB Way Large concat PB6.30   Size(1300000): 2025 ms
PB Way Large concat PB6.40a3 Size(1300000):  262 ms
ExString Large concat        Size(1300000):   18 ms (cache 64000)
StringBuilder Large concat   Size(1300000):    2 ms (cache 64000)
PureBasic 6.40 alpha 3 - C Backend (Windows - x64)
Feel the ..Pure.. Power :D


Sadly, I'm going to prepare a little funeral for my StringBuilder. It was really fun to do it. Sniff :cry:
Okay, we can prepare it together with HeX0R's StringBuilder Interface and mk-soft's FastString :wink:
Last edited by ChrisR on Sat Jan 31, 2026 4:41 pm, edited 1 time in total.
threedslider
Enthusiast
Enthusiast
Posts: 578
Joined: Sat Feb 12, 2022 7:15 pm

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by threedslider »

Even more impressive with the last version of PB :shock:

Again thanks all to Fred, Team and users !
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by Fred »

About the right() command, you should be able to do it before adding it, no? What's the real use case ?

About the naming, I was thinking to add may be some additional command like AppendStringBuilderDouble/Integer for fast number concat, that's why I put String at the end
Axolotl
Addict
Addict
Posts: 924
Joined: Wed Dec 31, 2008 3:36 pm

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by Axolotl »

Shouldn't there be a limit on the length of function names? (Just kidding.)
Keep up the good work, and continue to surprise me.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
skywalk
Addict
Addict
Posts: 4301
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by skywalk »

Thanks!
I still have heinous crash for this line in a 30k loc app.
wmi\mp$ = UCase(mpFileNamePath$)
I will need time to shrink snippet.
Compiler crash:

Code: Select all

[11:13:12] Waiting for executable to start...
[11:13:12] Executable type: Windows - x64  (64bit, Unicode, Thread)
[11:13:12] Executable started.
[11:13:19] [ERROR] my.pbi (Line: 4292)
[11:13:19] [ERROR] Invalid memory access. (write error at address 0)
[11:13:19] [ERROR] my.pbi (Line: 4292)
[11:13:19] [ERROR] Invalid memory access. (read error at address 5220935860488)
[11:13:19] [ERROR] my.pbi (Line: 4292)
[11:13:19] [ERROR] Invalid memory access. (read error at address 5220935860488)
[11:13:19] [ERROR] my.pbi (Line: 4292)
...REPEATING UNTIL...
[11:13:22] The Program was killed.
Is there a migration tutorial?
If it is a lot, shouldn't this be a major version change?
Like version method [Major-may-break-old-code].[Minor-backward-compatible-features].[Bug-fixes] ?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by ChrisR »

Fred wrote: Sat Jan 31, 2026 4:46 pm About the right() command, you should be able to do it before adding it, no? What's the real use case ?
Sure, but in my case, it's really easier (and faster) to do it this way by testing the double CRLF, otherwise I'll have to do some additional testing to find out what will be written next.
Since you must have the final address, it should be fairly easy PeekS(*FinalAddress - (Len * SizeOf(Character)), Len)
But I can understand, if you prefer to stay with a pure StringBuilder, in this case, is it possible to retrieve the initial and final addresses with something like: *mem = GetStringBuilderAdress(0, [#PB_StringBuilder_Last])?

Good, for AppendStringBuilderDouble/Integer :)
User avatar
mk-soft
Always Here
Always Here
Posts: 6529
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by mk-soft »

@skywalk
No crash with structure here...
Where does the variable "mpFileNamePath$" come from. If it comes from API, it must be corrected with PeekS.

Code: Select all

Structure udtData
  iVal.i
  sVal$
EndStructure

Define MyData.udtData

Filename$ = #PB_Compiler_Home
MyData\sVal$ = UCase(Filename$)

Debug MyData\sVal$
/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
User avatar
skywalk
Addict
Addict
Posts: 4301
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by skywalk »

Well, this is called at different times from different sources, basically the app path and subfolders are defined in some constants:
#MY_server$ = "C:\"
#MY_app_path$ = "mypath\"
etc.
Filename = #MY_server$ + #MY_app_path$ + "some-new-file-to-load.extension"
I will make a snippet, but this is basic stuff.
A new feature should not break basic code without a major version change.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Little John
Addict
Addict
Posts: 4843
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by Little John »

Axolotl wrote: Sat Jan 31, 2026 5:18 pm Shouldn't there be a limit on the length of function names? (Just kidding.)
:)
User avatar
kenmo
Addict
Addict
Posts: 2080
Joined: Tue Dec 23, 2003 3:54 am

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by kenmo »

freak wrote: Thu Jan 29, 2026 9:52 pmThe problem is spreading this code as a "tip" around the forum, which will lead to people blindly using it thinking they are doing a clever optimization without understanding the details. And then if we do change something, we have to deal with the complaints again. And all that for an "optimization" that is not even worth that word.
Freak, I agree with all this you've said, about this workaround that ChrisR and fryquez discussed. But I think that's more reason for a native "UpdateStringLength" or "ResetStringLength" command. Even if it's just doing a PeekS() internally! Then it could be optimized in the future, or string lib internals could be reworked, automatic benefits for the user with zero changes to the user's code...

...

...

... also I think it makes code cleaner than unexplained Var = PeekS(@Var) scattered around :)
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 3 is ready, surprise inside !

Post by ChrisR »

Personally, I think it would be good to let us play with this prefix, but it would be better with an official guarantee in its integrity. Then, it's the developer's responsibility to know what they're doing
There is few points in its favor, in the last 2 post here

I apologize in advance if I shouldn't, but someone sent me this macro recently, the fastest.
But the debate should not be about speed, PeekS is fast enough.

Code: Select all

CompilerIf #PB_Compiler_Version >= 640
  Macro UpdateStringLength(String)
    *string = @String : If *string : PokeI(*string - SizeOf(Integer), MemoryStringLength(*string)) : EndIf
  EndMacro
CompilerElse
  Macro UpdateStringLength(String)
    ;
  EndMacro
CompilerEndIf
Post Reply