Community:Intro to Programming: Difference between revisions

From VRChat Wiki
(Created page with "== About this guide == ⚠WIP⚠ Udon is a programming language for adding interactivity to VRChat worlds. UdonSharp is a tool for creating Udon scripts, but by writing 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 is able to create their own Udon scripts with UdonSharp. This is not meant to be a comprehensive guide on all things programming, it...")
 
m (added guides category)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Noticebox/Community}}
{{Noticebox/wip}}
== About this guide ==
== About this guide ==


⚠WIP⚠
[[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
|message=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.


[[Udon]] is a programming language for adding interactivity to VRChat worlds. UdonSharp is a tool for creating Udon scripts, but by writing 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 is able to create their own Udon scripts with UdonSharp.
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.


This is not meant to be a comprehensive guide on all things programming, it's aim is to just teach enough to help people create interactive VRChat worlds.
I can then make another circuit for performing subtraction and then have a special pin switch between which circuit is active.


== Computer Science 101 ==
Modern CPUs have billions of transistors switching between a massive amount of different circuits that all perform different actions.
=== How computers work ===
Silicon is a semi-conductor which basically means it's a material that can't quite make up it's mind on whether or not it wants to conduct electricity. We can nudge the conductivity of silicon one way or another by mixing it with other materials or by placing it in an electrical field such as that generated by a charged piece of metal. Here's a very scientific diagram on how that works.


<TODO>
=== 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.


=== Programming ===
<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 18:06, 11 September 2024

IconOnly CL Portal.png
V · ECommunity-written content
The following was created by the community. It may contain material not directly endorsed by the VRChat team. To learn more, consider reading Contributing to the VRChat Wiki.
Tools.png
V · EThis page is a work in progress
This page is actively being worked on, information may be incomplete or out of date. You can help the VRChat Wiki by editing it.
[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

CautionTriangle.png
Simplified Explanation Ahead
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[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:

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.

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> 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>