Hard Light Productions Forums
Off-Topic Discussion => Programming => Topic started by: Colonol Dekker on October 20, 2008, 09:59:16 am
-
1- PRINT "Hello world!"
2-NEW LINE
3-GOTO 1
How easy was it back then...........
:D
-
Perl is simply:
while (1) {
print "Hello, world!\n";
}
And many other languages are nearly as easy.
On the other hand, more complicated operations are much easier to perform in other languages as compared to Basic. The best example is quicksort. This is a simple thing to implement in any language with proper recursion, but basic makes it very difficult. I managed to write Quicksort for the TI-84 calculator (using TI-BASIC), but it basically involved writing my own call stack using a matrix and then writing a recursive Quicksort on top of that.
-
Ok. I'm too stupid to use anything besides basic and html and flash. I should have said that instead :lol:
-
Try learning Java, once you get your head around Object Oriented coding, it's a very easy language to learn ;)
-
I did learn, and forget; the basic bare basics of Javascript........ten years back :nod:
-
Javascript and Java are not the same thing though. Not by a long way. :)
-
Agreed, once you get over your initial concerns about it being interpreted rather than compiled, it's a nice little language, certainly preferable, in my opinion, to VB, which seems to make a mountain out of a molehill in 90% of cases.
-
If you still want to use basic, why not try the free Windows and Unix one, Yabasic?
http://www.yabasic.de/ (http://www.yabasic.de/)
It's rather fun, I've programmed a random colour fader before now...
-
Oh, this takes me back to the many hours I spent in QBasic...
<3
-
Gorillas.bas ftw
I don't care how old this thread is, the board needs more activity.
-
I spent many hours with Gorillas.bas. That was a lot of fun.
Now I spend many (most?) hours fighting with VS and MFC.
-
Turns out if you play gorillas at midnight it freezes :lol:
The timing routine wasn't sophisticated enough to handle the timer being reset to zero.
-
:bump:
I need to visit this forum more often...
I love BASIC. In all its varieties. :D Gorillas.bas was a classic, true, but the real goldmine came from all those books with BASIC code listings for games and such. Tim Hartnell FTW. Pretty much any book that he wrote is a must-read and must-code. :D Another must-have is the CIA adventure game from Basic Fun With Adventure Games by Susan Lipscomb and Margaret Zuanich.
-
I remember when I made FS2BASIC. I wonder if I still have it...
EDIT:
OPTION NOLET
SET WINDOW 0,1000,0,1000
RANDOMIZE
CALL Read_image("MS BMP",BAD$,"BAD.BMP")
CALL Read_image("MS BMP",BKGRND$,"BKGRND.BMP")
CALL Read_image("MS BMP",SUBF$,"SUBF.BMP")
CALL Read_image("MS BMP",PROMF$,"PROMF.BMP")
CALL Read_image("MS BMP",ROCKF$,"ROCKF.BMP")
CALL Read_image("MS BMP",HRPF$,"HRPF.BMP")
CALL Read_image("MS BMP",DIE$,"DIE.BMP")
CALL Read_image("MS BMP",HIT$,"HIT.BMP")
CALL Read_image("MS BMP",BFIRE$,"BFIRE.BMP")
DO
PRINT " FREESPACE"
PRINT " 1) Ready room"
PRINT " 2) Tech room"
PRINT " 3) Bath room"
PRINT " 4) Airlock"
PRINT
PRINT
PRINT "Where do you want to go? Input #"
INPUT GO
IF GO = 1 THEN
CALL PLAY
ELSE IF GO = 2 THEN
CALL WHAT
ELSE IF GO = 3 THEN
CALL POOP
ELSE IF GO = 4 THEN
STOP
ELSE
PRINT "Pick another number, idiot."
END IF
LOOP
END
!==================================================================
SUB PLAY
CLEAR
PRINT "What laser do you want?"
PRINT " 1) Subach HL-7 (Damage 8)"
PRINT " 2) Prometheus - S (Damage 12)"
PRINT " Input number"
INPUT GUN
CLEAR
PRINT "What missile do you want?"
PRINT " 1) Rockeye (10 missiles) (Damage 30)"
PRINT " 2) Harpoon (6 missiles) (Damage 50)"
PRINT " Input number"
INPUT MISS
PRINT "YOUR WEAPONS:";
IF GUN = 1 THEN
PRINT "Subach HL-7";
ELSE
PRINT "Prometheus - S";
END IF
IF MISS = 1 THEN
PRINT " and Rockeye"
ELSE
PRINT "and Harpoon."
END IF
PRINT
PRINT
PRINT "Press a key when you are ready."
GET KEY PSE
CLEAR
!=============================
PHLTH = 100
DO
BHLTH = 100
A=rnd*800
B=rnd*800
DO
FWB = FWB - 1
FW = FW-1
FWM = FWM-1
!BOX SHOW $ at ,
!32
!122
BOX SHOW BKGRND$ at 0,0
BOX SHOW BAD$ at A,B
GET MOUSE X,Y,S
GET KEY S
IF S=122 THEN
IF GUN = 1 AND FW >= 0 THEN
BOX SHOW SUBF$ at 0,0
ELSE
BOX SHOW PROMF$ at 0,0
END IF
IF X>A AND X<(A+200) AND Y>B AND Y<(B+200) THEN
BOX SHOW HIT$ at A,B
IF GUN = 1 THEN
BHLTH = (BHLTH-8)
FW = 6
ELSE
BHLTH = (BHLTH-12)
FW = 10
END IF
END IF
END IF
IF S=32 THEN
IF MISS = 1 AND FWM >= 0 THEN
BOX SHOW ROCKF$ at 0,0
ELSE
BOX SHOW HRPF$ at 0,0
END IF
IF X>A AND X<(A+200) AND Y>B AND Y<(B+200) THEN
BOX SHOW HIT$ at A,B
IF GUN = 1 THEN
BHLTH = (BHLTH-30)
FWM = 10
ELSE
BHLTH = (BHLTH-50)
FWM = 15
END IF
END IF
END IF
PAUSE 0.1
!PLOT TEXT, at x, y:
IF FWB >= 0 THEN
BOX SHOW BFIRE$ at A,B
PHLTH = PHLTH - (RND*4+6)
BAR =(100 - PHLTH)
SET COLOR "GREEN"
PLOT TEXT, AT BAR,10 : "|"
PLOT TEXT, AT 101,10 : "YOUR DAMAGE"
SET COLOR "BLACK"
FWB = (RND*5+4)
END IF
LOOP UNTIL BHLTH >=0 OR PHLTH >= 0
IF BHLTH >= 0 THEN
KILL = KILL + 1
END IF
IF PHLTH >= 0 THEN
CLEAR
PRINT " YOU SUCK AT THIS GAME! !! YOU LOSE!!"
END IF
LOOP UNTIL KILL = 10 OR PHLTH >= 0
IF KILL = 10 THEN
PRINT "YOU ROCK AT A GAME THAT TAKES NO SKILL WHATSOEVER TO PLAY! !"
END IF
END SUB
!======================================================================
SUB WHAT
PRINT " This is a 'port' of the most basic aspects of the game of Freespace 2 to True basic."
PRINT " When you go into play mode, you get to select guns. Some do more damage than others"
PRINT " Put your mouse pointer on the bad guys. 'Z' shoots your lasers, Spacebar shoots a missile"
PRINT " Click on bad guys to destroy them."
PRINT
PRINT " Back to the main hall! *press key"
GET KEY PSE
CLEAR
END SUB
!=====================================================================
SUB POOP
PRINT " You unzip your pants. Then you remember that this is a game"
PRINT " and you get up from your computer desk and walk to the real"
PRINT " bathroom. Thank goodness! *press key"
GET KEY PSE
CLEAR
END SUB
Unfortunately, I no longer have the pictures.
-
Same here, I should put this forum on my auto-notify of new topics.
BASIC Stuff (http://swc.fs2downloads.com/files/BASIC.7z)
There's a lot of stuff in there, from almost every version of QBASIC (and FirstBasic for DOS 1.0!), to gorilla.bas, plus a modified version I made where the building hits are as big as gorilla hits and the gorilla hits are like a nuke that wipes the screen (it was much more fun to watch on a Pentium 33/66 than it probably is on a new PC), to numerous other BASIC files I ran across, to a golf game I wrote my freshman year of high school (compiled!). That's right, QB after 1.1 had a compiler. Really I think it just wraps the interpreter and the script together, but whatever.
-
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
-- Edsger W. Dijkstra
And tbh, I agree. BASIC is ****e.
-
:bump:
I need to visit this forum more often...
I love BASIC. In all its varieties. :D Gorillas.bas was a classic, true, but the real goldmine came from all those books with BASIC code listings for games and such. Tim Hartnell FTW. Pretty much any book that he wrote is a must-read and must-code. :D Another must-have is the CIA adventure game from Basic Fun With Adventure Games by Susan Lipscomb and Margaret Zuanich.
How about all those classic 3.2.1 Contact magazines? ;)
-
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
-- Edsger W. Dijkstra
And tbh, I agree. BASIC is ****e.
Or maybe its just an excuse by someone who is better with computers than they are with people :D
-
It is ironic, therefore that many 30-somethings, i.e. a fair percentage of the programmers around, started on something like BBC or Commodore BASIC, probably moving on to PASCAL or something like 8-Bit machine code, if they were really lucky, they would have learned something like Amiga OS, which is heading towards Linux, but for the main part, I'd suggest that quite a lot of coders were 'born in BASIC', as it were, and then moved on to something more flexible.
-
I started on visual basic. While anything BASIC-related is a sh*tty programming language, saying that programmer's minds are hopelessly "mutilated beyond hope of regeneration" is stupid and wrong.
-
This may be true today. VB certainly is closer to Java, or other "real" programming languages, than the original version.
-
This may be true today. VB certainly is closer to Java, or other "real" programming languages, than the original version.
Keep in mind that I started on VB6, not VB.net
-
But Dijkstra made his comment back in 1975, when BASIC was being used as a teaching tool, and still relied on abominations like GOTO as a control structure.
Disclaimer: I have never, ever done anything with BASIC, in any form whatsoever.
-
True, which means someone shouldn't really be quoting a comment that now has no relevance to the present day :P
-
Except I was taught my first programming wiht BASIC in 1998/1999, using not only GOTO but GOTO with LINE NUMBERS. Dijkstra was right, you can really pick up some bad habits with BASIC. Honestly Java would probably make a better first language. Get you in that OO mode.
-
Except I was taught my first programming wiht BASIC in 1998/1999, using not only GOTO but GOTO with LINE NUMBERS. Dijkstra was right, you can really pick up some bad habits with BASIC. Honestly Java would probably make a better first language. Get you in that OO mode.
O.o;;;;;
-
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
-- Edsger W. Dijkstra
And tbh, I agree. BASIC is ****e.
Or maybe its just an excuse by someone who is better with computers than they are with people :D
What are you implying, really?
I started on visual basic. While anything BASIC-related is a sh*tty programming language, saying that programmer's minds are hopelessly "mutilated beyond hope of regeneration" is stupid and wrong.
Dijkstra was far from stupid. And no, it is not wrong. You do not learn anything about how a computer works from BASIC. There are a lot of bad practices in the language which are very hard to unlearn.
-
But Dijkstra made his comment back in 1975, when BASIC was being used as a teaching tool, and still relied on abominations like GOTO as a control structure.
Disclaimer: I have never, ever done anything with BASIC, in any form whatsoever.
Oh, I'd argue that goto has it's uses, but not necessarily as a control structure. It's a quck and easy way to kludge memory freeing when **** hits the fan, for example.
-
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
-- Edsger W. Dijkstra
And tbh, I agree. BASIC is ****e.
Or maybe its just an excuse by someone who is better with computers than they are with people :D
What are you implying, really?
In retrospect, we know that his statement does not hold water. So, the guy either didn't have a clue, or then just didn't have the patience to actually teach someone properly. And based on the stuff he did we can rule out the former explanation.
-
But Dijkstra made his comment back in 1975, when BASIC was being used as a teaching tool, and still relied on abominations like GOTO as a control structure.
Disclaimer: I have never, ever done anything with BASIC, in any form whatsoever.
Oh, I'd argue that goto has it's uses, but not necessarily as a control structure. It's a quck and easy way to kludge memory freeing when **** hits the fan, for example.
GOTO can be useful, no doubt about it. Consider this:
int parse()
{
Token tok;
reading:
tok = gettoken();
if (tok == END)
return ACCEPT;
shifting:
if (shift(tok))
goto reading;
reducing:
if (reduce(tok))
goto shifting;
return ERROR;
}
That is one beautiful use for a goto. Original source here. (http://david.tribble.com/text/goto.html)
However, I guess that Dijkstra merely wanted to point out BASIC's deficiencies as a teaching tool, as it was severely lagging behind the other languages that came up later. That he chose deliberately inflammatory language to get people thinking about his point, and the fact that it is still debated, proved that that discussion had to be made
-
But applying his quote to Visual Basic doesn't work.
-
Yep. But I guess his quote (and the ensuing discussion) had more than a little influence on VB's design.
-
I've used goto's when dealing with error retries.
something like this:
Retry:
if (DoStuff ().Failed) then
if (DisplayRetryMessage ().Answer == Retry) then
goto Retry
endif
endif
I know it can be done with loops, but it just looks more awkward.
-
The point is that GOTO is pretty much BASIC's primary way of accessing independent chunks of code. It's not saying it's totally useless, but there are far better ways in just about every other language. And kode, you don't need to know much about computers themselves to write code. Many programmers know very little about the hardware they write code for, and higher level programmers probably don't even know the difference between little-endian and big-endian. Doesn't mean they'll be bad programmers, good object oriented programming, among other things, usually takes away the need for that kind of intimate knowledge of the machine. The point is that getting engrossed in BASIC can develop habits that make it hard to fully grasp the fundamentals of object oriented programming, and can typically just make programmers lazy. There are so many programmers I work with, who some of my coworkers consider 'good' programmers, simply because they can work quickly. But their speed usually comes at the cost of good code design, with many things ending up hardcoded, no thought given to the more advanced features of the language we use, etc. I've a feeling many of them learned BASIC as a first language, and never thought to expand their programming methods too far beyond what was capable with it.
-
At least we don't need GoSub anymore :lol:
-
But their speed usually comes at the cost of good code design, with many things ending up hardcoded, no thought given to the more advanced features of the language we use, etc. I've a feeling many of them learned BASIC as a first language, and never thought to expand their programming methods too far beyond what was capable with it.
I have the same experience with some people, with the difference that most of them have no experience with basic at all. So (IMO) the problem has more to do with what they did not learn, rather than what they did learn wrong.
-
int parse()
{
Token tok;
reading:
tok = gettoken();
if (tok == END)
return ACCEPT;
shifting:
if (shift(tok))
goto reading;
reducing:
if (reduce(tok))
goto shifting;
return ERROR;
}
That is a beautiful piece of code.
-
The point is that GOTO is pretty much BASIC's primary way of accessing independent chunks of code. It's not saying it's totally useless, but there are far better ways in just about every other language. And kode, you don't need to know much about computers themselves to write code. Many programmers know very little about the hardware they write code for, and higher level programmers probably don't even know the difference between little-endian and big-endian. Doesn't mean they'll be bad programmers, good object oriented programming, among other things, usually takes away the need for that kind of intimate knowledge of the machine. The point is that getting engrossed in BASIC can develop habits that make it hard to fully grasp the fundamentals of object oriented programming, and can typically just make programmers lazy. There are so many programmers I work with, who some of my coworkers consider 'good' programmers, simply because they can work quickly. But their speed usually comes at the cost of good code design, with many things ending up hardcoded, no thought given to the more advanced features of the language we use, etc. I've a feeling many of them learned BASIC as a first language, and never thought to expand their programming methods too far beyond what was capable with it.
I hear there's this new invention called "paragraphs" that make large walls of text appear legible. I suggest you try it out if I am to be able to respond to any points you want made.
-
Sorry man, I'm a runaway train sometimes. But trust me, I've seen far worse (it may not look bad to me cause of the 1920 width my monitor is at though...).
-
Oh jesus, I just read up on big-endian and little endian. All I can say is THANK GOD FOR COMMON ARCHITECTURES. Also, I never want to write a networking engine. Ever.
-
Lol, see what I mean? If you've never had to write highly portable, but relatively low-level code, you've probably never had to worry about it. But it's good to know these things. Mostly because every compiler ever available, was built with a previous compiler, sometimes written in lower level code, all the way back to the first ones written in straight machine code. (Don't look that up on ED btw).
-
But Dijkstra made his comment back in 1975, when BASIC was being used as a teaching tool, and still relied on abominations like GOTO as a control structure.
Disclaimer: I have never, ever done anything with BASIC, in any form whatsoever.
I don't get it. How does having used GOTO in graphing calculator basic make you a terrible programmer? I don't think I've ever used GOTO when I'm doing real programming. Not even in True BASIC.
-
Oh jesus, I just read up on big-endian and little endian. All I can say is THANK GOD FOR COMMON ARCHITECTURES. Also, I never want to write a networking engine. Ever.
offtopic, but:
Have you ever tried different assemblers?
I forget which syntax is which, but in two different assemblers MOV D1, D0 can have totally different meanings (e.g. D1->D0 or D0->D1) :nod:
-
I actually enjoyed playing with Cool Basic...
It's cool...
-
Oh jesus, I just read up on big-endian and little endian. All I can say is THANK GOD FOR COMMON ARCHITECTURES. Also, I never want to write a networking engine. Ever.
offtopic, but:
Have you ever tried different assemblers?
I forget which syntax is which, but in two different assemblers MOV D1, D0 can have totally different meanings (e.g. D1->D0 or D0->D1) :nod:
In 6502 not only was the format little-endian, but you could only use indexed referencing, so if you wanted to jump to an address, you had to write it down (backwards) in memory and then order the code to jump to the address referenced to by the address you had just updated :)
-
Oh jesus, I just read up on big-endian and little endian. All I can say is THANK GOD FOR COMMON ARCHITECTURES. Also, I never want to write a networking engine. Ever.
offtopic, but:
Have you ever tried different assemblers?
I forget which syntax is which, but in two different assemblers MOV D1, D0 can have totally different meanings (e.g. D1->D0 or D0->D1) :nod:
In 6502 not only was the format little-endian, but you could only use indexed referencing, so if you wanted to jump to an address, you had to write it down (backwards) in memory and then order the code to jump to the address referenced to by the address you had just updated :)
Back in my day, we used to have to get up before we'd gone to bed and write windows applications in x86 assembler
http://www.youtube.com/watch?v=Xe1a1wHxTyo (http://www.youtube.com/watch?v=Xe1a1wHxTyo)
-
Aye, 26 hours a day down t'pit, 'were grim up North ;)