Community:Intro to Programming: Difference between revisions
m (Usr 6909a532-22e9-49f7-81e3-e964fe7dc00a moved page Intro to Programming to Community:Intro to Programming: Moved to Community Namespace) |
m (Text replacement - "Noticebox2" to "Noticebox") |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Noticebox/Community}} | |||
{{Noticebox/wip}} | |||
== About this guide == | == About this guide == | ||
[[Udon]] is a programming language for adding interactivity to VRChat worlds. UdonSharp is a tool for creating Udon scripts by writing in C#, which is the programming language most Unity games are made in. This guide aims to teach the basics of programming so that someone who has never programmed before can create their own Udon scripts with UdonSharp. | |||
This is not meant to be a comprehensive programming guide; its aim is to just teach enough to help people create interactive VRChat worlds. | |||
== Computer Science 101 == | |||
=== Hardware === | |||
{{Noticebox | |||
|image=CautionTriangle.png | |||
|title=Simplified Explanation Ahead | |||
|description=You don't need to know how CPU chips work to write code so I'm going to be simplifying all my explanations to get through it as quickly as possible. | |||
}} | |||
==== Silicon to Transistors ==== | |||
Silicon is a '''semi-conductor''' -- a material that isn't a conductor and isn't an insulator, but somewhere in between. We can nudge the conductivity of silicon one way or another by mixing it with other materials (known as doping<ref>https://en.wikipedia.org/wiki/Doping_(semiconductor)</ref>) or by placing it in the electric field of a nearby charged piece of metal (known as the field effect<ref>https://en.wikipedia.org/wiki/Field_effect_(semiconductor)</ref>). | |||
A transistor is a tiny microscopic device made from semi-conductors that utilize doping and the field effect to turn circuits on and off within your CPU. For example, you can dope the silicon within a transistor to make it not conductive so that it blocks the flow of electricity through a circuit. Then when you want to use that circuit, you would use the field effect to make the silicon conductive again. Here is a diagram showing how that'd work: | |||
[[File:Transistor-diagram-with-rats.gif|1920x1080px|frameless|Diagram of a transistor using the field effect to change its conductivity. The charges in the diagram are represented with rats.]] | |||
The above example shows a transistor whose default state is '''off''', but you can also make transistors whose default state is '''on''', meaning they only conduct electricity when there's no charge applied. | |||
==== Transistors to Computers ==== | |||
There are a bunch of pins on the back of your CPU that plug into your motherboard. Some are input pins, and some are output. Each CPU cycle, a specific pattern of input pins lights up, opening and closing different circuits inside the CPU. The electric current then races through the CPU, eventually exiting on a specific pattern of output pins. | |||
[[File:AMD3500X pins.webp|1280x720px|frameless|Closeup of the CPU pins on the back of my old AMD Ryzen 7 3800x]] | |||
Let's imagine that I was a CPU manufacturer who wanted to make a computer chip that only had one function: to tell if a number was 69 or not. I have a bunch of CPU pins and two types of transistors that I can attach to the pins: type '''A''' which only opens the circuit when the pin has a electrical charge, and type '''B''' which only opens the circuit when the pin has no charge. | |||
The binary representation for 69 is 1000101, so if I put all my transistors on the same circuit, and then arranged the type A's and type B's like ABBBABA, then I'd have a chip that detects the number 69. | |||
It's just as easy to make a circuit that detects two numbers and outputs their sum. Repeat that for all combinations of two numbers and I have a chip that performs addition. | |||
I can then make another circuit for performing subtraction and then have a special pin switch between which circuit is active. | |||
Modern CPUs have billions of transistors switching between a massive amount of different circuits that all perform different actions. | |||
=== Software === | |||
The input is known as the instruction and usually has two parts: the opcode and the operand. The opcode, short for operation code, tells the CPU what kind of operation to perform. The operand is the data that the opcode works with. For example, if the opcode is for adding two numbers and saving the result to a CPU register, the transistors that control the addition circuit will activate, as well as the circuit that leads to saving the output to the specified register. The operand is then routed through the pathway that just opened up. | |||
<TODO> | <TODO> | ||
binary -> assembly -> code -> natural language | binary -> assembly -> code -> natural language | ||
Line 45: | Line 75: | ||
=== Optimization === | === Optimization === | ||
<TODO> | <TODO> | ||
[[Category:Guides]] |
Latest revision as of 16:48, 19 November 2024
[Reason: No reason provided.]
About this guide
Udon is a programming language for adding interactivity to VRChat worlds. UdonSharp is a tool for creating Udon scripts by writing in C#, which is the programming language most Unity games are made in. This guide aims to teach the basics of programming so that someone who has never programmed before can create their own Udon scripts with UdonSharp.
This is not meant to be a comprehensive programming guide; its aim is to just teach enough to help people create interactive VRChat worlds.
Computer Science 101
Hardware
Silicon to Transistors
Silicon is a semi-conductor -- a material that isn't a conductor and isn't an insulator, but somewhere in between. We can nudge the conductivity of silicon one way or another by mixing it with other materials (known as doping[1]) or by placing it in the electric field of a nearby charged piece of metal (known as the field effect[2]).
A transistor is a tiny microscopic device made from semi-conductors that utilize doping and the field effect to turn circuits on and off within your CPU. For example, you can dope the silicon within a transistor to make it not conductive so that it blocks the flow of electricity through a circuit. Then when you want to use that circuit, you would use the field effect to make the silicon conductive again. Here is a diagram showing how that'd work:
The above example shows a transistor whose default state is off, but you can also make transistors whose default state is on, meaning they only conduct electricity when there's no charge applied.
Transistors to Computers
There are a bunch of pins on the back of your CPU that plug into your motherboard. Some are input pins, and some are output. Each CPU cycle, a specific pattern of input pins lights up, opening and closing different circuits inside the CPU. The electric current then races through the CPU, eventually exiting on a specific pattern of output pins.
Let's imagine that I was a CPU manufacturer who wanted to make a computer chip that only had one function: to tell if a number was 69 or not. I have a bunch of CPU pins and two types of transistors that I can attach to the pins: type A which only opens the circuit when the pin has a electrical charge, and type B which only opens the circuit when the pin has no charge.
The binary representation for 69 is 1000101, so if I put all my transistors on the same circuit, and then arranged the type A's and type B's like ABBBABA, then I'd have a chip that detects the number 69.
It's just as easy to make a circuit that detects two numbers and outputs their sum. Repeat that for all combinations of two numbers and I have a chip that performs addition.
I can then make another circuit for performing subtraction and then have a special pin switch between which circuit is active.
Modern CPUs have billions of transistors switching between a massive amount of different circuits that all perform different actions.
Software
The input is known as the instruction and usually has two parts: the opcode and the operand. The opcode, short for operation code, tells the CPU what kind of operation to perform. The operand is the data that the opcode works with. For example, if the opcode is for adding two numbers and saving the result to a CPU register, the transistors that control the addition circuit will activate, as well as the circuit that leads to saving the output to the specified register. The operand is then routed through the pathway that just opened up.
<TODO> binary -> assembly -> code -> natural language
Compiling and Running code
<TODO>
Structure of an UdonSharp script
Namespaces
<TODO>
Classes
<TODO>
Functions
<TODO>
Variables
<TODO>
Unity SDK
Events
<TODO>
VRChat SDKs
Players
<TODO>
Coding Tutorial
<TODO>
Advanced Concepts
Networking
Optimization
<TODO>