Page 1 of 1

Auto console mode and thread safety

Posted: Sun Dec 02, 2012 9:38 am
by MachineCode
I always wondered why the executable created by PureBasic wouldn't automatically be of console type if the OpenConsole() keyword was used; and why it doesn't create a threadsafe executable when CreateThread() was used. Why do we need to turn these on manually when using these keywords? My suggestion: make them automatic, since the keywords are there and it's obvious that we want the executables to be of that type.

(You can even go one step further and do an automatic UseJPEGImageEncoder() if our sources use SaveImage() with the #PB_ImagePlugin_JPEG flag). ;)

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 10:00 am
by Danilo
MachineCode wrote:I always wondered why the executable created by PureBasic wouldn't automatically be of console type if the OpenConsole() keyword was used; and why it doesn't create a threadsafe executable when CreateThread() was used. Why do we need to turn these on manually when using these keywords? My suggestion: make them automatic, since the keywords are there and it's obvious that we want the executables to be of that type.

(You can even go one step further and do an automatic UseJPEGImageEncoder() if our sources use SaveImage() with the #PB_ImagePlugin_JPEG flag). ;)
It may be a question of control for the user (us). I know what I want, so I create a console or GUI program.
If I want to support JPEG or PNG encoding or decoding, I include it in my application.
I can open an console from within a GUI program and I am able to open a GUI window from an console program.
If I use OpenConsole() in my code, it does not mean I want it to be a pure console application, and using CreateThread()
in my program does not mean automatically, I want to link to the threadsafe PureBasic libraries. If a programmer knows what
he is doing, he can use threads without need of the threadsafe PB libraries.
Your request would be nice for absolute beginners, but would take control from experienced programmers.

Most beginners are experts after 4 month with PureBasic, there are only very few people that still
would need the automatic control level after 1 year with PB. ;)
I know, "BASIC" stands for "beginners all-purpose symbolic instruction language", but in reality experienced
companies use this very same BASIC to write real-world applications and make money with it, feeding
many hundred of thousands customers world-wide with apps and make big $$$. That's our job, as developers.

I want to have as much control as possible over my code, so please don't take away this level of control.

-1

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 11:55 am
by freak
You can create threads with pure API commands as well. Also, inside a DLL you may have no CreateThread() at all and still want thread safety (because the main program uses threads).

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 12:02 pm
by Robynsveil
MachineCode wrote:I always wondered why the executable created by PureBasic wouldn't automatically be of console type if the OpenConsole() keyword was used; and why it doesn't create a threadsafe executable when CreateThread() was used. Why do we need to turn these on manually when using these keywords? My suggestion: make them automatic, since the keywords are there and it's obvious that we want the executables to be of that type.

(You can even go one step further and do an automatic UseJPEGImageEncoder() if our sources use SaveImage() with the #PB_ImagePlugin_JPEG flag). ;)
What? Huh? How?

Sheesh, stuff to *KNOW*... where is this documented? Not in any tutorials! Completely agree... why doesn't OpenConsole() open a console in Linux????

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 12:04 pm
by Robynsveil
So, for the total KNOW-nothings like me, something like OpenConsole()... isn't.

So, perhaps the tutorials need to include code so the OpenConsole()... does.

Ya reckon?

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 12:08 pm
by Robynsveil
I am SO going to rack up all these posts because of the bloody purists who insist on the language being thus-and-thus, making it impossible for newbies like me to *ever* get me head around it because behaviour doesn't happen. OpenConsole() means *what*, exactly, then? is there another way for something like Input() to actually show up? and then, WHY TF don't the tutorials provide this work-around so the language purists can have their way??????

is this really hard for people to get??? :shock:

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 12:09 pm
by Fred
Now stop your pathetic rant or your account will be suspended. Last warning.

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 12:40 pm
by Robynsveil
Thank you. According to Fred, it appears that OpenConsole() does not work as advertised in the Gary Willoughby tutorial, *in* *Linux* ... thanks for the heads-up, Fred. :)
Wished I'd known before - need to read the manual first before doing any tutorials, it seems.

Re: Auto console mode and thread safety

Posted: Sun Dec 02, 2012 2:02 pm
by MachineCode
freak wrote:inside a DLL you may have no CreateThread() at all and still want thread safety (because the main program uses threads).
I wasn't aware of that possibility. Thanks for pointing it out. Ignore this request, then. :)