• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
dave j

BASIC

17 posts in this topic

Many many years ago I was asked to alter a program written in BASIC by someone who had been learning to program as they went along. It was obvious that they only discovered subroutines part way through when I found the equivalent of the following in several places throughout the code:

10 REM early bit of code
20 GOSUB 40
30 GOTO 60
40 REM stuff they later decided they wanted to use in several places
50 RETURN
60 REM some more program
70 GOSUB 40
80 REM rest of program
90 END
1

Share this post


Link to post
Share on other sites

Now i understand where the "dont use goto" come from lol. Using lines numbers to jump is such a dumb idea. I sometime use 1 when i need to jump to the same place from multiples location inside a function, but that about it, and try to avoid them at all cost.

Edited by Vortez
0

Share this post


Link to post
Share on other sites

The procedural equivalent happens all the time too (where function calls become wrappers to other calls, etc.). It's probably a good way to save time.

 

Want something bad? On some code I worked not long ago somebody didn't figure out how to call subroutines yet, so he resorted to using an IRQ for the job instead... To give you an idea, that's like spawning a new thread just to call a function. Yuck.

1

Share this post


Link to post
Share on other sites

There are some neat tricks you can do in a similar way to save code-space, for example if you have reoutines to calculate sine and cosine, you can write the function for sine, and instead of writing a very similar function for cosine, you just add an instruction or two ahead of the sine function that shifts the cosine period to align with the sine period, and then continue through the sine function. There's not much reason to use this exact structure where code-space isn't a concern, but its common to see similar things where code-space is limited, such as in microcontrollers.

1

Share this post


Link to post
Share on other sites

Want something bad? On some code I worked not long ago somebody didn't figure out how to call subroutines yet, so he resorted to using an IRQ for the job instead... To give you an idea, that's like spawning a new thread just to call a function. Yuck.

 

lol

Edited by Vortez
0

Share this post


Link to post
Share on other sites


Want something bad? On some code I worked not long ago somebody didn't figure out how to call subroutines yet, so he resorted to using an IRQ for the job instead... To give you an idea, that's like spawning a new thread just to call a function. Yuck.


lol

I think that's more of an aaaargh! than a LOL.
0

Share this post


Link to post
Share on other sites

There are some neat tricks you can do in a similar way to save code-space, for example if you have reoutines to calculate sine and cosine, you can write the function for sine, and instead of writing a very similar function for cosine, you just add an instruction or two ahead of the sine function that shifts the cosine period to align with the sine period, and then continue through the sine function. There's not much reason to use this exact structure where code-space isn't a concern, but its common to see similar things where code-space is limited, such as in microcontrollers.

Compilers will do it for you these days anyway.

 


I think that's more of an aaaargh! than a LOL.

That's an understatement (took me a while to figure out how to deal with that thing...).

0

Share this post


Link to post
Share on other sites

For those of you who are feeling particularly sadistic, try baysick. It's essentially a BASIC subset in Scala so you can write BASIC in your Scala code. And for those of you who aren't familiar with Scala, Scala is nothing like BASIC.

2

Share this post


Link to post
Share on other sites

Many many years ago I was asked to alter a program written in BASIC by someone who had been learning to program as they went along. It was obvious that they only discovered subroutines part way through when I found the equivalent of the following in several places throughout the code:
 

10 REM early bit of code
20 GOSUB 40
30 GOTO 60
40 REM stuff they later decided they wanted to use in several places
50 RETURN
60 REM some more program
70 GOSUB 40
80 REM rest of program
90 END

 

 

The horrors of  GOTO  (jumps with index number labels)  would have started in early FORTRANs

 

Any instructor who says "NEVER" use GOTO  may never have done much serious programming  (where they are very useful for abnormal exiting of complex subroutines,  and the horrors of number goto labels are long gone)

Edited by wodinoneeye
0

Share this post


Link to post
Share on other sites

That looks surprisingly usable actually...

 

If you're a hardcore BASIC user, yes. Otherwise, if you're sane, no. As in, Oh hell no.

1

Share this post


Link to post
Share on other sites

Adding a quick goto must have been much easier for those people than listing a bit of code, guess some line number range thats free and will not be needed soon, editing all line numbers and hitting enter to copy them, listing it again, typing in the line numbers alone to delete the original, still remember all numbers and list the next bit cause the screen was too small, ...

And later they would have dicovered they moved the code to a place where they need the linenumbers now for new code and repeat it all again.sad.png

... or just add a quick goto at that point?tongue.png

Edited by wintertime
0

Share this post


Link to post
Share on other sites


Any instructor who says "NEVER" use GOTO  may never have done much serious programming  (where they are very useful for abnormal exiting of complex subroutines,  and the horrors of number goto labels are long gone)
That depends on the language -- error cleanup based around goto is idiomatic in C, but in most modern languages the idiomatic thing to do is to use throw instead.

I'd probably still teach a class to never use goto, but then also teach that C error cleanup idiom as being the exception to this rule, and as a look inside how exceptional stack unwinding might be implemented in C++ wink.png

0

Share this post


Link to post
Share on other sites
10 REM early bit of code
20 GOSUB 40
30 GOTO 60
40 REM stuff they later decided they wanted to use in several places
50 RETURN
60 REM some more program
70 GOSUB 40
80 REM rest of program
90 END
That's just pretty much how BASIC required code to be structured. That's not Microsoft Basic or whatever the language evolved into over the generations. That's BASIC as it was originally designed and popularized. That's what those pages of listings looked like as you typed them in to your TRS-80 or VIC-20 or whatever from your favourite magazine.

It's no more of a coding horror than Chaucer's Tales or Shakespeare's plays are an English literature horror. Of course, some sophomores may agree with that statement, but entirely for the opposite reason.
0

Share this post


Link to post
Share on other sites

I guess it was put here cause it was thought it should look like this:

10 REM early bit of code
20 GOSUB 1010
30 REM some more program
40 GOSUB 1010
50 REM rest of program
60 END
1010 REM stuff they later decided they wanted to use in several places
1020 RETURN

1

Share this post


Link to post
Share on other sites

I guess it was put here cause it was thought it should look like this:

10 REM early bit of code
20 GOSUB 1010
30 REM some more program
40 GOSUB 1010
50 REM rest of program
60 END
1010 REM stuff they later decided they wanted to use in several places
1020 RETURN
Very much that.

I was fortunate to learn programming using BBC Basic, which had procedures[1] and functions amongst many other things so finding that bit of MS BASIC[2] was a bit of a shock.

[1] I remember one program in a magazine having a delay procedure called PROCrastinate.
[2] MS BASIC might have evolved to have more modern features but didn't have them at that time.
0

Share this post


Link to post
Share on other sites

Any instructor who says "NEVER" use GOTO  may never have done much serious programming  (where they are very useful for abnormal exiting of complex subroutines,  and the horrors of number goto labels are long gone)


I've been programming for 20 years, professionally for 12, and I can say this is the first time in probably about six years that I've typed the four letter sequence "g o t o". When I did use goto, it was always preceded by "on error", because that's the exception handling idiom in VBScript - "On error goto label". I program at least 40 hours per week.
1

Share this post


Link to post
Share on other sites

 


Any instructor who says "NEVER" use GOTO  may never have done much serious programming  (where they are very useful for abnormal exiting of complex subroutines,  and the horrors of number goto labels are long gone)
That depends on the language -- error cleanup based around goto is idiomatic in C, but in most modern languages the idiomatic thing to do is to use throw instead.

I'd probably still teach a class to never use goto, but then also teach that C error cleanup idiom as being the exception to this rule, and as a look inside how exceptional stack unwinding might be implemented in C++ wink.png

 

I found Try and Catch to be about the same confuscation  in complex code  when a nice  well named goto label can make clear not only where the jump is going (I indent in a way labels stick out) but also (can) describe why.   I guess then its a matter of proper commenting for that anyway.    I recall good ole Pascal in a class where the instructor didnt want gotos and having bothersome condition checking at every nested layer of loops/blocks  to allow for the 'quick' exit.

 

I mention 'complex' code usually for this kind of issue because of the extra padding lines try/catch/finally  can add to an already  bulky/twisted  block of code (and rethrowing exceptions out thru  layers of calls...).

 

Systematic use of Gotos  as part of a state engine scheme is another place I have commonly uses goto labels  (where jumping upwards for retry situations  can happen alot)

Edited by wodinoneeye
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0