Why I use C
Published: 2023-08-26 01:40:18

---
title: Why I use C
published: true
description: 
tags: 
# cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/The_C_Programming_Language_logo.svg/1200px-The_C_Programming_Language_logo.svg.png
# c
# cpp
# rust
# c-sharp
# zig
# nim
# golang
# go
# programming
# published_at: 2023-08-26 00:45 +0000
---

#### Written Fri, Aug 25

### Introduction 

&emsp;For many years C has been a programming language that's considered old, ugly, and not viable for general use, I disagree with that. C is a programming language that is actually quite beautiful and amazing when used correctly. I use it for most of my projects and I use it whenever I can at my place of work. I use C because I chose it after a search through many programming languages. Here is a list of the ones I looked at and why I chose C over them:

### 1. Rust

> "Rust's primary first target seems to be drivers, simply because that's where you find just a lot of different possible targets, and you have these individual parts of the kernel that are fairly small and independent. That may not be a very interesting target to some people, but it's the obvious one" - Linus Torvalds on Rust

&emsp;Rust is an amazing language that has many applications. However, I enjoy being able to control the memory directly, and I also prefer the syntax of C over Rust. I also believe that C has a better standard library than Rust because it's very minimalist. In C you technically don't even need a standard library, or an operating system for that matter. Speak of operating systems, when it comes to OS programming I agree with Linus Torvalds on Rust. Rust seems like it would be great for writing drivers for an operating system. My ideal operating system would have a kernel written in C, drivers in Rust, and shell in Lua. Rusts `cargo` build/package system is something that I wish to see a C version of soon. Microsoft's `vcpkg` does seem like a good system at first, but then you attempt to actually use it to install a package and your code goes ape-shit. And `vcpkg` is more suited for C++ then C. On the topic of C++.

### 2. C++

> "C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C." - Linus Torvalds on C++

&emsp;I decided to use another Linus Torvalds quote in this paragraph because it perfectly sums up how I feel about the language. C++ is great, if you're a dumb-ass who thinks that data and code shouldn't be separate in projects. C++ ***forces*** you to integrate your data into your code with the terrible concept of `class`'s. C++ adds useless features every year, which would explain why people prefer to use one of the oldest versions of it over the newest version. Every C++ library I have ever seen has had enough issues with it to make a boomers marriage jealous.Most other programmers that realize how uselessly complex C++ is, C on the other hand is an actually good language to program in. The current standard for C++, C++20, has too many features and keywords that nobody will ever use. I have never seen something as useless as a smart pointer, you know the dangers of a pointer if you're using a pointer. C++ has become an ungodly beast that is a constant reminder of why you don't use OOP.

### 3. C Sharp

> “I’d much rather have a program explode in a shower of sparks and flames than silently do the wrong thing.” - Rob Miles, creator of C#

&emsp;That quote is definitely visible in the design of C#. When a C# program fails, you ***will*** know it. I don't want my programs to blow up like a sodium duck made by a protogen, I want them to `return -1` and write what went wrong to an output file. Another issue I have with C# is that its ecosystem is dominated nearly entirely by Microsoft, I hate Microsoft. C# is made and maintained nearly entirely by Microsoft, most actually useful libraries for C# are made by big corporations and are SaaS. Even if the library you're using isn't made by big SaaS, it's probably made by a teenager who doesn't even know what suckless is. And most FOSS libraries for C# use the MIT license, whcih allows companies to steal your code and use it in their own projects without crediting you at all.

### 4. Zig, Nim, and Golang

> "I leave Sisyphus at the foot of the mountain. One always finds one's burden again. But Sisyphus teaches the higher fidelity that negates the gods and raises rocks. He too concludes that all is well. This universe henceforth without a master seems to him neither sterile nor futile. Each atom of that stone, each mineral flake of that night-filled mountain, in itself, forms a world. The struggle itself toward the heights is enough to fill a man's heart. One must imagine Sisyphus happy" - Albert Camus

&emsp;You may be wondering why I chose a quote about Sisyphus for this section, and/or why I grouped these four very different languages into one section. That's because I believe the development efforts of them are a Sisyphean effort. However, I will talk about them separately.

### 4.1 Zig

&emsp;Let's take a look at some Zig code, shall we?

```zig
const std = @import("std");
const parseInt = std.fmt.parseInt;

test "parse integers" {
    const input = "123 67 89,99";
    const ally = std.testing.allocator;

    var list = std.ArrayList(u32).init(ally);
    // Ensure the list is freed at scope exit.
    // Try commenting out this line!
    defer list.deinit();

    var it = std.mem.tokenize(u8, input, " ,");
    while (it.next()) |num| {
        const n = try parseInt(u32, num, 10);
        try list.append(n);
    }

    const expected = [_]u32{ 123, 67, 89, 99 };

    for (expected, list.items) |exp, actual| {
        try std.testing.expectEqual(exp, actual);
    }
}
```

&emsp;This is the example listed on the Zig website, and I have no idea what it does. Zig seems like the perfect language for someone who loves how shitty JavaScript is, but likes the way Rust looks. Zig can be used for serious applications, but if you want to be paid you won't use it.

### 4.2 Nim

&emsp;Let's see if Nim is any better then Zig.

```nim


import std/strformat

type
  Person = object
    name: string
    age: Natural # Ensures the age is positive

let people = [
  Person(name: "John", age: 45),
  Person(name: "Kate", age: 30)
]

for person in people:
  # Type-safe string interpolation,
  # evaluated at compile time.
  echo(fmt"{person.name} is {person.age} years old")


# Thanks to Nim's 'iterator' and 'yield' constructs,
# iterators are as easy to write as ordinary
# functions. They are compiled to inline loops.
iterator oddNumbers[Idx, T](a: array[Idx, T]): T =
  for x in a:
    if x mod 2 == 1:
      yield x

for odd in oddNumbers([3, 6, 9, 12, 15, 18]):
  echo odd


# Use Nim's macro system to transform a dense
# data-centric description of x86 instructions
# into lookup tables that are used by
# assemblers and JITs.
import macros, strutils

macro toLookupTable(data: static[string]): untyped =
  result = newTree(nnkBracket)
  for w in data.split(';'):
    result.add newLit(w)

const
  data = "mov;btc;cli;xor"
  opcodes = toLookupTable(data)

for o in opcodes:
  echo o

```

&emsp;That's it? That's the language? That was just python, but compiled and with static types! That was the Nim example on [The Official Nim Website](https://nim-lang.org/), in my opinion it represents the language in a terrible way. I do believe that Nim has potential, just not a strong community. If Nim had a community like Golang or Rust, it would be successful. Also, screw you BoomBang.

## 4.3 Golang

> "I like Go a lot. In many ways it is C revisited, taking into account what has be learnt in the long years since it was released." - Johnathan Whiting

&emsp;Golang is good, don't get me wrong. However, garbage collection is a ***major*** downside to me. Golang also has some annoying features that I don't like to use in programs. For instance, I have no idea what `:=` is supposed to represent. And I don't exactly think that `fmt` was the best package name for what is essentially the standard library in C.

## Conclusion

&emsp;I still use C because it fits my needs and what fulfills my requirements from a programming language. You're of course free to use whatever fits your needs.

Have a Fantastic Day,
Teker