Auto console mode and thread safety

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Auto console mode and thread safety

Post 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). ;)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Auto console mode and thread safety

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Auto console mode and thread safety

Post 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).
quidquid Latine dictum sit altum videtur
Robynsveil
User
User
Posts: 44
Joined: Fri Nov 30, 2012 2:07 pm

Re: Auto console mode and thread safety

Post 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????
Robynsveil
User
User
Posts: 44
Joined: Fri Nov 30, 2012 2:07 pm

Re: Auto console mode and thread safety

Post 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?
Robynsveil
User
User
Posts: 44
Joined: Fri Nov 30, 2012 2:07 pm

Re: Auto console mode and thread safety

Post 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:
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Auto console mode and thread safety

Post by Fred »

Now stop your pathetic rant or your account will be suspended. Last warning.
Robynsveil
User
User
Posts: 44
Joined: Fri Nov 30, 2012 2:07 pm

Re: Auto console mode and thread safety

Post 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.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Auto console mode and thread safety

Post 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. :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply