How do I start to learn programming?

  • Thread starter GreatEscapist
  • Start date
  • Tags
    Programming
In summary, I think you should start with a basic computer programming book, like Kernighan and Ritchie, and then move on to more in-depth books as you get more comfortable with programming.
  • #1
GreatEscapist
180
0
My high school does not offer computer programming, because we are a, ah, *small* high school.
But I want to learn how to do it. I really want to go into programming, or CE.
I read bits and pieces, learn a bit here and there, but I really want to actually learn how. So, where do I actually start? Where's a good place to start? I don't know if I would know it already or not, but can you give me some ideas?
 
Technology news on Phys.org
  • #2
You could pick up an introductory book on Java, C, C++, Python or whatever other language you prefer (I recommend C++, but I'm biased because that's what I use for most of my research). I'm sure someone here can recommend you some good books.

I learned most of my programming skills through trial and error, and through online tutorials. For C++, you could try http://www.cplusplus.com/doc/tutorial/", or just google "<language> tutorial", and you should find a few results.

Whatever approach you follow, if you have any questions, you can always come back here and someone will be glad to help you.
 
Last edited by a moderator:
  • #3
if you want to learn C then i recommend "kernighan and ritchie" a fantastic book. C is used mainly by the "sciences" it is excellent for calculations ( root finding of functions, matrices, you name it), so it depends what you are looking to do with programming
 
  • #4
Awesome. Thanks. :)
 
  • #5
Take a summer course (or two) at a local Community College.
 
  • #6
K&R is more of a C language definition book than a learn how to program book. What you'd proably want instead is a "primer" for C. Better still would be a training book that starts off a minimalist C program, then goes through a series of programs, each one a bit more advanced and teaching one new aspect of programming at a time. You might consider an assembly primer as well.
 
  • #7
Well that didn't make a whole lot of sense.
But I do think that starting with the how/why programming works with computers is a better way to go.
But after that, I shouldn't learn C first? I always thought that's where everyone started. (Minus HTML and java. Everyone knows that.)
 
  • #8
I would recommend C or C++ for the exact reasons that Kajahtava is campaigning against them: In order to program well, you have to learn about how the computer works. Ask lots of questions on the forum here: if you see a couple of ways of doing something, try to find out which is better for your particular problem and why.

If you're making a conscious effort to learn, as opposed to simply "getting the job done", you'll come out of learning C or C++ as a better programmer, with a better understanding of computers.

In a lot of other languages you can learn to program "well" without ever learning anything about how the computer works or why you should do things a certain way. Your programs will be slower too. For research applications it's important that my code be as fast as possible. While you're writing simple programs, a factor of 2 in performance is nothing. You'll never care if you computer takes 5 milliseconds to run instead of 10 milliseconds. But if you're ever doing complex numerical calculations (I had some programs running for weeks on a super-computer last year to calculate some results) then even a small fractional improvement in performance can be significant, meaning you take 1 week, instead of 2 to get results.
 
  • #9
Kajahtava said:
Also, FORTRAN is also a candidate here.

I would have recommended it if it weren't obsolete and hardly ever used anymore, except for a few aging academics.

I had to learn some FORTRAN to make some of my advisor's old code work with my C++.
 
  • #10
:frown:
Now I'm just friggin confused. But it was my fault for not being specific in my OP.
Okay. Well, I have somewhat of a grasp on Java, and I can do DOS. (Hey...I have a real old computer. :wink:)
I eventually want to end up in game design (God, don't tell my mom I want to work on video games...) but I know that I would have to do regular programming first. So, what's good for ending up in games?
And I do want to know how everything works. I'm one of those annoying kids that high school teachers hate because i want to know exactly HOW stuff works. Not why. (That's why I love physics.) So I'm definitely going to pick up a few books on computers anyway. I know ideas of how stuff works, but not a great one.
And hey, now, I'm a pretty damn smart high school kid. :P
 
Last edited:
  • #11
Maybe I can make a suggestion that we can all agree on?

NOT Visual Basic!
 
  • #12
Sounds like I'm going to make a trip to Barnes and Noble today...
 
  • #13
Kajahtava said:
C# is completely useless outside the Common Langauge Infrastructure.

It's essentially a version of Java that is catered towards the CLI and made very type safe. No one designs games on C# and both BSD and the FSF take an active stance against using C# as they fear it's a ploy from Microsoft to make people dependent on a lighter version of Java they have some control over, though it's an ECMA standard.

I'm going to stress it again and again, it depends on what you want to do, different aspects of a game are written with different languages. I've explained the pros and cons of various languages and said why.

Whether you want to listen to the guy who in his first post already said 'depends on what you want to do' and explained the difference between different languages, or to the horde that said 'C!' before they even knew what you wanted to do and to this point keep defending that C is supposedly the best for about every-thing. (And name C# and C in one sentence while the languages are nothing alike except for syntax), that's your own choice.
Sorry, but C# makes me think of music. :D

But on a serious note, what type of game aspects is it used in? Obviously it WOULD be useful/not in different aspects, so elaborate please.
shoehorn said:
Your contribution to this thread amounts to nothing other than helping to confuse the OP...
*promptly screams in confusion* This is true- I am confused.. I don't want to have to un-learn stuff that I might learn wrong, so Kajahtava's comments show the cons. That's awesome. But how much weight do they hold? (In a non-rude way) Here's the thing- I want to become a very good programmer. Extremely good. Epicly good...so, where do i start to become a very good game designer?
And, *screams* I feel very lost. I don't this sh** you guys talk about. Or your codes.
Kajahtava said:
They aren't advanced, they're just concepts that C lacks, if you start in a different language, you'll be experienced in closures in two days and scratch your head around pointer arithmetic.

Also, advanced concepts? I'm saying he shouldn't start with C because it's just too difficult to understand it at first.

I took a dig at no one, I responded to every single point people direct at me, that's a different thing. I have quoted every paragraph that was directed at me and responded to each and every individual point instead of just cherry-picking them.
Let's just assume for sake of argument that this is true. Do you think that this makes these people impartial on to recommend a first language?

To be honest, better leave the OP confused about what to do, do his own research and pick the language that suits his or her own needs than to just follow the advise of the first couple of people here that said 'pick this language' and never gave a single argument why that language would be suitable or not.

And he got a reasonable answer, I gave two paragraphs at firs, no more no less about why I thought that C was not a good place to start, and I still have not recommended any language to start, I've explained the strength and weaknesses of various paradigms of programming and told him to make up his own mind after that.

Psychoanalysisforums.com?

Please, keep your ad hominems out of this thread, maybe that's true, maybe it isn't, but there is no way you can know this.
First:
It is advanced. TO ME. I'M STUPID. PRETEND LIKE YOU'RE TALKING TO A 16 YEAR OLD WHO ONLY KNOWS HTML, DOS, AND SOME APPLESCRIPT. OH WAIT. I AM.

Second:
No offense, but this is my research. I looked on the internet, got lost, and confused, so I decided to ask here. Isn't that what this site is FOR? I'm very sorry that I'm annoying you guys, but I really want to know how to do this, and I don't want to have to learn a bunch of stuff (Study the languages completely) just to learn that I shouldn't have learned that.

Is that bad? :frown:

And third:
I'm sorry that you gave a "reasonable explanation". I guess I'm dumb. Cause it didn't much help. It made me realize that this is no better than looking forever on google, where I get the same "C SUCKS DON'T USE IT" vs "C IS AMAZING DON'T EVER DO ANYTHING THAN THAT." Not that you all are saying that. But yeah.
 
  • #14
GreatEscapist,
C/C++ will have a steeper learning curve than the rest of the languages suggested here, but as long as you put in the effort to actually learn what the code/machine is doing, you will come out of learning it a better programmer than if you learn most any other language. If you don't mind putting in the effort, and making the conscious choice to keep figuring out what is going on "under the hood", as opposed to simply trusting the computer to do what's best, then I would strongly recommend starting with one of them.

If you're not too concerned about what the computer is doing, and want to write programs that "just work", and you have a particular subsection of game programming you're interested in, then read through Kajahtava's post, and pick the language most relevant to what you have in mind. If you want to learn more about algorithm structure, and less about the computer architecture, then go with python or perl.

Since you say you want to become a very good programmer, then I stand by my recommendation of C or C++ combined with lots of effort on your part.
 
  • #15
GreatEscapist said:
Sorry, but C# makes me think of music. :D

But on a serious note, what type of game aspects is it used in? Obviously it WOULD be useful/not in different aspects, so elaborate please.
XBox 360, for one. Microsoft is pushing the C#/.net stuff very hard when it comes to XBox 360.

*promptly screams in confusion* This is true- I am confused.. I don't want to have to un-learn stuff that I might learn wrong, so Kajahtava's comments show the cons.
If you learn to program on your own, you are almost certainly going to "do it wrong" -- no matter what language you use.

I am not, repeat am not, trying to dissuade you from learning to program on your own. I learned to program on my own in high school 35 years ago. Learning from your mistakes is a powerful way to learn. One problem with learning on your own is that you don't know you are making mistakes. That's okay, though. You will still be ahead of those of your classmates in college who have never taken a computer programming class in high school and have never bothered to learn how to do it on their own.

It made me realize that this is no better than looking forever on google, where I get the same "C SUCKS DON'T USE IT" vs "C IS AMAZING DON'T EVER DO ANYTHING THAN THAT." Not that you all are saying that. But yeah.
Yes, some of us are saying that. Every language has its pluses (and this includes Visual Basic) and minuses (and this definitely includes Visual Basic). If you want to be a computer game programmer, C/C++ and its kin are where almost everything is at these days.

If you want to be a good programmer you will learn a lot of different languages, and not just another variant of C/C++/C#/Objective-C/Java. You should learn some completely different paradigms. Eventually you should learn Lisp/Scheme to get a flavor for a rather different way of programming. Eventually you should learn assembler because that is as close as you are going to get to the computer (machine language is even closer, but nobody does that, not for a long, long time).
 
  • #16
GreatEscapist said:
I don't want to have to un-learn stuff that I might learn wrong.
You don't have to "un-learn" anything. You may end up changing your coding style or using a different algorithm to solve a problem. For example, there are various algorithms to sort data, with the two "best" being quicksort and (bottom up) mergesort. Merge sort takes double the memory space (at least for the pointers), but can be faster. As mentioned above, each job will usually have some type of coding standards, and these vary from job to job. Some jobs will be better than others.

I want to become a very good programmer. Extremely good. Epicly good...so, where do i start to become a very good game designer?
You need to learn the basics of programming first. For game programming, it depends on the game. Common things would be how to render a dynamic view of a 3d landscape filled with 3d objects, some (or all) of which may be moving. You'll also need some means to apply some set of physics rules on how those objects move around and how to deal with collisions. Other forms of interaction may also be involved. The most likely scenario is you'll be part of a team, and you'll be specializing in some aspect of game development. Some game designers are more artists than programmers, and all they do is implement the 3d objects used in a game.

I don't want to have to learn a bunch of stuff (Study the languages completely) just to learn that I shouldn't have learned that.
For most games, you'll be using a sub-set of C, and using libraries developed at the workplace to deal with the game components. You will not need to learn every function or template in standard C or C++ libraries. Unless the game is dialog based, you won't be doing much work with strings.

As far as game designing goes, I wouldn't know. There doesn't seem to be a lot of innovation in games anymore, it's mostly enhancements of previous games with similar gameplay. Racing games, first person shooters, strategy games, adventure / puzzle games, character leveling up multiplayer games.
 
  • #17
Last edited by a moderator:
  • #18
Integral said:
I have brutally chopped out a off topic digression if you wish to continue the discussion go here.

Lets see if we can keep this thread on topic.

Integral
Thanks. I'm not sure how I got an argument going...

Is Python hard to learn? I know some aren't (like Perl)
 
  • #19
Python is made to be simple to learn.

Python, together with Ruby and Smalltalk follow the so called 'principle of least surprise', the languages are designed in such a way as most human users expect things will happen.

Python is quite versatile, (as is Ruby), it are languages that are both suited for beginners as well as allowing a properly structured coding style to some degree.
 
  • #20
Python is a fairly easy language to learn. There are a couple of things I don't like about Python that have a bit of a hard time seeing past. Sometimes those http://pragmatic.nationalinterest.in/2008/09/05/gok-4-coffee-stains-tea-cups/" can be a bit hard to overlook, particularly for an old fart like me. That said, Python is a powerful yet easy to learn language.

You mentioned earlier that you are interested in computer games. At least for now, that means either C++ or C#. The Sony game console graphics interfaces are in C++ while XBox 360 is C#. Computer games without graphics are sooo 1980s. One can only go so far with "you are in a maze of twisty little passages, all alike."

You mentioned that you already know Java to some extent. I would suggest you stick to that for the time being. The path from Java to either C++ or C# is not all that hard to traverse. They all descend from C, after all. To do Python well you will learn some tricks and techniques that are quite specific to that language. Learning those is a bit of a waste if your goal is computer game development.

If your goal is to be a good (topnotch) programmer it is a good idea to learn many, many different languages over your career. I have lost count of how many languages I have learned over my career. Many (most?) do not even exist anymore. That, BTW, is one reason to learn how to quickly learn to use a new programming language. Becoming an expert in one, but only one, language is, well, stupid. Languages come and go. I doubt computer games of the 2030s will be written in C++ or C# -- or in Python.
 
Last edited by a moderator:
  • #21
Okay.
I still want to learn C++ first, just for the halibut, and since I'll definitely be using it later. And because C books seem to be hard to find where I live.
 
  • #22
I also think that your perception of game development might be different from what you think it will be in the end. Let's say you score a job working on the Havok engine, a job you might get will then be. 'Hey, can you write a function that returns the centre of gravity of a collection of objects if given a certain description of it.'

This all has very little to do with games, and because literally thousands of people in the end have contributed code to the final game and the other 999 people shouldn't be too concerned with how it works. Work is subdivided into such tasks 'a function should do one thing, and do it well', it's your job to make that function, to make sure it works as fast as possible, and to make sure it does not contain any bugs, so that others can just assume that function and use it, without being too concerned with how it works on the inside.

Programming computer games in the end has as little to do with games as programming a sound mixing environment for most developers on the team, they have a well-defined task of what they're supposed to do, and they've just to make sure that this meets the ends.
 
  • #23
D H said:
You mentioned earlier that you are interested in computer games. At least for now, that means either C++ or C#. The Sony game console graphics interfaces are in C++ while XBox 360 is C#. Computer games without graphics are sooo 1980s. One can only go so far with "you are in a maze of twisty little passages, all alike."
What the crap do the actual "game" game companies use then? Like Nintendo and SEGA?

And C++, after looking at a bit more, seems like an interesting language. I'm going to focus on that until I get it down.
 
  • #24
Kajahtava said:
I also think that your perception of game development might be different from what you think it will be in the end. Let's say you score a job working on the Havok engine, a job you might get will then be. 'Hey, can you write a function that returns the centre of gravity of a collection of objects if given a certain description of it.'

This all has very little to do with games, and because literally thousands of people in the end have contributed code to the final game and the other 999 people shouldn't be too concerned with how it works. Work is subdivided into such tasks 'a function should do one thing, and do it well', it's your job to make that function, to make sure it works as fast as possible, and to make sure it does not contain any bugs, so that others can just assume that function and use it, without being too concerned with how it works on the inside.

Programming computer games in the end has as little to do with games as programming a sound mixing environment for most developers on the team, they have a well-defined task of what they're supposed to do, and they've just to make sure that this meets the ends.
I actually do know that. That's where I want to end up. :P
 
  • #25
You won't end up there immediately, GreatEscapist. As Kajahtava mentioned, computer game development is now a big production effort. The days of a couple of guys hacking together a game in their garage are long gone. If you do get a job with a computer gaming company your first job will be to develop some tiny, tiny part of a game. It might have nothing to do with graphics. Your little part might not even look like part of a game. Focusing on the graphics, and the graphics only, is a good way to guarantee that you will not get in the gaming industry. You won't be versatile enough and you won't understand how those graphics work. You would better serve yourself to learn about programming in general with some (but not complete) attention paid to computer graphics.
 
  • #26
D H said:
You won't end up there immediately, GreatEscapist. As Kajahtava mentioned, computer game development is now a big production effort. The days of a couple of guys hacking together a game in their garage are long gone. If you do get a job with a computer gaming company your first job will be to develop some tiny, tiny part of a game. It might have nothing to do with graphics. Your little part might not even look like part of a game. Focusing on the graphics, and the graphics only, is a good way to guarantee that you will not get in the gaming industry. You won't be versatile enough and you won't understand how those graphics work. You would better serve yourself to learn about programming in general with some (but not complete) attention paid to computer graphics.

I seriously know that. I know I won't be much at first, and I'm not all about graphics.
I really am just trying to learn lots of programming stuff, and then if i can, go into game design.

So, does this sound good? I'm going to work on C++ for now, then move on to C#, and Python, and Perl if I have time before college.
 
  • #27
Whoa! One step at a time! You appear to be biting off more than you can chew, particularly as a first-time programmer.
 
  • #28
Perl is next to useless in games, Python also for a great degree. Perl and Python are mostly 'scripting languages' as in, languages fed into other things to automate some tasks, like generating a dynamic web page or organising the files on your computer.

Also, C# is easier than C++ I reckon. C++ is except for some minor details a superset of C. (Though C99 added some things that C++ lacks but the next version of C++ will probably take those with it.), Java is a significant workaround to C++ and removes some things and adds some things, from that came C# which is in fact a lot closer to Java than to C and except for the syntax really bares little resemblance to C any more. C and C++ are fairly low level (that does not mean easier or more proper), C# is a high level language.

It may also be important to look at the design goals of languages

http://en.wikipedia.org/wiki/C_Sharp_(programming_language)#Design_goals
http://en.wikipedia.org/wiki/Java_(programming_language)#Principles
http://en.wikipedia.org/wiki/C_programming_language#Characteristics
D H said:
Whoa! One step at a time! You appear to be biting off more than you can chew, particularly as a first-time programmer.
Maybe I'm just feeding him or her too much, I've been told often enough that I do that.
 
  • #29
D H said:
Whoa! One step at a time! You appear to be biting off more than you can chew, particularly as a first-time programmer.

I don't mean all at once. =P I mean over the next two years. But I real stuff really fast. *shrugs* But I want to do it well, so I'll take time on it.

Kajahtava said:
Perl is next to useless in games, Python also for a great degree. Perl and Python are mostly 'scripting languages' as in, languages fed into other things to automate some tasks, like generating a dynamic web page or organising the files on your computer.

Also, C# is easier than C++ I reckon. C++ is except for some minor details a superset of C. (Though C99 added some things that C++ lacks but the next version of C++ will probably take those with it.), Java is a significant workaround to C++ and removes some things and adds some things, from that came C# which is in fact a lot closer to Java than to C and except for the syntax really bares little resemblance to C any more. C and C++ are fairly low level (that does not mean easier or more proper), C# is a high level language.

It may also be important to look at the design goals of languages

http://en.wikipedia.org/wiki/C_Sharp_(programming_language)#Design_goals
http://en.wikipedia.org/wiki/Java_(programming_language)#Principles
http://en.wikipedia.org/wiki/C_programming_language#CharacteristicsMaybe I'm just feeding him or her too much, I've been told often enough that I do that.

Well, I'm learning Perl and Python more just to learn it and have it than to like, use it a lot. And it will be a awhile before I can good into the game world.

Thanks for the links. Wikipedia's got it all.

I'm a "her". And no, you're not *feeding* me. :P
 
  • #30
GreatEscapist said:
Well, I'm learning Perl and Python more just to learn it and have it than to like, use it a lot. And it will be a awhile before I can good into the game world.
Well, there are two stories to this, learning 'how to use a language' and 'learning to program', as in, learning the strategies, the structures and all behind it.

I'd still recommend you read http://mitpress.mit.edu/sicp/full-text/book/book.html or books based on it like 'How to Design Programs' to learn the structure behind computer programs, what a program is, how to approach a problem et cetera. I'd still not think that *a certain language* is the best language to learn well-structured programming in because it consciously removed a lot of features that enable well-structured programming for performance sake.

Thanks for the links. Wikipedia's got it all.
I'm surprised that wikipedia turned out to work that well, it's easily one of the most reliable sources on the web, at first I wouldn't believe it that any good could be on an place where all people can just edit it and it displays instantly, but the amount of good-willed users who check their sources so much outweighs the vandals that it works. All people can vandalise yap, but all people can also instantly correct a subtle error. (and vandalism)

I'm a "her".
You know that about every-one here assumed the other gender?

And no, you're not *feeding* me. :P
Good, social roles dictate girls can't be fat you know, but then again, we all know said roles dictate that girls can't possibly program either.
 
  • #31
Well, yeah. I want to learn how to do the strategies and stuff. That's what I'm aiming for.

I think I'll look for those books. I like that stuff.
Wikipedia is pretty damn good. People check it to make sure it's good...

And, yeah, most people think I'm like, a 27 year old man. Oh well.
Girls can do crap. Especially girls like me.

So how long did it take you people to learn C/C++/C#?
 
  • #32
Next step is to find an online tutorial that you like, for a basic introduction, or hit up your local book store or library for an intro to C++ book.
 
  • #33
GreatEscapist said:
So how long did it take you people to learn C/C++/C#?

As long as you're still using it, you never really stop learning it.

I still learn new ways of doing things in C++ on a regular basis.
 
  • #34
NeoDevin said:
Next step is to find an online tutorial that you like, for a basic introduction, or hit up your local book store or library for an intro to C++ book.

Yay Barnes and Noble. Thanks for all of the helpful (or not) stuff.

NeoDevin said:
As long as you're still using it, you never really stop learning it.

I still learn new ways of doing things in C++ on a regular basis.

I suppose that would make sense. :D
 
  • #35
GreatEscapist said:
Well, yeah. I want to learn how to do the strategies and stuff. That's what I'm aiming for.
Since I'm in a paedagogic mood and I can't sleep and I promised my sister I would try to sleep and I gave up and she would not like me to not sleep and destroy my life without at least helping some-one. I might as well introduce you to some 'paradigms' of programming. In descending order of best performance:

1: unstructured programming. DON'T use this. There is no advantage to unstructured programming, it's obsolete, it's so called 'write-only' programming as the program itself makes it impossible to infer for a human reader what the program is supposed to do. A reader may understand the individual statements, but has no idea what the result of all those together is supposed to be, maybe if the reader compiles and tries it. A simple example, say we want to find the first n prime numbers. In a hypothetical unstructured language this would go as so:

Code:
1: l = empty list
2: a = 2; //first number that is prime
3: b = 4; //first number that is not prime
4: c = b % a; // c is now the remainder of b divided by a
5: if c == 0 then jump to line 6 else to line 7
6: if c == a then add b to list and jump to line 7
5: b = b + 1; increase the value of b by one
6: jump to line 4 //try again for a higher number
7: if a == n then output list, else jump to line 8
8: a = a +1
9: jump to line 2

Don't try to comprehend this code, because I don't any more, I lost track while I made it, I don't even know if it's correct, it probably isn't, it's just to show you that unstructured programming is a really bad idea. You may understand the individual lines, but the entire program is obscure. Examples of unstructured programming are the old Fortran dialects, older COBOL, older BASIC, Assembly, yap, it all has 'old' because it has been abolished, thankfully.

2: structured programming, well, that's already different, maybe the biggest innovation in programming ever, we don't 'jump' to lines any more. We have a loop. So we get:

Code:
l = empty list; // no line numbers, line numbers no longer matter
a = 2; 
while (a < n) {
b = 2;
while (a % b != 0 and a < b) {
b = b + 1;
} if (a != b) then add a to l;
a + 1;
}
output l;

That's already a bit simpler to see where we jump to. Probably a thing you coded yourself at some point, I still can't guarantee that this is correct and it probably isn't either. But an important part of structured programming is that we can divide a program into smaller maintainable blocks. Examples of structured programming languages are Java, C, C++, C#, Python, Perl, Scheme, Common Lisp

Then we have object-oriented programming. This is again dividing it in more maintainable blocks. We introduce objects, encapsulated pieces of code whose internal workings aren't relevant to the people that use them, but only to the people that created them. These objects can interact but the important part is encapsulation, we don't know how they work on the inside and that's none of our concern, only that they work, so:

Code:
l =  new List(2,3); //we make l a new 'list object', and its no longer empty, its only element is are two and three
while (l.last < n) {//a list of course has a 'method' or 'message' depending on your flavour called 'last', that just gives us the last element of the list.
a = new Int(l.last+2) ; //I make a new integer 'a' who is 2 higher than the last element in the list. Do you know why two? and do you know also know why I specified (2,3) for the list?
if not (l.divides(a)) l.append(a);
} //lists in our language have a method called 'divide' and 'append', it just tests if a number can be divided by an element of the list, if it cannot, it adds it to the list and starts at the top of while loop again. This is because every number that is not a prime number can be divided by at least one lower prime number.
output list;

This is the first point where I'm confident that my code will work regardless of testing for bugs, because it's quite structured, of course, this language doesn't exist, but it should give you an idea of how this helps you. Examples of Object Oriented languages are Common Lisp, C#, Smalltalk, Ruby, Java, Scheme, Python, Ocaml

Next on, higher order programming, in C or Java, functions cannot take functions as argument, this might sound 'obvious', but in a lot of languages that's not a problem. Observe this puppy:

Code:
filter(list(2,n),prime?)

That's it! the function 'prime?' simply returns TRUE if its argument is a prime and FALSE otherwise. The function list simply returns a list, one argument its lowest element, another argument its highest. And 'filter' is a function that takes a list and another function, and simply only keeps the elements for which the other function returns 'true'. 'filter' is thus a 'higher order function' it can take arguments as functions, or return them.

Higher order programming comes at a significant cost though, it's performance is drastically slower than most other paradigms up to now. Object oriented is just a little bit slower than structured. But higher order programming makes up for it at various points. As you've noticed here, I never changed the value of a variable, I never even declared a variable to start with. A lot of higher order programs don't need to change values of variables at all, in fact, some higher order languages don't even allow it. So you don't ever need to copy or alter memory which gains some, but far from all, of the performance back. Examples of higher order programming languages are Scheme, Haskell, Python, C#, JavaScript, Smalltalk

Next on is 'declarative programming', this is even clearer but at a significant performance cost. In declarative programming we are mainly concerned with what we want to do, and not how to do it. Simply said:

Code:
def prime n : 2 or n > 1 and n % m > 0 : prime m
give all prime x : x < n.

We first just said 'a prime number is a number which is either 2, or a number greater than one which cannot be divided by another prime' and then said 'give all primes smaller than n'.

Examples of declarative languages are Haskell, Prolog, OCaml.

If you've paid attention you've noticed that a lot of languages are 'multi paradigm', they allow for more than one paradigm to be used. Common Lisp and Scheme are 'sister languages' in a way, their syntax is indistinguishable and they are often compared, though, Common Lisp is more used for Object Oriented and Structural Programming, and Scheme more for higher order, and a little bit of object oriented programming, even though both are effectively a different interpretation to the same syntax, and elementary programs are generally valid as either.

It also needn't be mutually exclusive, higher order programming is at some point also called 'functional programming', while prolog is 'logically declarative', Haskell is 'functionally declarative', and Scheme is often called 'functionally imperative' to contrast that.

Though these examples aren't symmetric, it does show to some degree the different flavours in programming style, for instance, we would want a 'prime?' function which we still have to code. And all algorithms used there are extremely inefficient. But it's just an illustration.

And, yeah, most people think I'm like, a 27 year old man. Oh well.
Girls can do crap. Especially girls like me.
Oh well, people think I'm a 27 year old man on the internet, and a 14 year old girl in real life, until I start to speak, then they notice that long hair needn't imply that you're female.

So how long did it take you people to learn C/C++/C#?
Nobody here 'knows' them as said before. C is fairly 'minimal', C++ is more extensive, but C# is so big that it's just impossible to know all of it.

There are some languages like Smalltalk, Scheme and Pure Prolog that are just so small that you can know every part of the language. All three have no 'reserved words', from the top of my head, the only characters with a special meaning in Smalltalk are: [:],. (plus a space), and in Scheme/Common Lisp: (,.`') (plus a space again), not sure about Prolog though.

Oh, P.S. in case you wonder, the first languages of each paradigm were:

Structured: ALGOL (1958)
Object Oriented: Smalltalk or Simula, depending on what your view on 'object oriented' is.
Higher order: Lisp (1960s, the first lisp that is, Lisp had a lot of variants over the decades, the only two that survived are Scheme and Common Lisp, Higher order programming is thus older than either object oriented or C, most people think it's fairly recent)
Declarative: Prolog, around the 1980's from the top of my head.

Sorry if I'm feeding you a bit too much by the way, but I'm actually enthusiastic about your eagreness here, I'm also needing a way to get tired. (See above)
 
Last edited:

Similar threads

  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
1
Views
722
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
8
Views
866
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
2
Replies
54
Views
3K
  • Programming and Computer Science
Replies
5
Views
936
  • Programming and Computer Science
Replies
17
Views
1K
Back
Top