
i would love to learn how to code
Moderator: OpenTTD Developers
i would love to learn how to code
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
so i'd appreciate it if someone could give me some pointers, thanks!

The sky isn't the limit, it's a challenge.
Re: i would love to learn how to code
Try compiling OpenTTD yourself (i.e. not using BuildOTTD or similar) and work your way from there.
Re: i would love to learn how to code
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.
- cmoiromain
- Chief Executive
- Posts: 655
- Joined: 15 Jan 2007 21:45
- Location: FRANCE
- Contact:
Re: i would love to learn how to code
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?
Re: i would love to learn how to code
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.
Re: i would love to learn how to code
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: i would love to learn how to code
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.
- orudge
- Administrator
- Posts: 25223
- Joined: 26 Jan 2001 20:18
- Skype: orudge
- Location: Banchory, UK
- Contact:
Re: i would love to learn how to code
I imagine coding is probably a lot easier than Japanese for most people here.adrenaguy wrote:(but i've heard that's easier than code so... yeah.)

Re: i would love to learn how to code
Amari muzukashikunai to omoimasu. [I think it's not so difficult.] 
[/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).

[/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

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).

Re: i would love to learn how to code
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).
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).
Re: i would love to learn how to code
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.
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: i would love to learn how to code
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
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
Re: i would love to learn how to code
That would be your problem.audigex wrote:but I find that even with 6 months of Java behind me
"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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: i would love to learn how to code
a "good" computer science introduction avoids teaching "mainstream" programming languages, because it is more important to learn programming concepts than programming languages.audigex wrote:You're going to the wrong university...
- whatever "hype" language you learn now, the next company you will work for probably does not use it
- learning concepts allows you to more easily learn other languages
- in "common" languages, the concepts are usually not clean
- also, "common" languages often come with a lot of clutter before you can actually get started
- some programming concepts do not even appear in languages like Java or C++, but knowing about them can fundamentally change your way of programming
- the more languages you know, the more easily you can chose the language that is "right for the job"
Re: i would love to learn how to code
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.

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
Re: i would love to learn how to code
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.
Re: i would love to learn how to code
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: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
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
...
Re: i would love to learn how to code
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.
QFTYexo
... the best way to learn is by finding the answers yourself.
My patches: Day length (new concept), Conditional loading, Auto separation, Unload all adds Leave empty, Better statue placement (in trunk)
My abandoned patches: Speed limits for RVs, Day length (old concept)
My abandoned patches: Speed limits for RVs, Day length (old concept)
Re: i would love to learn how to code
If you think that some concept doesn't exist in C++, chances are that you aren't familiar enough with Boost.Eddi wrote:some programming concepts do not even appear in languages like Java or C++
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
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: i would love to learn how to code
that's what point c is meant to catchDaleStan 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.

and for nitpicker's sake, boost is not part of the official langauge standard, it is merely an extension library.
Who is online
Users browsing this forum: No registered users and 6 guests