I know nothing of code. Let it not be so

To put it simply, I’d like to be able to look at lines of code without losing the will to live. The tutorials aren’t bad, but, as with all sites I’ve been to, it feels like it assumes I know what most of the lingo it uses means. I’m completely new to code and by that I mean I’m trying to enter a this building and don’t even know where the door is. You may say I’m maybe starting too complex by coming here to learn, and I won’t disagree there, yet I’ve even gone to sites that try to teach complete beginners, and I find myself with questions that… well, my monitor can’t exactly answer.

For example, a few questions I have:
-How do you guys remember what does what? Do you have a book full of commands you refer to?

  • What in the world does var mean?
  • Why are there {'s and }'s strewn about? What do those do?
    -The tutorials kept referencing to an “on()” but i could find no parentheses with an on before them.

You may have your face in your palms at this moment, wondering what on earth I’m doing in a place like this, but you now know at what point I’m at (and where I’m not at) in this process of learning. I’ve never been able to self teach myself something unless it’s very intuitive… and that’s where I’ve been falling short here. I have trouble learning something unless I know what I’m typing is actually doing. I tend to understand better when I’m asking a lot of questions, otherwise it drives me insane. I don’t want to give up on this either, though I’ve been close to due to frustration. Any help, or advice, or know of a site where I could learn from where I’m at?

P.S. If you’ve read all this I thank you for taking the time.

Making games is a great way to learn programming, but it is pretty daunting to start off. We do assume a certain level of understanding of javascript to use PlayCanvas.

You should check out this course: http://www.codecademy.com/en/tracks/javascript

It will teach you all the basics of programming and javascript and should answer most of your questions. Hopefully you’ll find it all easier to understand after that.

But to answer some of your questions:

var indicates that the following word is the name of a variable. e.g. var aNumber = 10;
Tells the program that there is a property called aNumber which I can use else where and it’s current value is 10.

Curly braces { and } indicate the start and end of blocks of code. Usually a function which is a re-useable section of code.

e.g. This function takes two values a and b and returns the result of adding them together.

function add (a, b) {
  return a + b;
}

A friend of mine is pretty much in the same situation like you. He is still at the very beginning, so I can’t tell you a receipt of how to learn JS but you’re very-very lucky to be here (at least I think so).

Main reasons for this are Dave and Will who are very friendly, patient and insanely talented professionals. I wish they’ll publish a book someday on how to make games with PlayCanvas… Community is helpful too!

Anyway, there are free JS books available. If you’re a cat (just like me), you may want to read this resource: JavaScript for Cats

1 Like

I’d love to write a book on making a game with PlayCanvas, if only there was more hours in the day…

4 Likes

I’d like to write a book on PlayCanvas as well. Of course it would be a little easier if it didn’t change faster than I could finish it :blush:

1 Like

I’ve never been able to self teach myself something unless it’s very intuitive… and that’s where I’ve been falling short here.

Computer programs do exactly what the programmer tells them to do. In some sense, that makes them ultra-intuitive. If you see in a program “6+7”, you know what the answer will be. Programming is more complex then that though, and you never stop learning. I started programming years ago, but I still find code I wrote last week “I did it that way? What an idiot I was, this way is much better”

The problem is that a huge amount of programming is language independent. You won’t find any language since the 80’s that don’t have functions:
python: def function_name(parameters)
C: return_type function function_name(parameter_type, parameter){}
etc.

And many ‘introductory’ books and tutorials forget that people new to programming don’t know what a function is. (Hint: think of a program as a recipe book, and a function is something like “Make a white sauce,” a small recipe used in other recipie’s).

Someone needs to write a “Generic Programming Guide” that teaches you all these concepts.

So here are a few genericisms:


Variables = A convenient way to store data so it can be used in multiple places. Example: num=10 sets the value of the variable “num” to 10. You can then do math such as other_num = num + 20. Not all variables are numbers. They can be strings and other more abstract things.

Function = Small programs that can be run multiple times with different sets of data. Think of an oven as a function called “bake” If we pop in some eggs and flour we may get out a cake. If we put in pasta and cheese, it may produce a lasagna.

Loop = A way to run a bit of code lots of times. A “For” loop runs the code for each element in a list. A “While” loop runs code until a certain condition is met (eg until a certain time).

List = A collection of variables in order. Like a numbered set of bullet points, the data stored in a list can be extracted using it’s number. To get the first item in a list in many languages: data = list[0]

Dictionary = A collection of variables stored by an ‘index,’ often a unique string. Just like a physical dictionary, you get the data when you look up it’s name. To get an item in a dictionary in many languages: data = dict[“index”]

Objects = Now this is an interesting one. Let’s say we want to represent a space ship in code. We can create a collection of variables, functions and wrap them all up into an “object.” Our spaceship may have an internal parameter called “fuel” and an internal function called “useEngines().” You can have multiple instances of these objects, and because the data is internal, they will be unique. Note that a string is an object. It stores it’s characters internal to itself, and in many languages has functions such as “string_instance”.split(’_’)

Instance = A single ‘copy’ of an object.

API = Application Programming Interface. The programmers bible for some other program. For instance playcanvas’ api tells anyone who knows how to use javascript how to use playcanvas. The Stellaris EKS-LM3S1968 (a microcontoller) also has an API. A lot of hardware has an API, and a lot of software has an API. It takes upwards of a month to become familiar with an API. This is the answer to your sample question. It’s our “book of commands we refer to,” and unless you’ve programmed the same program for a couple years, I guarantee you that you’ll need to refer to it.

Syntax = Every language has a syntax. It is the rules that say that: “In javascript an ‘if’ statement shall take the form if(LOGICAL_EXPRESSION){}” It specifies the layout of the () the {} and the ;
Every language has a different syntax.


There are of course a lot more generic programming concepts, but hopefully this gives you a little heads up.

A minor critique on the C function:

return_type function_name(parameter_type parameter) {
. . .
}

If you would like to javascript, youtube is a great place to learn the basics.