• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Trying to learn programming.

AgeGap

Master Poster
Joined
Jul 11, 2007
Messages
2,447
I have Ubuntu on my computer and would like to learn simple programming.
Python seems an obvious choice. It is already to use, and I have done the Print "hello" thing. I have looked at a few online tutorials but seem to get stuck after a fairly short time. Could anyone recommend a good book or other resources for me to use. Also a list of commands (not on Wikipedia, what's going on there?) and information on stuff like the use of the colon.
Feel free to say that Python is not a good place to start.
Only other programming I have done is on a BBC and Spectrum. (BASIC)
Not a clue about indenting, saving etc, etc, etc.
 
I am just a high school educated fellow that picked up programming a few years back, and I actually did begin with Python on a Linux partition that I set up on my C drive.

The best thing that you can do in my opinion is make simple math programs to start off. There was some website that I used called mathschallenge or mathchallenge .net that gave you hard problems that only an algo can solve. Just make programs that execute in the command prompt based on user input.

In terms of education resources, I am not the type of person that can learn from those tutorials. I have tried them with every language I pick up, but nothing works for me like just staring down an online reference and learning by using the operators and objects that are presented within.

If you don't mind using windows, the "express" installations of VB/C#/C++ are really really nice integrated development environments, and I do wish I had started with one of them.
 
Python is good for introductory programming.

It is nice because you don't have to deal with the extra wordiness of declaring your variables.
 
Python is good for introductory programming.

It is nice because you don't have to deal with the extra wordiness of declaring your variables.

Having used Python first, one thing that I had it in my head that I was going to do, was make these great graphical interfaces and whatnot, with buttons and input windows ect. While this is possible and not even troublesome later on when you become more advanced and download the components of your own little python IDE, at first it is just simply impossible.

I was shocked when I started working on my new game in C# and there was a dynamic error spotting window that updates as I code, full debugging support, and so on and on and on... Perhaps though for someone totally new, having all those trimmings may teach them to be sloppy. I reccomend at least trying out one of the express editions at some point, they are totally free and fully supported with huge online references and lots of examples.
 
Software development is, in many ways, much like many other creative fields e.g. the construction industry

If your aim is to simply knock together a kit-set garden shed, then you only need a few materials and simple tool box... although, if you only have a hammer, everything starts to look like a nail...

If your aim is to build a multi-purpose high-rise that will last for centuries, you need detailed plans of the whole environment

Writing good software (that really works, i.e. does seemingly complicated stuff simply, on any/all platforms - e.g Windoze, Linux, Nokia, etc - is easy to extend and maintain) requires detailed analysis, design and testing

I strongly recommend that, after your first fortnight or so of dabbling, you reappraise what 'level' you really want to attain

There's nothing wrong with wanting to hammer out some quick-and-dirty code... it can be fun, and as long as y'ain't coding a (literally) vital application, no-one will get hurt :)

However, if you want to be 'an architect' (as per the construction industry analogy), you'll need to learn the fundamentals of data/information management, the principles of human/computer 'interfacing', the ethical and legal issues pertaining to privacy, etc, etc, almost ad infinitum ... Of course, the learning curve is much steeper... but the rewards can be worth it
 
Last edited:
Thanks everyone. I am not planning to attempt anything ground breaking. Just want to play around. When I run into particular problems I will then beg for help. Thanks.:)
 
I have Ubuntu on my computer and would like to learn simple programming.
Python seems an obvious choice. It is already to use, and I have done the Print "hello" thing. I have looked at a few online tutorials but seem to get stuck after a fairly short time. Could anyone recommend a good book or other resources for me to use. Also a list of commands (not on Wikipedia, what's going on there?) and information on stuff like the use of the colon.
Feel free to say that Python is not a good place to start.
Only other programming I have done is on a BBC and Spectrum. (BASIC)
Not a clue about indenting, saving etc, etc, etc.

In general, though, I personally believe that duck typing and dynamically typed variables teaches newbie programmers how to write enthusiastically bad code. I actually recommend C# or Java, not because they're better languages, but because they have extremely good interactive debugging, C# Express and Netbeans are remarkably powerful and completely free IDEs, and statically typed languages make it hard to write incorrect code.

However, Python is a neat little language, its a reasonably good learners language; it also has lots of advanced features like generators and passing functions around as first-order values that experienced programmers can appreciate. If you need a good book, I recommend Python Power because its extremely accessible to beginning programmers.


Even though you didn't ask for it, I'll share a little programming wisdom:

You can learn just about any language in a month, but it takes about 10 years to actually learn how to write software (or you might squeak by with 7 or 8 years if you're really good). I cannot stress this enough: learning the syntax of a language does not teach you how to write software. Yes, part of a programmers job is to churn out sourcecode in some language or another, but learning how to write software is primarily concerned with the best way to organize interacting systems of code and correctly solve common software design problems. You only learn how to design correct software by writing code each and everyday.

Once you get passed the initial learning curve that comes with reading code, indenting, learning where to place commas and semicolons, etc, writing code is easy. You'll be able to churn out syntactically correct code automatically without even thinking about it; at that point, you'll start thinking about code from the point of view of a high-level strategy to solve general problems.

Unlike learning the syntax of a new language, you only need to master correct software design once; after that, you can carry the same high-level principles to any new language you want to learn in the future.

[/two cents]
 
Last edited:
May I ask why you want to program?

That, to me, vastly changes the answer.

If you are looking to do a specific project which requires knowledge you don't have, learning a language most appropriate to the project or even using more user-level software tools may be a better idea than if you were looking to learn programming for professional reasons.
 
You only learn how to design correct software by writing code each and everyday.
I disagree... not about the amount of time required... more about how that time needs to be spent

In complex environments, 'correct software systems developments' have to accommodate (often seemingly incompatible) stakeholder wants and needs that are not only diverse (e.g legal, ethical, cultural, privacy issues, time/money, accessibility/platform/media etc etc) but also subject to change over time

You won't learn that sorta stuff simply by writing code; hence the wide variety of (often hybridised) methodologies that have been/continue to be devised and refined over the years

Saying all that, after a quick skim of Teach Yourself Programming in Ten Years, I do agree that its absurd to think you can, in 21 days, learn a programming language... I have a hunch that it takes at least that long just to get your head around arrays, linked lists, array lists and hash tables/maps/trees
 
Again thanks. I bought a magazine called Linux Format. In the mag it walks you through getting a simplified space invader type game up and running. Basically that is the type of thing I want to do.
I am currently working through Python Tutorial-Guido van Rossum.
I just want to get my "head around arrays, linked lists, array lists and hash tables/maps/trees".:)
 
Thanks for the links. I am still trying to get through the tutorial.
It does seem to be a good tutorial and when I get stuck or hit a definition I don't get I can take a detour to Wikipedia.
 
I can take a detour to Wikipedia.
Whilst you're there, you might like what's on offer at http://en.wikipedia.org/wiki/Structured_English

Structured English is the marriage of English language with the syntax of structured programming. Thus structured English aims at getting the benefits of both the programming logic and natural language. Program logic helps to attain precision while natural language helps in getting the convenience of spoken languages.
 
What Princess said.

I'm 55 and have been programming since 1969 (when I first learned Algol-60 and Fortran-IV simultaneously at school - Scotland was very quick to embrace computing as an academic subject).

ETA: good luck Awesome Princess with your "project" - just had a look at your website.
 
Last edited:
I have often noticed that what seems to be well written, effective software is accompanied by explanatory notes and help files which are so full of factual and grammatical errors as to be more confusing than helpful.
This may be because English was not the programmers' preferred language, but I suspect it often reflects a lack of attention to and a lack of interest in a "normal" language
 
Again thanks. I bought a magazine called Linux Format. In the mag it walks you through getting a simplified space invader type game up and running. Basically that is the type of thing I want to do.
I am currently working through Python Tutorial-Guido van Rossum.
I just want to get my "head around arrays, linked lists, array lists and hash tables/maps/trees".:)

Its not really hard once to understand once you have your head in the right place. Heres a 5 minute Python lesson on the fundamentals:

Variables: a variable is just a clob of data, and the entire state of your program is held and manipulated through variables. If you have IDLE available, type the following:
x = 1[enter]
y = 2[enter]
z = x + y[enter]
z[enter]

IDLE will output something like this:

Code:
>>> x = 1
>>> y = 2
>>> z = x + y
>>> print z
3

x, y, and z are variables. Once you type the line "x = 1", it creates a variable called 'x'.

Once you create a variable, you can do things with it:

Code:
>>> name = "Princess"
>>> if name == "Princess":
	print "Hi, Princess"
else:
	print "You're not princess"

Arrays: arrays are just collections of related data. For example, how would represent the months of the year? I could do this:
Code:
>>> month1 = "Jan"
>>> month2 = "Feb"
>>> month3 = "Mar"
>>> #if you write code like this, you'll lose your job

That's a really awful way to write code, it becomes a maintenace nightmare. Its better to use an array:

Code:
>>> months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
	'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
Once you have an array, you can access each element of the array by its position in the array (or index), starting at 0.

Code:
>>> months[0]
'Jan'
>>> months[0]
'Jan'
>>> months[5]
'Jun'
>>> months[11]
'Dec'
>>> months[12]

Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    months[12]
IndexError: list index out of range
You access elements in the array using a pair of brackets. Notice, if you try to access an element that doesn't exist, you get an error as shown above.

Arrays are nice, because you can have arrays of arrays (multidimensional arrays) like this:
Code:
>>> board = [['x','o',' '],
      ['x','o','x'],
      ['o',' ','x']]

You access multidimensional arrays just like any other kind of array:
Code:
>>> board[2]
['o', ' ', 'x']
>>> board[2][2]
'x'
The code 'board[2]' returned the third element from the array, which just so happened to give me back another array.

The code 'board[2][2]' actually performs two operations at once. The code in red retrieves an array, and the code in blue access an element from that array. Effectively, it retrieves the third row, third element in the 3x3 array.

You can mix arrays and variables if you like:
Code:
>>> thirdrow = board[2]
>>> print thirdrow[2]
'x'
>>> impossibleBoard = [thirdrow, thirdrow, thirdrow]
>>> print impossibleBoard
[['o', ' ', 'x'], ['o', ' ', 'x'], ['o', ' ', 'x']]


Linked lists: linked lists are kinda like arrays, except you can't access elements in the list by index. This might sound like a limitation, but linked lists have the advantage of allowing users to insert and delete items from the list in O(1) time; inserts and deletes in an array take O(n) time, where n is the length of the list.

Arrays are useful when the size of your data is of fixed size or requires random access to the data. Linked lists are useful when you need to perform lots of inserts or deletes, and you don't need random access. When you start developing your programming skills a little more, you'll learn about two special types of linked lists called stacks and queues.

Unlike other languages like C# and Java, Python makes no distinction between linked lists and arrays. You use the same bracket syntax for making both:
Code:
>>> orders = []
>>> orders.append("pen")
>>> orders.append("paper")
>>> orders.append("mouse")
>>> print orders
['pen', 'paper', 'mouse']
>>> print orders[2]
mouse
>>> orders.sort()
>>> print orders
['mouse', 'paper', 'pen']
>>> orders.pop()
'pen'
>>> print orders
['mouse', 'paper']

As you can see, the 'append' and 'sort' methods do what they look like they do.

The pop() method isn't obvious to newbies: the function returns the last element in a list, then removes that element from the list. Most newbies are confused by this, because they can't imagine why anyone would ever need a function which does that; you'll be surprised just how often it comes up (appending and popping elements from lists is the basic function of a stack).

Hashtables - a hashtable maps keys to values.
Code:
>>> countriesByUser = {"Princess": "USA", "Powa": "Slovenia", "CFLarsen": "Denmark"}
>>> countriesByUser["Princess"]
'USA'
Hashtables are nice because they have O(1) lookup time. However, you don't have indexed access to elements in a dictionary like you have in an array. Indexed access is useful because of the way that most hashtables are implemented: the order of items in a dictionary is, for all intents and purposes, random.

If the order of your data isn't important and you can conveniently access by key, then a hashtable is a good way to store your data.



Now you're a professional Python programmer.
 
Last edited:
Thanks Princess. Very kind of you to take the time out to do that last post.
This Python thing is harder than I thought it was going to be. I thought by now I would have brought the internet crashing down and be holding several major governments to ransom. It is a lot more involved than BASIC on the old spectrums.
#if you write code like this, you'll lose your job
:) My job has nothing to do with computers. Guess I will be safe.
 

Back
Top Bottom