LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-07-2013, 05:41 AM   #1
thelinuxist
Member
 
Registered: Nov 2012
Location: Munich, Germany
Distribution: CentOS, Debian, Fedora, Ubuntu, DSL (Whatever neccessary)
Posts: 61

Rep: Reputation: Disabled
Question How was the first program ever written?


Hi,

after learning some programming languages, I got to philosophizing a bit. The first python interpreter was written in C (I think?) and the first C compiler was written in ASM. But in which language was the first assembler written?

That's what I don't understand, because humans cannot write machine language directly (Can anyone? Looking at binary files opened with less, I don't think anyone could understand or even write even a simple app that way - not to think about a compiler).

So how was that made? I hope the question isn't too dumb to be answered. It's not technical, but rather just an "understanding" question.
 
Old 08-07-2013, 05:54 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403Reputation: 2403
Mybe these 2 links will shed some light:
- How was the first compiler written?
- Bootstrapping (compilers)
 
Old 08-07-2013, 07:42 AM   #3
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,861

Rep: Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658
Quote:
Originally Posted by thelinuxist View Post
... humans cannot write machine language directly ...
Yes, they can. I am not personally able to do this, but I have seen it done by programmers who knew the opcodes by heart and consequently did not need the convenience of mnemonics.

Daniel B. Martin
 
Old 08-07-2013, 08:23 AM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,298

Rep: Reputation: Disabled
Quote:
Originally Posted by thelinuxist View Post
That's what I don't understand, because humans cannot write machine language directly (Can anyone? Looking at binary files opened with less, I don't think anyone could understand or even write even a simple app that way - not to think about a compiler).
Of course we can. Humans designed the CPU, so humans know which machine code instruction correspond to which assembly language mnemonic.

You write your program on paper using assembly or hexadecimal values. I've done that, and it's not that hard for a small program. You then transfer those values to the computer somehow.

The first computers were programmed with physical switches, each switch corresponding to one bit. Of course, entering large programs using switches would take ages, so the first program you make is one that can accept input from another source. Then perhaps you use that input to feed the computer a hex editor program, then use that to make an assembler, and so on.
 
Old 08-07-2013, 08:32 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,308

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by thelinuxist View Post
Hi,

after learning some programming languages, I got to philosophizing a bit. The first python interpreter was written in C (I think?) and the first C compiler was written in ASM. But in which language was the first assembler written?

That's what I don't understand, because humans cannot write machine language directly (Can anyone? Looking at binary files opened with less, I don't think anyone could understand or even write even a simple app that way - not to think about a compiler).

So how was that made? I hope the question isn't too dumb to be answered. It's not technical, but rather just an "understanding" question.
not a dumb question... when i was in college i had an ee course in microprocessors where on some of the written exams we would need to translate byte-code <-> assembly code for the 65c02 cpu...

something like
Code:
0xad05
would load the accumulator register with the value of 5. that is hard to read so assembly mnemonics were created to make it more readable:
Code:
lda $05 ; load the accumulator with a value of 5
still cryptic but notice i am allowed to add a comment that the interpreter will ignore. to make it more readable 3rd generation languages were created: (c):
Code:
int apples=5;
char fruit[10]; // character array of type of fruit.
which makes it very obvious what each variable is (and when compiled it will generate the proper machine code for the cpu arhetecture. and finally 4gl's make it seem like an english sentance (sql):
Code:
select count from food where fruit = apple

Last edited by schneidz; 08-07-2013 at 08:44 AM.
 
Old 08-07-2013, 08:46 AM   #6
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 882

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by thelinuxist View Post
... because humans cannot write machine language directly (Can anyone? Looking at binary files opened with less, I don't think anyone could understand or even write even a simple app that way - not to think about a compiler).
Yes, it's possible, and it's not that difficult, but it is tedious. I wrote a fullscreen text editor for a 6502-based Apple II computer back in the early '80s. I had a 6502 instruction reference, so I did all my coding on paper using assembler opcodes, then I hand-assembled it and entered all the machine code in my program file using a hex editor.

I have disassembled many programs by hand from machine code to symbolic assembly language too.

I had access to an Altair 8800 back in the early '80s also. Machine language programs had to be toggled in through switches on the front panel. All those programs had to be hand-assembled on paper first before entering them. When you turned off the computer, they were gone. At least, until floppy drives (8 inch) and drivers for cassette tape were available, and then they could be saved and reused.

Last edited by Z038; 08-07-2013 at 08:56 AM.
 
Old 08-07-2013, 09:03 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Bootstrapping must be done in the real world as much as in the virtual world. How were the first tools built ? By hand, piece by agonizingly tedious piece.
 
Old 08-07-2013, 09:18 AM   #8
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 15.0
Posts: 8,189
Blog Entries: 61

Rep: Reputation: Disabled
Maybe they used a binary keyboard?
 
Old 08-07-2013, 09:22 AM   #9
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,861

Rep: Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658Reputation: 658
As might be expected, the first computer program was written by the first computer programmer.

Refer to http://en.wikipedia.org/wiki/Ada_Lov...mputer_program

Daniel B. Martin
 
Old 08-07-2013, 09:29 AM   #10
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 123Reputation: 123
ENIAC was programmed largely by hardwiring plugboards and setting switches on "portable function tables".

http://www.columbia.edu/cu/computinghistory/eniac.html
 
Old 08-07-2013, 09:29 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,168
Blog Entries: 4

Rep: Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708Reputation: 3708
Augusta Ada King, the Countess of Lovelace is arguably (of course ...) the world's first computer programmer. She wrote programs for Charles Babbage's never-completed, steam-driven Difference Engine and Analytical Engine. By hand. It is unknown whether her programs contained any syntax errors.
 
Old 08-07-2013, 12:09 PM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,308

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ programmable loom came first, didnt it ?
 
Old 08-09-2013, 07:22 AM   #13
turboscrew
Member
 
Registered: Apr 2009
Location: Nokia (town), Finland
Distribution: Mint, Debian
Posts: 601

Rep: Reputation: 46
Quote:
Originally Posted by brianL View Post
Maybe they used a binary keyboard?
Actually, close:
http://www.quadibloc.com/comp/panint.htm
 
Old 08-09-2013, 07:37 AM   #14
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by thelinuxist View Post
humans cannot write machine language directly
I have written many programs in machine language (none recently).

Long ago computers had toggle switches on their front panels to let you directly store data/programs into memory while the computer was halted. I not only wrote programs in machine language, I also inserted such programs into the computer via the front panel toggle switches.

Later computers had loader programs stored in ROM chips, so you could type machine language programs in hex to get them into memory. I did a lot of that as well.

I never wrote anything as complicated as a compiler directly in machine language. Turing did. I'm not sure whether anyone else has. A multi layered bootstrap process is easier.

Once I did the full process of bootstrapping to a high level language compiler myself: Write a crude assembler in machine language: Write a better assembler in that crude assembly language. Write the compiler for a usable subset of a high level language in that assembler. Rewrite that, plus some extra language features in that subset language. Enhance the language and compiler together, using new language features to support newer language features.
 
Old 08-09-2013, 07:43 AM   #15
turboscrew
Member
 
Registered: Apr 2009
Location: Nokia (town), Finland
Distribution: Mint, Debian
Posts: 601

Rep: Reputation: 46
Writing a program using switches was really not so tedious, when the computer had something like 512 registers.
(Those days memory locations were called registers - or rather the computer only had registers, and if there were many of them, they were implemented as memory.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] A compiled C program copied using a self-written program, failed to work trainee Programming 8 06-27-2013 07:53 PM
running a written program judoka Linux - Newbie 14 07-17-2009 01:43 AM
How Do I Run/Compile a Program Written in C? debsan Fedora 2 05-25-2006 02:58 PM
have you ever written a program for linux? today53 General 33 12-05-2003 06:54 PM
another dumb program written in bash. micxz Programming 0 10-13-2003 07:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration