Answered by:
Couple questions about programming in general, and one specifically about turtle fractle?
Question

So I just got into programming about a week ago and so far its been... exhausting. I started out not knowing where to go at all. Then I read a couple of tutorials for "beginners" but their vocabulary was far beyond mine (yes English is my first language, im just not the smartest person in the world)
Anyway, after a couple of those, and being completely lost, I shamelessly looked up "programming for kids" and found small basic.
I read and copied all the exercises in the PDF "Intro to small basic. Can I ask something? Was I suppose to understand all of it? Because some of the things like fractals and arrays blew my mind completely. ALTHOUGH I DIDNT GIVE UP. I KEPT ON GOING JUST LIKE MY MOM USED TO TEACH ME.
I got to the end of the PDF to where it says "Fun samples" and I thought now would be a good time to start asking questions. So if you do answer my questions please phrase it like I am a child, because I think i may have borderline dyslexia (BUT THATS NOT GONNA STOP ME FROM TRYING!!)
My ultimate goal is to create games, which is why I am so determined to learn programming. But there is something I am concerned about and that is the math..... I have heard when progamming games there is a lot of math involved.. and math is 101% my worst subject :(
So is this true? Is there a lot of math involved? What do you recommend? Should I just forget about it now and spare time? because math is really hard for me, (to give you an idea of how much I know; im about at an 13 year olds mind level about math)
Ok enough blabbering and on to the program that has kept me up most the night: The Turtle Fractal program
I have already read this thread: http://social.msdn.microsoft.com/Forums/enUS/e071c124391e4d8ebd27336d8dc31722/helpunderstandingprogramflowoffractaltreeprogram
and I dont seem to understand much of what they said, haha
angle = 30
delta = 10
distance = 60
Turtle.Speed = 9
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.PenColor = "Green"
DrawTree()
Sub DrawTree
If (distance > 0) Then
Turtle.Move(distance)
Turtle.Turn(angle)
Stack.PushValue("distance", distance)
distance = distance  delta
DrawTree()
Turtle.Turn(angle * 2)
DrawTree()
Turtle.Turn(angle)
distance = Stack.PopValue("distance")
Turtle.Move(distance)
EndIf
EndSubOk, so what I dont understand is why the program doesnt end after the turtle moves back after the first 6 times he moves 30 degrees.
What I mean is why the program doesnt end after:
distance = Stack.PopValue("distance")
Turtle.Move(distance)
EndIf
EndSubOk well not sure if anyone is reading this but thanks in advance! :)
Answers

Programming is very mathematical in concept and appearance, but not necessarily in complex calculations. Even NASA engineers use computers and calculators to do the actual math. However, they DO understand the concepts of what they are working with.
From Algebra, you may recall:
X = 10
Y = 5
What does X + Y equal? Of course, 15.
What about X/Y ? It is 2.
And X * Y ? Why 50, of course.
Functions are another idea from mathematics. Recall F of X? That is F(X), where F is the name of the function and X is the value passed into the function F()
Programming is very similar. Variables may be single letters, whole words, or multiple words.
V = 1
MyVariableName = 2
Functions do things to the values passed into them.
Function DoubleMe(Value)
Return Value * 2
End Function
So DoubleMe(4) equals 8.
A subroutine may be thought of a function that does not return a value.
Both subroutines and functions may be used to group similar line of programming together.
A fractal is simply a design. Art. Something cool to look at.
If you think of your screen, or a window on a monitor as a grid of rows and columns with dots in it. Like a piece of graph paper, you can ask the “turtle” to walk from point A to point B. Recall from math, that a point is an X and Y coordinates? Think (x,y) = (column, row). So when you ask the turtle to move, or turn, it is leaving a trail of drawn pixels or dots in the process.
But your sample code gets fancy. It contains the function (or subroutine) DrawTree() that calls itself. That is called recursion. Google the definition of “recursive.” It simple means something that goes inside itself. Thinking about this too hard can make your brain hurt. But learning is work. And if the work doesn’t kill you, then it makes you stronger. Or in this case, smarter. Learning programming may actually make you better at math.
A Stack is a software place to save things and pull them off, later. It is like a Pez candy dispenser. When you PUSH a candy into the Pez dispenser, to get it out, you must POP it. Let’s pretend you PUSH three candies into the Stack (Pez dispenser), a red one, a blue one and a yellow one. You cannot get to the blue one, until you POP or remove the yellow one. Of course, the red one is buried deep, and you must POP two candies off the stack before you can get to the red one.
The Stack.PushValue simply saves the value of distance. The next line changes the UNSAVED value of distance and calls itself, again, with the new value. Further down, the original value is POPed off the stack and restored.
Don’t think about this too hard. It is like Time Travel and going back in time and killing yourself. It will make your brain hurt.
 Edited by Peter Schlosser Thursday, December 12, 2013 10:10 PM
 Proposed as answer by Nonki TakahashiModerator Wednesday, December 18, 2013 3:53 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:08 AM

Heyya FatRat27!
Even though programming involves math, generally it's just a subset of it. Only specialization areas such as fractals, physics, chemistry, etc., we'd really need a deeper knowledge!
The Turtle example above is very complex and uses a technique called recursive calling,in which a subroutine invokes itself again & again until it reaches its end condition in which it finally starts returning.
In that case we can see: If (distance > 0) Then. It means once distance becomes 0 or less, that whole block is skipped. Since all of the the recursive callings are there, it starts returning upwards!
Another technique used there is Stack.PushValue() + Stack.PopValue(). Small Basic doesn't have local variables. That trick pair is a way to overcome the lack of it!
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
 Proposed as answer by Nonki TakahashiModerator Wednesday, December 18, 2013 3:44 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:07 AM

Some programming can have quite a lot of maths, but most of the math for games is just geometry. However, what makes a good game is fun playing it and this skill is all about imaginative ideas  something like tetris is very addictive but not so complicated. The fractal example is quite advanced so don't let this put you off.
Small Basic was aimed at children, but actually a large number of people who use it are adults that are just interested in what programming is about.
I suggest:
 look at and work through the SB curriculum
 Some other introductory Technet articles Programming Tips, Event Basics, GraphicsWindow Basics, Array Basics, Stack Basics, Text Basics, Grammar Basics
 Solutions to monthly challenges and other posts on this forum  many questions and code snippets will help you
 look through the Additional Small Basic Resources and follow the links
 Have a go and ask questions
 Have fun  some of these may help, some not  people are all different so pick and choose what works.
EDIT
The page here has loads of Technet links including some of those above, but also many more Small Basic Portal
 Edited by litdevModerator Thursday, December 12, 2013 9:28 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:06 AM

Some comments:
1] Use TextWindow.ReadNumber() when the input has to be a number.
2] For each friend name entered you call the sub friends(), but only output if the current i >= input (i.e the last one.
Perhaps enter all the friends, then output them at the end.
TextWindow.Write("How many friends do you have? ") input = TextWindow.ReadNumber() For i = 1 To input TextWindow.Write("Enter the names of your friends: ") friends[i] = TextWindow.Read() EndFor friends() 'SUBROUTINES Sub friends TextWindow.Write("These are your holmes: ") For i = 1 To input TextWindow.Write(friends[i] + " ") EndFor TextWindow.WriteLine("") ' to start a new line EndSub
EDIT
Also it is good practice to use different names for variables and subroutines, don't use a variable friends and a subroutine called friends(). It works in SB, but not a good idea in general.
 Edited by litdevModerator Thursday, December 12, 2013 10:12 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:08 AM

Hello Fatrat
You mention that you started a week ago and have read the Intro to Small basic. That's very fast. Perhaps too fast which can lead to bad moral which primarily is caused from not being able to code what you want or a program not doing what you want it to. I suspect bad moral/frustration is the underlying cause of people giving up.
In litdevs post above there's links to the curriculum and other good learning resources. My tip is: download the curriculum and work through every chapter from start to finish. Take your time and be patient. When you get to an exercise or code sample, attempt it yourself and refer/check your code against the sample. Avoid skipping ahead if you don't understand something at 1st attempt. Perhaps take a break, come back to it and ask questions here.
Start small, read curriculum, practice (learn by doing), do some of the easier monthly challenges and you'll build your skill. Experience at coding is what you'll get with time and practice.
I've done a little bit of research into learning to be a good programmer here's an article all about learning to become a good programmer. Development Map for Becoming a Good Programmer Using Small Basic and MSDN
re math: I recently read a book called Coders at Work, it has biographies of some esteemed and very skillfull developers. Quite a few of them weren't very good at math, yet they were brilliant developers and had a hand in some of the big applications we use today. Besides a lot of the math is already done for us or you can always ask a Mathematician. I just joined a good math forum. So many resources.
A lot of people on this forum have been learning with sb for a year or 2 first then maybe pick another language after that. Takes 5 years to get any good at it. Same deal for most things, takes 5 years to become a plumber....
All the best, hope to see you round. Coding is very rewarding and satisfying. Fun. Don't let it ever frustrate you. There's always a reason why something doesn't work.
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:22 AM
All replies

Heyya FatRat27!
Even though programming involves math, generally it's just a subset of it. Only specialization areas such as fractals, physics, chemistry, etc., we'd really need a deeper knowledge!
The Turtle example above is very complex and uses a technique called recursive calling,in which a subroutine invokes itself again & again until it reaches its end condition in which it finally starts returning.
In that case we can see: If (distance > 0) Then. It means once distance becomes 0 or less, that whole block is skipped. Since all of the the recursive callings are there, it starts returning upwards!
Another technique used there is Stack.PushValue() + Stack.PopValue(). Small Basic doesn't have local variables. That trick pair is a way to overcome the lack of it!
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
 Proposed as answer by Nonki TakahashiModerator Wednesday, December 18, 2013 3:44 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:07 AM

But I want you to know that example got nothing to do w/ game development! I don't understand much that complex logic myself either!
You should begin w/ simple things like make a Shape moving w/ the arrow keys or something like that! :D
You should definetely take a look at this excellent article below:
And even though it's got nothing to do w/ SB, these beginner videos are so good & easy that you should watch them too:
We'll surely help you out if you post a troublesome code. Welcome aboard! :P
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
 Edited by GoToLoopEditor Thursday, December 12, 2013 2:20 PM

Yes maths is involved quite a lot but i was in the lowest maths at my school and started the computing courses at my school and i feel it's helped with my maths, So I recommend starting off with smallbasic and just work on your programming and maths.

Some programming can have quite a lot of maths, but most of the math for games is just geometry. However, what makes a good game is fun playing it and this skill is all about imaginative ideas  something like tetris is very addictive but not so complicated. The fractal example is quite advanced so don't let this put you off.
Small Basic was aimed at children, but actually a large number of people who use it are adults that are just interested in what programming is about.
I suggest:
 look at and work through the SB curriculum
 Some other introductory Technet articles Programming Tips, Event Basics, GraphicsWindow Basics, Array Basics, Stack Basics, Text Basics, Grammar Basics
 Solutions to monthly challenges and other posts on this forum  many questions and code snippets will help you
 look through the Additional Small Basic Resources and follow the links
 Have a go and ask questions
 Have fun  some of these may help, some not  people are all different so pick and choose what works.
EDIT
The page here has loads of Technet links including some of those above, but also many more Small Basic Portal
 Edited by litdevModerator Thursday, December 12, 2013 9:28 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:06 AM

Hey, thanks for your advice. I'm reading the SB curriculum right now.
I made this program, (it doesnt work they way i want it to) and I was wondering if you could help.
What I want it to do is:
Ask how many friends do you have
Asks the user to enter the names
Tells the users all the names of the friends they entered.
I know that is simple, but I can't figure it out. Below is how far I have gotten. Thanks!
TextWindow.Write("How many friends do you have? ")
input = TextWindow.Read()
For i = 1 To input
TextWindow.Write("Enter the names of your friends: ")
friends[i] = TextWindow.Read()
friends()
EndFor
Sub friends
If i >= input Then
TextWindow.Write("These are your holmes: " + friends[i])
EndIf
EndSub 
Some comments:
1] Use TextWindow.ReadNumber() when the input has to be a number.
2] For each friend name entered you call the sub friends(), but only output if the current i >= input (i.e the last one.
Perhaps enter all the friends, then output them at the end.
TextWindow.Write("How many friends do you have? ") input = TextWindow.ReadNumber() For i = 1 To input TextWindow.Write("Enter the names of your friends: ") friends[i] = TextWindow.Read() EndFor friends() 'SUBROUTINES Sub friends TextWindow.Write("These are your holmes: ") For i = 1 To input TextWindow.Write(friends[i] + " ") EndFor TextWindow.WriteLine("") ' to start a new line EndSub
EDIT
Also it is good practice to use different names for variables and subroutines, don't use a variable friends and a subroutine called friends(). It works in SB, but not a good idea in general.
 Edited by litdevModerator Thursday, December 12, 2013 10:12 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:08 AM

Programming is very mathematical in concept and appearance, but not necessarily in complex calculations. Even NASA engineers use computers and calculators to do the actual math. However, they DO understand the concepts of what they are working with.
From Algebra, you may recall:
X = 10
Y = 5
What does X + Y equal? Of course, 15.
What about X/Y ? It is 2.
And X * Y ? Why 50, of course.
Functions are another idea from mathematics. Recall F of X? That is F(X), where F is the name of the function and X is the value passed into the function F()
Programming is very similar. Variables may be single letters, whole words, or multiple words.
V = 1
MyVariableName = 2
Functions do things to the values passed into them.
Function DoubleMe(Value)
Return Value * 2
End Function
So DoubleMe(4) equals 8.
A subroutine may be thought of a function that does not return a value.
Both subroutines and functions may be used to group similar line of programming together.
A fractal is simply a design. Art. Something cool to look at.
If you think of your screen, or a window on a monitor as a grid of rows and columns with dots in it. Like a piece of graph paper, you can ask the “turtle” to walk from point A to point B. Recall from math, that a point is an X and Y coordinates? Think (x,y) = (column, row). So when you ask the turtle to move, or turn, it is leaving a trail of drawn pixels or dots in the process.
But your sample code gets fancy. It contains the function (or subroutine) DrawTree() that calls itself. That is called recursion. Google the definition of “recursive.” It simple means something that goes inside itself. Thinking about this too hard can make your brain hurt. But learning is work. And if the work doesn’t kill you, then it makes you stronger. Or in this case, smarter. Learning programming may actually make you better at math.
A Stack is a software place to save things and pull them off, later. It is like a Pez candy dispenser. When you PUSH a candy into the Pez dispenser, to get it out, you must POP it. Let’s pretend you PUSH three candies into the Stack (Pez dispenser), a red one, a blue one and a yellow one. You cannot get to the blue one, until you POP or remove the yellow one. Of course, the red one is buried deep, and you must POP two candies off the stack before you can get to the red one.
The Stack.PushValue simply saves the value of distance. The next line changes the UNSAVED value of distance and calls itself, again, with the new value. Further down, the original value is POPed off the stack and restored.
Don’t think about this too hard. It is like Time Travel and going back in time and killing yourself. It will make your brain hurt.
 Edited by Peter Schlosser Thursday, December 12, 2013 10:10 PM
 Proposed as answer by Nonki TakahashiModerator Wednesday, December 18, 2013 3:53 PM
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:08 AM

Yes! This is exactly what I wanted, thank you so much!
I tried adding some punctuation with commas and periods, tell me if I shouldve done this another way:
TextWindow.Write("How many friends do you have? ")
input = TextWindow.ReadNumber()
For i = 1 To input
TextWindow.Write("Enter the names of your friends: ")
friends[i] = TextWindow.Read()
EndFor
friends()
Sub friends
TextWindow.Write("These are your holmes: ")
For i = 1 To input  1
TextWindow.Write(friends[i] + ", ")
EndFor
TextWindow.WriteLine(friends[input] + ".")
EndSubIs that how you wouldve done it?
 Edited by FatRat27 Thursday, December 12, 2013 10:09 PM



Programming is very mathematical in concept and appearance, but not necessarily in complex calculations. Even NASA engineers use computers and calculators to do the actual math. However, they DO understand the concepts of what they are working with.
From Algebra, you may recall:
X = 10
Y = 5
What does X + Y equal? Of course, 15.
What about X/Y ? It is 2.
And X * Y ? Why 50, of course.
Functions are another idea from mathematics. Recall F of X? That is F(X), where F is the name of the function and X is the value passed into the function F()
Programming is very similar. Variables may be single letters, whole words, or multiple words.
V = 1
MyVariableName = 2
Functions do things to the values passed into them.
Function DoubleMe(Value)
Return Value * 2
End Function
So DoubleMe(4) equals 8.
A subroutine may be thought of a function that does not return a value.
Both subroutines and functions may be used to group similar line of programming together.
A fractal is simply a design. Art. Something cool to look at.
If you think of your screen, or a window on a monitor as a grid of rows and columns with dots in it. Like a piece of graph paper, you can ask the “turtle” to walk from point A to point B. Recall from math, that a point is an X and Y coordinates? Think (x,y) = (column, row). So when you ask the turtle to move, or turn, it is leaving a trail of drawn pixels or dots in the process.
But your sample code gets fancy. It contains the function (or subroutine) DrawTree() that calls itself. That is called recursion. Google the definition of “recursive.” It simple means something that goes inside itself. Thinking about this too hard can make your brain hurt. But learning is work. And if the work doesn’t kill you, then it makes you stronger. Or in this case, smarter. Learning programming may actually make you better at math.
A Stack is a software place to save things and pull them off, later. It is like a Pez candy dispenser. When you PUSH a candy into the Pez dispenser, to get it out, you must POP it. Let’s pretend you PUSH three candies into the Stack (Pez dispenser), a red one, a blue one and a yellow one. You cannot get to the blue one, until you POP or remove the yellow one. Of course, the red one is buried deep, and you must POP two candies off the stack before you can get to the red one.
The Stack.PushValue simply saves the value of distance. The next line changes the UNSAVED value of distance and calls itself, again, with the new value. Further down, the original value is POPed off the stack and restored.
Don’t think about this too hard. It is like Time Travel and going back in time and killing yourself. It will make your brain hurt.
Thanks for the kind advice!
That pez comparison REALLY helped me

This forum is the place to ask  there are plenty of helpful and knowledgeable coders ready to help pretty much round the clock on different time zones.
My advice for the best help is to work on the problem you have a bit first, narrow the question down to a short and concise code example and question (just like you did here). Ask separate questions on new threads as they are easier for others to follow.

Hello Fatrat
You mention that you started a week ago and have read the Intro to Small basic. That's very fast. Perhaps too fast which can lead to bad moral which primarily is caused from not being able to code what you want or a program not doing what you want it to. I suspect bad moral/frustration is the underlying cause of people giving up.
In litdevs post above there's links to the curriculum and other good learning resources. My tip is: download the curriculum and work through every chapter from start to finish. Take your time and be patient. When you get to an exercise or code sample, attempt it yourself and refer/check your code against the sample. Avoid skipping ahead if you don't understand something at 1st attempt. Perhaps take a break, come back to it and ask questions here.
Start small, read curriculum, practice (learn by doing), do some of the easier monthly challenges and you'll build your skill. Experience at coding is what you'll get with time and practice.
I've done a little bit of research into learning to be a good programmer here's an article all about learning to become a good programmer. Development Map for Becoming a Good Programmer Using Small Basic and MSDN
re math: I recently read a book called Coders at Work, it has biographies of some esteemed and very skillfull developers. Quite a few of them weren't very good at math, yet they were brilliant developers and had a hand in some of the big applications we use today. Besides a lot of the math is already done for us or you can always ask a Mathematician. I just joined a good math forum. So many resources.
A lot of people on this forum have been learning with sb for a year or 2 first then maybe pick another language after that. Takes 5 years to get any good at it. Same deal for most things, takes 5 years to become a plumber....
All the best, hope to see you round. Coding is very rewarding and satisfying. Fun. Don't let it ever frustrate you. There's always a reason why something doesn't work.
 Marked as answer by Nonki TakahashiModerator Monday, December 23, 2013 8:22 AM

Also you mention you looked at Arrays and it blew your mind. Of course. Would blow anyone's mind.
I looked at arrays after about 2 or 3 months and had a reasonable understanding of them after about 5 or 6.
We're all in the same boat. Takes time. A bit like rolling a snow ball. It just builds as it rolls.

re Math prerequisite.
I think everyone has a unique skill set grown upon a sea of dna in an unique environment.
I think programming (as well as all other things) can help develop unique skill sets and personal attributes. I liked the comment about creativity.
Some programs are reliant upon approximations as opposed to super accurate and complicated math.
I've been picking up a bit math as I go, also a bit of physics, some social science (UI), some art and also an open mind to the thoughts of others on how to code something.