Thread: Learning Coding

Page 2 of 4 FirstFirst
1
2
3
4
LastLast
  1. #21
    Deleted
    How my uni teaches programming is learning the basics with python and then moving on to C in order to understand what computer actually does with the code. I like that approach.

  2. #22
    I admit it totally depends on how you write the C code. Your stack example is a great one; considering these two functions:

    void func(struct foo x);
    void func(struct foo *x);

    The former will put the entire structure on the stack (could be hundreds of bytes!). The latter will put a pointer to it on the stack (typically 4 bytes). Of course how this maps to calling conventions is a completely separate topic, but the idea is there. No compiler can optimize you out of the performance hit you take with option 1. This is why writing C code can be hard at times; and for a beginner effort you don't even want to consider these things. Thus Python is my recommendation for beginners.

    But in general, a compiler will always beat a human when it comes to writing efficient assembly/instruction code. If you have an algorithm contained within one compilation unit, with restricted access to memory, a compiler should be able to write the best possible assembly/instructions for this algorithm. If there is a better implementation available it is usually because the compiler had to consider constraints that you don't care about as a programmer. For example; whether memory access is restricted to one pointer or not; or whether memory is defined to never change content. Usually it is easier to add such information to the function by adding restrict as needed in time critical code, than it is to rewrite the time critical code by hand.

    There is nothing preventing you from doing it yourself by hand of course. There are even situations where this makes a lot of sense; especially when dealing with instruction set extensions that the compilers aren't too good at handling. ARM NEON is a great example; the compilers out there aren't too good at taking advantage of this instruction set extension, and thus there is a lot of gain to write code that can (I've seen a 10x performance gain). Since the use of ARM NEON cannot be forced in C easily; you''re left with doing it by hand.

    But - those are special cases. I maintain that the compilers we use these days are pretty darned good. When it comes down to it; a compiler should beat a human, every day. If not, look at your design or constraints. If it still isn't working out, you need a better compiler.
    Non-discipline 2006-2019, not supporting the company any longer. Also: fails.
    MMO Champion Mafia Games - The outlet for Chronic Backstabbing Disorder. [ Join the Fun | Countdown | Rolecard Builder MkII ]

  3. #23
    Quote Originally Posted by Danner View Post
    Ultimately, the language you pick does not matter.
    But it will have some serious implications on how you get there.

    Python
    Pros: Very straightforward to learn, clean structure. Fantastic 3rd party support.
    Cons: It's a high level scripted language; don't expect bleeding edge performance.

    Python is a great place to begin. It will offer a sandbox where you can easily master the concepts of variables, arrays, conditionals and loops, functions, classes and all the basics. The interactive mode makes debugging very trivial. The language is generally considered the de-facto training language; it replaced Java at my university. And it's powerful enough to do almost anything. Anything you master in Python is transferrable to any other C-like language.

    Python has some of the best library support out there. There is a library for anything; from game development to advanced sound processing. The hard part is finding which library you want, the sheer range of options is sometimes a bit daunting.

    At the end of the day, it is a high level scripting language. Usually this doesn't matter too much, but at the end of the day every instruction matters if you want bleeding edge performance. This is why C/C++ is still the major game development language. Still, you can get very far with Python, and it's not wasted effort to go there. Quite often you will find AI and tools to be written in high level programming languages like Python, while the main game engine is written in C/C++.

    Learning difficulty: Low(est)
    Setup difficulty: Medium. Need an interpreter.

    Javascript
    Pros: Very slick language.
    Cons: Javascript's browser integration makes grown men cry.

    Let me state the improbable first. Javascript is my ideal programming language. The syntax is c-like, yet it contains all the powerful features you ever wanted. Javascript is a fantastic language, and it runs really fast in all browsers. Unlike Python, you don't need that interpreter to run your game; you have the browser to do this. This means developing javascript programs is incredibly easy. The only setup you need is a very simple web page.

    At least that's the theory. In practice you will be limited to operating in your browser. I don't mind browser games, and the stuff you can do in javascript far exceeds what you can do in adobe flash. But sometimes you want a standalone app, and javascript can't really offer it. Also, each browser is slightly different. And that means your game is slightly different for every browser. You'd imagine this would be a solved problem in 2013, but not so. You still need to relate to the Browser "Document Object Model (DOM)". And that part of javascript sucks donkey, being designed by the same people who thought a TV remote should have 120 buttons and use 14 different standards.

    Learning difficulty: Low, medium for the DOM
    Setup Difficulty: Negligible if you know some HTML, far steeper if you don't.

    C / C++
    Pros: SPEED!
    Cons: With great power comes great responsibility

    If you want total control of your computer, you need to learn assembly. In theory, assembly allows you the maximum performance possible, as you can optimize anything. However, learning assembly is a pain in the ass, and it is such a low level programming language that it's hard to actually do anything; even the simplest operation can take a day to program. Also, compilers are so good today that assembly programming is usually just wasted time. Your compiler can always outdo a human when it comes to writing optimal code.

    This is where C comes in. You write program code that the compiler can easily translate into machine code, almost in a 1:1 fashion, with little to no middle layers. And since C is a higher-than-assembly level language, you can easily do a days worth of assembly code in 5-10 lines of C code. Learning assembly is a great skill to have. But I wouldn't want to code in it. That's why I code in C.

    C is IMO the ultimate programming language. With C you not only have to decide what you want to do; you also have to decide how it is done. If you pick the right "howto", you get code that translates into the fastest machine code equivalent, and that means the fastest possible game. But if you pick a poor algorithm, operation or scheme to do things, you will run slower. C gives you the power to do exactly what you want. If you wanted the power to shoot yourself in the foot; C will happily oblige. To master C, you need to not only consider what you want to do, but also how you want to do it. This is true for most languages, but C in particular. Writing code in C takes a little longer for a beginner as a result.

    C doesn't do anything for you automatically. Higher level code like Python f.ex does garbage collection; whenever you stop using some memory it will be reclaimed and can be reused. In C... that memory is just lost (a memory leak). You need to actively consider when memory is done being used, and actively free it. That's an additional burden on the programmer. But since you can explicitly control where memory is allocated and freed, you can ensure that no unnecessary garbage collection takes place. As a result, C programs just won't have lagspikes where garbage collection occurs as a result. There is never any hidden side effects!

    The biggest problem of C is that the libraries out there are kinda messy. The standard C library sucks, and is widely considered to be misdesigned on many levels.

    C++ seeks to redeem the issues of C. And it is widely considered to have worsened the deal. Mainly it adds additional functionality to C - things like classes, exceptions and inheritance. This makes it easier to do higher level stuff, and it also means more things happen automatically for you, so that you don't have to consider them when coding. However; that directly contradicts the main benefit of C - no hidden side effects. Where in C it is easy to shoot yourself in the foot, C++ offers you easy limb-amputation functionality. It's easy to find an error in C code. It can be a royal PITA to find an error in C++ code. C++ also has some really awkward syntax. I like C. C++ is great if you avoid the murkier parts of it, but I wouldn't want to start there.

    Learning difficulty C: Medium
    Learning difficulty C++: Medium, if you have mastered C. Otherwise hard.
    Setup difficulty: Medium. Need to care about compilers and stuff.

    --

    To the OP: I recommend starting with a simple tutorial in pyhton. Learn what a variable is. Learn what an array is. Learn what an if statement is. Learn what a for and while loop is. Learn what a function is. Learn what a class and object is. Make a very small text based adventure game or something.
    "You are in a room with low light. Go north or west?"

    Then make yourself a pong game in python. It's a great learning experience.

    Once you have that down, try out C. Do the same.
    I wan to say, as a person with a B.S and Masters in Computer Science from Computer Science from Carniege Mellon University... this is an excellent excellent post and people should read it.

    As I strongly encourage learning Python-> Java -> C before C++. Going from Java to C will be a frustrating reality check, but it's experience and knowledge building. It's like going from Duplos (Python) to Legos (Java) to an unpainted and disassembled 5000 piece model (C). By the time you get to C++, you really have an appreciation of the power of what you can do though. I would not skip Java between Python and C. It's ideal to learn data structures in because of it's built in garbage collection.

  4. #24
    Deleted
    Jave/C# are not good places to start - they are object orientated languages and this approach is difficult to grasp, especially more advanced parts of it.

    Do not start with scripting language (bash, python, php, ruby, javascript) etc, because you will not understand how things work there and get spoiled which will translate into hard migration to other languages.

    I strongly encourage you to start with C or C++ if the book/tutorial you find heavily focuses on procedural part of it, leaving Objects for later.

    To make things easier grab yourself free copy of Micro$oft Visual Studio Express - this is as good as IDEs goes at the moment. Or if you do not like MS, Code::Blocks or Netbeans will do just fine.

  5. #25
    If you really wanna start small OP, I'd suggest looking at "BASIC" programming language from 1980's computers. Sure, it's almost useless today, but it will give you the fundamental ideas of how programming works.

    I started with BASIC when I was 13 by reading an old 1983 book about it, and it really taught me a lot.

  6. #26
    Quote Originally Posted by chazus View Post
    I hear a lot of people starting with Ruby or Python. Python is often a starter for a lot of people. The only reason I wouldn't recommend Java is that A) It's primarily a web design language, and learning other languages first (Python, C, Ruby) give you a better "understanding of code", and B) If you want to learn Java, you're probably also going to want to learn HTML and CSS to make it useful.

    There are a ton of "which should I start first" guides, and it may well depend on your level of understanding, as well as what you want to do. Website design? Mobile apps? iOS development? High level animation/design?
    I'm guessing you're thinking of JavaScript if you're suggesting he learn HTML and CSS as well. Java and JavaScript are two completely different things.

  7. #27
    Deleted
    Quote Originally Posted by Zamfix View Post
    I'm guessing you're thinking of JavaScript if you're suggesting he learn HTML and CSS as well. Java and JavaScript are two completely different things.
    Or he could be talking about JaveEE and assuming that all other members of Java family are not worthy!

    But I do agree that he probably does not know wtf he is talking about

  8. #28
    Quote Originally Posted by Duronos View Post
    Well you see that's the thing, I want to know everything down to the most basic form and I've heard from others that C is huge for gaming but wasn't fully sure. I want to become a programmer in the future and from what you're saying C is the place to start no matter how hard it is.
    Wanting to know everything from the ground up is a very good idea, IMHO. Now to do that I would strongly recommend by learning C.

    Programming languages tend to fall into one of four 'bins' - imperative languages, object-orientated languages, functional programming languages and logic-based programming languages. I would strongly recommend learning at least the basics of a language form one of each of this bins as it will expose you to new programming techniques. Additionally, by learning one language from each bin you will be well positioned to learn a related language if the need arises. Some examples are:

    1. Imperative - C, Basic (not visual basic), Algo-60, Fortran, Pascal
    2. Object-orientated - Smalltalk, Oberion, Python, Simula, Java
    3. Functional - SML (any flavor, SML-NJ seems to be most well known), Haskell, Lisp
    4. Logic based - Prolog

    You will note that some very-well known languages are not on the list, C++ for example. The reason is that C++ really spans two areas (imperative and object-orientated), there is nothing that prevents you from writing imperative style code in C++.

    In addition to learning programming languages, you will need to learn data-structures and algorithms. There are numerous books teaching both of these topics.

    Finally, you might be interested in reading the "Wizard Book" (Structure and Interpretation of Computer Programs, by Abelson, Sussman, and Sussman.
    see books web-site) it gives a good over view of how to write programs and how to think about them. It is used in the introductory CS courses at MIT (only problem might be that the language of choice is Scheme (a dialect of Lisp)).

  9. #29
    The Lightbringer Hottage's Avatar
    15+ Year Old Account
    Join Date
    Feb 2009
    Location
    The Hague, NL
    Posts
    3,835
    Quote Originally Posted by larix View Post
    Jave/C# are not good places to start - they are object orientated languages and this approach is difficult to grasp, especially more advanced parts of it.

    Do not start with scripting language (bash, python, php, ruby, javascript) etc, because you will not understand how things work there and get spoiled which will translate into hard migration to other languages.

    I strongly encourage you to start with C or C++ if the book/tutorial you find heavily focuses on procedural part of it, leaving Objects for later.

    To make things easier grab yourself free copy of Micro$oft Visual Studio Express - this is as good as IDEs goes at the moment. Or if you do not like MS, Code::Blocks or Netbeans will do just fine.
    I found C# very easy to grasp, however I was previously working on PHP so Object Oriented Programming was familiar to me.
    Dragonflight: Grand Marshal Hottage
    PC Specs: Ryzen 7 7800X3D | ASUS ROG STRIX B650E-I | 32GB 6000Mhz DDR5 | NZXT Kraken 120
    Inno3D RTX 4080 iChill | Samsung 970 EVO Plus 2TB | NZXT H200 | Corsair SF750 | Windows 11 Pro
    Razer Basilisk Ultimate | Razer Blackwidow V3 | ViewSonic XG2730 | Steam Deck 1TB OLED

  10. #30
    C++ is way to go in video game realm.

  11. #31
    Deleted
    Quote Originally Posted by mrgummage View Post
    I found C# very easy to grasp, however I was previously working on PHP so Object Oriented Programming was familiar to me.
    that's my point, if you already have basics it is rather simple to switch to c#. But for someone who have no previous programming experience throwing right into heavy OO language might be confusing

  12. #32
    Elemental Lord Duronos's Avatar
    10+ Year Old Account
    Join Date
    May 2009
    Location
    In the jungle
    Posts
    8,257
    Well I did this last night and did it again today (it actually worked better today) and just finished this now after trying to do it myself without looking at any Youtube videos. I was joking with my dad so don't think much of the message.



    - - - Updated - - -

    Quote Originally Posted by Danner View Post
    Ultimately, the language you pick does not matter.
    But it will have some serious implications on how you get there.

    Python
    Pros: Very straightforward to learn, clean structure. Fantastic 3rd party support.
    Cons: It's a high level scripted language; don't expect bleeding edge performance.

    Python is a great place to begin. It will offer a sandbox where you can easily master the concepts of variables, arrays, conditionals and loops, functions, classes and all the basics. The interactive mode makes debugging very trivial. The language is generally considered the de-facto training language; it replaced Java at my university. And it's powerful enough to do almost anything. Anything you master in Python is transferrable to any other C-like language.

    Python has some of the best library support out there. There is a library for anything; from game development to advanced sound processing. The hard part is finding which library you want, the sheer range of options is sometimes a bit daunting.

    At the end of the day, it is a high level scripting language. Usually this doesn't matter too much, but at the end of the day every instruction matters if you want bleeding edge performance. This is why C/C++ is still the major game development language. Still, you can get very far with Python, and it's not wasted effort to go there. Quite often you will find AI and tools to be written in high level programming languages like Python, while the main game engine is written in C/C++.

    Learning difficulty: Low(est)
    Setup difficulty: Medium. Need an interpreter.

    Javascript
    Pros: Very slick language.
    Cons: Javascript's browser integration makes grown men cry.

    Let me state the improbable first. Javascript is my ideal programming language. The syntax is c-like, yet it contains all the powerful features you ever wanted. Javascript is a fantastic language, and it runs really fast in all browsers. Unlike Python, you don't need that interpreter to run your game; you have the browser to do this. This means developing javascript programs is incredibly easy. The only setup you need is a very simple web page.

    At least that's the theory. In practice you will be limited to operating in your browser. I don't mind browser games, and the stuff you can do in javascript far exceeds what you can do in adobe flash. But sometimes you want a standalone app, and javascript can't really offer it. Also, each browser is slightly different. And that means your game is slightly different for every browser. You'd imagine this would be a solved problem in 2013, but not so. You still need to relate to the Browser "Document Object Model (DOM)". And that part of javascript sucks donkey, being designed by the same people who thought a TV remote should have 120 buttons and use 14 different standards.

    Learning difficulty: Low, medium for the DOM
    Setup Difficulty: Negligible if you know some HTML, far steeper if you don't.

    C / C++
    Pros: SPEED!
    Cons: With great power comes great responsibility

    If you want total control of your computer, you need to learn assembly. In theory, assembly allows you the maximum performance possible, as you can optimize anything. However, learning assembly is a pain in the ass, and it is such a low level programming language that it's hard to actually do anything; even the simplest operation can take a day to program. Also, compilers are so good today that assembly programming is usually just wasted time. Your compiler can always outdo a human when it comes to writing optimal code.

    This is where C comes in. You write program code that the compiler can easily translate into machine code, almost in a 1:1 fashion, with little to no middle layers. And since C is a higher-than-assembly level language, you can easily do a days worth of assembly code in 5-10 lines of C code. Learning assembly is a great skill to have. But I wouldn't want to code in it. That's why I code in C.

    C is IMO the ultimate programming language. With C you not only have to decide what you want to do; you also have to decide how it is done. If you pick the right "howto", you get code that translates into the fastest machine code equivalent, and that means the fastest possible game. But if you pick a poor algorithm, operation or scheme to do things, you will run slower. C gives you the power to do exactly what you want. If you wanted the power to shoot yourself in the foot; C will happily oblige. To master C, you need to not only consider what you want to do, but also how you want to do it. This is true for most languages, but C in particular. Writing code in C takes a little longer for a beginner as a result.

    C doesn't do anything for you automatically. Higher level code like Python f.ex does garbage collection; whenever you stop using some memory it will be reclaimed and can be reused. In C... that memory is just lost (a memory leak). You need to actively consider when memory is done being used, and actively free it. That's an additional burden on the programmer. But since you can explicitly control where memory is allocated and freed, you can ensure that no unnecessary garbage collection takes place. As a result, C programs just won't have lagspikes where garbage collection occurs as a result. There is never any hidden side effects!

    The biggest problem of C is that the libraries out there are kinda messy. The standard C library sucks, and is widely considered to be misdesigned on many levels.

    C++ seeks to redeem the issues of C. And it is widely considered to have worsened the deal. Mainly it adds additional functionality to C - things like classes, exceptions and inheritance. This makes it easier to do higher level stuff, and it also means more things happen automatically for you, so that you don't have to consider them when coding. However; that directly contradicts the main benefit of C - no hidden side effects. Where in C it is easy to shoot yourself in the foot, C++ offers you easy limb-amputation functionality. It's easy to find an error in C code. It can be a royal PITA to find an error in C++ code. C++ also has some really awkward syntax. I like C. C++ is great if you avoid the murkier parts of it, but I wouldn't want to start there.

    Learning difficulty C: Medium
    Learning difficulty C++: Medium, if you have mastered C. Otherwise hard.
    Setup difficulty: Medium. Need to care about compilers and stuff.

    --

    To the OP: I recommend starting with a simple tutorial in pyhton. Learn what a variable is. Learn what an array is. Learn what an if statement is. Learn what a for and while loop is. Learn what a function is. Learn what a class and object is. Make a very small text based adventure game or something.
    "You are in a room with low light. Go north or west?"

    Then make yourself a pong game in python. It's a great learning experience.

    Once you have that down, try out C. Do the same.
    I think I'll try Python then, Java is nice but I did notice there were a few things I didn't understand (I understood other words and what they meant every now and then like displaying a shell) but everyone is saying Python so why the hell not.
    Hey everyone

  13. #33
    Quote Originally Posted by Duronos View Post
    I think I'll try Python then, Java is nice but I did notice there were a few things I didn't understand (I understood other words and what they meant every now and then like displaying a shell) but everyone is saying Python so why the hell not.
    Mind you, python is not easiest language in the world. You will have "I didn't understand" in any language so brace yourself.

  14. #34
    Elemental Lord Duronos's Avatar
    10+ Year Old Account
    Join Date
    May 2009
    Location
    In the jungle
    Posts
    8,257
    I actually have another question, should I learn the terms for each language before I start using it?
    Hey everyone

  15. #35
    Mechagnome
    10+ Year Old Account
    Join Date
    Mar 2011
    Location
    Savannah, GA
    Posts
    544
    Quote Originally Posted by Duronos View Post
    I want to start teaching myself how to code but my question is where to start? Which language is good to start on because I need that initial stepping stone so I can move forward.

    Well actually I think I've sort of figured it out, Java sounds like a good place to start.
    Maybe look into this...

    http://www.processing.org/

    I could not get over the hump with any other language. This helped me tremendously. There are some very good beginner texts for it on Amazon too.

  16. #36
    C/C++ is the only way to go in my opinion. Once you figure out the libraries, and go through some debugging in C/C++, everything else will seem like a joke. Learning Java and python after those two was child's play.

  17. #37
    Quote Originally Posted by Duronos View Post
    Preferably something that could be made into a little video game over time, I'd assume that's high level animation stuff. I plan to make a video game one day or to work on one I guess.
    I would start with C#. Similar to java syntax and you can interface with directX better than java

  18. #38
    Deleted
    I hate codeacademy purely for the bad environments. I just can't get it out of my head. You don't run code like that.

  19. #39
    Elemental Lord Duronos's Avatar
    10+ Year Old Account
    Join Date
    May 2009
    Location
    In the jungle
    Posts
    8,257
    Alright so I figured out the difference between type and class but correct me if I'm wrong. Class is the object, the main thing and type is the interface inside of the class, again correct me if I'm wrong. Also a superclass is explaining a certain part of a class in greater detail?

    Also, I want to understand what a term does before I implement into coding so that's why I'm just asking you guys to clarify on things like this.
    Last edited by Duronos; 2013-12-31 at 05:45 AM.
    Hey everyone

  20. #40
    I am Murloc! crakerjack's Avatar
    10+ Year Old Account
    Join Date
    Sep 2010
    Location
    Ptwn, Oregon
    Posts
    5,014
    Thought I'd fall in love with coding, but i took a coding class in high school and realized how much I hate it... maybe it was also because the class was overfull and there weren't enough computers for everyone, so i'd be stuck watching someone code, which didn't help me memorize it at all. Even when I was coding, it was stupid stuff like font size and font color... I just wanted to make games, but I realized how much I hated the actual work that went into video games.
    Most likely the wisest Enhancement Shaman.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •