I am new 2 FreeBasic.

New to FreeBASIC? Post your questions here.
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

especially if you compress your files into .zip or .rar, those space and tabes essentially 'don't even exist'
2
Posts: 75
Joined: Mar 28, 2006 21:01

Maybe

Post by 2 »

If 50% of people actually cared about reading my code,I might
change it.The way I see it is that really programmers can read any
kind of code.I'm not a real programmer though.Been playing around
with stuff.I rarely do anything besides loops and basic math functions.
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

what you need to do is think for a second. you're now coming to a forum filled with programmers devoted to fb.
I'm not a real programmer though.Been playing around
with stuff.I rarely do anything besides loops and basic math functions.
yeah ... we are real programmers. and we are telling you, that kind of stuff is the absolute fundamentals of good programming.

thinking "good programmers can read any code" is like saying "good maids can clean anything, so i'm gonna $%#@ on my kitchen floor"
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

If you care about speed and accuracy. . .Care about it for all of us :D

If you show your code to others, make sure it's readable. Proper Coding "Grammar" is important for you to be able to understand your own code, and for other people to read it.
tunginobi
Posts: 655
Joined: Jan 10, 2006 0:44
Contact:

Re: Maybe

Post by tunginobi »

2 wrote:If 50% of people actually cared about reading my code,I might
change it.The way I see it is that really programmers can read any
kind of code.I'm not a real programmer though.Been playing around
with stuff.I rarely do anything besides loops and basic math functions.
Oh, we care, otherwise we wouldn't be replying.

And we can almost read any kind of code, but if I saw a dev team member give me this sort of code as source for a bigger project, I'd skin them. Alive.

You said yourself that you compress your source files with ZIP? Well, ZIP, like virtually all other compression formats, is designed to reduce redundancy in your files. In plain English, it removes repeated stuff. Putting in spaces and/or tabs in your source, once compressed, won't even make a scratch in the size of your archive, especially if it's ZIP.

Besides, programming tersely (i.e. small) went out of fashion in the 1980s. Your computer isn't sitting on your lap with a 15 x 5 LCD staring back up at you from the keyboard anymore. Your monitor isn't emitting the phosphorus green glow signifying the yesteryears of the computing age.

The technology has grown. Now's as good a time as any to grow with it.
2
Posts: 75
Joined: Mar 28, 2006 21:01

Well,OK,maybe.

Post by 2 »

When that guy said

>thinking "good programmers can read any code" is like saying "good >maids can clean anything, so i'm gonna $%#@ on my kitchen floor"

I wouldn't go quite that far.I might include comments sometimes,but
seriously,is it really THAT hard 2 read? You can see where the end
of a FOR loop is cause you see NEXT.You know when an IF statement
ends cause you see END IF.The programs I post recently are actually
the biggest I do.These programs wouldn't be neccessary if FreeBasic
automatically had arbitrary precision.I ONLY use FreeBasic because
it can compile.Compiling is something that a lot of the Basic languages
don't have.Remember that site where you can download the powers
of 2? ALL those files were made with FreeBasic.
Except the negative exponents.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

It's hard to find a next when it's clutterred with a bunch of other code on the same column...But I kind of get what you're saying.

If you plan to actually get serious in coding, start good habbits now. Whether it's a small program or a large one, do it.

If you don't plan to ever get serious with coding, at least do the proper indentations before you show it to others.
2
Posts: 75
Joined: Mar 28, 2006 21:01

Well,that's a bit hard.

Post by 2 »

I don't exactly know what is easier 2 read.When code has indents in it,
it actually makes it harder 4 me 2 read! I am VERY weird.I don't
like the things that most people do.Did you know I think black and white
are the most beautiful colors? I also am not attracted 2 girls like most
guys.If I think something makes something easier 2 read,I'll do it.
This is pretty easy 2 read.

Code: Select all

print "This program will print prime numbers up 2 the number you want."
print "Enter a number."
DIM AS ULONGINT a,b,c
input c
cls
print "2"
for a=3 to c step 2
p=0
for b=3 to sqr(a)
if a mod b=0 then
p=1
exit for
end if
next
if p=0 then
print a
end if
next
sleep
This is what I call hard!

Code: Select all

print "This program will print prime numbers up 2 the number you want.":print "Enter a number.":DIM AS ULONGINT a,b,c:input c:cls
print "2":for a=3 to c step 2:p=0:for b=3 to sqr(a):if a mod b=0 then:p=1:exit for:end if:next
if p=0 then:print a:end if:next:sleep
hippy
Posts: 84
Joined: Nov 04, 2005 18:13
Location: UK

Re: Well,that's a bit hard.

Post by hippy »

2 wrote:I am VERY weird ... This is pretty easy 2 read.
Not for me it isn't - well 'reading' may be easy, but understanding what is written or meant isn't.

You are free to be as weird as you want, you can choose to reject all and any conventions others may have or require, but, if you ever come to seek help or advice from others on your programs you are reducing the chance of anyone giving help if you reject the conventions they are expecting.
tunginobi
Posts: 655
Joined: Jan 10, 2006 0:44
Contact:

Re: Well,that's a bit hard.

Post by tunginobi »

2 wrote:This is what I call hard!

Code: Select all

print "This program will print prime numbers up 2 the number you want.":print "Enter a number.":DIM AS ULONGINT a,b,c:input c:cls
print "2":for a=3 to c step 2:p=0:for b=3 to sqr(a):if a mod b=0 then:p=1:exit for:end if:next
if p=0 then:print a:end if:next:sleep
Well, if it makes you feel any better, I call that hard to read as well. :)
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

i timed it, it took me 59 seconds to make that code clean. would taken no time if i just coded it originally in that form.

Code: Select all

Dim As uLongInt a,b,c 

Print "This program will print prime numbers up 2 the number you want." 
Print "Enter a number." 

Input c 

Cls 

Print "2" 

For a = 3 To c Step 2 

  p = 0 

  For b = 3 To Sqr( a ) 

    If a Mod b = 0 Then 
      p=1 
      Exit For 

    End If 

  Next 

  If p = 0 Then 
    Print a 

  End If 

Next 

Sleep
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

Yeah but Cha0s, you put spaces in between every line :D - Is that necessary for those not turning in code reports to their professors?
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

lala...
2
Posts: 75
Joined: Mar 28, 2006 21:01

Well,I'm not against learning.

Post by 2 »

The real reason I can understand my code is because I wrote it!
If somebody else makes their own program,I might need time
2 figure it out.If only I could see what my code looks like from
somebody else's view.Have you ever wondered if people see the
same colors as you do?
thegrogen
Posts: 118
Joined: Mar 15, 2006 3:39
Contact:

Post by thegrogen »

I have wondered that... It's an interesting question.

Anyhow, you should check into some other programming languages. A good programmer is always flexible, remember! I would recommend checking out something other than a BASIC dialect, just to learn something new.

Here's a bit of C++ for you to chew on:

Code: Select all

int Parser::LineStartPhrase(std::string phrase) 
{
	char token;
	std::string final;
	do
	{
		token = currentfile.get();
		if (token != ':')
            final+=token;
        else
            break;
	} while (token != ':');

    
	if (phrase == final)
        return 1;
        
	return 0;
}
That's a bit of code I'm actually using in my current project... It's part of my config file parser.

edit: By the way, if you use Dev-C++, how do you not know how to use SUBs and FUNCTIONS? A SUB is just like a void function in C, and a FUNCTION is the same as a normal function in C.
Post Reply