Language?

Started by
5 comments, last by frob 6 years, 11 months ago

GameDev.net community,

I apologize for my lack of knowledge, but my expertise extends mostly into some sciences (biology, chemistry, physics, therefore excluding computer). I'm trying to get into the computer jargon, but I'm not sure how to start. I've read too much about the "languages," but I don't really know what a "language" is. Is anyone able to give me an example? What distinguishes languages from one another? How does one learn them if they've never even seen them before?

Thanks for the consideration and help.

Advertisement

No need to apologize, everybody started from zero one time.

Computers are very stupid devices; they are incredibly fast workers, but you have to tell them in very minute detail what to do. Their own primitive language is machine language, which is literally numbers in a specific order. If you want to know, have a look at eg the AMD64 instruction set, but really, don't bother at this time (and probably never).

Since we suck at putting large amounts of numbers in a specific order, we invented other languages that are closer to us. We also told our fast workers how to interpret what we write in those languages. So we can write recipes in such a language (such a recipe is called a 'program'), and by ordering a computer to do what the program says, we can 'execute' that program, the computer follows all instructions of the recipe one after the other, and that's it.

Usually, at some point in the program you tell the computer it should display a result. We interpret such output as result of the program, and if it is correct, we're happy, otherwise, we're sad, and need to look for an error in the program.

An example


a = 1
b = 2
print(a + b)

The first line "a = 1" says 'compute the numerical value of "1" (which is 1, of course), and attach a label called "a" to it'. The second line works similarly. The 3rd line says 'compute the numerical value of 'a + b' (as in, find labels 'a' and 'b', and add their values). Then find a small subroutine called 'print', and call it, with the computed sum'. Now 'print' is a standard function that displays the value that you give it onto the screen.

So it should be no surprise this program will print "3" to the screen.

The language I showed here is called "Python". It's freely available from python.org, and designed for ease of use. Maybe relevant to you, it's used a lot in science.

As you can see, Python is a long way from a large sequence of numbers. It has labels, infix computation that we are used to, and a thing called "print". Actually, it has a lot more that I didn't show. The computer knows how to execute that by another program called the "Python interpreter", which you can download from python.org.

Python is not the only language, there are zillions of them. Each one is expressing this "execution" idea from something close to us, to this large amount of numbers that happen deep inside the computer. Depending on the kind of problem that you have, different languages work better. For example, ancient language Fortran aimed at fast numerical computations, and it still is used for that purpose, even today, after 40 years or so. Java aimed at being a safe language (as in, it's quite hard to make mistakes in it). C and C++ aim at being fast, etc.

As usual, anything you aim for comes with a cost. Python is very high level, it takes a small amount of lines to express a program, but it's relatively slow. Java is safe, but it limits you in what you can express. C/C++ is fast, but complicated and unforgiving. So you pick a language that is strong in the area of what problem you aim to solve, and not too much getting in the way of costs.

While there are differences between languages, there are also a lot of similarities. Language designers (people making new languages) all peek at what the competition does, and borrow the good parts. That means that to a large degree, ideas you picked up in one language can be re-used, after adjusting them a bit to that new language. Picking and learning one language thus doesn't mean you have to start all over again in a new language.

I would recommend to stop reading, and start learning. Download a Python 3.6 or something, which contains the Python interpreter and a simple editor. I don't know what they have in terms of tutorials for beginners (I have been programming too long), but I am sure there exist many, likely python.org has a list of recommendations for that.

If you want to program games rather than do science, you could check our FAQ with pointers. There is also an article that describes some first steps:

https://www.gamedev.net/resources/_/technical/game-programming/your-first-step-to-game-development-starts-here-r2976

Happy coding!

Alberth,

You are AWESOME!!!! Thank you so much for the informative explanation, examples, and link(s) to help me further! I'll be sure to check out Python.org. I was looking at programming for games though, yes, so do you have any advice for how I should familiarize myself there? I'd still check out Python-- I mean, I'm still checking out Python as I post. :)

I was looking at programming for games though, yes, so do you have any advice for how I should familiarize myself there?
Read the FAQ, and read the article, one of the questions is "what programming language do you know or use", which you already have an answer to, other ideas are still relevant. Programming is not something you learn in a week, so even if the topics discussed there are not immediately useful, it's good to read it, for background information.

It's a large new world, it'll take time to settle :)

As for actual programming, first do the Python tutorial, at least up to statements and functions. Classes are useful too, if you can manage. Do the exercises. Nothing works better in learning than experiencing it yourself. Don't be afraid to extend an exercise if you see an opportunity, trying to make modifications is an important skill too. Then, try to make a game like the article suggests.

The reason why I suggest to first learn Python as language before trying to apply it for making a game, is because making a game is complicated, even something seemingly trivial like tic-tac-toe or hangman needs a lot of details to explain to a computer. By knowing Python at least somewhat before handling the complexity of a game program, you make it easier for yourself, you can focus on that one problem, instead of having to do both Python learning and game programming at the same time.

That said, don't worry, there are plenty of problems left that you will bump into. you will get into trouble so ask for pointers when you get stuck. Also, if you want feedback on something, ask.

As for actual programming, first do the Python tutorial, at least up to statements and functions. Classes are useful too, if you can manage. Do the exercises. Nothing works better in learning than experiencing it yourself. Don't be afraid to extend an exercise if you see an opportunity, trying to make modifications is an important skill too. Then, try to make a game like the article suggests.

Thank you so much, again! I've been reading everything, and I read mostly about Python. Is this the tutorial you're talking about, and by go up to statements and functions, do you mean where it says the glossary, etc below in the tutorial?
https://docs.python.org/3.6/tutorial/index.html

Why at least to statements and functions? Is everything past that "not important," not currently useful, not something to learn then but later on, etc?

docs.python.org tutorial isn't really intended for new programmers, it's aimed at people that can already program, and does a tour through the entire language in a few hours.

You likely need a lower pace,

https://wiki.python.org/moin/BeginnersGuide

in particular

https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

looks more like your kind of needs.

ie assuming you never programmed before :)

Why at least to statements and functions? Is everything past that "not important," not currently useful, not something to learn then but later on, etc?

It's more that less is not enough.

"a = 1" is a statement (control flow they call it in the tutorial you linked), and "print" is a function, although making your own functions is at least as useful as knowing how to use the standard existing ones.

Besides reading, do practice. When you read something it soon seems simple and easy, while if you actually have to do it, you'll find the easy things are less easy than expected. It's almost impossible to practice too little.

not currently useful, not something to learn then but later on

When you are a kid and learning how to glue paper together, you were probably told not to use too much glue because it makes the paper wrinkle. You likely didn't understand anything about how paper is bound together and how it stretches and breaks down when the glue wets it, all you needed to know was that it wrinkled with too much glue.

If you've ever grown plants from seeds, you were probably first told that you needed to keep the seeds damp because that's how they'll grow, not to let them drown with too much water or dry out completely. You probably didn't understand anything about the germination process, and probably didn't start to wonder about how seeds could grow under far less ideal conditions, but that didn't matter. All that matters is you follow the instructions and the seed grows.

When you first learn to program and are following tutorials, you will need to do things at first that you haven't been taught. After you learn more you will learn the details, but at that point it is more like the details above. You're still learning and eventually you'll learn the details. Just trust that the people teaching you are giving you enough to learn the basics first.

This topic is closed to new replies.

Advertisement