PDA

View Full Version : Where to start?



yobusta
August 11th, 2006, 18:05
I have been interested in learning some programming for a while now. Lua seems like a good start. My question is where do i start from? what do i need to learn? And how long will it take to learn?

ACID
August 11th, 2006, 18:32
Lua is a powerful light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. Lua is free software.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways. Extensible semantics is a distinguishing feature of Lua.

Lua is a language engine that you can embed into your application. This means that, besides syntax and semantics, Lua has an API that allows the application to exchange data with Lua programs and also to extend Lua with C functions. In this sense, Lua can be regarded as a language framework for building domain-specific languages.

Lua is implemented as a small library of C functions, written in ANSI C, and compiles unmodified in all known platforms. The implementation goals are simplicity, efficiency, portability, and low embedding cost. The result is a fast language engine with small footprint, making it ideal in embedded systems too.

http://www.lua.org/

Lua Tutorial

This tutorial is aimed at all newcomers to the language Lua. We start off with where to find relevant introductory material and then progress to using the language with tutorials in the TutorialDirectory. The style is directed at newcomers to scripting languages, as well as newcomers to Lua. Common uses of Lua are:


A configuration language for applications.
A standalone scripting language.
An embedded language in applications to modify runtime behaviour.
The tutorial tries to appeal to users of Lua on several levels:


Users who are relatively new to programming.
Experienced programmers who may not have used a scripting language before.
Programmers who may have used scripting languages, but not Lua.
Users of previous versions of Lua who want to learn about new features.
The style is simple, with lots of examples. It is hoped that from this straightforward approach that the information presented can be assimilated by all of the above users at their own pace. Since Lua is very versatile you may have to search a little to find what you want.

Note to programmers wanting to embed Lua: Please note that this tutorial is aimed at usage of the scripting language, rather than the C API for embedding. A tutorial for usage of the C API may be added at a later date.



About the wiki
This site you are reading is a wiki. It allows contributors to edit page content at will. It is built up from many different sources by a CastOfCharacters and anonymous sources, so you may notice some inconsistency in style. The site has a vague content structure starting at LuaDirectory. You can find help on how this wiki works in WikiHelp and more information on wikis in WikiFurtherReading.



About Lua
Lua is a powerful, lightweight scripting language. A more complete description is available at the official website [1]. If you haven't encountered Lua before, and you don't know anything about it, you may want to spend some time reading some of the articles on LuaOrgGuide. This will provide some background and insight into the nature of Lua. It is a useful source of inspiration, and may help you to use the language more fully.


Let's start

Running Lua
Please note that this tutorial assumes you are using Lua version 5. A lot of the content will work with version 4 but obviously not all. It is assumed that you will try the examples and experiment with Lua whilst learning it. You will therefore need an executable version of Lua.

There is a page for contributed LuaBinaries for various platforms. Should you prefer to compile Lua yourself, the source is available from the official site [2] and there are some notes and build packages on BuildingLua.

WebLua: If you are curious and would like to quickly try Lua without having to download anything you could try WebLua. Please note this uses Lua 4.0 and so will not be compatible with all of the tutorial. It is planned that this will be upgraded.


The tutorials
The tutorials are listed in the TutorialDirectory. It is suggested that you read them in the order from top to bottom. The topics increase in complexity as you progress down the page.



Notes on tutorial authoring style
The following are some notes about the style used to author the tutorial. If you are thinking of contributing to the tutorial then please read the following:


The tutorial aims to be accessible to all manner of programmers, as explained in the first section of this page. It is hoped this can be accomplished by explaining everything clearly in simple terms. Experienced users will read at great speed and beginners can digest the text more slowly; both can take advantage of the examples to clarify. It is thought that learning by example is the best form of learning.

Please keep all wording: expressive but concise, objective but polite, unambiguous, and always try to give examples using Lua.

Please try not to express an opinion or style of programming preference. Certainly do not start discussions about your thoughts in the tutorial. There are pages for SampleCode, personal pages off CastOfCharacters for personal comments, and a page for TutorialComments.

Terminology regarding scripting and Lua's implementation is primarily lead by the Lua Users Reference Manual [3]. Please try not to introduce unfamiliar terminology or terminology not applicable to Lua.

Try and keep the number of "buzz words" to a minimum. Where new words or important phrases have been introduced emphasis has been used.

Reference to other languages is restricted to C because it is the language of implemention of Lua. Please do not add references to the usage and implementation styles of other languages. All things are discussed in terms of Lua and C in the tutorial. This keeps the style nice and simple. There are plenty of other places on this wiki you can add this material and people can find it, e.g. LuaComparison.

http://lua-users.org/wiki/LuaTutorial

Good luck and hopefully we seee some work from you in the future.

jak66
August 11th, 2006, 20:31
yea...what Acid said, erm....lua scripting is a good start as its easier than c (not sure about python)
threr are a couple of lua tutorials at psp-programming.com and a few more at evilmana.com

ninja9393
August 11th, 2006, 20:33
www.evilmana.com has the most simple tutorials

jak66
August 11th, 2006, 20:36
also, if you do use lua, its worth noting that lua player 0.20 seems restrictive compaired to lua player 0.16

yaustar
August 11th, 2006, 21:11
I completely disagree with learning to program with Lua. It isn't the best language to start learning from as I have found out be helping other beginners in the past couple of months mainly due to the lack of documentation aimed at new programmers and the limitations of tools.

If you are seriously about learning to program then forget about the PSP altogether until you have actually learned to program on the PC.

The main three routes are:
1) Learn python with pygame [ http://www.pygame.org/news.html ] , tutorials for python can be found on the site. eg:
http://www.ibiblio.org/obp/thinkCSpy/ and
http://www.pygame.org/wiki/tutorials

Good article to read: http://www.gamedev.net/reference/articles/article2259.asp

After you are comfortable with making small apps and games in python, then moving on to C/C++/other language should be pretty easy. AFter a while you should be able to move onto specific platforms such as the PSP, GP2X, GBA, etc

2) Learn a simple procedural language to get the basics of logic. ie:

Learn the fundamentals first, these include:
- Variables
- Conditional Statements
- Loops
- Functions
- Return values
- Parameter passing

Languages good for this are Pascal and Basic. After you have the basics then moving on C/C++ won't be as daunting then before.

3) Go straight into C/C++ in which case I direct you to my old post:


Notice: The following text is based off my experience. What worked for me may not work for you or anyone else. Please bear that in mind.

If you are just starting out with C++, then completely forget about programming for the PSP for the moment. It will only add an extra layer of complexity that will stop you from learning the language and the main concepts of programming.

Learn the fundamentals first, these include:
- Variables
- Conditional Statements
- Loops
- Functions
- Return values
- Parameter passing

Gamedev have a C++ workshop that has been going for a while now that you still might be able to catch up. 'Thinking like a Computer scientist' is also considered a good free ebook but nothing will substitute a good 'real' book on paper. At this point, you be mostly working with text in a 'console' (ie command prompt).

Targets: simple applications such as a Line based text editor that reads and writes to a file, Tic Tac Toe, a Text Adventure (with a command parser), Hangman, etc.

Workshop: http://www.gamedev.net/community/forums/forum.asp?forum_id=76
Thinking like a computer Scientist (C++ version): http://www.andamooka.org/reader.pl?section=thinkcpp
C Plus Plus Site: http://www.cplusplus.com/doc/tutorial/

After this you can move onto more language specific areas such as the macros, pointers, references, const, header/source organisation. Also you can start looking at graphical libraries such as SDL and OpenGL, both of which are cross platform and work on the PSP. This means that you can work on the PC and with some minor changes to the code, recompile and it should work on the PSP as well.

Targets: Graphical games such as Tetris, Breakout, snake, Mario clone, a small FPS level.

Thinking In C++ Vol 1: http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
SDL tutorials: http://lazyfooproductions.com/SDL_tutorials/index.php
OpenGL tutorials: http://nehe.gamedev.net/

Finally, you can jump into Object Orientation programming and the finer areas of the language (although you can do this at any point really). Thinking in C++ Vol 2 is probably the best free ebook in this area.

Targets: Anything you want, think big and go for it.

http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

Working on games? At the bottom line, there is little difference in approach to designing a Word Processor and a Game. They both require careful thought and preparation before starting otherwise you end up with very hacky and messy code base which will hinder your project's progress. At present, some of the Lua projects going on here (no offence to anyone, I know you guys are still learning) are falling in that trap, I myself have done so several times in the past as well. However, there several areas that will help you greatly in designing and building a game. One of them is Finite State Machines (FSM). This has been used for the game's structure, AI, item behaviour etc. The other skill is Abstraction which you will pick up with experience. It is basically taking an object and form it in code, from 'base' componments. Eg:

What is a bullet? It has an position in space (X, Y ,Z value), graphical representation and a velocity.

Some other bits and pieces of information:
Keep up your math skills at a good level, especially areas such as Trigonometry, Algebra and Vector math. They are invaluable in programming especially game programmming. Later on, you will need to have some knowledge of matrix math when dealing with 3D scenes.

Here are some FAQs for the C++ language, Matrix math and vectors although you wont need them for a while yet:

C++ FAQ lite: http://www.parashift.com/c++-faq-lite/
Matrix Math FAQ: http://www.gamedev.net/reference/articles/article1691.asp
Vector Math FAQ: http://www.j3d.org/matrix_faq/vectfaq_latest.html

Learn the Standard Template Library (STL) or/and Boost. They have a number of template classes that are extremely useful such as vectors, lists and smart pointers. Abuse them.

Here are a list of good books to read although they will be at an advance level so keep the list as future reference:
Code Complete
Rapid Development
Pragmatic Programmer
Game Coding Complete (Fantastic book, MUST READ)
Effective C++
Design Patterns: Elements Of Reusable Object Orientated Software

There is a ton more information that I can pass on but I think this should keep you going for a while and you will pick up the rest as you go along.

Route 1 is longer but has a much more even learning curve. Route 3 *can* be shorter but the learning curve is steeper. Route 2 was the one I took, you don't see results happening as fast as Route 1 but the learning curve isn't as steep as route 3 and you can dive into C/C++ quicker then route 1.

As for how long to become a decent programmer and actually know fully what you are doing. Months, most likely years.

The language doesn't nearly matters as much as the programming concepts that you pick up and learn along the way. I have more books based on concepts and theory then I do on language syntax.