Advertisement
Guest User

learning to code guide for agdg

a guest
Sep 13th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.06 KB | None | 0 0
  1. Since people often ask where to start learning programming, I decided to try and whip up a little guide people can follow in order to learn proper programming and have some perspective about their options. I don't have the space or time to write a detailed guide so this will be more of a short intro you can follow, with references to good resources that will go in depth and various thoughts appended at the end. Programming is an endeavor in and of itself and some of the best resources aren't focused on making games (and often can't be for simplicity's sake) so don't be discouraged if all these don't lead you by hand and tell you step by step you how to like make game.
  2.  
  3. First of all, programming is a craft rather than science. You absolutely can not learn it just by reading books. Programming books are supposed to be a supplement to the learning not the core of it. Write code as you go through books, when you read about a new thing, write a program using it. It's also better to write many smaller programs (couple hundred lines at most) rather than immediately trying to write an open world RPG, if you tried to do that, it would take ages you'd be stuck rewriting your bad code over and over and in the end never getting any results. My recommendation is in the beginning jst try to use the newest thing you learn in a simple way(ie you just learned how to use an array and a cycle so try to find the highest number in a sequence of numbers in array). After you have basic understanding of the language try solving algorhithmic problems from high school algorhithmic competitions, their solutions are usually short(within 1K lines depending on dificulty) and they will teach you algorithmic thinking. (I have a couple books full of these which I won in these competitions, I might translate some and put them on pastebin.)
  4.  
  5. As a first language to learn, go with C. I know you might think C is an incredibly low level language that's unusable in real projects but this is a meme and it's patently untrue, C is a high level language(albeit simple) and it's perfectly usable for making games(I'll provide examples later). C is in fact perfect for beginners for a couple of reasons:
  6. a) C is simple and easy to learn. It only has 32 keywords, it provides the most essential tools which you'll find in pretty much any other language and the vast majority of languages have syntax inspired by C. You'll find learning new languages really easy after learning C (with some exceptions like functional languages).
  7. b) C is procedural. It's focused on procedures and algorithms rather than some esoteric design of object hierarchies. When coding in C you will be focused on trying to solve problems with procedures(functions) which are simply implementations of algorhithms. You will learn how a big problem can often be broken down into smaller ones, each solved with a procedure of it's own.
  8. c) C is relatively close to the hardware. It makes you understand how memory is handled by the OS on a more fundamental level which in turn gives you an understanding of how the higher level languages work "under the hood" and about their limitations and inefficiencies which you wouldn't know otherwise.
  9.  
  10. C is best learned using the book The C Programming Language by K&R (it's the only book you need, C is very simple). Supplement it by a great book Algorhithms + Data structures = Programs by Niclaus Wirth which will give you a very solid foundation to build on for the rest of your programming adventures. I also recommend using Linux for programming, it has much better enviroment for programmers. Getting set up, installing libs and overall programming in windows is a pain. Don't make programming harder for yourself with clunky enviroment, take advice from someone who lived it.
  11.  
  12. For making games in C you're going to want to use SDL2 for creating windows and simple 2D graphics, OpenGL for 3D or 2D(more complex than SDL and provides more features), OpenAL for sound. Here are tutorials (remember to heavily use official library docs as well):
  13. SDL2 tutorial: http://lazyfoo.net/tutorials/SDL/index.php
  14. OpenGL tutorials: http://learnopengl.com/
  15. http://lazyfoo.net/tutorials/OpenGL/index.php
  16.  
  17. Handmade Hero is a project of one programmer to make a full game in C from scratch (without even using graphics libraries like OpenGL), it's made by a great professional programmer who worked on The Witness and he records and streams all the coding sessions with commentary: https://handmadehero.org/
  18.  
  19. Here are some real games written in C with source codes you can scrounge through:
  20. 3D Star Trek bridge simulator: https://github.com/smcameron/space-nerds-in-space (made by one dude with a couple friends without any prebaked engine)
  21.  
  22. Minecraft clone - https://github.com/fogleman/Craft
  23.  
  24. Puzzle game in C - https://github.com/DusteDdk/Wizznic
  25.  
  26. Many old games by ID Software are in C - https://github.com/id-Software
  27.  
  28. There are many other you can find online. I hope you see that writing games in C is more than possible, not some herculean task. In fact there is no proof OOP itself speeds up the process, you can write games procedurally in high level languages and make games as fast than in OOP languages.
  29.  
  30. From C you can go anywhere
  31. a) You can get into OOP if you so desire with C++, Java, C#, D and tons more.
  32. It's really hard to recommend one book and most books you find on OOP are literal garbage (I try to be moderate here but with this I can't), while they teach you to code and you may be able to write working software, your code will suck. It's sad that it is like this but alas. One of the best ways to code in these languages would be using functional principles. So I think that, ironically, to really write good code in C++ you should dabble a bit in Haskell.
  33.  
  34. Here are some articles about this by some really good programmers on using functional principles in C++, one is from Carmack and one is from the post mortem of The Witness: http://www.gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
  35. https://mollyrocket.com/casey/stream_0019.html
  36. I recommend reading the whole post mortem, this is the same guy who makes Handmade Hero: https://mollyrocket.com/casey/index.html
  37. From regular books, Eckel and Stroustrup will get you started sufficiently in C++.
  38. Decent Java books would be Java in a Nutshell or The Java Programming Language.
  39. I have no idea about C# or D books since I don't use them.
  40.  
  41. b) Scripting languages.
  42. I recommend learning at least one at least one scripting language like Bash (extremely useful if you work in linux), Python, Lua, Ruby, JS or other. These languages have an advantage that they are interpreted and very high level and you can write code in them extremely quickly, the tradeoff is much slower performance than compiled languages, this makes them useful at quickly writing short programs(scripts) for small tasks and prototyping. Most of these have some type of game library(often more than one) you can use to make games quickly (LOVE for lua, PyGame for Python etc).
  43. Fun book on Ruby: http://poignant.guide/book/
  44. Interactive Python tutorial: http://www.learnpython.org/
  45. Another Python book: https://learnpythonthehardway.org/book/ (i haven't read this one just heard it's ok)
  46. Short and concise book on Python: http://www.greenteapress.com/thinkpython/thinkpython.pdf
  47. This one serves great as reference: http://www.diveintopython3.net/
  48. A quick overview of Lua: http://tylerneylon.com/a/learn-lua/
  49. Crashcourse in Lua, this one starts with complete script and analyses it: http://tylerneylon.com/a/learn-lua/
  50. Great book on Lua: Programming in Lua - 1st edition is available online but i'd recommend using the newest
  51. Advanced concepts in Lua: http://www.lua.org/gems/
  52. Remember to use official reference manuals(this applies to all languages): http://www.lua.org/manual/5.1/
  53.  
  54.  
  55. c) Functional languages like Haskell and Lisp are for the more adventurous people but they are worth learning just for what an eye opening experience they are. Game programming in lazy languages is especially weird due to it's real time nature. For the science minded coders, you can check out R.
  56.  
  57. Learn you a Haskell is popular, fun to read but not that great from the educational standpoint, use at your own discretion: http://learnyouahaskell.com/
  58. Good compilation of resources for learning haskell: https://github.com/bitemyapp/learnhaskell
  59. Interactive Haskell tutorial: https://tryhaskell.org/
  60. Lisp: http://www.gigamonkeys.com/book/
  61.  
  62.  
  63. There are tons of other procedural languages and many languages that don't fit into the previous specific boxes, mix and match between features or do something weird. You can explore and find whatever you like. Everything is up to you. Good luck with your games.
  64.  
  65.  
  66.  
  67. Some afterthoughts I decided to just slap on the end cause I ain't no writer:
  68.  
  69. I know OOP seems like all the rage now, just don't think it's going to be a godsend that solves programming problems for you. OOP is in fact really not that great and doesn't actually provide any advantage it originally promised over procedural imperative programming. OOP is just popular because it's easy to superficially teach in a corporate enviroment to create armies of code monkeys that write really bad code. Popularity has an advantage of tons of libraries but even that is a bit of a hidden disatvantage as most libraries are shoddily written and not as universal as you'd think. If you want to make an argument about "reinventing the wheel" then please realize that libraries are not wheels but complex pieces of code which you have no idea how they're written, and they might not be implemented the way that fits your problem domain. So just be careful and don't overly rely on external libraries and if you do make sure they are good and fit your problem(SDL2 for example is one of the best libs out there with virtually 0 overhead and provides extreme simplification and crossplatform support).
  70.  
  71. If you want a different paradigm that actually does some very interesting things then get into functional programming. It's weird, it's completely different but it provides some amazing things like referential transparency, laziness and immutable state which actually solve a lot of problems procedural programming has and OOP promised to solve but made worse(let's solve problems with mutable state by making an entire paradigm dependent on mutable state wew lad). The problems with FP are that it's often not as efficient as C since it's high level, however, Haskell compiler for example offers some performance options and with a little understanding of compilation you can optimise the heavy parts of code for C-like performance. There's an extra benefit to learning these since functional principles can be applied in any language.
  72.  
  73. Hacking: The Art of Exploitation by Jon Erickson - with all the shitty meme books on "hacking" it can be hard to identify any serious ones so I decided to throw one in here. This one is good. Really fucking good. However it's also pretty terse and you should already know how to code and know C pretty well. It's worth reading even if you're not planning to make a career in security because it will teach you a lot about the inner workings of operating systems.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement