Lack of info

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

Allo all!

A little relevant background: I used to do a bit of programming in Visual Basic, Delphi and (way back) 6502 assembly language. All of them were self taught, but I was also not writing the next office suite - mostly just small utility apps for myself. After college I got away from programming because my career took an odd turn somewhere and I never had the time.

I'm looking to get back into programming. Again, mostly utility apps for myself - file parsers, information managers, database front ends, etc... But I would like the ability to "grow" into bigger, more robust apps that may eventually end up as shareware.

I am a windows user but crossplatform to linux is nice, Mac OS would also be nice - but less of a priority.

My main concerns are
a) small, relatively self contained files (ie. no "runtime")
b) ease of learning and quick to get "up and running"
c) stability
d) speed

After looking at literally 100's of free and almost free language options I've come down to Euphoria and Purebasic. Problem is that while it is very esy to find tutorials and fanatics about Euphoria - there seems to be a blackhole on the net for Purebasic. I can not find any "getting started" info or even reviews of the language.

Can anyone point me to some write-ups or "first steps" kind of tutorials? How "friendly" is Purebasic for writing windows GUI apps? Euphoria is a very nice language and even with the runtime it is small and fast - but when it comes to writing GUI apps it gets a bit cumbersome.


thank you in advance!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

PureBasic is especially great for writing Windows GUI apps. The links here http://www.purebasic.com/links.php3 should guide you for your first steps.
Especially the Ressources Site is very helpful...

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Nonproductive

a) small, relatively self contained files (ie. no "runtime")
PureBasic applications are very small and the only time you need any runtime libraries which are external to your program (and are not supplied with the OS) are if you use the 3DEngine commands, the module commands, or you specifically make use of some other library directly.

Obviously the user will need to have DirectX installed if you use any of the commands which use that.
b) ease of learning and quick to get "up and running"
The reference manual is complete, but the information is being improved. A user guide is currently being written. At the moment, the best way to learn the language is to look at a combination of the reference manual, and as Andre said, other people's sources and the code on these forums.
c) stability
Take a look through the bug report forum. You'll see a mixture of different types of bugs but you'll notice that most problems get fixed pretty quickly. The only "major" problems are (AFAICR) some problems with floating point maths.
d) speed
The code that PureBasic generates is fast, although there were some recent postings in one of the forums saying it was slower than other basics. Search for "integer too slow" and possibly "float too slow". The libraries are all pretty fast, since I think most of them are still being written in assembly language. Some are written in C (if the library developer docs are to be believed). Console output seems to be fairly slow.
there seems to be a blackhole on the net for Purebasic. I can not find any "getting started" info or even reviews of the language.
I don't know if there is any. I haven't seen a review of PureBasic in major publications and I don't know why.
tutorials? How "friendly" is Purebasic for writing windows GUI apps?
It is certainly better now that it has a GUI designer which will automatically create the GUI code for you. The commands for GUI apps are not that complicated, but you cannot control every aspect of the Windows GUI. However, if you really need to, you can use Windows commands in your code to overcome this limitation.


--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

Excellent info! Thanks to both of you for the prompt responses!
The resource site is very good, but unfortunately is targeted to a more advanced user. I also took a look at the "integer too slow" thread and it doesn't bother me much - coming from VB I'm used to much slower execution :) Other threads on this forum seem to indicate that Purebasic holds it's own quite well in terms of speed.

Are there any "gotchas" with Purebasic? You know, those things where code doesn't do what you think it should because of a quirk in a library or the compiler.

Can someone give example code for the following:
a) a simple "hello world!" *windows* program. (ie. written onto a form not a console window)
b) a program with one "label", one "text edit field" and one "button" that does the following (without API calls):
enter text into text edit field
push button and text is read from edit field and written to label.

These kind of "beginner" programs are what I have been trying to find so that I can make some kind of comparison to Euphoria. It would also be helpful if you could indicate what portion of the code is "generated" byt he GUI designer (if any of it)


Thank you for your patience with my many questions. The community here seems very helpful already - which is a big plus for Purebasic as well.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Nonproductive

Are there any "gotchas" with Purebasic? You know, those things where code doesn't do what you think it should because of a quirk in a library or the compiler.
Yes, although I think most of the quirks I can think of are things that have been reported here as bugs and would hopefully be fixed. I've been using PureBasic for a while though, so I may just be used to it's quirks.

For example, people here always complain that there is two commands for converting strings to numbers and back again (Str() and Val() for integers, StrF() and ValF() for floating point numbers). I don't see the problem in that.

Then there is arrays. If you create an array specifying 20 as the size you will get 21 items (numbered 0 to 20). If you create an array within a structure (a Type I think they are in VB) and specify 20 as the size then you really only do get 20 items (0 to 19).

Pointers to the built in types are not that useful without some extra work (as compared to pointers to the built in types in C compilers).
a) a simple "hello world!" *windows* program. (ie. written onto a form not a console window)

Code: Select all

If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget| #PB_Window_TitleBar|#PB_Window_ScreenCentered, "Example")

  Repeat
    ev.l = WaitWindowEvent()
    
    If ev=#PB_Event_Repaint
      StartDrawing(WindowOutput())
      Locate(50, 50)
      DrawText("Hello, world!")
      StopDrawing()
    EndIf
      
  Until ev=#PB_Event_CloseWindow

EndIf
End
b) a program with one "label", one "text edit field" and one "button" that does the following (without API calls):
enter text into text edit field
push button and text is read from edit field and written to label.

Code: Select all

If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget| #PB_Window_TitleBar|#PB_Window_ScreenCentered, "Example")

  If CreateGadgetList(WindowID())
    StringGadget(1, 50, 50, 150, 20, "")
    ButtonGadget(2, 50, 80, 150, 20, "Change label")
    TextGadget(3, 50, 110, 150, 20, "")
  EndIf

  Repeat
    ev.l = WaitWindowEvent()
    
    If ev=#PB_Event_Gadget
      If EventGadgetID()=2
        SetGadgetText(3, GetGadgetText(1))
      EndIf
    EndIf
      
  Until ev=#PB_Event_CloseWindow

EndIf
End
be helpful if you could indicate what portion of the code is "generated" byt he GUI designer (if any of it)
I think the GUI designer will generate all the code for forms, controls, dialogs, menus and localisation. But I'm not sure because I have not used it for more than 5 minutes.



--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

Thank you, Tinman! Exactyl what I was hoping to see - and as simple as I had hoped :)

It mostly makes sense to me but I do have two questions:

1) the window and gadget initialization is enclosed in an "If" statement. Why is this? What happens if the "If" evaluates to false?

2) It appears as though the main body of a Purebasic program will pretty much always be enclosed within a "repeat...until" I assume you would code to catch all events you care to within this loop. Does this cause any problems with the application "taking over" or does Purebasic automatically check to see if Windows needs something. I guess what I am asking is if there is a need for a visual basic command like "DoEvents" within a Purebasic event processing loop. Aditionally, are events that are *not* explicitly coded for "thrown away?"

Last, unrelated to the examples, question - how is garbage collection and memory management handled?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Nonproductive

1) the window and gadget initialization is enclosed in an "If" statement. Why is this? What happens if the "If" evaluates to false?
The first If will evaluate to false if the window cannot be opened. If the window cannot be opened then you cannot put controls on it and you cannot get any window events.

The second If will evaluate to false if the gadget (controls are called gadgets in PureBasic - another quirk, but the three OSes that PB supports have different names for everything :) list could not be created. If the gadget list cannot be created, you should not create any gadgets :)

The reason for this is that there is no exception type of error andling in PureBasic. You need to check things yourself. The reference manual describes when you should check the result of commands, and should probably also say what you cannot do if a command fails.
2) It appears as though the main body of a Purebasic program will pretty much always be enclosed within a "repeat...until" I assume you would code to catch all events you care to within this loop. Does this cause any problems with the application "taking over" or does Purebasic automatically check to see if Windows needs something. I guess what I am asking is if there is a need for a visual basic command like "DoEvents" within a Purebasic event processing loop.
You could put all the code to handle the events in that loop (could also be a While...Wend loop, and does not need to be based on the event being a #PB_Event_CloseWindow one) if you wanted, or you could put code in functions and call those, and so on. I don't know if the GUI designer will automatically generate a main loop for you, like VB automatically handles the main loop.

By using the WaitWindowEvent() command your PureBasic program will wait for the next event to appear in a completely system friendly way, freeing up your CPU for the other programs you have running. There is another command, WindowEvent() which does not wait, but it will steal all your CPU cycles unless you add some delays (using the Sleep() command for example).
Aditionally, are events that are *not* explicitly coded for "thrown away?"
If you do not handle an event PureBasic will report it, but you would write your code so that it just ignores it. For example, this modification to one of the above examples will show you that you get a lot of events geenrated, but the code simply does nothing with them.

Code: Select all

If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget| #PB_Window_TitleBar|#PB_Window_ScreenCentered, "Example")

  If CreateGadgetList(WindowID())
    StringGadget(1, 50, 50, 150, 20, "")
    ButtonGadget(2, 50, 80, 150, 20, "Change label")
    TextGadget(3, 50, 110, 150, 20, "")
  EndIf

  Repeat
    ev.l = WaitWindowEvent()
    
    If ev=#PB_Event_Gadget
      If EventGadgetID()=2
        SetGadgetText(3, GetGadgetText(1))
      EndIf
    Else
      Debug "I'm ignoring this event"
    EndIf
      
  Until ev=#PB_Event_CloseWindow

EndIf
End
Last, unrelated to the examples, question - how is garbage collection and memory management handled?
PureBasic libraries are usually (Fred writes them like this, other people should do too) written so that memory is allocated and freed correctly when needed or not, and all memory and resources should be freed cleanly on program exit.

There is no garbage collection during program run. You would manually need to free things if you wanted them freed. Strings that are stored in procedure local variables are freed automatically on exit from the procedure (I think). String memory is freed if required by any operations performed on strings. General memory allocations are done by the programmer so must be freed by the programmer. All this stuff is freed on exit from your program though.

Another quirk - arrays and linked lists are always globally accessable and so do not get freed on exits from procedures and things.


--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

PureBasic code structure is so easy to understand, see this code:

Code: Select all

#MyTextBox = 1
#MyButton  = 2

If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  StringGadget(#MyTextBox,50,50,350,20,"")
  ButtonGadget(#MyButton,200,100,50,25,"Test")
  Repeat
    EventID=WaitWindowEvent()
    
    Select EventID
    
      Case #PB_EventGadget
      
        Select EventGadgetID()
        
          Case #MyButton
            MessageRequester("Button","Click",0)
            SetGadgetText(#MyTextBox,"Clicked!!")
        EndSelect
    
    EndSelect
    
  Until EventID=#PB_EventCloseWindow
EndIf
If we made a little trick then it could be more similar to VB code

Code: Select all

#MyTextBox = 1
#MyButton  = 2

Procedure Button_OnClick()
  MessageRequester("Button","Click",0)
  SetGadgetText(#MyTextBox,"Clicked!!")
EndProcedure


If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  StringGadget(#MyTextBox,50,50,350,20,"")
  ButtonGadget(#MyButton,200,100,50,25,"Test")
  Repeat
    EventID=WaitWindowEvent()
    Select EventID
      Case #PB_EventGadget
        Select EventGadgetID()
        
          Case #MyButton
            Button_OnClick()
        EndSelect
    EndSelect
  Until EventID=#PB_EventCloseWindow
EndIf
And even if you check Tinman style its different, this flexibilitie is a great thing in PureBasic.


If you accept one suggestion: Forget about Euphoria, dosent has anything to do compared with PureBasic.

Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

I can't thank you guys enough! Very fast and easy to understand responses.

I just spent some time looking at the source (thank you for Puredemo, Bob Houle!)of various programs included with the demo as well as spending some time with the visual designer. At this point it looks like Purebasic is everything I am looking for. The programs seem incredibly fast and *TINY!* I am amazed at how small the executables are.

I also read many of the messages in the General and Beginner forums here. It must be said that the community here is very patient and friendly with new users. That alone makes Purebasic worth using.

I put in my order a little while ago :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
I put in my order a little while ago :)
Welcome to PureBasic!!



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

Thank you! :)

General question: Should I grab the files in http://www.purebasic.com/update/ regularly? I assume those are bug fixes?

By the way, after placing my order I posted the message and by the time I finished typing and hit "subit" my registration email had arrived. :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by theogott.

The NEED for this thread from "Nonproductive" shows that there is
still a lack of written information on Purebasic.

The help is from my point of view worse then the help from other systems.

The builtin ASM is undocumented if you don't go "elsewhere" looking.
I am quite shue there are SOME "Nonproductive" out there who do NOT take time to make postings here and just quitely go to Euphoria.

Euphoria btw. has its strengths, however it is NOT Speed, and its not file-size even though it has "builtin UPX" (which would be nice as an optional checkbox in Compiler-settings for Purebasic too).

The help-files are OK, so a beginner can learn it much more easily then for example purebasic.

Euphoria has definitely the strength of producing very short code.
However updates are NOT free and come only very seldom (count years rather then month). However If you look at the many "Features" most other languages cannot compete.

But don't look at documentation. If I'd take it serious, I'd still assume there is NASM in Version 3.63 ...


*************************
The best time to do things is now !
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by theogott.

Correction:

The last two sentences are meant for Purebasic.

Euphoria has no such "Features" as it is also an "P-Code interpreter" and as such normally far from beeing fast enough.

You can use it for testing algorhytms and for description of nested data-structures.

Otherwise it could have been missunderstood.


*************************
The best time to do things is now !
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by blueb.
I just spent some time looking at the source (thank you for Puredemo, Bob Houle!)

Thank you Nonproductive!

I don't expect any thanks for any programs that I cobble up. I really think beginners need these kind of things. Even PureDemo is extendable if everyone adds to it, so that newbies can benefit.

Welcome to a great programming environment. It beats Euphoria hands down (yes, I've got a registered copy somewhere, but haven't used it since coming over to PB) PureBasic is by far a superior language in every way.

Every day, some of the better programmers are adding things like SQLite database functions (complete database server under 200k), the Visual Designer, etc, etc.

There's not much you can't do with PB.

--blueb
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Nonproductive.

Oh my god! If I didn't think the neighbors would call the police, I would be doing a happy dance right now. I hadn't even gotten to the Tips and Tricks forum - but after reading that SQLite functions were available I searched for and found the thread about the wrapper. I am now positive that I chose the right language to jump back into programming with!

Euphoria's EDS was one of the things that kept me on the fence. I figured MySQL is easy enough to configure and Purebasic could access it though and purchased my license. Now the SQLite DLL is *infinitely* better for my purposes!

Oh happiness! :)

As far as Puredemo - honestly, it was a contributing factor in my decision to buy a license. Without Puredemo I would probably still be looking through the examples and scratching my head. For me, it served two purposes - 1st, it made the example source code immediately accessible without knowing anything about Purebasic. 2nd - as a program written in Purebasic I was able to get an idea of the size and speed of a "typical" windows app. In addition, since the source was included, I can look at it with Puredemo running and learn from that as well!

It would really benefit Purebasic to distribute the PB demo and registered versions with Puredemo - it's that useful to new (and I'm sure veteran as well) users.

Thank you again!
Post Reply