Page 2 of 2

Re: PB to SB Conversion Q's

Posted: Sun Aug 11, 2019 9:05 pm
by bbanelli
Peter wrote:
bbanelli wrote:Instead, for server side, consider GoLang.
Consequently, you would have to use GopherJS or the Joy Compiler now. ;)
I don't see a single reason why would you do so.

Go

Code: Select all

package main

import (
	"encoding/json"
	"net/http"
)

type spiderStruct struct {
	NavigatorPlatform string `json:"navigatorPlatform"`
}

func spiderTest(w http.ResponseWriter, r *http.Request) {
	decoder := json.NewDecoder(r.Body)
	var spiderJson spiderStruct
	decoder.Decode(&spiderJson)
	w.Write([]byte(spiderJson.NavigatorPlatform + " - Go!"))
}

func main() {
	fs := http.FileServer(http.Dir("static"))
	http.Handle("/", fs)
	http.HandleFunc("/spiderPost", spiderTest)
	http.ListenAndServe(":8080", nil)
}
SpiderBasic

Code: Select all

Procedure HttpGetEvent(Success, Result$, UserData)
  If Success
    Debug Result$
  Else
    Debug "HTTPRequest(): Error"
  EndIf
EndProcedure

Procedure ButtonHandler()
  Protected.s s
  !v_s = navigator.platform;
  s = ~"{\"navigatorPlatform\": \"" + s + ~"\"}"
  HTTPRequest(#PB_HTTP_Post, "/spiderPost", s, @HttpGetEvent())
EndProcedure

If OpenWindow(0, 100, 100, 320, 240, "", #PB_Window_SizeGadget)
  ButtonGadget(0, 10, 10, 100, 20, "Click me")
EndIf

BindGadgetEvent(0, @ButtonHandler())
Will produce:

Image

Go is serving both static SpiderBasic files and provides HTTP request endpoints.
the.weavster wrote:
bbanelli wrote:I know this is an old topic, but I would strongly discourage using (any, let alone PB's) CGI in 2019.
Why? CGI is wonderfully simple and simple solutions are invariably the most robust.
I seriously have to answer that?

CGI is a Internet atavism, server and platform dependent, incompatible with any modern relevant technology for deployment, calls/forks new process with each request making reuse of connections and objects impossible, its last specification is 15+ years old, has no support for any sane modern approach of HTTP communication, it is very hard to debug... I could go on but it would be pointless.

In other words, there is nothing "robust" or "simple" in CGI; especially not in 2019. Not even as a joke. And you seemed to be pretty serious. Which is very bad, very bad, since someone could actually believe you.

Re: PB to SB Conversion Q's

Posted: Mon Aug 12, 2019 5:09 pm
by skywalk
Ouch :? Just a bit harsh for poor old CGI.
Still in use in embedded processors and closed networks that serve up compiled code.
Very light weight and the O/S handles its memory on close.

Re: PB to SB Conversion Q's

Posted: Mon Aug 12, 2019 7:17 pm
by the.weavster
bbanelli wrote:
the.weavster wrote:Why? CGI is wonderfully simple and simple solutions are invariably the most robust.
I seriously have to answer that?
Or perhaps you could try answering it seriously.
bbanelli wrote:server and platform dependent
GoLang also has to be compiled for a particular platform too.
bbanelli wrote:incompatible with any modern relevant technology for deployment
Oh, I didn't realise web servers had become irrelevant.
bbanelli wrote:calls/forks new process with each request making reuse of connections and objects impossible
With modern hardware who cares? Does it respond fast enough? Yes? What's the problem?
bbanelli wrote:its last specification is 15+ years old
It's so simple, what needs to change?
bbanelli wrote:has no support for any sane modern approach of HTTP communication
:roll:
bbanelli wrote:it is very hard to debug...
Make it write a log.
bbanelli wrote:In other words, there is nothing "robust" or "simple" in CGI; especially not in 2019.
If you can't make a robust CGI how are you going to cope with something more complex?
bbanelli wrote:Not even as a joke. And you seemed to be pretty serious. Which is very bad, very bad, since someone could actually believe you.
Perhaps they could try it for themselves and see whether I'm right.

Re: PB to SB Conversion Q's

Posted: Mon Aug 12, 2019 11:19 pm
by bbanelli
skywalk wrote:Ouch :? Just a bit harsh for poor old CGI.
Still in use in embedded processors and closed networks that serve up compiled code.
Well, COBOL is still used in certain applications, but you don't see anything new and sane (in terms of usefulness) written in it in last... 30 years?
Very light weight and the O/S handles its memory on close.
OS that wouldn't handle "memory on close" wouldn't be much of an OS, right? As for being lightweight, based on its concept, it is certainly far from that, except for maybe echoing stuff back to user. Which doesn't make it quite useful altogether.
the.weavster wrote:
bbanelli wrote:
the.weavster wrote:Why? CGI is wonderfully simple and simple solutions are invariably the most robust.
I seriously have to answer that?
Or perhaps you could try answering it seriously.
For a moment I thought you were just a troll. Now I simply see that you are truly incompetent for this business. Which is fine, as long as you are not providing "advice" publicly.
bbanelli wrote:server and platform dependent
GoLang also has to be compiled for a particular platform too.
It does, but it is completely (web)server and platform independent. Regardless of Go, you have to make prior engagement for enabling, running and securing your CGI scripts. Which makes them awfully impractical and requires system (or if you wish a more modern buzzword - devops) knowledge.

But than again, you are writing CGI scripts (in PureBasic) in 2019., so that probably isn't too relevant for you anyway.
bbanelli wrote:incompatible with any modern relevant technology for deployment
Oh, I didn't realise web servers had become irrelevant.
I was talking about orchestration, PaaS and SaaS, but as I said - guy advocating PB's CGI in 2019. probably has no clue about those as well.
bbanelli wrote:calls/forks new process with each request making reuse of connections and objects impossible
With modern hardware who cares? Does it respond fast enough? Yes? What's the problem?
We are eager to hear your success story with CGI in 2019. JMeter results with some database action in your CGI scripts will do, you don't have to disclose your heavily NDA protected CGI based errands, don't worry about that.
bbanelli wrote:its last specification is 15+ years old
It's so simple, what needs to change?
Geez, you are right! That's the best thing about CGI; it was written so well and "robust" and... yeah, whatever, that it could stay on a rock solid 2004. technology foundations!

Hope you are communication with us from DOS. It's so simple! So is Arachne. Far simpler that Chrome, that's for sure!
bbanelli wrote:has no support for any sane modern approach of HTTP communication
:roll:
So, your example of REST architecture through PB's CGI, pretty please? WebSockets? I am not even sure a simple preflight OPTIONS requests is doable through it. You can Google all this terms, since I doubt they ring a bell.

JFTR, we are actually talking about someone using your service, not you being at home playing programming with CGI in PureBasic. Alone.
bbanelli wrote:it is very hard to debug...
Make it write a log.
Do'h! How haven't I thought of that! Thanks! Let's tell Fred to remove that stupid lousy debugger from SpiderBasic as well, the.weavster discovered console.log()!!!
bbanelli wrote:In other words, there is nothing "robust" or "simple" in CGI; especially not in 2019.
If you can't make a robust CGI how are you going to cope with something more complex?
"Robust"... Look it up in the dictionary. This word obviously doesn't mean what you think it means. Than perhaps enroll in some programming course, preferably one published in 21. century, reconsider your "knowledge" and get back to us.
bbanelli wrote:Not even as a joke. And you seemed to be pretty serious. Which is very bad, very bad, since someone could actually believe you.
Perhaps they could try it for themselves and see whether I'm right.
Well... Sorry to break it to you, but you are so far from being right as CGI is far from (any) web development... 10 years ago. In other words - very, very wrong.

This has been so much fun, but seriously, if you are trolling, knock it off, it isn't remotely funny any more and you are being plainly stupid without any understandable reason; and if you are still sure CGI is a way to go, disconnect from the Internet so you would be tempted giving advice to people on it.

Re: PB to SB Conversion Q's

Posted: Tue Aug 13, 2019 3:03 pm
by skywalk
Forums are for knowledge transfer and I appreciate your opinions on this topic.
I would only ask for a bit more civility. Sometimes passion gets in the way. ;)

Re: PB to SB Conversion Q's

Posted: Tue Aug 13, 2019 6:13 pm
by bbanelli
skywalk wrote:Forums are for knowledge transfer and I appreciate your opinions on this topic.
I would only ask for a bit more civility. Sometimes passion gets in the way. ;)
C'mon, the.weavster is a big tro^H^H^H boy, so am I, we'll live through this. ;)

Not only am I looking forward to reading his reply, but we are making some traffic here, hopefully Fred will notice us and shut both of our mouths with some Spider Basic 3.0 release!!!

Re: PB to SB Conversion Q's

Posted: Tue Aug 13, 2019 8:35 pm
by Peter
bbanelli wrote:hopefully Fred will notice us and shut both of our mouths with some Spider Basic 3.0 release!!!
In that case, go ahead, guys! ;)