News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Need Programming Advice  (Read 8042 times)

Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3532
    • View Profile
    • Aeon Genesis
Re: Need Programming Advice
« Reply #20 on: March 04, 2015, 06:27:18 pm »
I think you exagerate a little when you say "incredible awkward". I've read quite often code by other, and common Python code is generally (not always) much easier to understand than C++ for example.

As for the untyped things, as far as it means anything (it's dynamically typed, which is different from what you said, but I suppose you know it), I agree that it's not a good thing for a beginner. But it's sometimes really handful :) And Python works much better as a first language for complete beginners (then again, from a teacher point of view).
I

Working in an enterprise environment with python driving automated tests and having a shared codebase that half a dozen engineers contribute to and have to make use of, figuring out exactly what any given object is supposed to do, what member methods it contains, and how to access the data it holds when said engineers don't comment their code? Trust me, it's a massive headache. I've used the analogy before elsewhere, but in my experience trying to use someone else's python code in yours is like coming into a ten-season TV series halfway through the sixth season.

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Need Programming Advice
« Reply #21 on: March 04, 2015, 07:04:22 pm »
If you want to learn 6502, you're best off just starting there. The higher-level stuff doesn't really have anything to do with programming NES games.
^^^ THIS ^^^

KaioShin

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 5698
    • View Profile
    • The Romhacking Aerie
Re: Need Programming Advice
« Reply #22 on: March 05, 2015, 03:53:53 am »
To reply to some questions on the BASIC part and the level of what I know.  The book states BASIC quite a bit in its introduction chapter so it made me believe that there is something else to learn beforehand.  Again, I have no clue if this BASIC programming bit was necessary or not to learn.  For the level of programming that I know, just extremely simple stuff like changing the hexadecimal points around for the color palettes and that's about it (some sort of YouTube video showed something about it while using FCEUX.)

What Dr. Floppy said. That's just รก common beginner programming language from the time when the NES was brand new, but it's not relevant for romhacking or learning NES ASM. Just ignore that stuff.
All my posts are merely personal opinions and not statements of fact, even if they are not explicitly prefixed by "In my opinion", "IMO", "I believe", or similar modifiers. By reading this disclaimer you agree to reply in spirit of these conditions.

Bregalad

  • Hero Member
  • *****
  • Posts: 2751
    • View Profile
Re: Need Programming Advice
« Reply #23 on: March 05, 2015, 10:59:08 am »
Quote
You're a good example of what I said before that people make it look so hard when it really isn'
I didn't said C++ was "hard", just that the number of concepts that you have to learn before knowing what is going on is high.

Namely, in order to write a C++ program and have a good in-depth understanding of what is going on (not trying random stuff until it appears to work), in addition to the normal unavoidable basic stuff that comes with every language (loops, conditional, variables, functions), you also need to learn :

  • What a pre-processor is and how it expands macros (and how to peek at your code after the macro's expansions if you have trouble)
  • What separate compilation is, how to separate stuff in header and source files, what is a linker
  • Namespaces
  • The basic integers and double types
  • Storage allocation (stack, heap and bss)
  • Concept of a segfault / bad memory access in order to be able to localize bugs and fix them
  • Functions overloading
  • Implicit types conversion
  • How to use pointers correctly, what is a NULL pointer, how the '*' sign is overloaded for 3 unrelated things
  • Strings constants, how they decay into pointers
  • Arrays, how they are initialized, how they decay into pointers
  • Memory management with heap, malloc and free, and new and delete
  • How to use references, the difference with pointers, how the '&' sign is overloaded for 3 unrelated things
  • Name mangling, why the linker error messages are so obscure and how to fix this
  • How to deal with const correctness (and to a lesser extent, the rarely used volatile correctness
  • What struct, unions and enumerations are, and how you can create your own types using them
  • What classes are and how they are an extension of struct
  • Concept of member functions (a.k.a methods), how they extend a struct
  • Concept of "private" members / methods, how to use them, how they relate to const correctnes and private variables
  • Concept of "friends" functions
  • Constructors, desctructors, copy constructors, assignement constructors
  • How to correctly manage memory within class, using the rule of three
  • Creation of temporary objects
  • Operator overloading, how it makes C++ (in my subjective point of view) powerful (in order to understand what std::count is for example)
  • The 'static' keyword and how it is overloaded for 4 completely different things
  • Concept of inline functions and member functions, how to make them correctly in a .cpp or .hpp file
  • Templates and genericity
  • A deep knownledge of the standard library, (std::string, std::vector, etc, etc...)
  • A grap of containers and iterators
  • Inheritance, virtual functions and such object-oriented concepts

Then you can being to have an understanding of C++.... If you don't have a good understanding of at least what I wrote above, then your knownledge of C++ is superficial and you run into the risk of writing bad programs that leak memory and/or are packed with bugs. None of what I listed is particularly hard to learn, in fact most of it is very easy in my opinion, but still the number of concepts to learn is incredibly large as opposed to other programming language.

As for whether it's a good language or not it's completely opinion based. I think it's probably not that good per se, but being compiled it is fast enough, and is so wide that if you want to do something you can almost certainly do it in an elegant and sensible way using C++.

Finally I agree with what everyone else said, if you want to learn 6502 just do so, C-family languages are highly unrelted and will just get in the way.

Quote
[C] language is close enough to ASM to make sure your mind is tuned for the job ahead.
In my opinion this is yet-another fallacy over C that everyone repeats again and again but it does not make it become true.
« Last Edit: March 05, 2015, 11:08:37 am by Bregalad »

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Need Programming Advice
« Reply #24 on: March 05, 2015, 12:26:56 pm »
Fortunately, 6502 ASM isn't as daunting as it may seem. There are only 151 opcodes, and I find myself only using 36 of them on any regular basis. (Yes, I actually sat down and counted last week. And prior to the exact-count, I predicted it would be something like 15-20.)

The 6502 isn't purely orthogonal by design, but it's just orthogonal enough that you don't have to memorize every opcode individually. The x1-x5-x9-xD series is a good example of this: learn eight basic functions and eight addressing modes, and you've already got 63 opcodes down! Not to mention the subsequent patterns/applications beyond...

Say.
Any chance the Y-A-X clusters* inspired the NES Sprite-OAM YtAX format?

*Whenever a 6502 instruction has one version for each of the three main registers, and the three are clustered together, they always occur in the order of: Y-version, A-version, X-version.

Jorpho

  • Hero Member
  • *****
  • Posts: 4781
  • The cat screams with the voice of a man.
    • View Profile
Re: Need Programming Advice
« Reply #25 on: March 05, 2015, 09:02:19 pm »
To reply to some questions on the BASIC part and the level of what I know.  The book states BASIC quite a bit in its introduction chapter so it made me believe that there is something else to learn beforehand.  Again, I have no clue if this BASIC programming bit was necessary or not to learn.  For the level of programming that I know, just extremely simple stuff like changing the hexadecimal points around for the color palettes and that's about it (some sort of YouTube video showed something about it while using FCEUX.)
BASIC was everywhere thirty years ago.  (The success of Microsoft's BASIC interpreter did much to shape its history, in fact.)  But that was then, and few would recommend it nowadays.

When it comes to things like this my inclination is to suggest getting your toes wet before deciding if you want to go any deeper.  Programming in any form can be a challenging exercise in patience.  But I've heard of some people learning programming starting with assembly, so I guess it can be done if you have the right mindset.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Need Programming Advice
« Reply #26 on: March 06, 2015, 09:58:42 am »
But I've heard of some people learning programming starting with assembly...
Mea maxima culpa.

...and it was fun, too!  8)