Question:
How do programming languages work?
2014-07-29 15:05:54 UTC
this is my first time posting a question on stack overflow. I am 14 and I have learned a lot of programming languages and even read the book "code the hidden language of computer hardware and software" to learn about how 0's and 1's were used to make words and numbers. But I still don't understand how assembly/c++/c/java was created using machine code. Also, why are there so much grammar (I know what they are used for but why cant it be simple as English?). I know grammar is used in English but I see braces, brackets, semi colons for these silly things like semi colons are used to end a statement in c++. I know the history of programming languages.

Let me rephrase this in the form of several different questions:

1.)How does a 22nm transistor work and make 0's and 1's. (Literally, how does it work, give me a detailed answer please.)

2.)How does machine code be used to make a full language like c++ (I want details because people only give short answers on how they work instead of saying the process of how to actually do it.)

3.) How does the GPU output text? (Detailed answer please)

4.)Finally, why are there so much nonsense grammar involved instead of something like english. I know what is is used for but why cant you just write to say hello: /print "hello" or to open a file: /open file = whateverfile.file and it would just open the damn file. Why does C++ have to be so hard!!!!
Five answers:
?
2014-07-30 15:46:43 UTC
2.)How does machine code be used to make a full language like c++ ?

- that took decades of work by thousands of people, and nowadays no-one does that they just add a new target CPU to an existing compiler like GCC

Around 1978 I had a computer I programmed in hex - machine code. I'd write a program in assembler and convert it to hex by hand, computing the jumps by counting instructions or subtracting addresses in hex. No OS and the typical program was a few kilobytes. I still had stuff like a program to read a temperature sensor and control a 240V lamp, and a little game like space invaders with sound effects. Then I got a BASIC interpreter, but I didn't write that myself though in theory I could have if I had even more time on my hands. I wrote the keyboard interface and the CRT interface and burned the interpreter to an EEPROM from a paper tape. It just takes time - I think Bill Gates wrote one. Something like C++ is about a thousand times more complicated, at least, and isn't practical for a single person to do by themselves.



1. Transistors have gain, usually in the thousands or more. In a digital circuit they are connected so that the output saturates - either zero volts or 5 volts, for instance. With a current gain of at least 10 one output can drive at least 10 inputs. In TTL under 1V is a 0 and over 3V is a 1, or something (I forget). If you have a basic circuit for a NAND gate using a transistor, you can make anything you want just by connecting enough of them. See e.g. FPGA design kits.



4. Grammar. C++ was written by Unix nerds who'd rather type "x++" than

"ADD ONE TO DAILY_INCOME GIVING DAILY_INCOME" or whatever one does in COBOL. Partly because they never learned to touch-type, and old keyboards were really clunky.

If you think C++ is hard to print "hello", try FORTRAN IV, or assembler which doesn't know about I/O devices at all.
Chris
2014-07-29 15:54:47 UTC
1) A transistor does not literally create zeros and ones, those are just symbols for low power versus high power.

A basic transistor has three contactors, with power flowing through the first making power flow from the second to the third.

Two of them and a few other components allows the construction of a flip flop, which is a small circuit capable of storing a state (on or off) pretty much indefinitely, as long as it has power.

Combine a few billion of them and you'll have CPUs and RAM, capable of doing calculations and storing information.



2) A simple analogy is how you don't need to move each individial finger to grab something off a table. You just think "I'm going to grab that pencil", and the brain does all the tedious little steps, like "tighten muscle #47 by 4%".

That's pretty much what the compiler does when it turns a single C++ command into 35 machine code operations. Everything can be broken down further and further, until it's just lots of turning 0s to 1s and back.



I'll keep it short, too, because I doesn't really matter. In order to learn how to drive a car, you don't need to know the exact details of how and why its engine does what it does.



You can also go watch Minecraft videos on youtube where people build graphical calculators using redstone and pistons to get an idea.



3) This question is much too vague. What you see on the screen is stored in the computer's RAM; it's a digital image exactly like one you get out of your phone's camera, only that it is sent to the monitor 60 times per second, and updated just as fast when something changes. How typing text in Word exactly translates to changing the pixel information that is sent to the monitor might sound interesting at first, really isn't though.



4) This question is ridiculous, assuming that you actually "learned a lot of programming languages".

C++ is closer to machine code than, say, Python, so you might want to look at that for code that's a bit closer to English.

The thing is that programming isn't like talking at all. Talking is imprecise and arbitrary, while programming has to be exact down to the letter. Which is probably why people tend to find it difficult.
?
2014-07-29 15:46:29 UTC
Thank you Eddie J for that response. About the nonsense, what I meant was some languages have many brackets and braces like a brace followed y another brace. Computer languages are exactly like English but different syntax and Pol Pot Pie, please respect my question instead of bringing negativity. Thanks. Also I do know how buzzers and light bulbs work but not how a 22nm one works. Programming is for me, it's just that I don't like c++'s syntax but I love python. Since c++ is the best language preferably but I don't like the syntax so I want to create my own. I also heard that you first create the syntax and language and design. Then, you create a compiler for it, right?
John
2014-07-29 17:01:35 UTC
Agash, if you want to avoid "negative" responses, you need to take care with your

> claims. Most of us who program find that we are still learning new gems about the

> languages that we "know". When we apply for a position, we take care to back up

> claims of knowledge of computer languages by experience at a previous company,

> or by published code on GitHub, or both. Have you published much of the code that

> you've written on www.ideaone.com or on www.pastebin.com, so that we can see

> your capability in several languages? It would be an excellent way to silence your

> critics. Just show them twenty-five or thirty substantial programs in c++, and a like

> number in Python, and they need not be tough programs, but people will see that

> you're not just bs-ing when you say that you've been coding. See, EddieJ has been at

> it for forty years, man and boy, so you're asking a big favor of him. You claim to have

> read one book, and you're not giving us the title. Give us a break, buddy.

>

> John (gnujohn)
2014-07-29 15:23:54 UTC
Programming is not for you then .. :(


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...