Results 1 to 8 of 8
  1. 10-22-2010, 11:59 PM
    #1

    The Scrub

    Expand

    RatzloffToYa's Avatar
    • My Statistics
      Join Date
      Aug 2010
      Location
      Sweden
      Posts
      82
      Contest Points
      0
      Beli
      0
      Received Thanks
      14

    Default [Guide] Basic/Simple programming terms and concepts

    What this guide is:
    Basic understanding of programming terms.
    Basic understanding of programming concepts.
    More reference than a guide.

    What this guide isn't:
    A tutorial.
    How to program something.
    How to make 1337 haxx.

    Who this is for:
    Beginner programmers
    People who learned how to program by themselves (seriously)
    People who have never programmed before, and want to see what it's about.

    This guide is about giving some general concepts that you will see in all programming languages. If you have never programmed before, and want to get in to it, I would suggest reading this guide for some background information so you understand what is going on.

    So let's begin.

    Part 1: Memory, bytes, bits, and binary.

    A good place to start is memory. Memory stores actively accessed information. A smart man (whose name I forgot) came up with the idea that data that doesn't need to constantly be accessed can run slowly while data that needs to be accessed a lot must run quickly. This is very much in use today; with hard disks (slow, accessed less often) and RAM (fast, accessed a lot).

    Memory holds data for the program. It stores variables, information, and whatever else a program needs to run. You may know memory better as "RAM", or Random Access Memory. RAM is divided in to bytes.

    Bytes
    You have more than likely heard this term before. Each byte in RAM has exactly one address, and stores exactly one value. A byte can be divided even smaller, into what are called bits.

    Bits
    Bits are parts of bytes, as stated before. Each bit can have one of two values: 1 (on) or 0 (off). This is where binary comes in. Yes, you will learn the concept of binary. It's not that hard.

    So let's learn some binary, shall we?

    You know how to count to 10, right? And 100?
    So in the number 10, how many digits do you have? 2.
    What does that first digit represent?
    It represents the number of tens there are in the number.
    So in the number 34, there are three tens and four ones.

    Binary works very similarly, except instead of 10 possibilities for a digit (0-9), there are only 2 (0 and 1).

    Here's our 8 bits.

    0 0 0 0 0 0 0 0

    That last bit represents the number of 1's.
    0 0 0 0 0 0 0 1 = 1
    The one next to it represents the number of 2's.
    0 0 0 0 0 0 1 0 = 2
    The one next to it represents the number of 4's.
    0 0 0 0 0 1 0 0 = 4
    The one next to it represents the number of 8's.
    0 0 0 0 1 0 0 0 = 8

    Are you noticing a pattern?
    Each place you go, you increase by a power of 2 each time.
    Code:
    2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0
    0    0    0    0    0    0    0    0
    128  64   32   16   8    4    2    1
    So the leftmost digit in a binary number represents the 128th's place.

    Have some practice for yourself with binary numbers.

    1. 00110110
    2. 01001111
    3. 10001000
    4. 10101010

    Answers:
     

    1. 2 + 4 + 16 + 32 = 54
    2. 1 + 2 + 4 + 8 + 64 = 79
    3. 8 + 128 = 136
    4. 2 + 8 + 32 + 128 = 170


    One more important thing:
    1 1 1 1 1 1 1 1

    This is the maximum value for a single byte.
    Don't bother working it out, I'll just tell you that it's 255.
    In this next section, I will cover how these bytes work together to make bigger types of data (called datatypes, so original).

    So what have we learned so far?
    Summary
    1) RAM is divided into many, many different sections called bytes.
    2) Bytes are comprised of 8 bits.
    3) Bits have 2 positions: 1 (on) and 2 (off).
    4) These combinations of on's and off's work together to make up binary.
    5) The maximum value for a byte is 255.

    Part 2: Primitive data types

    Bytes have a max value of 255. So I'm sure there's one of you reading this wondering how you could possibly have a number that's above 255 on a computer. They do it all the time, but how?

    The answer, my friend, is datatypes.

    Many programming languages have different sets of datatypes, yes, but here are the most common "primitive" data types.

    Integers
    Facts about integers:
    -They are signed or unsigned (more about that later).
    -They cannot have decimals.
    -There are 4 commonly used integers.

    byte
    Hey, we know what this is! It's a single byte. Its value is between 0 and 255. Not much else to say.

    short
    Also called a 16-bit integer, or if you're oldschool, also called a Word. This is comprised of, well, 2 bytes. Hence, the name 16-bit integer (2 * 8 = 16). It can hold values from -32768 to +32767.

    int
    One of the most common datatypes, and probably (if not the) most used integer. It uses 32-bits, and 4 bytes in memory. Oldschool name is a DWord, or Double word. It can hold values from -2 ^ 31 to 2 ^ 31 - 1. Yeah, it's somewhere around 2.1 billion, in case you were wondering. Oh, but wait, it gets better and even larger numbers. Get ready for...

    long
    Long values have 64 bits, and are 8 bytes long. They range from -2 ^ 63 to 2 ^ 63 - 1. I honestly have no idea as to what number that would be. I have no idea, and I have never needed to know. Longs are not uncommon, but not common at the same time. They just pop up every once in a while.

    Floating points
    Facts about floating point numbers:
    -They are decimal numbers.
    -There are 2 commonly used floating point numbers

    Float
    Floats hold 4 bytes (I believe) and have an accuracy that differs. All you need to know that they are accurate, but should not be used for very precise math.

    Double
    Doubles hold 8 bytes and also have an accuracy that differs. They are called "doubles" because they are double-precision floating point numbers. They are more accurate than floats at the cost of more memory used.

    Single-byte values
    Facts about single byte values:
    -They take up, well, only one byte.
    -There are 2 of them that are commonly used (and are not the "byte" datatype stated above).

    Boolean
    A boolean value holds a true or a false. Usually, 1 is held for "true" and 0 is for "false". In some programming languages, however, booleans are considered as "false" if their value is 0, and "true" if their value is anything else.

    Character
    Generally referred to as "char". They take up one byte, and use the ASCII encoding (pronounced ask-ee). This includes all English alphabet letters. Each letter, both upper case and lower case, has their own unique value. 255 characters in all.

    That's all about the most common primitive data types. These are somewhat complicated, so don't feel stressed if you don't remember everything. Even I, a no-life loser who knows most of these by heart, had to look some stuff up to confirm some thoughts that I had.

    One final note:
    Signed vs unsigned
    If you start in a less complex programming language, you won't hear much of this, but it is a very important concept to understand.
    Signed numbers can go negative.
    Unsigned numbers cannot go negative.

    In fact, the integer value of -1 isn't really -1 at all, but it is 2^32.
    The way signed numbers work is that halfway through their range, it goes into the negatives and starts counting up again.
    So 32766, 32767, -32768, -32767...

    The difference between signed and unsigned numbers really is only significant with small amounts of Java and C#, and much more so with C++, C, and assembly.

    Here's a quiz for you.

    1. How many bytes does an "int" datatype have? How many bits?
    2. Name all four integer datatypes.
    3. How many bytes does a float use in memory? How many does a double use?
    4. What does a boolean represent?
    5. What is the range of a short?

     

    1. 4 bytes, 32 bits.
    2. Byte, short, int, long.
    3. Float uses 4 bytes, double uses 8 bytes.
    4. Booleans represent a true or false value.
    5. They range between -32768 and 32767.


    What we have learned in this part:
    1) Bytes are arranged in fashions to make them more useful, called datatypes.
    2) There are 4 commonly used integer types.
    3) There are 2 commonly used floating point number types.
    4) There are 2 commonly used single byte types.
    5) ASCII is the table of characters assigned to unique values.

    The conclusion
    I know, I know, it's a short guide. But I can't think of much else to put in here. I wanted it to be a beginner's guide and help for people who have a few holes in their knowledge about programming. It's helpful to know.

    Leave me feedback. I want to know what people think, and whether or not I should make a follow-up intermediate guide.

    Thanks for reading.

  2. The Following 4 Users Say Thank You to RatzloffToYa For This Useful Post:

    feebas200 (02-06-2011), GENRE (11-08-2010), Gold kaiser//~ (10-26-2010), PillLimey (12-05-2010)

  3. 10-29-2010, 02:48 AM
    #2

    Super Noob

    Expand

    Ignignokt's Avatar
    • My Statistics
      Join Date
      Oct 2010
      Location
      The Moon
      Posts
      43
      Contest Points
      0
      Beli
      0
      Received Thanks
      5

    Default Re: [Guide] Basic/Simple programming terms and concepts

    signed/unsigned is meaningless to the computer, it's only an abstraction of software

    as for the bit ranges

    2^8 = 256
    2^16 = 65,536
    2^32 = 4,294,967,296
    2^64 = 18,446,744,073,709,551,616

    Frankly regarding booleans and chars?

    They are bytes period. No way around it because the smallest datatype in 8086 is a byte.

    There is more I would nitpick but this is a beginner's guide.

  4. 10-30-2010, 01:31 PM
    #3

    The Scrub

    Expand

    RatzloffToYa's Avatar
    • My Statistics
      Join Date
      Aug 2010
      Location
      Sweden
      Posts
      82
      Contest Points
      0
      Beli
      0
      Received Thanks
      14

    Default Re: [Guide] Basic/Simple programming terms and concepts

    I know this. I'm just assuming that most people reading this guide are going to be starting out with C# or Java or something like that. The only point where bytes aren't primitive datatypes are in the lower-level languages, and I doubt that a beginner is going to start out with C or C++ (and succeed on their own.)

  5. 10-31-2010, 02:10 AM
    #4

    Super Noob

    Expand

    Ignignokt's Avatar
    • My Statistics
      Join Date
      Oct 2010
      Location
      The Moon
      Posts
      43
      Contest Points
      0
      Beli
      0
      Received Thanks
      5

    Default Re: [Guide] Basic/Simple programming terms and concepts

    Quote Originally Posted by RatzloffToYa
    [Dear Visitor, you're restricted from viewing links until you are registered & logged on.
    Click Here To Register Today
    I know this. I'm just assuming that most people reading this guide are going to be starting out with C# or Java or something like that. The only point where bytes aren't primitive datatypes are in the lower-level languages, and I doubt that a beginner is going to start out with C or C++ (and succeed on their own.)
    Java and C# are horrible languages to be learning anyway. I learned C/ASM on my own, then C++.

  6. 10-31-2010, 09:59 PM
    #5

    The Scrub

    Expand

    RatzloffToYa's Avatar
    • My Statistics
      Join Date
      Aug 2010
      Location
      Sweden
      Posts
      82
      Contest Points
      0
      Beli
      0
      Received Thanks
      14

    Default Re: [Guide] Basic/Simple programming terms and concepts

    Quote Originally Posted by Ignignokt
    [Dear Visitor, you're restricted from viewing links until you are registered & logged on.
    Click Here To Register Today
    Java and C# are horrible languages to be learning anyway.
    It all depends on what you're developing.

  7. 10-31-2010, 11:57 PM
    #6

    Super Noob

    Expand

    Ignignokt's Avatar
    • My Statistics
      Join Date
      Oct 2010
      Location
      The Moon
      Posts
      43
      Contest Points
      0
      Beli
      0
      Received Thanks
      5

    Default Re: [Guide] Basic/Simple programming terms and concepts

    Quote Originally Posted by RatzloffToYa
    [Dear Visitor, you're restricted from viewing links until you are registered & logged on.
    Click Here To Register Today
    It all depends on what you're developing.
    There are better alternatives to C# and Java.

  8. 11-10-2010, 07:20 AM
    #7

    The Scrub

    Expand

    RatzloffToYa's Avatar
    • My Statistics
      Join Date
      Aug 2010
      Location
      Sweden
      Posts
      82
      Contest Points
      0
      Beli
      0
      Received Thanks
      14

    Default Re: [Guide] Basic/Simple programming terms and concepts

    Quote Originally Posted by Ignignokt
    [Dear Visitor, you're restricted from viewing links until you are registered & logged on.
    Click Here To Register Today
    There are better alternatives to C# and Java.
    Well, that's your opinion, now isn't it.

  9. 12-06-2010, 08:11 AM
    #8

    Informed Hacker

    Expand


    • My Statistics
      Join Date
      Aug 2010
      Posts
      131
      Contest Points
      0
      Beli
      0
      Received Thanks
      126

    Default Re: [Guide] Basic/Simple programming terms and concepts

    I agree with Ignignokt. People tend to learn VB, C# but fail at learning C++. I suggest people learn C before C++.

Posting Permissions

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