Thursday, October 11, 2007
Half Life 2 Episode 2
So why am I posting about a video game here? Because I'm dying to play it, but I won't play because I can't allow myself to be distracted from working on Run BASIC right now. Probably I'll give myself permission to enjoy some game playing abandon when the holidays roll around.
In the meantime Run BASIC development is a lot of fun too in many important ways. :-)
Thursday, September 27, 2007
Parsing XML in Run BASIC
One of the important feature that a Web 2.0 language needs is an XML parser. Run BASIC now has one built in. The XMLPARSER statement parses an XML string and returns an XML accessor object with a bunch of handy built-in methods for making your way through an XML document.
Here is a simple example of what that sort of code looks like:
a$ = "<program name=""myprog"" author=""Carl Gundel""/>"
xmlparser #parser, a$
print #parser key$()
for x = 1 to #parser attribCount()
key$ = #parser attribKey$(x)
print key$; ", ";
print #parser attribValue$(x)
next x
This short program produces:
program
name, myprog
author, Carl Gundel
And here is a short program which will display the tag names and contents of an artibrarily nested XML document:
xmlparser #doc, s$
print #doc key$()
call displayElements #doc
end
sub displayElements #xmlDoc
count = #xmlDoc elementCount()
for x = 1 to count
#elem = #xmlDoc #element(x)
print "Key: "; #elem key$();
value$ = #elem value$()
if value$ <> "" then
print " Value: "; value$
end if
print
call displayElements #elem
next x
end sub
Monday, September 24, 2007
Do-it-yourself programming
A friend of mine pointed me at this article "Do-It-Yourself Software" in the Wall Street Journal.
http://online.wsj.com/public/article/SB119023041951932741.html
Run BASIC and Liberty BASIC are both aimed at this market, and in fact this is the traditional niche of BASIC language products.More on modularity
[masterPage]
cls
html "Program manager"
link #wiki, "Wiki", [runTheWiki]
print " ";
link #multi, "Multicounter", [runTheMulticounter]
if launchFlag then render #subProg
wait
[runTheWiki]
run "runWiki", #subProg
launchFlag = 1
goto [masterPage]
[runTheMulticounter]
run "multicounter", #subProg
launchFlag = 1
goto [masterPage]
Here is a version that doesn't use any GOTOs:
global launchFlag
call displayMasterPage
wait
sub displayMasterPage
cls
html "Program manager"
link #wiki, "Wiki", runSubprogram
#wiki setkey("runWiki")
print " ";
link #multi, "Multicounter", runSubprogram
#multi setkey("multicounter")
if launchFlag then render #subProg
end sub
sub runSubprogram linkKey$
run linkKey$, #subProg
launchFlag = 1
call displayMasterPage
end sub
So what does this do? It creates a simple web page with a title and two links. Click on the wiki link and the wiki program becomes part of the web page. Click on the multicounter link and the multicounter replaces the wiki part of the page. You can switch back and forth between the wiki and the multicounter at will with just the click of a mouse. What's even more interesting is that the multicounter is already a modular program, so you get three levels of modularity but you aren't limited to that.
So for programmers who like to put all their code in one file, there's nothing to prevent that. But people who like modules can have a field day.
Tuesday, September 11, 2007
Run BASIC enters beta testing
Run BASIC Personal Server is an all in one web app server, BASIC scripting language, database engine and more. It offers an extremely easy way to get into web application development. When I say extremely easy I am not exaggerating. We are talking "a child could do it" easy web programming.
When I asked my testers how they would describe Run BASIC, here is what some of them said:
" - - Run BASIC provides a complete alternative to the complex development languages that have evolved to script web content. Run BASIC wrests control back to you, allowing BASIC language scripting of web content. Create web pages in an easy to use project development environment and publish on the web at the click of a mouse."
" - - If you've ever used one of the classic BASIC interpreters, then you already know most of what you need to build dynamic websites using Run Basic."
" - - Run BASIC moves desktop programming out onto the internet. The screen displays, forms, interactions, graphics, and data-handling processes you create with clear, understandable BASIC programs suddenly become web applications, usable by anyone, on any platform -- Windows, Mac, Linux -- on any computer with browser access to the internet. With Run BASIC, you can write your program from anywhere, on any computer, and run it everywhere, on every computer."
If you are interested in Run BASIC and feel you have enough time to spend at least a few hours testing it out, please send an email to me at carlg@libertybasic.com and explain why you would like to be a beta tester.
We will accept only a certain number of applicants and I'll post a note here when we have enough.
Thanks!
-Carl Gundel
Saturday, July 07, 2007
Database and web capabilities
We also have added an httpget$() function so you can use HTTP to retrieve web documents like web pages, RSS feeds, etc. We plan to include an XML parser, and if we can come up with an easy to use way to stream through an HTML document we will provide that also.
These capabilities (except for the table rendering) will also be included in Liberty BASIC v5.0.
To keep up with what we're doing with Run BASIC, make sure to visit this blog and also http://libertybasic.conforums.com/index.cgi?board=runbasic
Wednesday, June 27, 2007
Adding SQLite to Run BASIC
sqliteconnect #users, "test.db"
call execAndPrint "select * from users"
call execAndPrint "select count(*) from users"
#users disconnect()
end
sub execAndPrint query$
#users execute(query$)
while #users hasanswer()
result$ = #users nextrow$(",")
print result$
wend
end sub
SQLite is a popular database engine provided as a library and is supported for Windows, Mac and Linux. The source code is available and is in the public domain so it is completely free. We will support the parts of Run BASIC that integrate with SQLite, but as for the specific level of conformance to the SQL standard and other technical details, see http://www.sqlite.org/
The SQLITECONNECT #obj, "databasefile.db" statement connects to a database and sets the #obj variable to be a connection object. The connection object understands EXECUTE(), HASANSWER(), NEXTROW$() and DISCONNECT(). I'm sure there will be more commands.
Notice the NEXTROW$() method. It returns each query result row as a string, with each item delimited by the specified string ("," in the example but it could be CHR$(9) or something else). It is trivial then to use the WORD$() function to extract the information. We will certainly also add the ability to get items by name.
Wednesday, June 20, 2007
Run BASIC and the iPhone
I have a Treo 650 myself, and I can use it to access the Run BASIC site, but it is awkward because the web browser it includes is slow and the Treo has a tiny little screen. I am eager to see how this all works on the iPhone, and if it is compelling I may even buy one just so I can demonstrate Run BASIC wherever I am. ;-)
Thursday, June 14, 2007
Support for CSS class tags
One new addition to Run BASIC is the ability to add a CSS class tag to an object on a web page, so that it can be manipulated.
For example the following would create a link and set a class to "button".
link #doMyBidding, "GO", [go]
#doMyBidding cssclass("button")
And the following statement would add the CSS needed to style the link (or any object that has the class tag "button"):
cssclass ".button", "{ put some css styling in here }"
Here is a link to a video demonstrating how this all works.
http://www.youtube.com/watch?v=1qomg67VdF0
Sunday, June 03, 2007
Component Based Web Development
In addition to inserting graphics into a web page, Run BASIC's RENDER statement can now be used to insert a module into a web page. We have this in a rough state now. It does work, but we need to iron out a couple of things.
What is this useful for? You can now create different parts of your web application as separate programs. You load them in and render them into the page. You can also control them using their own functions.
For example you might have a blog application with different parts of the page rendered by their own modules:
- BannerLogin
- Navigation bar
- Entries
- Archive outline
- etc.
By using the DIV and CSS statements, the modules can be formatted on the web page in an attractive and useful way.
Saturday, June 02, 2007
Rumblings under the surface
Wednesday, May 30, 2007
Modules and Run/Liberty BASIC
The RUN statement has a new form. If I want to use mymodule.bas as a module in a program I am writing I would code it like this:
run "mymodule.bas", #myModule
This causes mymodule.bas to be compiled into memory. It will execute code up to the first wait statement. This is how values will be initialized. The program then becomes an object assigned to the #myModule handle.
Then you can call any function on that program from within the calling program, like so:
#myModule myFunction(myParameter)
or even use the invokation in a more complex expression:
print "digits: "; len(#myModule myFunction(myParameter))
You may recognize this syntax as being the same as for controlling widgets. It relies on the same underlying mechanisms to do its work.
When we're done with this, modular programs loaded this way will be cached in memory and will only recompile when the source file changes.
Monday, May 21, 2007
Inkey$ and Liberty BASIC
- Getting the next character in the mainwindow without stopping the program. Currently only INPUT and INPUT$() are supported. Both stop the program and wait.
- Getting the next character typed for some window or widget that has focus. In other words, reading keypresses for objects with handles (ie. #thisWindow)
What I suggested in the forum is a function called inkey$().
The following would read keypresses for the mainwindow:
print inkey$()
or it could be abbreviated to:
print inkey$
To read keypresses for windows or widgets with handles:
print inkey$(#handle)
I'd like to solicit feedback here. Any ideas? Please leave a comment, and thanks!
Thursday, May 10, 2007
BASIC and CSS
However there is a better way. It is called CSS (Cascading Style Sheets). This provides a way to wrap the things on your web page with tags that you give your own names to, and you defined the appearance of the stuff wrapped in those tags somewhere else. This way your program's code has very little extra stuff in it to clutter up your code. If there is too much clutter it can be very hard to understand what code means, and this can slow you down and lead to bugs.
So, Scott McLaughlin and I have begun to integrate CSS with Run BASIC. We added a CSSID statement (originally this blog entry had this as CSS, but we changed the command), a DIV statement, and an END DIV statement. Here's a very short example:
cssid #myTag, "{ background: #FFDDDD; font-family: tahoma }"
div myTag
print "count to ten"
for x = 1 to 10
print x
next x
end div
Okay, so this displays all the text printed between the DIV and the END DIV with a light red background, and using the tahoma font. The #myFont token isn't a handle like the ones used for files and GUI controls. The # is simply part of CSS syntax.
DIV statements can be nested, and the contents of one DIV block will be rendered on the page nested inside of each other.
There is a lot more that can be done with CSS, and we're trying to explore what are the simplest and most useful things to include in Run BASIC.
We will be posting a screencast in the next few days that shows how this works.
Friday, May 04, 2007
Demo of Run BASIC at Smalltalk Solutions
Here is James Robertson's blog entry with a photo of me presenting.
http://www.cincomsmalltalk.com/blog/blogView?entry=3355631481
I'm very small in the frame, but yeah that's me all right. You can make out the Run BASIC web page up on the screen if you look carefully.
The demo was a little bit scary since I was modifying the Run BASIC code almost right up to the last second before the meeting. Scott and I were spending most of our free time at the conference working on some simple CSS integration. I'm hoping to put a screencast up to show how it all works.
Thursday, April 26, 2007
Artificial Intelligence and BASIC
I was able to use the techniques in the book to create demos for the computers at NEECO. A person visiting the store would ask the computer about itself, and the computer would try and respond appropriately with a demonstration of features.
The book can still be purchased used on Amazon.
Wednesday, April 25, 2007
Missing the Point
So in this case the language in question is a simple one, specialized for the robot ideas as a gentle way to introduce programming.
Later in the same paper they described how a newer version of the system switched to Java as the language for the robot. I am amazed how easily people are brainwashed into using the popular thing in place of the right thing. Instead of something simple use the "industry standard" language, no matter how much it might damage their minds. :-/
What would be better? I guess the robot language they were using before would be just fine. Or pick some other simple language if you're looking for mindshare. BASIC, LOGO, Forth, Smalltalk.
Tuesday, April 17, 2007
BASIC Contributed to Success of Industry
- bought a computer twenty or thirty years ago
- learned BASIC and did fun and productive things
- migrated to Microsoft Windows when it became the defacto standard OS
- found Windows programming languages to be too hard
- stopped programming for a LONG time
- stumbled across Liberty BASIC http://www.libertybasic.com
- started programming again in earnest!
The remarkable thing to me is that Liberty BASIC isn't as simple as the original BASIC interpreters were, but it is still so much easier than VB or Java that it serves as an acceptable gateway back into computing for so many people.
Saturday, April 14, 2007
BASIC versus RoR?
While I don't doubt that some people will use Run BASIC to create commercial sites, this is not the focus we are pursuing. Instead we are creating a tool for the traditional users of BASIC. If you want to learn or teach programming, if you want to create web apps for your use at home (or on your iPhone!), or if you need a custom application at the office and the IT folks and programmers are too busy to build it for you then Run BASIC is designed for you. :-)
Coming back to performance, the processing of large web applications is bottlenecked at the database. A Run BASIC front end to a database will perform similarly to other languages like Perl, Ruby, etc.
Saturday, March 17, 2007
Run BASIC Personal IDE sneak peek
http://www.libertybasic.com/basicology.html