i would love to learn how to code

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
User avatar
adrenaguy
Engineer
Engineer
Posts: 11
Joined: 22 Apr 2009 19:54
Location: england
Contact:

i would love to learn how to code

Post by adrenaguy »

well this is pretty self explanatory, i would love how to learn to code for OTTD, even if i could just have some simple coding tips just so i can get a taste of it i would really appreciate it, because i know A LOT of you code for OTTD, I don't know much about it as well, because to me all the (%refcod237) and all that stuff just makes very little sense, i have been told it's quite simple when you know what the f**k you're on about, but i don't :D so i'd appreciate it if someone could give me some pointers, thanks!
The sky isn't the limit, it's a challenge.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: i would love to learn how to code

Post by FooBar »

Try compiling OpenTTD yourself (i.e. not using BuildOTTD or similar) and work your way from there.
User avatar
adrenaguy
Engineer
Engineer
Posts: 11
Joined: 22 Apr 2009 19:54
Location: england
Contact:

Re: i would love to learn how to code

Post by adrenaguy »

yeah see, i have no idea what you mean, i mean i am at square one with this, i don't have any new sets yet, i don't know what all these buildTTD things are, i am just a tiny little n00blet right now :(
The sky isn't the limit, it's a challenge.
User avatar
cmoiromain
Chief Executive
Chief Executive
Posts: 655
Joined: 15 Jan 2007 21:45
Location: FRANCE
Contact:

Re: i would love to learn how to code

Post by cmoiromain »

Then ask google for a "C++ tutorial". You'll probably end up with loads of them, no matter what language you use.
I am little, ugly, and nasty. How do you do?
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: i would love to learn how to code

Post by Zutty »

Anyone can do it IMHO, but if you are a beginner then you should start small and progress slowly. If you try to dive straight in with the OpenTTD code you'll just get lost and frustrated and you probably wont enjoy yourself. As cmoiromain says, a C++ tutorial would be an excellent place to start.
PathZilla - A networking AI - Now with tram support.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: i would love to learn how to code

Post by DaleStan »

Also, be prepared to spend several years at it. Not "several weeks", not even "several months. "Several years".
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
adrenaguy
Engineer
Engineer
Posts: 11
Joined: 22 Apr 2009 19:54
Location: england
Contact:

Re: i would love to learn how to code

Post by adrenaguy »

thanks for the tips guys! and i know what you mean about it taking a VERY long time to learn, it's amazing how people think they can jump right in, i knew it was gonna be hard and it didn't fail to surprise me how much code goes into just writing a couple words :S so i'll keep you updated on this but i won't expect it to go very fast, seeing as i'm attempting to learn japanese, as well! (but i've heard that's easier than code so... yeah.) thanks again!
The sky isn't the limit, it's a challenge.
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: i would love to learn how to code

Post by orudge »

adrenaguy wrote:(but i've heard that's easier than code so... yeah.)
I imagine coding is probably a lot easier than Japanese for most people here. ;)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: i would love to learn how to code

Post by Roujin »

Amari muzukashikunai to omoimasu. [I think it's not so difficult.] 8)

[/offtopic]

Well, I've heard only a tiny little bit about C++ in university, basically we got a stone-old, incomplete handbook on C++ thrown at us and got told "read this, you'll need to know C++ for this lecture" at the beginning of a "operating systems and systems engineering" lecture. Turned out we needed it only in a very small part of the exercise of that lecture about threading, semaphores (not the OpenTTD ones ;)) and such.
After that, I wanted to do something with my "knowledge" of C++, so I started to poke around in the OpenTTD code, trying out stuff, learning from it, and eventually writing some patches that actually did something (more or less) useful, of which some were actually picked up by the devs, reviewed, and went into trunk. *proud*
I wouldn't say I'm a good coder, but I think it's not really only "cannot code" or "can code", but there's a lot in between. You just have to start and like the link from DaleStan said, read other code, and code yourself to improve..

Anyway, for me it wasn't so hard to get into C++ because it wasn't the first programming language for me. So I just had to learn things that are new or different compared to languages I've done something with before.
If you're learning your first programming language, I would recommend something else than C++. I'm not an expert, but I know that C++ can be quite confusing, and there's a lot that can go wrong.

Regardless of what language you choose, you need some point where you can start off, so google for "[language of your choice] tutorial" and follow what it says. A good beginners tutorial should include everything you need to start.


Good luck with your studies (all of them). :)
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Re: i would love to learn how to code

Post by Expresso »

Well, if you want to donate code to openttd you'll first have to learn C++. You'll need a book ("C++ primer plus" or "Thinking in C++" come to mind here (you'll need a grounding in C for the latter though)), as well as a compiler and a good text editor (one which supports things like syntax highlighting).

Now, those books can help you with knowledge and, provided you do the exercises, with a bit of experience. If you don't understand something stop and come back later, it's more important to understand then to know. Keep practicing, programming is a skill of which 0.1% is knowledge, the rest is experience and understanding (both of which cannot be learned from a book or somebody else).
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: i would love to learn how to code

Post by DaleStan »

Accelerated C++ is the book I've seen recommended.

If the title contains either of the words "days" or "hours", leave it on the shelf.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
audigex
Tycoon
Tycoon
Posts: 2056
Joined: 09 Dec 2007 21:28
Contact:

Re: i would love to learn how to code

Post by audigex »

You're going to the wrong university...

Unless they're teaching you java, which is basically C++ without the pointers and a different API.

Essentially you should expect it to take a couple of years of "hobby" coding - an hour or so most evenings. You can learn it in 6 months to a useable level if you spend 5 hours a day on it, but I find that even with a decent PHP background and 6 months of Java behind me, I still can't quite get what's going on in the OTTD code.

It could also be that I'm not trying hard enough though :-)
Jon
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: i would love to learn how to code

Post by DaleStan »

audigex wrote:but I find that even with 6 months of Java behind me
That would be your problem.

"I used to recommend Java as a good language to learn early, but this critique has changed my mind (search for 'The Pitfalls of Java as a First Programming Language' within it). A hacker cannot, as they devastatingly put it 'approach problem-solving like a plumber in a hardware store'; you have to know what the components actually do. Now I think it is probably best to learn C and Lisp first, then Java." -- ESR, How To Become A Hacker
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: i would love to learn how to code

Post by Eddi »

audigex wrote:You're going to the wrong university...
a "good" computer science introduction avoids teaching "mainstream" programming languages, because it is more important to learn programming concepts than programming languages.
  1. whatever "hype" language you learn now, the next company you will work for probably does not use it
  2. learning concepts allows you to more easily learn other languages
  3. in "common" languages, the concepts are usually not clean
  4. also, "common" languages often come with a lot of clutter before you can actually get started
  5. some programming concepts do not even appear in languages like Java or C++, but knowing about them can fundamentally change your way of programming
  6. the more languages you know, the more easily you can chose the language that is "right for the job"
audigex
Tycoon
Tycoon
Posts: 2056
Joined: 09 Dec 2007 21:28
Contact:

Re: i would love to learn how to code

Post by audigex »

They are to some extent my point :-) I think they all do it wrong, but to touch on C++ as a ten second "learn this little bit" jobbie seems wrong to me.

Personally I think teaching majority java is my uni's biggest weakness (actually, no - teaching JSP is their biggest weakness) since although it's popular at the moment, it's actually an "easy" language in terms of computer science techniques; the compiler and interpreter do all the work for you; and the API contains a massive amount of code. Those things can make it a great language to USE - but to learn it? It teaches laziness and misses out on a lot of fundamental techniques.

As for JSP - it's a complete pile of crap; a bad mix of pre-compiled and runtime (survivable in a desktop environment to some extent for the sake of cross-platform compatability) which is absolutely no use whatsoever in a client->server system mixed in with a stupid way of mixing java, xml, html(+css, javascript) and the worst database support in any language I've ever seen - basically the cornerstone of web development. How I wish they'd stop being java fan boys and teach a proper language for the job. It'd even teach more skills to use PHP!

Gah, turned into a rant there... but my belief is that time should be split between C and C++ (and the differences taught), Java, LISP, Fortran (it's still around enough!), PHP, ASP, Ruby; not because the aforementioned languages are guaranteed to be in the market forever, but because 1) There's enough around that most people will likely see all of them in a career - with the possible exception of fortran, 2) They teach a wide variety of techniques both in the coding style and the delivery of the program - interpreted, compiled, semi-compiled then interpreted, and a mix of different environments.

God I hate JSP.
Jon
User avatar
adrenaguy
Engineer
Engineer
Posts: 11
Joined: 22 Apr 2009 19:54
Location: england
Contact:

Re: i would love to learn how to code

Post by adrenaguy »

so the opinion would appear that right now, C++ tutorial is where i should start, because tbh i'm getting a bit baffled by all this stuff about JSP and LISP and all other sortsa stuff, i just want some clear advice about where to START for coding as a hobby, nothing really about later in it, i'll cross that bridge when i come to it, as i am completely clueless i'd like to know where to begin and nothing more for now, thanks
The sky isn't the limit, it's a challenge.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: i would love to learn how to code

Post by Yexo »

adrenaguy wrote:so the opinion would appear that right now, C++ tutorial is where i should start, because tbh i'm getting a bit baffled by all this stuff about JSP and LISP and all other sortsa stuff, i just want some clear advice about where to START for coding as a hobby, nothing really about later in it, i'll cross that bridge when i come to it, as i am completely clueless i'd like to know where to begin and nothing more for now, thanks
First stop is your local library / bookshop to get a book on c++. Then just try to follow the book and if you don't understand something: google. If you wish to try something and your book can't help you: google. Anything else: google. You may have noticed that I'm a search fan, but the best way to learn is by finding the answers yourself. That hold even know, if you want to start, google for "C++ tutorial". Second hit:
http://www.intap.net/~drw/cpp/ wrote:Section 0.2: Who Is this Tutorial For?

This is a tutorial designed for a wide variety of people:

* Beginners who have never programmed before
...
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: i would love to learn how to code

Post by pavel1269 »

This topic contains very usefull info, for almost everyone who even thought about coding.
http://norvig.com/21-days.html
A language that doesn't affect the way you think about programming, is not worth knowing.
http://norvig.com/21-days.html
Which way would you rather learn to play the piano: the normal, interactive way, in which you hear each note as soon as you hit a key, or "batch" mode, in which you only hear the notes after you finish a whole song? Clearly, interactive mode makes learning easier for the piano, and also for programming. Insist on a language with an interactive mode and use it.
Yexo
... the best way to learn is by finding the answers yourself.
QFT
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: i would love to learn how to code

Post by DaleStan »

Eddi wrote:some programming concepts do not even appear in languages like Java or C++
If you think that some concept doesn't exist in C++, chances are that you aren't familiar enough with Boost.
Metaprogramming? Got it.
Object of any type? Got it.
Functors? Got it. (C++ does this pretty well on its own, however)
Lambda programming? Got it.

ObBackpedaling: No implications are made concerning the quality of boost's implementations relative to $LANGUAGE_ORIGINALLY_DESIGNED_TO_DO_THAT, nor the quantities of SAN damage taken in the process of learning any particular system.
Last edited by DaleStan on 25 Apr 2009 22:39, edited 1 time in total.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: i would love to learn how to code

Post by Eddi »

DaleStan wrote: ObBackpedaling: No implications are made concerning the quality of boost's implementations relative to $LANGUAGE_ORIGINALLY_DESIGNED_TO_DO_THAT, nor the quantities of SAN damage taken in the process of learning and particular system.
that's what point c is meant to catch ;)

and for nitpicker's sake, boost is not part of the official langauge standard, it is merely an extension library.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 6 guests