binary

This is a discussion on binary within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I've always wondered, is binary a programming language? I always thought it was....

  1. #1
    Registered User webturtle0's Avatar
    Join Date
    Nov 2002
    Posts
    76

    binary

    I've always wondered, is binary a programming language? I always thought it was.
    "Yo"

  2. #2
    Registered User neo_strife's Avatar
    Join Date
    Nov 2002
    Posts
    15
    Binary is the lowest form of code and the only thing computers can really understand. I think it is a programming language however not a practical one. It would take way to long to write a decent program in binary.
    If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut.
    --Albert Einstein

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Enter assembler.
    Assembler is a simplified version of programming in pure "binary". Basically a search-and-replace with macros representing different CPU operatons. That's about as low as most people go.

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by neo_strife
    I think it is a programming language however not a practical one.
    Binary is in no way a programming language.

    If you were to consider binary a language, then you'd just as well be saying that the arabic base 10 number system was a programming language. Binary just happens to be the medium.

  5. #5
    npc
    npc is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    8
    in terms of the computer, "binary" usually refers to either the binary number system (as poly mentions), or actual bits ('0' and '1'). in terms of bits, "binary" then can mean data that a program would use, or the actual cpu instructions that make up that program. so in a sense, yes, "binary" can be thought of as a programming language (although many might object to this claim). basically when you design a cpu, you also must provide a set of instructions for this cpu. without too much detail, a cpu consists of some internal memory ("registers", to temporarily store binary data), an alu (which peforms arithmetic and logic operations on binary data), an input/output unit (to exchange data with the outside world) and a control unit. it this control unit that the set of instructions, you provide for your cpu, depend upon. this control unit basically manages the way binary data moves about between these various units mentioned above (alu, registers, i/o, ...). it would be nice for a programmer to be able to tell the control unit what to do (for example, take this binary data which represents some number, give it to the alu and tell the alu to multiply this number by 2, then send the result over to the main memory at such and such memory address...). thus you design your control unit to be able to accept various instructions that perform these operations, that a programmer would like a cpu to do. when designing your control unit, you find it best to represent these instructions as "binary" strings (strings of '0's and '1's, i.e. 1001101101), after all your cpu can only understand binary (so in this case, you design a decoding unit to decode these binary strings into control signals that perform operations that programmers would like cpu's to do).

    so in that sense, yes, "binary" could be thought of as a programming language. you have this cpu that comes with a set of instructions that it can execute. these instructions are encoded as binary strings. you create a program composed out of these cpu instructions and store them in memory. set up the cpu to start executing the first instruction, and let her rip.
    really this is what assembly language is. we would create this "assembly" language for our cpu that would represent these instructions encoded as binary strings in a nicer way
    (i.e. "0011011001011001" vs. "move.b #5,d0"; 16-bit cpu in this case). in this sense, neo_strife is correct in thinking that programming in binary is not practical.
    Last edited by npc; 11-29-2002 at 12:34 AM.

  6. #6
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    No, that's like saying our alphabet is a language.

    Just because you can use the alphabet to create a language doesn't make it a language by itself! The alphabet is simply a medium upon which languages can be created. They are two entirely different things.

  7. #7
    npc
    npc is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    8
    that's a good point. i supposed then that the language would really be defined in terms of its grammar (for rules to produce meaningful sentences), rather than the actual alphabet (or binary strings) it uses. but then why do some people say "assembly language" when assembly language is really nothing but a set of symbols with a one-to-one correspondence with the instructions of a particular cpu? you cannot create new cpu instructions out of the blue using some grammar of a language, there are only a finite number of sentences (instructions). perhaps it is an abuse of the word "language" in this case?

  8. #8
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    That's because the cpu provides the language which uses the "alphabet" and numbering system of binary. Assembly languages are just a more abstract language that get converted to the cpu's language.

    So you could look at different machine code and assembly languages as languages, just not binary.

    If I said write a narrative in english, you could do it.

    If I said write a narrative in italian, you could do it.

    If i said write a narrative using the letters A through Z, you could write in spanish, italian, english, etc. (that is, if they actually did have the exact same alphabet). But then, when someone said "read that narrative in the language defined by the letters A through Z" you can interperet that as any of the languages above (and an infinite number of others)

    Now -- if you said write a program in x86 Assembly, you could do it.

    If you said write a program using a particular type of machine code, you could do it.

    If you said write a program in binary, what would one do? Like the "A through Z" example you are stuck, only in this case it's even more cryptic, because a number system has no beginning or end, while an alphabet does.

    That's why machine code can be looked at as languages and that's why assembly languages are considered languages, and that's why binary is not. It's when you can take a medium such as an alphabet or a nubmer system and use it in such a way that you define what combinations of "letters" mean, and grammar, etc. that it becomes a language.

  9. #9
    npc
    npc is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    8
    poly you are right, thanks for the insight.

  10. #10
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    no problem, npc, it's a common misconception. I just think it's kind of neat why things are called what they are. Glad I was actually able to explain the reasoning behind it.

  11. #11

  12. #12
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Wow, that helps! Thanks! Wait, no it doesn't. It has no relevance on the original question. Like someone said, binary is the medium, and all that link to google is going to provide is information about binary; NOT opcodes or programming with binary.

    Posts++ I guess. See if you can get 100 in one day, maybe you'll overtake Ride -or- die.

  13. #13
    Banned Cgawd's Avatar
    Join Date
    Oct 2002
    Posts
    405
    maybe you'll overtake Ride -or- die.
    hehe , im not trying to up my post count, and if you actually click on some of those links you would see the answer to the question. jeese, some people

  14. #14
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    How do you thing people entered code into machines before they had cute languages/assemblers to make it easier?

    I can well remember long sessions in front of a desk with a big row of up/down switches, where you set the switches and then pressed the "Clk" button to read that BINARY in, and repeat for HOURS. Then when you figured you'd got it all in right, you pressed "Exec" or something and watched while nothing happened.

    Of course you can program in binary, (or hex if you have the relative luxury of a hex keypad).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  15. #15
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    binary isn't the only way you can write programs at the lowest level
    you could write programs in hex i guess since one hex character will represent one half-byte

    so FF
    would be
    1111 1111

    hexedecimal makes things so much easier.


    on another note, a simple hello world program written in dos debug can be as small as 23 bytes, but one compiled in mingw is 11905 bytes. So if everybody who wrote hello world programs had written them in assembler, that would be a saving of many megabytes. yay.
    Last edited by Brian; 11-29-2002 at 04:48 PM.

Page 1 of 4 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arrays vs lists? And containers in general!
    By clegs in forum C++ Programming
    Replies: 22
    Last Post: 12-03-2007, 02:02 PM
  2. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21