RetroBASIC
Offtopic => Offtopic => Topic started by: Tomaaz on August 25, 2016, 06:17:22 PM
-
I can't understand it and it annoys me a little bit. ;) Languages that do have a "BASIC" part in their names are automatically accepted by this community (previously on BP.org), even if they have almost nothing in common with classic BASIC (Microsoft Small Basic, VB.NET, Oxygen Basic...). Languages that do not have it, are ignored. Even if they really are BASIC-like (Ring, Julia, NaaLaa, Lua...). Why do you care that much about the name? ;)
-
BASIC to me suggests classic BASIC languages - line numbers, primarily. Lack of types (and type casting) other than numeric and string. If those two requirements aren't met, I don't bother with it for my hobby time. Obviously in my work time I use much more powerful compiled languages (mostly Delphi and ObjC/C++), but for kicks it's as BASIC as I can get.
And very few languages meet that spec for me. But I don't get mad about it; I just ignore them.
-
For me, the issue here is simplicity. Take Ring, for example: the syntax is nice and straightforward:
see "Reading the file..." + nl
whole_text = lower(read("warandpeace.txt"))
Similar in MasmBasic:
PrintLine "Reading the file..."
Let esi=FileRead$("warandpeace.txt")
PrintLine Lower$(Left$(esi, 100))
BASIC is a philosophy for me:“Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
― Ernst F. Schumacher
If you want to know what is NOT Basic for me, see my Understanding C structures (http://masm32.com/board/index.php?topic=5617.0) thread in the Masm forum. C++ is the ultimate nightmare for me - slow and clumsy. A big {pile} of [shit] with semicolons; all; over; the place;
Try the file read example above in C++...
-
BASIC should remain true to its name.
Script BASIC tail
OPEN "warandpeace.txt" FOR INPUT AS 1
PRINT RIGHT(INPUT(FILELEN("warandpeace.txt"),1),COMMAND())
jrs@laptop:~/sb/sb22/test$ time scriba warandpeace.sb 400
particular paper edition.
Most people start at our Web site which has the main PG search facility:
http://www.gutenberg.org
This Web site includes information about Project Gutenberg-tm,
including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how to
subscribe to our email newsletter to hear about new eBooks.
real 0m0.048s
user 0m0.046s
sys 0m0.000s
jrs@laptop:~/sb/sb22/test$
-
BASIC should remain true to its name.
OK. So, we agree that this isn't BASIC:
Dim FILE_NAME As String = "C:\Users\Owner\Documents\test.txt"
Dim TextLine As String
If System.IO.File.Exists( FILE_NAME ) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
Textbox1.Text = TextLine
Else
MessageBox.Show("File Does Not Exist")
End If
Cool. I hope you'll remember this when we have another discussions about BASIC popularity and usage in real world. ;)
-
The only thing I care for is the mentality that nothing should be more complicated than neccessary (excellent example, John!). With a non-complicated language - without classes, pointers and god knows what - things are forced to stay simple. But ... I guess this has nothing to do with "BASIC or not BASIC".
The mentality ... it's like the difference between using the IUP toolkit and win api to create and manage the GUI of a program.
-
I think Mopz summed up my thoughts. More importantly, is new programmers seeing there code executing in the order it was type. I started out on qbasic, which is a lot newer than the dialects many of you probably started with but it was not bogged down by classes, call backs, threads, and so on. While I use C++ a lot these days, I could never have imagined it as my first language because it does not make sense to someone who has not already learned the basics and familiarized themselves with these advanced concepts.
-
If System.IO.File.Exists( FILE_NAME ) = True Then
Googling "System.IO.File.Exists" (with quotes) yields 70,000+ hits. Which means coders are desperately looking for help on a command that could be as simple as
.if Exist("Test.txt")
Print "the file exists"
.endif
So why do these poor #xx coders have to add System.IO.File.? Does it look cooler? How many other frequent uses are their for the keyword exist()?
The other question, Tomaaz, is why you feel personally attacked when people express an opinion, especially since you explicitly asked for such opinions. When somebody writes that BASIC should be as simple as possible, it is certainly not meant to attack you. Take it easy, we are all hobby coders in a tiny niche market here, no need to feel attacked, or to attack anybody...
@n00b: "not bogged down by classes, call backs, threads"
- "classes" is just an obfuscation for "sub", "proc", "function" or whatever
- callbacks are cool, their main problem is that they are so badly explained. They are much simpler than people think, and really helpful
- threads are actually simple, although I very rarely need them
-
So why do these poor #xx coders have to add System.IO.File.? Does it look cooler? How many other frequent uses are their for the keyword exist()?
That was a piece of VB.NET code and, as you can see in my first post, I do not consider this language to be BASIC. Other members do. For me it's to complex and not easy to read. Ring, Julia, NaaLaa, Lua, Python are more BASIC-like and what? How many members here had a look at them? How many consider them BASICs? Very few (myself only?), as they don't have the "BASIC" part in their names.
The other question, Tomaaz, is why you feel personally attacked when people express an opinion, especially since you explicitly asked for such opinions.
I don't. :) I'm just curious why, for some people, the name of the language seems to be "everything". There is a "BASIC" part in the name? It is BASIC then. That's silly. :) I think you've totally missed my point. I agree with all replies here, especially with what Marcus said. Things shouldn't be more complicated than necessary. This is the first thing I'm looking while testing programming languages. And I find it more in languages like Ring, Julia, NaaLaa, Lua than in majority of BASIC dialects. But I still need to read a nonsense like "Why should I waste my time for Lua or Julia if I can do things faster and easier in BASIC". Well, to finally understand that, in fact, other languages are easier than BASIC?
When somebody writes that BASIC should be as simple as possible, it is certainly not meant to attack you.
Why should it be? I think the same. The problem is that majority BASIC dialects aren't as simple as possible. Other languages are, but because BASIC dialects tend to have "BASIC" attached to their name, people automatically assume that they are easier to learn/use than other languages (Ring, Julia, NaaLaa, Lua, Python, Ruby...). Well, that's simply not true. ;)
-
So, we agree that this isn't BASIC:
Dim FILE_NAME As String = "C:\Users\Owner\Documents\test.txt"
Dim TextLine As String
If System.IO.File.Exists( FILE_NAME ) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
Textbox1.Text = TextLine
Else
MessageBox.Show("File Does Not Exist")
End If
To me, VB.NET above is the world's second best BASIC after VB6 in the year of 2016. Apart from FBSL, of course. Which effectively means there are and will always be people -- thousands upon thousands of them -- who value A more than B in BASIC. We've discussed that issue more than once before and I see no real reason to raise it once again on the new site. It can only bring about the worst that was there on the late BP dot org -- endless trolling, flaming, and flooding.
-
To me, VB.NET above is the world's second best BASIC after VB6 in the year of 2016.
Firstly - this topic is not about "the best BASIC". Sorry, you've totally misunderstood my first post. Secondly - all people who've already answered in this topic, tend to disagree with you. :)
EDIT Let's imagine that Julia developers did name their language "Julia BASIC". I'm 100% sure that the language would get much more attention here. Even if, apart from the name, it would be exactly the same language. Do you understand what I'm talking about, now? ;)
-
@jj2007 - I am not arguing that these are indeed useful and arguably necessary for modern software development. But that is also why I feel BASIC and BASIC-like languages are good starting points for new programmers. I used callbacks in rcbasic. As far as classes go, I think they are overused and makes alot of code unreadable. Google is notorious for this. I know how to construct a class but in I have only found it useful if I was using an API that depends on overwriting classes to do anything (ie. WxWidgets). But I don't think OO makes an API easier to use and it definitely doesn't effect its speed or efficiency. I have used threads in a few programs but I would say for a majority of code I have seen that used them, there was a better solution. They are necessary for OS, next-gen games, and lots of modern applications, but they are not a concept that someone should dive into until they get some experience with basic concepts. The original BASIC was designed to teach students in non computer science fields how a computer works. It has evolved since then, but that mentality is why I think BASIC still has a following. Although I personally think everyone should avoid modern Microsoft dialects as they are simply java without semicolons.
-
The original BASIC was designed to teach students in non computer science fields how a computer works.
I think that the original goal was to let ordinary users to start programming and do something creative with their machines. That's why BASIC was easy and human readable. To understand how computer works, you had to move to assembly at some point. ;)
-
O
-
Visual Basic is BASIC based on BASIC...
;D So, VB.NET is BASIC based on Visual Basic that is BASIC based on BASIC. ;D
and i really don't understand why you think that language name is so
important ???
Well, I said something quite opposite. The name is not important to me, so they can name VB.NET "The Most BASIC-like Visual BASIC based on BASIC" and, for me, it still won't be BASIC. ;D
...only maybe because there is no interest here for languages presented
in your topics so you kinda dissappointed
Of course, that's the reason! I would like to know why you're not interested in languages that are more BASICs than majority of, so called, "BASIC dialects".
-
..h
-
..and this is also TRUE:
Why should I waste my time for Lua or Julia if I can do things faster and easier in BASIC".
OK. I understand that this is your opinion. But tell me why. Show me examples etc.
-
The mentality ... it's like the difference between using the IUP toolkit and win api to create and manage the GUI of a program.
IUP is great and cross platform. The Windows GUI API is a crock of sh*t.
-
IUP is great and cross platform. The Windows GUI API is a crock of sh*t.
I'm pretty sure that is exactly what Marcus meant. ;) I'm also pretty sure that everybody will agree with that. Apart from Aurel, of course. ;)
-
and, for me, it still won't be BASIC.
I have gotten by all this confusion with simply saying I use traditional BASIC.
-
Tomaaz,
You are basically right 8)
The name shouldn't matter. Simplicity should. Besides the "keep it simple" philosophy, there is also an acquired common set of commands that matters for many people, including me. You may remember that I had started a "CoreBasic" thread in the defunct bp.org forum, asking to identify no more than 100 commands that are common to all Basic dialects.
Output to the console is print, not printf(), see, cout or shout or whatever. Such small aspects may sound trivial, but was würdest Du sagen, wenn ich hier statt Englisch in Deutsch schreibe. Not everybody is happy to learn a new language just because the author of a programming language believes that couting is better than printing. BASIC in the name is a reassuring message - "don't be timid, you'll understand most of this language immediately because it's BASIC syntax". That is not the case for most languages that do NOT have Basic in the name, like Python, Ruby, Julia, Ring, whatever. Here, the message is "you'll have to learn a new language". Not a problem for people for whom it's language #1, but if you have used a dozen Basic dialects in your coding career, you appreciate the familiarity of the syntax.
In short: There may be better Basic-like languages around, but there are valid reasons why people like the Basic in the name :)
-
[
-
everyone who ever code something on windows knows that there is no better option over winApi for GUI programming.
Everyone knows writing device drivers is best done in ASM. What is your point?
-
That's why probably no one ever wrote anything about DiscoRunner (http://discorunner.com/) here.
-
Thanks for the link!
I'll give it a try.
-
This is typical nonsense and everyone who ever code something on
windows knows that there is no better option over winApi for GUI programming.
Is using WinAPI the easiest way? No. Is it the fastest way? No. These are the two most important things about BASIC, so combining BASIC with WinAPI is well... insane? ;D What next? Let's use WinAPI with Scratch to teach 10 years old kids to code. ;D
In short: There may be better Basic-like languages around, but there are valid reasons why people like the Basic in the name :)
Valid? ;)
That's why probably no one ever wrote anything about DiscoRunner (http://discorunner.com/) here.
;)
-
[
-
i was talking to John
about IUP and WinApi not about BASIC
Were you talking about the WinAPI that is focused mainly on C or were you talking about wrapper libraries (I think John was talking about the WinAPI)? Do you know that IUP supports calling native WinAPI?
by your definition then PureBasic is insane....
Really? That's very interesting. I've tried PureBasic on Linux. I was running exactly the same pieces of code and it worked the same way. Were I using WinAPI? ;) Or the way that PureBasic works is a bit different that you want me to believe it? Isn't it that PureBasic adds another layer which interacts with low level elements both on Windows and Linux (perhaps, slightly different in each case)?
And yes - combining BASIC with pure WinAPI is like embedding Assembler in Scratch code. Insane. ;)
-
And yes - combining BASIC with pure WinAPI is like embedding Assembler in Scratch code. Insane
If you're going to go through all the trouble of interfacing directly with the WinAPI, you might as well just write your application in C/C++ in the first place.
PowerBASIC was one of those that interfaced with the rest of the world at low level.
-
And yes - combining BASIC with pure WinAPI is like embedding Assembler in Scratch code. Insane. ;)
I do that all the time, and have done so the last 25+ years. Why should that be insane? It's easy, and often the most elegant way to do things.
-
And yes - combining BASIC with pure WinAPI is like embedding Assembler in Scratch code. Insane. ;)
I do that all the time, and have done so the last 25+ years. Why should that be insane? It's easy, and often the most elegant way to do things.
Lol, it looks like you said you combine assembler with scratch. Now that would be interesting. :D
-
BASIC and other interpretive/scripting languages are focused on getting various tasks completed quickly and without a lot of coding. No one uses BASIC to develop commercial Windows applications. Calling specific libraries like cURL, SQLite, ODBC from an interpretive environment is the only sane way of interfacing with OS resources. Calling OS specific API functions from these languages is nuts.
-
That's why probably no one ever wrote anything about DiscoRunner (http://discorunner.com/) here.
Not here, but the author(s) actually posted details on BP.org
-
Lol, it looks like you said you combine assembler with scratch. Now that would be interesting. :D
Right ;-)
But I meant, of course, combinining Basic with WinAPI. Simple example:GuiParas equ "Hello, I am a full-fledged Windows application"
GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
Event Menu
invoke MessageBox, 0, Str$("This is item #%i", MenuID), Chr$("Menu was clicked:"), MB_OK
GuiEnd
Just in case you don't spot it: MessageBox is a low level Windows API function 8)
-
But I meant, of course, combinining Basic with WinAPI. Simple example:GuiParas equ "Hello, I am a full-fledged Windows application"
GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
Event Menu
invoke MessageBox, 0, Str$("This is item #%i", MenuID), Chr$("Menu was clicked:"), MB_OK
GuiEnd
Just in case you don't spot it: MessageBox is a low level Windows API function 8)
Somehow, I'm not convinced. Your example doesn't look either BASIC-like or elegant to me. Also, it seems to be more complex than displaying a simple message, but the only one low level function you're using is the one that is the easiest to use. But I don't want to argue about it anymore, as it's something different than what I wanted to discuss in this topic.
EDIT OK, I'm a bit curious, so could you show me an example of, let's say, downloading a file from the internet and saving it to the hard disk that uses only/mostly WinAPI low level functions?
-
That's why probably no one ever wrote anything about DiscoRunner (http://discorunner.com/) here.
Not here, but the author(s) actually posted details on BP.org
Oh, I didn't remember.
-
Not here, but the author(s) actually posted details on BP.org
And most likely was totally ignored. That's why
Oh, I didn't remember.
I don't recall it, either. Well, the author should have used "BASIC" when naming his interpreter. That would have gained him much more attention on BP.org and here. ;)
-
F
-
Not here, but the author(s) actually posted details on BP.org
And most likely was totally ignored. That's why
Oh, I didn't remember.
I don't recall it, either. Well, the author should have used "BASIC" when naming his interpreter. That would have gained him much more attention on BP.org and here. ;)
Nope. There was a discussion. Dunny and the author discussed some of the similarities between their respective projects.
-
First ...
Pure Basic have set of wrapper functions to work on winApi on windows
is that clear to you?
Linux version have also set of wrapper functions to work with GTK libs.
Why do you ask me this question? Did you read my posts at all? For example, this part?
Isn't it that PureBasic adds another layer which interacts with low level elements both on Windows and Linux (perhaps, slightly different in each case)?
Or this one, maybe?
Were you talking about the WinAPI that is focused mainly on C or were you talking about wrapper libraries (I think John was talking about the WinAPI)? Do you know that IUP supports calling native WinAPI
Unless you start reading my posts, this conversation doesn't make any sense.
-
Nope. There was a discussion. Dunny and the author discussed some of the similarities between their respective projects.
I was wrong then. ;) But I had several breaks from using BP.org. ;)
-
[
-
]
i can say same to you.
Considering the fact that I posted and asked you some questions first, you can't. Sorry.
-
OK, I'm a bit curious, so could you show me an example of, let's say, downloading a file from the internet and saving it to the hard disk that uses only/mostly WinAPI low level functions?
Here is an example that uses low level WinAPI functions only:GuiParas equ "Hello, I am a full-fledged Windows application"
GuiMenu equ @File, &Download, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
Event Menu
.if MenuID==0
Let esi=FileRead$("http://retrogamecoding.org/board/index.php")
invoke MessageBox, 0, NoTag$(esi), Chr$("You clicked 'Download':"), MB_OK
.else
invoke MessageBox, 0, Str$("This is item #%i", MenuID), Chr$("Menu was clicked:"), MB_OK
.endif
GuiEnd
Exe & source attached. I have a suspicion, though, that you meant an example that shows all the WinAPI functions that are being used under the hood... and here we are back to the question: Would that be BASIC?
The Windows API has over 20,000 functions. BASIC should have about 100 commands. You can have both 100 simple basic commands and a huge default library in peaceful coexistence.
-
The Windows API has over 20,000 functions. BASIC should have about 100 commands. You can have both 100 simple basic commands and a huge default library in peaceful coexistence.
That's the whole point. Using these 20,000 functions directly from BASIC would be insane. So, the question is - is it better to go for specific wrappers written for particular BASIC dialects or go for something like IUP, which in fact, to some extent, is probably a WinAPI wrapper? As far as I understand it, it's not possible to program on Windows without calling WinAPI, so why can it be IUP that does it? For me using WinAPI means calling its function directly and not via special wrappers (how would be it different from calling it from IUP?). Things like IUP are ready to use, well tested, multi-platform, they support many languages... I can understand IUP vs pure WinAPI discussion. But IUP versus wrappers? I don't really know what is that Aurel wants to prove. That IUP is crap? I'm pretty sure it interacts with WinAPI at some point, so? Maybe someone else can explain it to me... I'm serious. I'm always happy to learn new things.
-
So you can have a basic language that is not BASIC, or a BASIC that is not basic or a BASIC that is basic :)
For me BASIC should offer:
- simplicity
- common set of key words derived from Dartmouth, 80s BASICs and second generation structured BASICs
- option of using line numbers
- GOTO and GOSUB
- structured programming and related key words
Anything else would be an extension to BASIC and could be offered as a separate library / tool.
-
So you can have a basic language that is not BASIC, or a BASIC that is not basic or a BASIC that is basic :)
You can also have BASIC that is based on BASIC that is BASIC based on BASIC, but doesn't have "BASIC" in its name anymore (it has only reference to the historical name). ;D But only Aurel is able to understand all the nuances between different categories of BASIC. ;)
-
Using these 20,000 functions directly from BASIC would be insane. So, the question is - is it better to go for specific wrappers written for particular BASIC dialects or go for something like IUP, which in fact, to some extent, is probably a WinAPI wrapper?
I have written "wrappers" for about 200 of them (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm). That is 1% of the WinAPI. Take Recall() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1172) - it loads a textfile into a string array, for me it's a Frequently Used FunctionTM. But why should I write a wrapper for, say, SetupRemoveInstallSectionFromDiskSpaceList? That is a well-documented function, why should I invent a new syntax for it, and write new documentation? Just because it's fun to do everything through a wrapper?
There is an optimum somewhere. For me, it's around 200 functions that deserve a dedicated BASIC command, like Print, Open, Input$, Recall, Left$, Mid$, Right$, Replace$, etc - Frequently Used Functions. Rarely used functions do NOT deserve a wrapper, on the contrary, it would be truely insane to write wrappers for all rarely used 19,800 Windows functions. That is why I won't touch IUP. My experience with QT is sufficient. These "wrap-it-all" packages are the desperate attempt to write truely portable code. The result is bloated, slow and inefficient code on Windows, Linux and MacOS.
-
. Rarely used functions do NOT deserve a wrapper, on the contrary, it would be truely insane to write wrappers for all rarely used 19,800 Windows functions. That is why I won't touch IUP. My experience with QT is sufficient.
IUP is very small and simple (about 100 functions) (I think that's the reason why it was brought as an example of something opposite to WinAPI ). It's not a "wrap-it-all" package, it's not QT. It's the same argument like "I'm not gonna touch Lua or Julia. BASIC is easier and faster to write". Sorry, but both are based on ignorance.
-
IUP is very small and simple (about 100 functions)[/b]
Excuse my ignorance, Tomaaz. Could you post the Lua or C equivalent (source & exe) to my code above (the simple menu & messagebox example, not the FileRead$() stuff), so that we have something to compare?
-
I'm not sure what the problem is, tbh. I've already answered my thoughts on the actual question asked in the OP, but for completeness' sake I'll just add that I don't care what the language is called so long as it adheres to my specifications for a BASIC.
John likes ScriptBASIC, he's invested a lot of time and energy in it, he has a tool that's uniquely suited to his needs and he sees that as his BASIC.
I don't.
Tomaaz likes to code in many languages, they fascinate him and he enjoys their nuances and celebrates their differences. A toolkit of many languages that do the tasks he uses them for is his BASIC.
None of them, individally or collectively are my BASIC.
Mike lovingly crafts a veritable swiss-army knife of a language that offers everything from hobbyist to professional level codegen, achieving speeds that other interpreters can only dream of. This is his BASIC.
Again, it's certainly not mine.
Aurel likes to mess with the internals of interpretation and bytecode, he's learning as he goes and each iteration of his languages gets a bit better each time. They don't do much, but they do what he needs them to and when he needs them to do more he adds more and learns a bit more. This is his BASIC.
And yet again, it's not mine.
Mine is the one that I play with when I'm not coding for a living. I make the interpreter for fun, I use it for kicks to see if it can do what the others do or if it can maybe do it better. It sticks to my idea of a BASIC.
And that most certainly is my idea of what a BASIC is.
And you know what? Nobody else thinks it is. And you know what else? I don't give a toss. Not one. And what I love about BASIC forums is that nobody else does either.
Each to our own.
-
Excuse my ignorance, Tomaaz. Could you post the Lua or C equivalent (source & exe) to my code above (the simple menu & messagebox example, not the FileRead$() stuff), so that we have something to compare?
Well, you know that my comment was about something else, don't you? ;) So, I couldn't. The code would be much more elegant and clear, but I'm pretty sure you will focus on something else to proof your point, so I'm not gonna waste my time (I don't know C and, at the moment, don't have Lua installed on my machine). But here is an example how shockingly difficult and bloated IUP is:
res, name = iup.GetParam("Title", nil, "Give your name: %s\n","")
iup.Message("Hello!",name)
But you know that this is off-topic and there is no point to continue this discussion here. BTW The GUI toolkit I know the most is Tk. I've used it with Tcl, Python, Ruby, Perl, Julia and, if I remember correctly, with Newlisp.
-
John likes ScriptBASIC, he's invested a lot of time and energy in it, he has a tool that's uniquely suited to his needs and he sees that as his BASIC.
What rock are you living under?
Script BASIC is an open source BASIC written by Peter Verhas that I took over managing the project back in 2005. I feel Script BASIC is the only true traditional cross platform BASIC's still left.
-
Script BASIC is an open source BASIC written by Peter Verhas that I took over managing the project back in 2005. I feel Script BASIC is the only true traditional cross platform BASIC's still left.
This idea of traditional BASIC is kind of silly. BASIC like many other programming languages has evolved with the times. The original BASIC didn't even have INPUT. I agree ZXDunny on how everyone has there preferred dialect. I personally love graphics programming but don't really care about gui programming. That is why I migrated from freeBASIC to sdlBasic to begin with. But for 3d programming freeBasic, pureBasic, or masmBasic with openGL would probably be the way to go. What many consider traditional BASIC was not only influenced by the goal of keeping it simple, but also by the technology they had available.
-
...and
-
Traditional BASIC is the foundation of most more advanced languages being used.
-
Traditional BASIC is the foundation of most more advanced languages being used.
Yes, every genius exposed to it feels the need to fix it! ;D
Easy sound and graphics was not in the original BASIC but it sure was in all the adaptations to different systems.
Those who now find graphics boring, might not remember that aspect of the second wave of BASIC's tradition.
-
John likes ScriptBASIC, he's invested a lot of time and energy in it, he has a tool that's uniquely suited to his needs and he sees that as his BASIC.
What rock are you living under?
Script BASIC is an open source BASIC written by Peter Verhas that I took over managing the project back in 2005. I feel Script BASIC is the only true traditional cross platform BASIC's still left.
Yes, I know all that but it's just your opinion - and that's fine, you can believe whatever you want to believe about how your chosen language is traditional or the best there is. I personally disagree - it doesn't meet very many of my requirements for a traditional BASIC, and I regard it as being amongst the same category of languages that contains VB and others. But that's my opinion and therefore only applicable to me.
Can ScriptBASIC perform a calculated GOTO? If not then it's not BASIC as far as I am concerned - but everyone else is free to decide what they believe it to be.
-
Can ScriptBASIC perform a calculated GOTO?
Better. It can embed itself into itself (http://www.allbasic.info/forum/index.php?topic=449.msg4805#msg4805) as a process or a thread.
Should a real BASIC ...
- be able to use variables without predefining their type or range including arrays? (index/associative)
- be restricted to line numbers or labels to execute code?
- imply limitations to array indices's or structure, string length or the ability to extend the language in any direction?
- be restricted to an OS platform or require more than one code base?
-
So, this was a real BASIC:
(https://upload.wikimedia.org/wikipedia/commons/e/e2/Plus4-animated.gif)
I used this, which was really great (I even coded my own GUI for it):
(https://upload.wikimedia.org/wikipedia/commons/5/53/C128-animated.gif)
But most people used this (although it was limited and one had to use POKEs for graphics):
(https://upload.wikimedia.org/wikipedia/commons/4/48/C64_startup_animiert.gif)
And, heck, they all were from Microsoft ... ;)
Anyway, I wish there were a BASIC like one of those nowadays. I miss the distraction free coding.
-
BASIC might have a chance to survive and prosper if folks would make up their minds which BASIC is worth saving and supporting going forward. Everyone having their own pet BASIC doesn't do the language any favors.
-
BASIC might have a chance to survive and prosper if folks would make up their minds which BASIC is worth saving and supporting going forward. Everyone having their own pet BASIC doesn't do the language any favors.
BASIC has existed in many flavors for almost half a century now. I have already given my thoughts on the idea of traditional BASIC but I think it is important to understand why the language has been as popular as it has. Microsoft introduced the language to personal computers and has since continuously developed it until it reached the level they are at now with Visual Basic and Small Basic (both of which are terrible languages). But other computers adapted the language to there systems (ie. comodore, atari, sinclair, and that small company with the logo of the rainbow colored apple). If it wasn't for the language being spread and adapted in so many ways it could have died with the Dartmouth Time-Sharing System. So I feel that instead of trying to limit it to specific dialects that are "worth saving and supporting", we as a community need to embrace each dialect for what it is. Its not like any BASIC dialect is in competition with each other and I think its nice that new users have as many options as they do.
-
Can ScriptBASIC perform a calculated GOTO?
Better. It can embed itself into itself (http://www.allbasic.info/forum/index.php?topic=449.msg4805#msg4805) as a process or a thread.
Should a real BASIC ...
- be able to use variables without predefining their type or range including arrays? (index/associative)
- be restricted to line numbers or labels to execute code?
- imply limitations to array indices's or structure, string length or the ability to extend the language in any direction?
- be restricted to an OS platform or require more than one code base?
But again, you're overlaying your opinion on what a BASIC language should and insisting that this is how they should be - and that's all it is, your opinion. Just as it's my opinion that if language doesn't support line numbers and be able to calculate a destination for GO TO such as the result of an expression, then it's not BASIC. My definition of BASIC doesn't match yours, but I don't try to convince you that your pet language isn't worthy of your attention - just that I don't find it worthy of mine.
And that's fine.
-
If I was still intsrested in 8 bit BASICs, I could maybe see your point.
Can ScriptBASIC perform a calculated GOTO?
Yes. If the program errors it goes to the label assigned or continues as intended.
ON ERROR GOTO ErrorHandler
-
Just as it's my opinion that if language doesn't support line numbers and be able to calculate a destination for GO TO such as the result of an expression, then it's not BASIC. My definition of BASIC doesn't match yours
Dear Dunny,
You do know that you are a very special person, don't you? ;)
I have stopped using line numbers, but not BASIC, almost 30 years ago. Just checked my oldest source, 600kB written in GfaBasic, no GOTO. But I had a GOTO in the 15k lines that I wrote in Gfa for Atari ST (an editor); it served to create space for embedded assembly code.
Apropos assembly: In MasmBasic, I could easily implement calculated GOTOs. The two of us against the rest of the World?
-
If I was still intsrested in 8 bit BASICs, I could maybe see your point.
Can ScriptBASIC perform a calculated GOTO?
Yes. If the program errors it goes to the label assigned or continues as intended.
ON ERROR GOTO ErrorHandler
I don't think you understand the question, John. ScriptBASIC cannot do the one thing that sets BASIC apart from all other languages -
GO TO a*20
Without that, I'm afraid that it doesn't meet my standards for BASIC and therefore it (like most other languages discussed here) is not BASIC. It's a beginner's language, sure.
-
GOTOs were popular back in early 80s when functions/subs and namespaces did't exisit. I only use a GOTO when they make sense.
Sometimes you need TO let GO.
@Paul - You are welcome to be the curator for the retro BASIC museum.
-
Variable GOTO's are pretty cool but I guess now days Select Case covers all that.
-
IF .. THEN
.
ELSE IF .. THEN
.
ELSE
.
END IF
Pretty much covers it for me without the limitations that SELECT/CASE imposes.
-
w
-
whole discussion is pointless and useless as OP ;D
Our goal is to get you to realize your opinion is pointless not these threads.
-
IF .. THEN
.
ELSE IF .. THEN
.
ELSE
.
END IF
Pretty much covers it for me without the limitations that SELECT/CASE imposes.
Right that probably came first, select case not limited if it can do Booleans.
-
[
-
... the one thing that sets BASIC apart from all other languages -
GO TO a*20
I'm afraid that's pretty much not so, Paul. "Computed goto's" are part of C99 C language specification. They are also supported in FBSL's Dynamic C: 8)
-
select case not limited if it can do Booleans.
CASE can't do expressions. Only variables (maybe ranges) and constants.
-
whole discussion is pointless and useless as OP ;D
I've always enjoyed discussions like that on BP.org and here. I don't want this place to be something similar to StackOverflow. You ask anonymously a very specific question, get a very specific answer (from someone who's completely anonymous to you) and that's it. This place is something more for me. And I will be starting topics like that in the future. If you're not interested, don't reply. Simple. Cause, you see - the topic is "pointless", "stupid", "no one cares" and then you realize that it has more replies than anything else here. ;)
-
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius—and a lot of courage to move in the opposite direction.
-- E. F. Schumacher
-
... the one thing that sets BASIC apart from all other languages -
GO TO a*20
I'm afraid that's pretty much not so, Paul. "Computed goto's" are part of C99 C language specification. They are also supported in FBSL's Dynamic C: 8)
Yes, but that takes a fair amount of setting up - and you'll have to insert labels for each section that you want the code to be able to jump to - and yeah, a CASE statement would be fine for that. Not *quite* the same thing, but I'll concede that one. You still lack line numbers though - and let's not forget that a GO TO to a non-existing line number will jump to the next line number in sequence... Which you could simulate by manipulating the array look-up somehow, I suppose.
As for John's assertion that CASE can't take an expression - it can in Pascal, and also in SpecBAS. I wasn't aware of that limitation in other languages?
-
select case not limited if it can do Booleans.
CASE can't do expressions. Only variables (maybe ranges) and constants.
Nope. Depends on the language implementation. Charles' OxygenBasic supports
CASE <[=] var|lit
CASE <> var|lit
CASE >[=] var|lit
And I will be starting topics like that in the future.
a) That's called trolling;
... "pointless", "stupid", "no one cares" ...
b) that's flaming;
... and then you realize that it has more replies than anything else here. ;)
c) and that's flooding.
Remember I warned you?
-
But again, you're overlaying your opinion on what a BASIC language should and insisting that this is how they should be
BASIC is achieving the minimal number of steps to accomplish a specific goal.
That is my quest with Script BASIC and I think it represents that concept well.
-
Yes, but that takes a fair amount of setting up - and you'll have to insert labels for each section that you want the code to be able to jump to ...
My C example in fact shows two use cases of computed gotos: a lookup table that should've been declared as static void** t[] to be filled only once at app start, and also goto *&&done; that's a computation of label's real memory address at run time. It could be goto *(&&done + 1 + 2 + 1);, whatever...
... and let's not forget that a GO TO to a non-existing line number will jump to the next line number in sequence...
Such cases are handled very efficiently in modern BASICs with an On Error Resume Next and On Error GoTo error trapping statements. Jumping to the line number following the non-existing one in sequence will eventually lead to an out-of-script-bounds exception if the miscalculated line number appears too high or too low.
As for John's assertion that CASE can't take an expression - it can in Pascal, and also in SpecBAS. I wasn't aware of that limitation in other languages?
FBSL BASIC doesn't support either Case ranges or Case boolean logic, only explicit enumeration. Its Dynamic C supports Case ranges as per the C99 specs. O2 supports both Case ranges and Case boolean logic.
-
About John vs Paul situation. I kinda agree that "retro BASIC" and "traditional BASIC" is not exactly the same. Don't blame me - it wasn't me who made this mess with hundreds BASIC dialects etc. ;) For me, it looks like this:
1. Retro BASIC. Line numbers, ":" to group statements in one line, heavy usage of GOTO (SpecBAS, Blassic, Vintage Basic...)
2. Traditional BASIC. No line numbers, functions ans subroutines instead of GOTO (Yabasic, ScriptBasic, QB64, FreeBASIC...)
3. Modern BASIC. No/optional sigils, generic FOR, build-in easy functions for manipulating files, networking and Internet, cryptography, sorting, mapping, matching, associative arrays, regular expressions., but still procedural syntax, no OOP. (PureBasic(?), Julia, Ring...)
a) That's called trolling;
Nope, that's not. Trolling is deliberately posting something that is off-topic and provocative. I've started this topic (in a off-topic section), so how can it be off-topic? Also, I was 100% serious and hasn't started this topic to see replies like "Well, because some people are retarded" etc. That would be trolling. You may not like my question but, considering the mess in BASIC world, it is absolutely valid.
b) that's flaming;
Agreed. And thanx for naming the things you and Aurel do in this topic.
c) and that's flooding.
Never heard of this one in a context you're trying to place it. Could you explain, please?
I remember from BP.org that you like to abuse the "you are just a troll" argument, when you don't like other people opinions or questions. As far I remember the next step is "OK. I've had enough of this place and the ignorant members here. Please, close my account". I hope it's not gonna happen here, but I'm not gonna stop writing about what is interesting for me. ;)
-
Could you explain, please?
No. That would be taking part in flooding. So, no.
I remember from BP.org ... As far I remember the next step is ...
You memory serves you badly.
I'm not gonna stop writing about what is interesting for me. ;)
Even for a banana? ;D
-
You memory serves you badly.
That's almost trolling, but you're not quite there, yet. You need to try harder.
Even for a banana? ;D
Yes! Congrats! That's trolling in a pure form. :)
-
1. Retro BASIC. Line numbers, ":" to group statements in one line, heavy usage of GOTO (SpecBAS, Blassic, Vintage Basic...)
2. Traditional BASIC. No line numbers, functions ans subroutines instead of GOTO (Yabasic, ScriptBasic, QB64, FreeBASIC...)
3. Modern BASIC. No/optional sigils, generic FOR, build-in easy functions for manipulating files, networking and Internet, cryptography, sorting, mapping, matching, associative arrays, regular expressions., but still procedural syntax, no OOP. (PureBasic(?), Julia, Ring...)
I can live with that. MS QB4.5 & 7 should go into the traditional slot.
-
[
-
Script BASIC Retro Fun
30 LET A = 0
50 LET A = A + 1
60 IF A < 5 THEN GOTO 50
20 PRINT A
40 PRINT
10 END
jrs@laptop:~/sb/sb22/test$ scriba retro.sb
5
jrs@laptop:~/sb/sb22/test$
-
..
....AND DO YOU CAN FINALLY TELL US WHO IS THE MEMBER OF THIS FORUM
Those, who voted for "comparing other languages", but didn't bother to check Julia or Ring. Plus general atmosphere. Marcus is still not sure if posting NaaLaa examples is off-topic or not. The same can be said about Lua. Of course, it was much worse on BP.org, but this place kind off took over from that forum. And you're the one who first jump into the topic with "Who care? This is BASIC forum and dont post on Python, Lua, Julia, becose is offtopic and junk.", so don't pretend you don't know what I'm talking about.
-
About John vs Paul situation. I kinda agree that "retro BASIC" and "traditional BASIC" is not exactly the same. Don't blame me - it wasn't me who made this mess with hundreds BASIC dialects etc. ;) For me, it looks like this:
1. Retro BASIC. Line numbers, ":" to group statements in one line, heavy usage of GOTO (SpecBAS, Blassic, Vintage Basic...)
2. Traditional BASIC. No line numbers, functions ans subroutines instead of GOTO (Yabasic, ScriptBasic, QB64, FreeBASIC...)
3. Modern BASIC. No/optional sigils, generic FOR, build-in easy functions for manipulating files, networking and Internet, cryptography, sorting, mapping, matching, associative arrays, regular expressions., but still procedural syntax, no OOP. (PureBasic(?), Julia, Ring...)
Still not very clear cut in all cases.
SpecBAS, for example, also allows for the use of procedures (DEF PROC) instead of GO TO / GOSUB as well as functions (DEF FN) and DO...WHILE and DO...LOOP[UNTIL] loops, CASE and has lots of in-built functions you would otherwise find in 'traditional' or 'modern' BASICs.
Having said that, no category framework is going to be perfect and I don't think anyone would argue if you did describe SpecBAS, for example, as a 'retro-style' BASIC :)
-
Still not very clear cut in all cases.
I claim Script BASIC to be a traditional BASIC but with its limitless extension ability, it does COM, GUI, DBs along with embedding various other languages. (including itself)
@Paul - You may want to check out ProvideX (PvxPlus) Business BASIC (http://pvxplus.com/). It has all the virtues you believe in. They have a single user full featured free version which should work fine for your needs.
-
I'm enjoying learning C, but sometimes BASIC is so much simpler. It struck me again when I was completing an exercise to display the powers of 2.
Here is the C version...
#include <stdio.h>
#include <math.h>
int main()
{
int b=0;
float value=2.0;
int increment=0;
float result;
for(b=0;b<=10;b++)
{
result=pow(value,increment);
printf("%.1f to the power of %d is %.1f\n",value,increment,result);
increment+=1.0;
}
return 0;
}
Here is the alternative in BASIC using SpecBAS...
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP
-
CASE can't take an expression - it can in Pascal, and also in SpecBAS
And a few others :)
include \masm32\MasmBasic\MasmBasic.inc
SetGlobals int somevar=5
Init
m2m ecx, -5
PrintLine "----------------------------- testing the new MasmBasic Switch_ macro -----------------------------"
.Repeat
Print Str$(ecx), Tb$
m2m edx, -127 ; don't trigger the edx case...
If_ ecx==11 Then mov edx, ecx ; ... except for testing the Case_ edx at position 11
Switch_ ecx
Case_ somevar
PrintLine Str$("Case var=%i", somevar)
Case_ edx ; this case triggered if ecx==edx; takes preference over 'immediate'
PrintLine "Case edx ###" ; cases but must come before lt or gt cases
Case_ lt -2
PrintLine "Case less than -2"
Case_ -2
PrintLine "Case -2"
Case_ 0
PrintLine "Case NULL"
Case_ 10, 12
PrintLine "Case 10 or 12"
Case_ 18
PrintLine "Case 18"
Case_ 14 .. 16 : PrintLine "Case 14 .. 16 (one-liner)" ; OK if only one instruction is needed
Default_
PrintLine "---" ; no matching case found
Endsw_
inc ecx
.Until signed ecx>20
Inkey "You better switch to MasmBasic"
EndOfCode
-
JJ,
Just to put things in the proper perspective, does anyone use masmbasic for anything useful other than you?
-
Hey, don't tell me that you are the Spikowski troll who sent out his lawyers and wanted to shut down the other forum. Really, still around? What do your shrinks tell you nowadays?
-
Thanks for answering my question in your classic bitter way.
-
I'm enjoying learning C, but sometimes BASIC is so much simpler. It struck me again when I was completing an exercise to display the powers of 2.
Here is the C version...
#include <stdio.h>
#include <math.h>
int main()
{
int b=0;
float value=2.0;
int increment=0;
float result;
for(b=0;b<=10;b++)
{
result=pow(value,increment);
printf("%.1f to the power of %d is %.1f\n",value,increment,result);
increment+=1.0;
}
return 0;
}
Here is the alternative in BASIC using SpecBAS...
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP
Here is the C BASIC version of it.
#include <stdio.h>
#include <math.h>
#include "cbasic.h"
MAIN
BEGIN_FUNCTION
DIM AS int b = 0;
DIM AS int increment = 0;
DIM AS float value = 2.0;
DIM AS float result;
DEF_FOR (b = 0 TO b <= 10 STEP INCR b)
BEGIN_FOR
result = POW(value, increment);
PRINT ("%.1f to the power of %d is %.1f\n", value, increment, result);
increment += 1.0;
NEXT
RETURN_FUNCTION (0);
END_FUNCTION
jrs@laptop:~/c_basic$ gcc cpow.c -lm -o cpow
jrs@laptop:~/c_basic$ ./cpow
2.0 to the power of 0 is 1.0
2.0 to the power of 1 is 2.0
2.0 to the power of 2 is 4.0
2.0 to the power of 3 is 8.0
2.0 to the power of 4 is 16.0
2.0 to the power of 5 is 32.0
2.0 to the power of 6 is 64.0
2.0 to the power of 7 is 128.0
2.0 to the power of 8 is 256.0
2.0 to the power of 9 is 512.0
2.0 to the power of 10 is 1024.0
jrs@laptop:~/c_basic$
-
Thanks John. Interesting to see the two languages combined like this.
-
Thanks for answering my question in your classic bitter way.
John Spikowski,
Your "question" was a personal attack, everybody can see that:
Just to put things in the proper perspective, does anyone use masmbasic for anything useful other than you?
And don't believe that anybody who was on BP.org at the time will ever forget that you threatened through your lawyers to shut down the site, thus destroying years of work of the forum members. The Internet has a damn good memory, Spikowski.
-
I can count the number of active users of SpecBAS on one hand. Why is that a problem?
-
Hi Richey,
Since we are off topic in the off topic place, here is SmallBASIC version of your code:
for power in seq(0, 10, 11) do ? 2 ^ power;" ";
-
No way to do it in one line, but here at least we see the use of Genuine BasicTM line numbers:
include \Masm32\MasmBasic\Res\JBasic.inc
Init
mov ebx, 1
_10:
Print Str$("%i ", ebx)
shl ebx, 1
cmp ebx, 1024
jbe _10
Inkey Chr$(13, 10, "This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
EndOfCode
Output:1 2 4 8 16 32 64 128 256 512 1024
This code was assembled with JWasm in 64-bit format
;)
-
Here is another highly evolved BASIC dialect (JB v1.01) that does boolean evaluations in Select Case:
goPlace = 1
while goPlace <> 0
print : input "Enter number for place to go to "; go$
goPlace = val(go$)
select case
case goPlace < 0
print "Going down!"
case goPlace > 0
print "Going up!"
case len(go$) > 0 and goPlace = 0 and go$ <> "0"
print "Did you enter a number?"
goPlace = 1
case goPlace = 0
print "Going no where!"
end select
wend
Output Enter number for place to go to Montana
Did you enter a number?
Enter number for place to go to -100
Going down!
Enter number for place to go to 100
Going up!
Enter number for place to go to -9999999999999999999999999999999999999.9999999999999999999999999999999999999999999
Going down!
Enter number for place to go to 0
Going no where!
-
Thanks John. Interesting to see the two languages combined like this.
I have been using C BASIC for all my Script BASIC extension modules. More or less for clarity and self documenting.
-
Genuine BasicTM
BASIC masturbation. :)
-
Hi Richey,
Since we are off topic in the off topic place, here is SmallBASIC version of your code:
for power in seq(0, 10, 11) do ? 2 ^ power;" ";
And in SpecBAS:
10 FOR EACH i IN [0 TO 10]: PRINT 2^i;" ";: NEXT i
Very similar.
JJ: What happens if we GO TO 11 (jbe _11) in your last snippet? :)
-
JJ: What happens if we GO TO 11 (jbe _11) in your last snippet? :)
Dunno, Dunny. Probably MASM barks at you ;)
-
Richey,
Here is the Script BASIC version of your example.
FOR i = 0 TO 10
PRINT "2 TO THE POWER OF ",i," IS ",2^i,"\n"
NEXT
jrs@laptop:~/sb/sb22/test$ time scriba pow.sb
2 TO THE POWER OF 0 IS 1
2 TO THE POWER OF 1 IS 2
2 TO THE POWER OF 2 IS 4
2 TO THE POWER OF 3 IS 8
2 TO THE POWER OF 4 IS 16
2 TO THE POWER OF 5 IS 32
2 TO THE POWER OF 6 IS 64
2 TO THE POWER OF 7 IS 128
2 TO THE POWER OF 8 IS 256
2 TO THE POWER OF 9 IS 512
2 TO THE POWER OF 10 IS 1024
real 0m0.003s
user 0m0.000s
sys 0m0.002s
jrs@laptop:~/sb/sb22/test$
I also rewrote the C BASIC version as well.
#include <stdio.h>
#include <math.h>
#include "cbasic.h"
MAIN
BEGIN_FUNCTION
DIM AS int i;
DEF_FOR (i = 0 TO i <= 10 STEP INCR i)
BEGIN_FOR
PRINT ("2 TO THE POWER OF %d IS %0.f\n", i, pow(2,i));
NEXT
RETURN_FUNCTION (0);
END_FUNCTION
jrs@laptop:~/c_basic$ gcc cpow.c -lm -o cpow
jrs@laptop:~/c_basic$ time ./cpow
2 TO THE POWER OF 0 IS 1
2 TO THE POWER OF 1 IS 2
2 TO THE POWER OF 2 IS 4
2 TO THE POWER OF 3 IS 8
2 TO THE POWER OF 4 IS 16
2 TO THE POWER OF 5 IS 32
2 TO THE POWER OF 6 IS 64
2 TO THE POWER OF 7 IS 128
2 TO THE POWER OF 8 IS 256
2 TO THE POWER OF 9 IS 512
2 TO THE POWER OF 10 IS 1024
real 0m0.002s
user 0m0.000s
sys 0m0.002s
jrs@laptop:~/c_basic$
Here is the expanded version without the C BASIC clothes.
#include <stdio.h>
#include <math.h>
int main (int argc, char** argv)
{
int i;
for (i = 0 ; i <= 10 ; ++ i)
{
printf ("2 TO THE POWER OF %d IS %0.f\n", i, pow(2,i));
}
return (0);
}
-
Still not very clear cut in all cases.
SpecBAS, for example, also allows for the use of procedures (DEF PROC) instead of GO TO / GOSUB as well as functions (DEF FN) and DO...WHILE and DO...LOOP[UNTIL] loops, CASE and has lots of in-built functions you would otherwise find in 'traditional' or 'modern' BASICs.
Well, we could argue about many things, but we have to agree that SpecBAS is a retro interpreter. ;) Firstly - mandatory line numbers. Secondly - the way it interacts with OS at the moment. Of course, it doesn't change the fact that SpecBAS is a very cool BASIC. "Retro" doesn't mean "bad" or "useles".
ScriptBasic is a completely different beast and I think that John has proved here that it's something more than a retro BASIC.
Of course, it's impossible to draw a line and say "everything on the left is retro, everything on the right isn't", but everyone who's tried different flavours of BASIC should, more or less, know what I'm talking about. And I'm pretty sure we can all agree that mandatory line numbers = retro. ;)
EDIT Things have got a bit nasty, here. Despite what Mike thinks and says, it wasn't my intention at all. ;) BP.org is gone, so please do not bring old conflicts here. ;)
-
Here is the alternative in BASIC using SpecBAS...
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP
Probably not the best one. LET A=2 had better be taken out of the loop. It's a constant, after all. :)
And in SpecBAS:
10 FOR EACH i IN [0 TO 10]: PRINT 2^i;" ";: NEXT i
.. and both in FBSL BASIC: :)
#APPTYPE CONSOLE
#OPTION IMPLICIT
20 LET A = 2
10 FOR I = 0 TO 10
30 PRINT A, " TO THE POWER OF ", I, " IS ", POW(A, I)
40 NEXT I
FOR EACH I IN {1, 5, 10}: PRINT 2 ^ I: NEXT
PAUSE
Ouput:
2 TO THE POWER OF 0 IS 1
2 TO THE POWER OF 1 IS 2
2 TO THE POWER OF 2 IS 4
2 TO THE POWER OF 3 IS 8
2 TO THE POWER OF 4 IS 16
2 TO THE POWER OF 5 IS 32
2 TO THE POWER OF 6 IS 64
2 TO THE POWER OF 7 IS 128
2 TO THE POWER OF 8 IS 256
2 TO THE POWER OF 9 IS 512
2 TO THE POWER OF 10 IS 1024
2
32
1024
Press any key to continue...
Here is the expanded version without the C BASIC clothes.
#include <stdio.h>
#include <math.h>
int main (int argc, char** argv)
{
int i;
for (i = 0 ; i <= 10 ; ++ i)
{
printf ("2 TO THE POWER OF %d IS %0.f\n", i, pow(2,i));
}
return (0);
}
... and the same in FBSL DynC: :)
#AppType Console
C()
Pause
DynC C()
double pow(double, double);
void main() {
int i;
for (i = 0; i <= 10; ++i)
printf("2 TO THE POWER OF %d IS %0.f\n", i, pow(2, i));
}
End Dync
Output:
2 TO THE POWER OF 0 IS 1
2 TO THE POWER OF 1 IS 2
2 TO THE POWER OF 2 IS 4
2 TO THE POWER OF 3 IS 8
2 TO THE POWER OF 4 IS 16
2 TO THE POWER OF 5 IS 32
2 TO THE POWER OF 6 IS 64
2 TO THE POWER OF 7 IS 128
2 TO THE POWER OF 8 IS 256
2 TO THE POWER OF 9 IS 512
2 TO THE POWER OF 10 IS 1024
Press any key to continue...
Just to put things in the proper perspective, does anyone use masmbasic for anything useful other than you?
It is my firm belief that as long as at least one living person uses his pet language for whatever purpose he sees fit, be it JJ and his MasmBasic, or JRS and his Script BASIC, or me and my FBSL, the respective language is alive.
-
Out of interest, mike, how does you {}s work in your example above? I can't find any documentation that mentions them on the FBSL forums beyond addressing string characters.
-
FBSL BASIC v3.4's documentation is a) ridiculously frenglish, and 2) dramatically incomplete.
{} is an old-timer in FBSL and IIRK it would work in v3.4 and earlier as well as in v3.5. {} in FBSL is not just a "figure of speech" but rather a distinct anonymous object that's roughly equivalent to a collection. It can contain anything from literals to class instances and is most often used for initializing dynamic variant arrays. It can't however be used for static arrays for stricter data type checking reasons.
Consider:
#AppType Console
Dim a[] = {%4321, %%4321, !4321, !!4321, "four three two one"}
For Each Dim e In {%1234, %%1234, !1234, !!1234, "one two three four"}
Print e
Next
For Each e In a: Print e: Next
Pause
Ouput:
1234
1234
1234.000000
1234
one two three four
4321
4321
4321.000000
4321
four three two one
Press any key to continue...
-
Ahh, yes I see. Actually, that's a really neat way of auto-filling an array - I might steal that :)
-
You are most welcome. :)
-
I currently allow DIM var=(1,2,3,4) style, but using SpecBAS ranges might be better:
DIM a=[1 TO 10 STEP 2,40,50,60 TO 70,71 TO 72 STEP .1]
Of course, one of my seven users might have already used the old style with ()s...
-
Perhaps you could leave the older syntax as an option?.. They'll all switch to the new one eventually because it would look more distinct in the overall "spaghetti" style of SpecBAS scripts and would catch one's attention better, and then you'll be able to deprecate the use of parentheses for that particular purpose...
I'm often irritated with FBSL BASIC not supporting ranges. Don't really understand how I could overlook that feature. Might also add them though for consistency with other BASICs one of these days when I'm through with my WIP to update the Eclecta editor.
-
ScriptBasic is a completely different beast and I think that John has proved here that it's something more than a retro BASIC.
Thanks Tomaaz!
Script BASIC is really a core traditional BASIC that is easy to use and extend. Runs on everything.
-
Retro... Commodore BASIC 3.5 was capable of that ...
-
Here is the alternative in BASIC using SpecBAS...
10 FOR I=0 TO 10
20 LET A=2
30 PRINT A;" TO THE POWER OF ";I;" IS ";POWER(A,I)
40 NEXT I
50 STOP
Probably not the best one. LET A=2 had better be taken out of the loop. It's a constant, after all. :)
Gaahh...of course, thanks Mike. As our friends from across the pond say, my bad.
Thanks to you, B+, John, JJ and D for your versions - very much appreciated :)
John, where can I get hold of the latest Windows versions of C BASIC and Script BASIC and the accompanying documentation? (Yes, Aurel, I know...don't worry, I'm keeping my focus :)...)
-
Still not very clear cut in all cases.
SpecBAS, for example, also allows for the use of procedures (DEF PROC) instead of GO TO / GOSUB as well as functions (DEF FN) and DO...WHILE and DO...LOOP[UNTIL] loops, CASE and has lots of in-built functions you would otherwise find in 'traditional' or 'modern' BASICs.
Well, we could argue about many things, but we have to agree that SpecBAS is a retro interpreter. ;) Firstly - mandatory line numbers. Secondly - the way it interacts with OS at the moment. Of course, it doesn't change the fact that SpecBAS is a very cool BASIC. "Retro" doesn't mean "bad" or "useles".
ScriptBasic is a completely different beast and I think that John has proved here that it's something more than a retro BASIC.
Of course, it's impossible to draw a line and say "everything on the left is retro, everything on the right isn't", but everyone who's tried different flavours of BASIC should, more or less, know what I'm talking about. And I'm pretty sure we can all agree that mandatory line numbers = retro. ;)
Yes, I don't think I'll split hairs over retro or Retro-style interpreter :)
-
John, where can I get hold of the latest Windows versions of C BASIC and Script BASIC and the accompanying documentation?
(http://www.talklocal.com/blog/wp-content/uploads/2013/01/mouse-trap-bait.jpg)
C BASIC is nothing other than an include file of #define's that substitute or add place holders for a BASIC like translation. It isn't platform specific but you need to use gcc as the C compiler.
I would suggest joining the C BASIC Forum (http://www.basic-compiler.com/forum/index.php) as we are adding BASIC string function support along with math.
Script BASIC - You have a couple choices with the Windows version. If you want a cool IDE w/Interactive debugger, VB COM/OLE/OCX support, than I would suggest Dave's Windows setup. If a traditional console mode interpreter is your cup of tea, there is a Windows 32 bit and 64 bit binary set on the Script BASIC forum you can download.
Look at the upper right corner of the Script BASIC forum for links to the BitBucket C BASIC examples and the wiki for Script BASIC.
-
[
-
... as we are adding BASIC string function support along with math.
John, I followed your link and had a quick look at your (nsilva's, to be exact) set of proposed string function translations.
You're falling into a monumental trap. I remember I pointed that out a couple years ago: you can't get away with strings as easily as you do with #defines. Those will be leaking memory like hell, especially in loops.
Matter is, almost all of them are calloc'ing memory chunks from the process heap but none of them is actually freeing anything, ever. You must implement some sort of transparent memory management to match that would collect and free temporary and function-local string var allocations similar to the ring allocator of BCX/UBX/MBC (haven't I overlooked anyone?), or else design a full blown memory manager with garbage collection similar to the one used in Script BASIC itself to also cater for the memory discardable by global string vars at the moment when their string values are reassigned for whatever purpose -- concatenation, trimming, etc.
That done, you'll end up with perhaps 75% of a new BASIC-to-C (BCX??) translator reincarnation in your lap.
There is absolutely no other way out of this blind alley.
-
That done, you'll end up with perhaps 75% of a new BASIC-to-C (BCX??) translator reincarnation in your lap.
C BASIC isn't a translator. It's a preprocessor trick making C look more like BASIC.
I know. I had to fight to get him to make the start of a string 1 instead of 0. :o
I'm thinking of using Script BASIC's MyAlloc if I can't find something else.
AIR already has a C BASIC with string support but it's for C++ called JADE (http://www.allbasic.info/forum/index.php?topic=284.0).
-
It's a preprocessor trick making C look more like BASIC.
If that's what you intend it to stay in the future, then you'll have to keep track of string calloc's throughout your pseudo-BASIC sources yourself exactly like in C programming and encode all the appropriate deallocations manually. Might be a good exercise for a BASIC-er to learn one or two things about memory management though... :)
-
It's a preprocessor trick making C look more like BASIC.
If that's what you intend it to stay in the future, then you'll have to keep track of string calloc's throughout your pseudo-BASIC sources yourself exactly like in C programming and encode all the appropriate deallocations manually. Might be a good exercise for a BASIC-er to learn one or two things about memory management though... :)
I have seen the project and in the c string file does have a function like
void destroy(char *str)
{
free(str);
}
This way it can be called in the end n times to release the mem alloc, or is there a best way of doing that?
How would you implement it?
Thanks.
-
@cvirus:
destroy(char *str) is the only one on the list that doesn't have to be implemented as a function. It would only add function call overhead to the resultant C code. It had better be implemented as a macro:
#define destroy(s) free((void*)(s))
C provides two ways to create a function local string:
1) directly on the function stack in the form of a fixed size character array, e.g.
char s[128] = "bla-bla";
in which case it needs no special freeing because it's going to be destroyed together with the function stack automatically on function return; and
2) as a character pointer on the function stack that would point to a memory chunk allocated elsewhere, e.g.
char *s = (char*)malloc(128); // => uninitialized; (char*)calloc(128,1) => initialized with 0's
in which case it must be freed explicitly before the function returns if only the pointer value s isn't returned by the function itself for use somewhere else in the program code. If this isn't done, then the pointer value s will be lost together with the function stack on function return but the chunk will still hang in memory forever unallocatable due to the exact value having been irrevocably lost.
Variant 1 is seldom used because the default stack size is typically 1MB for the entire program and it can be exhausted very quickly if the function calls are nested deeply in one another or are recursive, especially if the character arrays are large.
In short, the C-Basic programmer should behave exactly like a C programmer would following the rules of proper memory management. Further reference materials on this topic are likely to be found in C programming manuals. You may very well start here (https://en.wikibooks.org/wiki/C_Programming/Memory_management).
-
Mike,
Is what we have now fixable of should we start over from scratch?
John
-
John,
Just replace the destroy() function with the macro and off you go. But the user will be supposed to keep track of their strings' visibility scope and lifetime manually like a mature low-level C programmer, not a BASIC beginner.
To improve the situation, you will have to add some kind of a memory manager that would offload the task of track keeping and garbage collection from you, effectively turning C-Basic into a HLL.
C-Basic has stopped being a macro file the moment it hosted its first string function. I think at least some of them could also be turned into C multiline macros and thus be effectively inlined verbatim in their entirety at every spot they would occur in the script making it a little faster, albeit fatter. But the need to abstract from manual memory management will inevitably lead to adding code that shouldn't and/or couldn't be expressed with macros no matter what. Hence, no other way out but the BCX/UBX/MBC/FreeBASIC/MasmBasic way. (haven't I overlooked anyone else again?)
-
It looks that the better aproach is to build a memory menager like Mike said, any idea on how to build one? Any links that could help out? Thanks.
-
My goal wasn't to make C BASIC another BASIC but help BASIC programmers learn C using BASIC like syntax as a mask.
-
@cvirus:
First off, you'll have to cope with function locals. Those could be handled by a simple ring allocator very efficiently. BCX is an open-source GNU GPL project. If you subside to the GNU GPL with C BASIC, you can freely borrow the relevant code from BCX/UBX/MBC. You would also have at least two good potential advisors into the bargain, AIR and/or J.C.Fuller (of MBC and UBX, respectively), who could possibly help you out should anything go wrong.
By saying the BCX way, I don't mean literally becoming another BCX. I mean, building a HLL translator presupposes some standard solutions, just because if you wanna fly you're bound to have wings. Having a ring allocator doesn't mean literally taking after BCX. What you'll be able to offer as translations is what could make the real difference (or similarity, for that matter). BCX is built around functions -- try to build C BASIC around macros wherever possible, and that'll be your distinctive feature. You might even become a little faster than BCX that way and who would then care if your resultant binaries are just a little fatter?
@John: (sorry for mis-spelling the project name)
There's nothing to prevent you from writing low-level C-like code (not inline C that's also possible!) directly in BCX bypassing its garbage collection facilities whenever you feel like it. But who would care to, given the advantages of automated GC if and when it's already built in? The projected C BASIC translator could offer just as much as well.
-
C provides two ways to create a function local string:
1) directly on the function stack in the form of a fixed size character array, e.g.
char s[128] = "bla-bla";
in which case it needs no special freeing because it's going to be destroyed together with the function stack automatically on function return
Which is a pretty stupid use of the stack btw, because C will on each call to that function copy a global fixed size character array to the stack area. And in 99.9% of all cases, it will be read-only anyway, so you might as well use the global pointer directly, without the copy.
-
This was just to exemplify that fixed size char or byte arrays on the function stack can be initialized with literal string values. They can also be initialized with string variables. Or usable as temporary buffers for various other purposes, they would often require prior initialization with zeros with the aid of a dedicated call to cdecl memset() or stdcall RtlZeroMemory() -- something that calloc() would offer out-of-the-box but using the process global heap.
So what?
I wasn't talking about efficiency here. I was talking about available memory storage areas and their pros and cons. And I was answering the question of a person who, for all I know, might be reading the words stack and heap for the first time in his life having been curtained off by beginner's BASIC that in fact knows, or lets its users know, nothing about the real basic notions like pointers, addresses or other memory-related stuff.
(wink-wink)
-
I feel the string funtionality in C BASIC should be approached the same way a C programmer would adding string support to their C code.
-
John,
That would be yet another reason to try and re-implement the suggested string functions as macros (wherever possible, of course) for verbatim inlining in the resultant C-language output. A human C programmer would usually code buffer operations and associated memory allocation/deallocation in situ rather than resort to separate reusable but slower procedures like in automatic translation or interpretation.
C is essentially as low-level as the MASM macro processor with the only exception that it prefers to read and dump its variables from and to the memory rather than try and keep them in the CPU registers at all times, which would require meticulous hand crafting. That way it abstracts from the CPU particulars entirely but instead acquires the ability to improve suboptimal code pieces automatically at a higher typical code block level through its -O optimization options.
-
The plan was to mask C string functions with BASIC like syntax. Once again, I'm not interested in creating another BASIC. This is all about helping BASIC programmers becoming familiar with C.
-
Aye aye, Cap! :)
-
As an example, here is the beginning of the JS (JavaScript) extension module using C BASIC masking.
/* V7 JavaScript Engine Extension Module */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include "../../basext.h"
#include "../../scriba.h"
#include "cbasic.h"
#include "v7.h"
/****************************
Extension Module Functions
****************************/
besVERSION_NEGOTIATE
RETURN_FUNCTION((int)INTERFACE_VERSION);
besEND
besSUB_START
DIM AS long PTR p;
besMODULEPOINTER = besALLOC(sizeof(long));
IF (besMODULEPOINTER EQ NULL) THEN_DO RETURN_FUNCTION(0);
p = (long PTR)besMODULEPOINTER;
RETURN_FUNCTION(0);
besEND
besSUB_FINISH
DIM AS long PTR p;
p = (long PTR)besMODULEPOINTER;
IF (p EQ NULL) THEN_DO RETURN_FUNCTION(0);
RETURN_FUNCTION(0);
besEND
/*******
V7 API
*******/
besFUNCTION(js_create)
struct v7 *v7 = v7_create();
besRETURN_LONG(v7);
besEND
besFUNCTION(js_destroy)
DIM AS unsigned long v7;
besARGUMENTS("i")
AT v7
besARGEND
v7_destroy(v7);
besRETURNVALUE = NULL;
besEND
besFUNCTION(js_exec)
DIM AS unsigned long v7;
DIM AS const char *js_code;
DIM AS v7_val_t result;
enum v7_err rcode = V7_OK;
besARGUMENTS("iz")
AT v7, AT js_code
besARGEND
rcode = v7_exec(v7, js_code, result);
besRETURN_LONG(rcode);
besEND
js.bas include
MODULE JS
declare sub ::CREATE alias "js_create" lib "js"
declare sub ::DESTROY alias "js_destroy" lib "js"
declare sub ::EXEC alias "js_exec" lib "js"
END MODULE