Jump to content
The Dark Mod Forums

Learn to program


pakmannen

Recommended Posts

So, since I'm going to study a subject that includes programming I thought I'd try to learn a few of the basics in advance. I've never done any "proper" programming but I know php quite well. That means I know the basic syntax, functions, loops, conditions etc. Never had to deal with a compiler or any of that stuff. I know the theory behind object oriented programming, but since I've mostly concerned myself with php 4.x (which apparantly sucks at OO) I never bothered to study it carefully.

 

I don't have any specific language in mind; I'd like to learn the stuff that applies to programming in general.

 

What do I need to get going? What language would be a good starting point? (Just don't say Pascal..) Do you have any book reccomendations? How did you guys go about learning this stuff? What were your first programs? I want know everything! :)

Link to comment
Share on other sites

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

That depends on what do you want to achieve with your programming. Coding for the Dark Mod? Go for C++, I'd say.

 

There was a good tutorial (recommended by OrbWeaver) on zdnet, which is still accessible via archive.org:

http://web.archive.org/web/20060515052844/...t.com/book/c++/

 

It really helps to start with a book that explains the syntax and the specialties along with what can be done in the first place. Next step is to find a proper application which you can use as a testbed. I took DarkRadiant. :P

Link to comment
Share on other sites

Now, I wasn't thinking primarily of the dark mod (I'm not promising ANYTHING) :laugh:

 

The programming I'm going to study focuses on visualisation, which is a fancy way of saying computer graphics. That could mean anything from VR to be used by surgeons to Hollywood film effects. (Or computer games for that matter) I don't really want to jump headlong into that though :)

 

I guess most people go with Java or one of the C languages these days when they start out. What is the difference between C, C++ and C#?

 

Oh, and yeah, I do realize the importance of having your own little project when you learn stuff like this. That's sort of why I asked what your first programs were. I don't think I should endanger DarkRadiant just yet.. :P

Link to comment
Share on other sites

C is the classic language. C++ is its successor which is fully compatible to C. C++ is more powerful.

 

C++ extends C by the concept of classes, which makes it a object oriented language. There are also a lot of other convenient extensions in C++ over C (like references, operator overloads, more freedom of where to define your variables and such). Generally, I'd say it's better to start with C++ and skip C entirely to get into C++ thinking right from the start.

 

I don't know a thing about C#, someone else have to answer this for you.

Link to comment
Share on other sites

C# is kind of MS Java from what I heard. I think a good way to start learning object oriented programming is Java, because it has a rather good object model and you cn learn a lot from it. Never used C# so I can't comment on it, apart that it is proprietary and thus not a good way to start learning programming in general. ;)

 

Of course you can also learn OO paradigm in C++, but Java enforces it. In C++ you can do whatever you want, and you may think it is OO. I once had a project leader who coded really bad spagetthi code and thought it was object oriented because he used C++ syntax. :)

 

Java is also rather similar to C++ in many regards, so you shouldn't have to many problems switching to if you need to, even though there are some differences of course.

 

If you want to learn real programming and computers, you should go for assembly though. This is programming for the real men. ;)

Gerhard

Link to comment
Share on other sites

Under NO circumstances should you start out programming in C if you haven't programmed before, that is like learning to drive by studying welding. Give C# a miss as well, I know nothing about it as a language but I haven't heard particular good things about it and you don't want to get sucked into Microsoft's proprietary crap at such an early stage.

 

For a new starter with no programming experience, I recommend Python -- it's a great language, very well documented and beginner-friendly but also extremely powerful and flexible. Once you've learnt the basics you might want to try Java, which is a pure-OO language widely used in the enterprise and commercial sectors.

 

At that point, you could look at C++ but only if you think you will need (or want) to actually use it; it is a very large and complex language and is best studied after you have considerable programming experience. The only reason to learn C is if you want to do low-level driver programming or development for embedded systems (mobile phones etc).

Link to comment
Share on other sites

I read somewhere that C# was a mix of C++ and Java but yeah, I shunned away from it as soon as I read Microsoft. It's not that I have much against them but as you say, why start with a proprietary language?

 

Java seems to be the most sensible option, since I want to learn OO from the start. I'll take a look at Python as well, thanks for that one OrbWeaver.

 

Oh, any of you have experience with Ada?

Link to comment
Share on other sites

Orb, when I wrote that posting, I was also thinking about Python at the beginning. The pro is that python is also OO (or at least it can be) and it is to learn. I don't know if it is a good language to learn programming though, because it still a scripting language, and feels rather "loose" to me.

That's why I recommended java. I already had quite a long experience with C++ before, and only learned Java last year or so, but I was really impressed by it's strict adherence to object modelling. It was really the first language, where I felt that the OO paradigm really had a meaning, beyond being just a fancy name to have on your resume. It's also quite powerfull for all kind of tasks.

 

Of course you can still mess up with the OO part, because you can still write bad code with it, but if you take the time to look at the thought that went it, you can really learn a lot about good OO programming.

Gerhard

Link to comment
Share on other sites

Orb, when I wrote that posting, I was also thinking about Python at the beginning. The pro is that python is also OO (or at least it can be) and it is to learn. I don't know if it is a good language to learn programming though, because it still a scripting language, and feels rather "loose" to me.

 

Sure, you are not going to learn about type safety and compile-time checks with Python, but I do believe it is a very good way of learning the fundamentals of programming such as loops, iteration versus recursion, data structures (lists, arrays, hashtables etc), algorithms etc. I think working with dynamic languages is also very useful in its own right, since passing functions as arguments etc would be quite counterintuitive if you had never been exposed to it.

 

That's why I recommended java. I already had quite a long experience with C++ before, and only learned Java last year or so, but I was really impressed by it's strict adherence to object modelling. It was really the first language, where I felt that the OO paradigm really had a meaning, beyond being just a fancy name to have on your resume. It's also quite powerfull for all kind of tasks.

 

Yes, I too would recommend Java hence my suggestion to Pak. However as an absolute beginner language I think it is a little clunky -- for example, you are going to have to write "public static void main(String[] args)" just to print Hello World, without actually knowing what "public", "static", or "void" mean, whereas with Python you will only need to use the features of the language you are currently learning.

 

Also learning data structures would be quite verbose in Java, for example to iterate through a list of items you have to mess around with getIterator() and iter.next() whereas with Python you can just do "for item in list: print 2 * item" in a single line.

Link to comment
Share on other sites

Java seems to be the most sensible option, since I want to learn OO from the start. I'll take a look at Python as well, thanks for that one OrbWeaver.

 

I was going to suggest Python too. :)

 

Here's another good tutorial: How to Think Like a Computer Scientist. It covers Python but it's intended to cover the programming "frame of mind" as well, which IMO is the most important thing to learn.

 

Oh, any of you have experience with Ada?

A little. My advice: If anyone tries to teach you Ada, don't walk away; run! And don't look back! :P

 

To be fair it's not a bad language, it's just really strict and formal. Which might be useful in combination with formal software engineering practices if you're writing software which will kill people if it crashes, but for the rest of us it's mostly a hindrance.

 

However as an absolute beginner language I think [Java] is a little clunky -- for example, you are going to have to write "public static void main(String[] args)" just to print Hello World, without actually knowing what "public", "static", or "void" mean, whereas with Python you will only need to use the features of the language you are currently learning.

 

Also learning data structures would be quite verbose in Java, for example to iterate through a list of items you have to mess around with getIterator() and iter.next() whereas with Python you can just do "for item in list: print 2 * item" in a single line.

Agreed. Java is not a good beginner language, whatever my university CS department thinks. It forces you to think about syntax and advanced concepts just to get anything done, with the result that you'll be focusing more on syntax than on concepts while you're learning. That's a bad thing, since concepts are much more important.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

I would probably agree if I had to go back I guess. I remember now we were protected from the complex stuff at first by having sort of templates so we only had to write the basic stuff.

 

But if he's already done php and basic logic structures like loops etc. then he might already be ready to move on to C++?

Link to comment
Share on other sites

Let me offer one piece of advice. First of all I tried unsuccessfully to learn programming for years in late junior high and early high school. I read countless books, tried to apply myself, etc. But the problem wasn't the "language" per se, it was the math. I failed to realize that mathematical logic was the basis of all programming and if you were bad at math, you are doomed to never be cut out for programming. It wasn't so much I was terrible at math, though I hated math--I simply didn't have that knowledge at that point in high school. I read through at least three learn C books (after BASIC) and it was like learning 5,000 vocabulary words with no grammatical knowledge. You'll learn the language sure, but I certainly didn't learn how to use it. As with anything I'd say start small and work your way up. Master one small concept before tackling the next.

 

Also learning anything complicated through simply a book is a bitch and if you aren't that kind of learner, as I wasn't, don't set your expectations too high. I'm more a kinesthetic and auditory learner. I like to work through things and hear them in a lecture, but technical reading is arduous and painful. Get used to math, and wear a hat. You'll be tempted to pull your hair out more than on one occasion.

Edited by Ombrenuit
Link to comment
Share on other sites

Well depends on what sorts of programming. Making a 3D game engine requires a lot of math. Rendering, physics...

 

I didn't do that well in math in high school.

 

But at University, I generally came up with "smarter" solutions than my classmates in my programming classes because I tried to think of the most direct and simple route to acheive the result, whereas a lot of people got stuck in programming for functionality that would never be needed, but seemed like "the right thing to do". They lost marks for that.

 

And even with my level of mathematical ability back then, I learnt more about quaternions than my classmates, (even to the point of solving a problem the lecturer had during class), and it was enough to use them and get the effects I wanted in game, with a bit of experimentation. I was able to create a space ship that angled left right forward and back with the mouse, like a helecopter, but didn't suffer from "rolling" when you moved the mouse in circular motions, which was initially a problem.

 

And having a creative mind is extremely useful with programming, because you can come up with neat ways to optimse things. Being awesome at math won't be of any use unless you can apply it creatively. So I believe that a creative mind is more important than maths. I don't doubt that our programmers on DarkMod have had to apply their mathmatical skills in creative ways to acheive the light gem, sound propagation, etc.

 

I am the only student who took the Game Programming class who then went straight into a Game Programming job, so I like to think I'm on the right track here :) But this is my experience and I don't mean to start a debate with anyone. I guess what I'm trying to say is that I don't believe that programming is simply all about math.

Link to comment
Share on other sites

Also learning data structures would be quite verbose in Java, for example to iterate through a list of items you have to mess around with getIterator() and iter.next() whereas with Python you can just do "for item in list: print 2 * item" in a single line.

 

You don't need to use iterators. There is a simpler way that I stumbled upon accidently when researching something. :)

 

ArrayList<String> dev = CReferenceData.GetInstance().GetReferenceDataByGroup("DEVELOPER");
for(String s : dev)
{
if(s.startsWith("Send-In") == false)
	mDevelopers.add(s);
}

 

This syntax is quite usefull because I also feel the itreators quite cumbersome, especially for simple loops like this one.

Gerhard

Link to comment
Share on other sites

I don't know about the math problem. I learned programming at a time where I had no good knowledge in math. I'm still not THAT good, but I learned a lot more in the meantime. For most problems you don't really need math, unless you want to attack a mathematical problem. What you really need to learn is to look into a problem by tearing it apart in smaller and smaller, manageble chunks.

If you look at a comlpex problem don't focus on the endproduct and see how complicated it is. Rather you must look on the smaller stuff. What is it composed off, where do I start, where are components that have somethign in common with seemingly other components unrelated to it. You must find the basic building blocks it is composed of. That's the creative part of programming.

If you look at TDM it's incredible complex, but of course you have to start somewhere. You need a lightgem, you need some AI functionality and so on. And from there you go deeper and look into each identified task if you can still make it into smaller parts, until you can actually start programming it.

Gerhard

Link to comment
Share on other sites

Being good at mathematics isn't a prerequisite for learning programming, sure, but a good knowledge of maths does help you think in the logical, structured way that programming requires. The maths itself is somewhat secondary, except when you really are solving a maths problem (3D graphics, anything requiring trig, etc.); it's the thought processes that enable you to do the maths that are useful.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

You don't need to use iterators. There is a simpler way that I stumbled upon accidently when researching something. :)

 

That's interesting, I guess that must be something introduced in some of the more recent Java versions. I haven't kept up with the syntactical changes and tend to think in terms of Java 1.2 / 1.3.

 

Being good at mathematics isn't a prerequisite for learning programming, sure, but a good knowledge of maths does help you think in the logical, structured way that programming requires. The maths itself is somewhat secondary, except when you really are solving a maths problem (3D graphics, anything requiring trig, etc.); it's the thought processes that enable you to do the maths that are useful.

 

Absolutely. The only maths you need for programming is simple counting and arithmetic; at no stage do you need to use any advanced mathematics unless you are actually writing a mathematical program (engineering, 3D graphics etc).

Link to comment
Share on other sites

That's interesting, I guess that must be something introduced in some of the more recent Java versions. I haven't kept up with the syntactical changes and tend to think in terms of Java 1.2 / 1.3.

 

Currently I'm using 1.5, but I think I already used this in 1.4 as well. Not sure though, as I only started recently with Java, so I don't know if this was added lately or not. It's definitely usefull though, because it saves you a lot of typing for simple common tasks. :)

Gerhard

Link to comment
Share on other sites

Sure, you are not going to learn about type safety and compile-time checks with Python, but I do believe it is a very good way of learning the fundamentals of programming such as loops, iteration versus recursion, data structures (lists, arrays, hashtables etc), algorithms etc. I think working with dynamic languages is also very useful in its own right, since passing functions as arguments etc would be quite counterintuitive if you had never been exposed to it.

After reading a bit on the python website, I think it seems a fine starting point, and also quite useful in that you can quickly whip up a program to do basic stuff like batch renaming files. I don't see anyone writing a java application for that sort of thing. It (python) does feel more like a scripting language though.

 

Yes, I too would recommend Java hence my suggestion to Pak. However as an absolute beginner language I think it is a little clunky -- for example, you are going to have to write "public static void main(String[] args)" just to print Hello World, without actually knowing what "public", "static", or "void" mean, whereas with Python you will only need to use the features of the language you are currently learning.

I do have php experience, so I know about a lot of the basic concepts like arrays, loops, conditions, functions and classes. Of course, php isn't nearly as strict as C++ or Java. There are no datatypes per se, you just create a variable and it can take any sort of value. As for your example, here are some guesses: "public" = the function can be accessed from other classes, "static" = um, not dynamic? :P, "void" = function does not return anything, "main" = constructor?

 

 

A little. My advice: If anyone tries to teach you Ada, don't walk away; run! And don't look back! :P

 

To be fair it's not a bad language, it's just really strict and formal. Which might be useful in combination with formal software engineering practices if you're writing software which will kill people if it crashes, but for the rest of us it's mostly a hindrance.

Ha! Yeah I looked it up and it's apparently developed by the US army and used in planes and helicopters and spaceships and stuff. I do have a course in ADA, so we'll see how that goes. Mmm, strictness..

 

Let me offer one piece of advice. First of all I tried unsuccessfully to learn programming for years in late junior high and early high school. I read countless books, tried to apply myself, etc. But the problem wasn't the "language" per se, it was the math. I failed to realize that mathematical logic was the basis of all programming and if you were bad at math, you are doomed to never be cut out for programming.

Sure, you need logical thinking, and basic math knowledge, in order to get started. Same concept applies with php though.

 

Well depends on what sorts of programming. Making a 3D game engine requires a lot of math. Rendering, physics...

Since that's the sort of programming I'm going to do (physics simulations, computer graphics etc) I have, spread over five years, one and a half years of math ahead of me. :) Ahh..

 

And having a creative mind is extremely useful with programming, because you can come up with neat ways to optimse things. Being awesome at math won't be of any use unless you can apply it creatively. So I believe that a creative mind is more important than maths. I don't doubt that our programmers on DarkMod have had to apply their mathmatical skills in creative ways to acheive the light gem, sound propagation, etc.

True, most types of programming require very little mathematical skill, but a lot of creative logical thinking.

Link to comment
Share on other sites

It (python) does feel more like a scripting language though.

It certainly has scripting overtones. I don't count that as a bad thing. :)

 

As for your example, here are some guesses: "public" = the function can be accessed from other classes, "static" = um, not dynamic? :P, "void" = function does not return anything, "main" = constructor?

All pretty much correct, except for "static". :) Which is understandable since it has to do with OO, which you said you hadn't learnt yet. "static" means that the method is not associated with a particular instance of the class. So if you have this:

 

class MyProgram {
public static void main() {
	// do-nothing program
}
}

 

Then no object of the class MyProgram is ever actually created, despite the fact that a method is called on the class.

 

Static methods have certain limitations, which are obvious once you understand how they work. For example, you can't refer to the "this" object (explicitly or implicitly), since there is no "this" object.

 

...but I guess that all Greek to you if you haven't done OO at all! Which just goes to show Java's drawbacks as a teaching language.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

After reading a bit on the python website, I think it seems a fine starting point, and also quite useful in that you can quickly whip up a program to do basic stuff like batch renaming files. I don't see anyone writing a java application for that sort of thing. It (python) does feel more like a scripting language though.

 

Yes, you rapidly develop an arsenal of useful everyday techniques with Python, which makes it a good starting point.

 

Don't worry about whether something is a "scripting language", there is actually no such thing. Some languages tend to be interpreted, while others are compiled, but this is not set in stone: Python can be compiled to Java ByteCode (with Jython), for example, while you could have intepreted C if you really wanted to. The distinction between "programming" and "scripting" tends to be more of a relic from the elitist "Real Programmers use Assembler" days, which are thankfully long gone. Just use the language that is the best tool for the job (although some hardcode geeks will insist on using C for processing text files, it is their own time they're wasting).

 

As for your example, here are some guesses: "public" = the function can be accessed from other classes, "static" = um, not dynamic? :P, "void" = function does not return anything, "main" = constructor?

 

Static means that you don't need to instantiate the object to call the method, you can just use it like a global function, while main() is the main method which is called when you run a Java program from the command line.

Link to comment
Share on other sites

It certainly has scripting overtones. I don't count that as a bad thing. :)

All pretty much correct, except for "static". :) Which is understandable since it has to do with OO, which you said you hadn't learnt yet.

 

"static" is certainly not associated to OO in any way. Your example is correct but doesn't go deep enough. static is also available in plain C where no OO existed and simply describes a variable that is immediately available like a globhal variable, only with a limited scope. Only in reference to a function it is related to OO, because in C a static function usually doesn't make much sense. Except maybe to limit the scope of a function to the current module.

Gerhard

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • The Black Arrow

      Any of you heard Age of Wonders 4's OST?
      https://www.youtube.com/watch?v=Q0TcoMGq4iA
      I love how after all these years, Michiel van den Bos still conserves his "Melodic" spirit.
      · 0 replies
    • nbohr1more

      Moddb article is up:  https://www.moddb.com/mods/the-dark-mod/news/the-dark-mod-212-is-here
      · 3 replies
    • Petike the Taffer

      I've been gone for a while, but now I'm back, have a new desktop and I want to get back to making missions and playing missions. And doing other contributions. Waiting for my reset password for the wiki, but I'll take a look at it soon. Hello, all.
      · 4 replies
    • snatcher

      TDM Modpack 4.0 for The Dark Mod 2.12 released!
      · 1 reply
    • nbohr1more

      Congrats to all the busy Dark Mod developers! TDM 2.12 is here!
      · 4 replies
×
×
  • Create New...