basicprogramming.org


Welcome, Guest. Please login or register.
Did you miss your activation email?
Forum time; Sep 02. 2010, 23:32
Home Help Search Calendar Login Register
News: The forum structure has been changed! Let us know what you think.

+  BASIC programming forum
|-+  BASIC programming
| |-+  General questions and discussions
| | |-+  A matter of opinion?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Reply Print
Author Topic: A matter of opinion?  (Read 403 times)
Jacob
Sr. Member
****
Offline Offline

Posts: 441


« on: Apr 28. 2009, 05:08 » Reply with quote

I've finally found some more time to put some more work into my own BASIC interpreter. And I came to wonder, for example in Yabasic, we have ":" to allow for multiple statements per line, and you're also allowed to write things like this:

Code:
if( 1 = 1 ) then print "wow, that's a surprise" fi

and

Code:
for i = 0 to 10 step 1 print "hello!" next i

and ":" allows you to do:

Code:
print "Hello: ";: print "you person";

These things, while they take up a small amount of space, makes code less readable(in my opinion), and I was wondering what your guys take on this is. Often BASIC is seen as an entry point to programming in general, and I was wondering if I should allow for things like this. Because in my opinion doing these things, while they makes code very small, they can make it a lot harder to read for someone new at the game.

So I'm simply wondering, what's your guys take on this? Personally I'm against it.
« Last Edit: Apr 28. 2009, 05:20 by Jacob » Report to moderator   Logged

"The truth is rarely pure and never simple."  - Oscar Wilde
Derek
Administrator
Hero Member
*****
Offline Offline

Posts: 1036



WWW
« Reply #1 on: Apr 28. 2009, 10:29 » Reply with quote

Hi,

in my opinion one statement per line is enough. Readability, no matter what the age or experience of the programmer, is the most important thing. When BASIC interpreters used line numbers and there was only a limited number of lines allowed there may have been a use for multistatement lines but that is no longer true.

Derek.
Report to moderator   Logged

wget http://*
aurelB
Hero Member
*****
Offline Offline

Posts: 769



WWW
« Reply #2 on: Apr 28. 2009, 11:02 » Reply with quote

I have only one command by line in Abasic.
Becose is developed on this way.
I dont have nothing against multiple statments by line
becose is sometimes use much less space.
Report to moderator   Logged

Jacob
Sr. Member
****
Offline Offline

Posts: 441


« Reply #3 on: Apr 28. 2009, 11:13 » Reply with quote

At AurelB:

That's also what I have at the moment, because it's simpler for me as a developer, but seeing as I've only ever really used one BASIC dialect(Yabasic), it would be interesting to know what more experienced BASIC programmers thought.

At Derek:

As I said, that's also what I was thinking, then it comes with the added bonus of removing just a tiny bit of work. Not that I'm lazy... Not at all  Cheesy

An added bonus question would be, how important is functions for manipulating strings? I mainly use Yabasic for small scale number crunching and graphics, so I don't really know how much use these things see.
Report to moderator   Logged

"The truth is rarely pure and never simple."  - Oscar Wilde
Garrett
Administrator
Full Member
*****
Offline Offline

Posts: 163


WWW
« Reply #4 on: Apr 28. 2009, 11:18 » Reply with quote

The only possible reason to break a line down is if it is just so long that it far exceeds the limits of the editor's view.  But even then, how hard is it to simply scroll out a bit to read your code for that long line?

Only once in my life did I wish I could break a line down in a language I used, but since the language didn't support such, I found myself optimizing that line of code until it was much shorter.  In the end, that line of code ended up being short enough to fit within the view of the editor.

So from my experience, I don't see the need for being able to break a line down into multiple lines.

Besides, any line that is that long can likely be broken down into seperate lines of code anyway.

In the end, it's not so much the amount of lines of code in a program, it's the amount of characters.  And adding just one more function to check for multiple single line code will only add to the bulk of the interpreter and slow things down a bit.

As for string manipulation, that's up to you.  What's the intent and goal of your interpreter?  Graphics?  Games?  Scientific?  Mathmatical?  User Interface and General?
« Last Edit: Apr 28. 2009, 11:20 by Garrett » Report to moderator   Logged

'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
aurelB
Hero Member
*****
Offline Offline

Posts: 769



WWW
« Reply #5 on: Apr 28. 2009, 11:19 » Reply with quote

functions for manipulating with strings is the main part of each
interpreter ,parser,lexer all that things operete with strings.
Variable call also work with strings becose you call variable by name not by
value.
Report to moderator   Logged

aurelB
Hero Member
*****
Offline Offline

Posts: 769



WWW
« Reply #6 on: Apr 28. 2009, 11:24 » Reply with quote

Jacob
If  i may ask you...
What kind of basic you prefer GUI - console or bouth?
And how will look your interpreter?
Report to moderator   Logged

Jacob
Sr. Member
****
Offline Offline

Posts: 441


« Reply #7 on: Apr 28. 2009, 11:37 » Reply with quote

Currently my plan is to implement it much like Yabasic, so you have a console, with the option for opening a window for graphics(But that's far out in the future, once I get things working).
Report to moderator   Logged

"The truth is rarely pure and never simple."  - Oscar Wilde
LanceGary
Hero Member
*****
Offline Offline

Posts: 704


« Reply #8 on: Apr 28. 2009, 13:50 » Reply with quote

I've finally found some more time to put some more work into my own BASIC interpreter. And I came to wonder, for example in Yabasic, we have ":" to allow for multiple statements per line, and you're also allowed to write things like this:

Code:
if( 1 = 1 ) then print "wow, that's a surprise" fi

and

Code:
for i = 0 to 10 step 1 print "hello!" next i

and ":" allows you to do:

Code:
print "Hello: ";: print "you person";

These things, while they take up a small amount of space, makes code less readable(in my opinion), and I was wondering what your guys take on this is. Often BASIC is seen as an entry point to programming in general, and I was wondering if I should allow for things like this. Because in my opinion doing these things, while they makes code very small, they can make it a lot harder to read for someone new at the game.

So I'm simply wondering, what's your guys take on this? Personally I'm against it.

In some early basics (GWBasic?) the If.. statement interacted with the ":" - so for example, if the If condition was true everything on the line containing the If got carried out (including additional statements separated by ":"), and if the If condition was false the interpreter would skip to a new line. So it may make a difference if you want to be able to read early code in your compiler/interpreter.

Lance
Report to moderator   Logged
E.K.Virtanen
Blah
Hero Member
*****
Offline Offline

Posts: 2517



WWW
« Reply #9 on: Apr 28. 2009, 16:56 » Reply with quote

Quote
if( 1 = 1 ) then print "wow, that's a surprise" fi

Works, but i dont like it that way.

Quote
for i = 0 to 10 step 1 print "hello!" next i

Works, but i like that even less. Statements should be seperated with somethin. I basic scene, : has generally been the marker. So that line should (imo) look like; for i = 0 to 10 step 1 : print "hello!" : next i

Quote
print "Hello: ";: print "you person";

That is valid line in my books. There is two statements (prints) seperated as should. ; at the end of statement, only tells to the basic interpreter that line is not changed after keyword PRINT.
Report to moderator   Logged

My website & my osBasic interpreter project.

-- My code reflects my faces...ugly as sh*t --
Jacob
Sr. Member
****
Offline Offline

Posts: 441


« Reply #10 on: Apr 28. 2009, 18:14 » Reply with quote

Thanks for all the useful input on this topic guys.

E.K. I agree that the last one would be a reasonable use of the ":", so I'll probably implement that particular feature for separating multiple statements, while leaving out the option of making overly complex statements constructed without the use of ":". That way the user will have the option, but be forced to do it explicitly... So they have to know what they're doing  Cheesy

LanceGary, thanks for the insight on earlier BASIC dialects, I didn't know those details. But I don't strive to make something that's fully compatible with older style BASICS, at most, it will be partially compatible with the style that Yabasic uses, with some changes.
Report to moderator   Logged

"The truth is rarely pure and never simple."  - Oscar Wilde
Pages: [1] Go Up Reply Print 
« previous next »
Jump to:  
Atom RDF RSS 0.91 RSS 2.0


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!