Using PureBasic to create websites?

Just starting out? Need help? Post your questions and find answers here.
wysardry
User
User
Posts: 37
Joined: Sun May 27, 2012 4:58 pm

Using PureBasic to create websites?

Post by wysardry »

I was just wondering if anyone has written a program in PureBasic that helps with creating websites or blogs. I was thinking of something along the lines of a desktop version of Wordpress that creates static HTML files ready to upload to a hosting service.

Is this something that PureBasic is suitable for, or would I be better off writing something in Perl?
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Using PureBasic to create websites?

Post by skywalk »

You could try SpiderBasic. It compiles to javascript and allows for more than static html. You still need a backend to process the web responses that go outside the sandbox.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
wysardry
User
User
Posts: 37
Joined: Sun May 27, 2012 4:58 pm

Re: Using PureBasic to create websites?

Post by wysardry »

Javascript is an interpreted language, so it would be a lot slower to build the pages than a compiled PureBasic program. I don't need any dynamic features in the completed pages, I just want a program that will do all the repetitive tasks for me.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Using PureBasic to create websites?

Post by IdeasVacuum »

Hello wysardry

I think understand what you mean - create a desktop application that can be used to create websites, like Serif WebPlus, Coffee Cup, Xara etc?

I think you could build a good app to do that with PB, but if only for personal use, the time and effort required is a big consideration.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Using PureBasic to create websites?

Post by Marc56us »

It is easy to create static pages since they are simple text files.
I do it for the download page of my site where a simple PB program reads my new version number, create the MD5 files of my programs, create the PHP page and upload all through FTP.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Using PureBasic to create websites?

Post by Lunasole »

wysardry wrote:I was just wondering if anyone has written a program in PureBasic that helps with creating websites or blogs. I was thinking of something along the lines of a desktop version of Wordpress that creates static HTML files ready to upload to a hosting service.
That's what I've coded once for my homepage ^^ And that's better/more optimized and customized than Wordpress or any existing stuff.

Surely PB is suitable for that, and probably even more than Perl. For now that my stuff has about 1500 lines of code and builds static site with menus/files/screenshots/CSS/some other things processed semi-automatically. Originally it was much simpler, yet made in a few hours.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Using PureBasic to create websites?

Post by Dude »

wysardry wrote:Is this something that PureBasic is suitable for
Yes.
wysardry
User
User
Posts: 37
Joined: Sun May 27, 2012 4:58 pm

Re: Using PureBasic to create websites?

Post by wysardry »

Although what I have in mind is a desktop application, it isn't really very similar to Serif WebPlus, Coffee Cup, Xara etc. They really only allow you to create and edit web pages one at a time and you need to include very similar code for every page.

It would be more like a desktop version of Wordpress, Drupal or Joomla, as (once it is set up) all I want to do is enter some details, such as the title, category and keywords, along with the main page text, and the program would add the rest of the code for navigation etc. and add links to it on any index.html listing pages.

My main concern with creating something like this in PureBasic is whether it could easily cope with storing HTML fragments as strings without symbols such as <, > and " causing problems.

Perl allows you to define any symbol as a string delimiter and even lets you have multi-line strings, but it is an interpreted language, so it would be noticeably slower for larger sites. I'd also need to install web server software if I wanted to enter data using forms.

I don't have any experience of creating desktop GUI applications either, so learning that would take some time. I'm hoping it will be worth it in the long run, as this could potentially make things much easier once the site is larger.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Using PureBasic to create websites?

Post by skywalk »

What you describe is the combo of both Purebasic and Spiderbasic. Prototyping is their sweet spot. Get it working quickly and then decide if you need more speed.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Using PureBasic to create websites?

Post by Marc56us »

In PB, there is no problem with <> " ...

Two ways:
- Escape string :arrow: ~""
- Constants :arrow: #DQUOTE$

Code: Select all

Debug #DQUOTE$ + "Hello World" + #DQUOTE$
Debug ~"\"Hello World\""
(off reply: Perl)
... but it is an interpreted language, so it would be noticeably slower for larger sites.
Perl is not (realy) an interpreted language. The entire code is read and pre-compiled before execution (unlike the first Basic ones that operated line by line). No language is faster than it is for managing large text files (apart from C and Assembler). It's his job for 30 years.
Perl is used regularly to migrate large document management systems (DMS), precisely because of its speed and simplicity (yes)
(Even if we say that a Perl code UUencoded, it still looks like Perl :P )
wysardry
User
User
Posts: 37
Joined: Sun May 27, 2012 4:58 pm

Re: Using PureBasic to create websites?

Post by wysardry »

skywalk: I'm sorry, you've lost me. Why would I need to use a browser-based language for a program that has a desktop interface?

Marc56us: Can you also escape strings stored in text database files, such as in CSV format?

I haven't had much recent experience with Perl programs, but I used to use Links 2 from Gossamer Threads about 8 years ago. It was used for creating a directory of links and created static HTML pages. If you had a few hundred links it would take several minutes to build all the pages on a local web server.

There is a static website generator program called Hugo (written in Go) that takes less than 1 ms to build each page.

I know that PureBasic isn't likely to be as fast as Go, but I thought it would be much quicker than Perl, as the programs are already compiled. Has anyone done a speed comparison?
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Using PureBasic to create websites?

Post by Marc56us »

EditorGadget do the job
Sample: Write text inside with CR/LF/Tab "" <> etc

Code: Select all

EnableExplicit

Enumeration 
     #Win
     #Edit
     #File
EndEnumeration

Define FileName.s = GetTemporaryDirectory() + "Test.txt"

OpenWindow(#Win, 0, 0, 500, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(#Edit, 10, 10, 480, 280)

; If file exist, load it
If FileSize(FileName) > 0
     ReadFile(#File, FileName)
     While Not Eof(#File)
          AddGadgetItem(#Edit, -1, ReadString(#File))
     Wend
     CloseFile(#File)
EndIf

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend

; Save when close
OpenFile(#File, FileName)
WriteString(#File, GetGadgetText(#Edit))
CloseFile(#File)
GetGadgetText(#Edit) = Full text in editor in one time
run again: <> " tab are here
for other usage, use Regex
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Using PureBasic to create websites?

Post by Lunasole »

wysardry wrote: I know that PureBasic isn't likely to be as fast as Go, but I thought it would be much quicker than Perl, as the programs are already compiled. Has anyone done a speed comparison?
Well speed will depend on your skill. For example, those 0-terminated strings may be slow if used somehow like you used strings in Perl or that Go or another newbie languages (yea, today I feel sarcastic about fact that "BASIC" in 2017 generally requires more knowledges and skills than "pro"-languages :3). If your code is bad, it will work long, there is no complex compiler or JIT analysis to fix programmers stupidity.

Anyway, results will surely be much faster/optimized than Perl. Go will also lose in speed/resources consumption, if only that will be an aim too.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
wysardry
User
User
Posts: 37
Joined: Sun May 27, 2012 4:58 pm

Re: Using PureBasic to create websites?

Post by wysardry »

Marc56us: Thanks. Storing the data in separate text files will make the whole process a lot easier.

Lunasole: I probably know Perl slightly better than PureBasic, but have never used Go. Although I prefer BASIC syntax, Perl is well known for its text processing capabilities, which is why I'm still slightly undecided.
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Using PureBasic to create websites?

Post by firace »

Post Reply