From 501b9debe7e3be4d31f307983172920d5523dff5 Mon Sep 17 00:00:00 2001 From: Jeremie Bornais Date: Sat, 31 Aug 2024 10:51:09 -0400 Subject: [PATCH] fix devcontainer config, add comp1400 dev guide from my blog (#184) * fix devcontainer config, add comp1400 dev guide from my blog * link 1400 guide and 1st year guide within each other --------- Co-authored-by: tanzimfh <51885607+tanzimfh@users.noreply.github.com> --- .devcontainer/devcontainer.json | 27 ++++--- .github/dependabot.yml | 12 +++ courses/comp-1400/comp-1400-setup-guide.md | 89 ++++++++++++++++++++++ courses/comp-1400/overview.md | 2 +- courses/courses-sidebars.js | 7 +- resources/guides/first-year-guide.md | 2 + 6 files changed, 124 insertions(+), 15 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 courses/comp-1400/comp-1400-setup-guide.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0fcf8a232..ea1e9be3c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,19 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node { - "name": "Node.js", - "image": "mcr.microsoft.com/devcontainers/javascript-node:16-bullseye" + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm", - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "yarn install", + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", - // Configure tool-specific properties. - // "customizations": {}, + // Configure tool-specific properties. + // "customizations": {}, - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f33a02cd1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/courses/comp-1400/comp-1400-setup-guide.md b/courses/comp-1400/comp-1400-setup-guide.md new file mode 100644 index 000000000..0b7b6bafb --- /dev/null +++ b/courses/comp-1400/comp-1400-setup-guide.md @@ -0,0 +1,89 @@ +--- +id: comp-1400-setup-guide +title: COMP-1400 Development Environment Setup Guide +sidebar_label: COMP-1400 Setup Guide +slug: /comp-1400/setup-guide +--- + +Setting up a development environment on Windows for coding in C can seem daunting for a new CS student. However, with the right tools and a step-by-step guide, the process can be straightforward. In this tutorial, we will walk through the process of setting up a development environment on Windows for coding in C. + +To learn more about the tools being used and for other helpful information for first year students, check out the [First Year Guide](../../resources/guides/first-year). + +## Step 1: Install WSL + +WSL (Windows Subsystem for Linux) is a compatibility layer that allows running Linux binaries natively on Windows. It provides an easy way to get a full Linux environment running on Windows, including a terminal and package manager. + +To install WSL, follow the steps on the official [Microsoft docs](https://learn.microsoft.com/en-us/windows/wsl/install). Essentially, though, you should only need to run one command in an **admin Powershell window**: + +```sh +wsl --install +``` + +This command should install WSL and Ubuntu. You'll most likely need to reboot your PC, then when Ubuntu is run for the first time, you'll get to create a username and password for Ubuntu. Then, WSL will be installed! Make sure to consult the official [Microsoft documentation](https://learn.microsoft.com/en-us/windows/wsl/install) when installing WSL as sometimes things change. + +## Step 2: Install GCC + +GCC (GNU Compiler Collection) is a collection of programming language compilers, including C. It is an essential tool for compiling and running C programs. + +To install GCC on Ubuntu, follow these steps: + +1. Open a terminal window in Ubuntu by typing "ubuntu" in the Start menu search bar and selecting "Ubuntu" from the list of results. +1. Run the following command to update the package list: `sudo apt-get update` +1. Run the following command to install GCC: `sudo apt-get install gcc build-essential` + +**NOTE**: If you want additional recommended tools, run the following command as well: + +```sh +sudo apt-get install git htop curl wget screen neofetch python3 python3-pip +``` + +## Step 3: Install VSCode + +Visual Studio Code (VSCode) is a popular code editor with many features, including syntax highlighting, debugging, and extensions. It is a powerful tool for writing and editing C programs. + +To install VSCode on Windows, follow these steps: + +1. Go to the VSCode website at https://code.visualstudio.com/. +1. Click on the "Download for Windows" button to download the installer. +1. Run the installer and follow the on-screen instructions to complete the installation process. + +## Step 4: Configure VSCode + +Once you have installed VSCode, you need to configure it to work with WSL and GCC. Follow these steps to set up the necessary configurations: + +1. Open VSCode on Windows. +1. Install the "Remote Development" extension pack by clicking on the "Extensions" icon in the left-hand toolbar and searching for "Remote Development" + +## Step 5: Opening VSCode Within WSL + +Now that VSCode is installed and configured, let's create a folder to store all of our C files and open it in VSCode in WSL. **You can create a folder anywhere you like. However, for the purposes of this tutorial, I'm going to assume the folder is `C:\code\`** + +1. Launch the WSL terminal: Open the WSL terminal by searching for "WSL" or the specific Linux distribution you have installed (in your case, probably **Ubuntu**) in the Windows Start menu. This will open a Linux shell within the Windows environment. +1. Navigate to the desired folder: Use the cd command to navigate to the folder on your C drive that you want to open in VSCode. For example, if your folder is located at `C:\code`, you can use the following command to navigate to it: `cd /mnt/c/code` +1. Create an empty C file: Use the `touch` command to create a "hello.c" file: `touch hello.c` +1. Launch VSCode from the WSL terminal: In the WSL terminal, you can launch VSCode and specify the current directory to open. Use the `code .` command to open the current directory in VSCode. The dot (.) represents the current directory. +1. Now, VSCode should be open and you can see `hello.c` on the left. You can now click on the file to edit it. (You can find a sample "hello world" program at the bottom of this article) + +## Step 6: Compiling and Running your C Files + +Editing files is fun and all, but our real objective is to compile and run them. Luckily, this is a simple process and only requires 3 commands. + +1. First, you'll need to open up a terminal within VSCode. This can be done by clicking `Terminal` under the `View` menu of VSCode. +1. You should now see a terminal open at the bottom of your screen. At this point, you can compile the C file by typing the command `gcc hello.c -o hello.exe` +1. You should see a `hello.exe` file appear on the left side of VSCode. You can run it by typing `./hello.exe` in the terminal. You should see the text "Hello World!" printed in the terminal. + +Congratulations! You have now set up a development environment on Windows for coding in C. You can use this environment to write, compile, and run C programs. + +## Appendix + +### Sample C Program + +Here is a sample "hello world" C program you can use to test your new dev environment: + +```c +#include + +int main(){ + printf("Hello World!\n"); +} +``` diff --git a/courses/comp-1400/overview.md b/courses/comp-1400/overview.md index 12f73f85d..0176ef3a4 100644 --- a/courses/comp-1400/overview.md +++ b/courses/comp-1400/overview.md @@ -1,7 +1,7 @@ --- id: overview title: COMP 1400 - Overview -sidebar_label: COMP-1400 +sidebar_label: COMP-1400 - Overview slug: /comp-1400/overview --- diff --git a/courses/courses-sidebars.js b/courses/courses-sidebars.js index 373970579..aae55f498 100644 --- a/courses/courses-sidebars.js +++ b/courses/courses-sidebars.js @@ -30,9 +30,12 @@ module.exports = { id: "comp-1047/overview", }, { - type: "doc", + type: "category", label: "COMP-1400", - id: "comp-1400/overview", + items: [ + "comp-1400/overview", + "comp-1400/comp-1400-setup-guide", + ], }, { type: "doc", diff --git a/resources/guides/first-year-guide.md b/resources/guides/first-year-guide.md index d2e2ca04e..6fb9c012e 100644 --- a/resources/guides/first-year-guide.md +++ b/resources/guides/first-year-guide.md @@ -51,6 +51,8 @@ Incoming first year students typically have the earliest **appointment time** an As a computer science student, you will learn to program in a variety of programming languages, starting with the **C Programming Language** in COMP-1400. Installing and familiarizing yourself with the necessary software on your personal computer _before_ the first day of classes will save you time and stress, **especially if you are new to programming**. All of the following software can be downloaded for free. +This section goes over some fundamental software for developing code. For a more focused step-by-step guide for setting up a development environment on Windows for coding in C, check out the [COMP-1400 Development Environment Setup Guide](../../courses/comp-1400/setup-guide). + ### Code Editor: Visual Studio Code #### Description