commit f09dc59da9d6d2005be869258e7693f0da1201ea
parent eac51b353cfd6e538d7d0d047e448ea8b44ddf07
Author: Samdal <samdal@protonmail.com>
Date: Sun, 23 Feb 2025 15:49:08 +0100
improve quotes, fix some spelling
Diffstat:
3 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/_posts/2024-05-08-VGA-Kontroller.md b/_posts/2024-05-08-VGA-Kontroller.md
@@ -17,7 +17,8 @@ Denne bloggen går ut på å implementere en kommunikasjonsprotokoll i fastvare,
### VGA protokollen
> **Video Graphics Array (VGA)** is a video display controller and accompanying de facto graphics standard, first introduced with the IBM PS/2 line of computers in 1987, which became ubiquitous in the IBM PC compatible industry within three years. The term can now refer to the computer display standard, the 15-pin D-subminiature VGA connector, or the 640x480 resolution characteristic of the VGA hardware.
>
-> \- [Video Graphics Array, Wikipedia](https://en.wikipedia.org/wiki/Video_Graphics_Array)
+> > \- [Video Graphics Array, Wikipedia](https://en.wikipedia.org/wiki/Video_Graphics_Array)
+> {: class="quote-cite"}
VGA har lenge vært brukt i industrien. Det er en analog standard som er relativt timing kritisk. Videoprotokollere krever at du sender informasjon hele tiden, dette betyr at å sende hver byte fra CPU vil bruke nesten 100% av utførelsestiden. I tillegg vil timing sannsynligvis være et problem ved enkelte oppløsninger og oppfriskningshastigheter. Å ha diskret fastvarekomponenter som står mellom CPU og VGA er derfor nødvendig.
@@ -432,7 +433,8 @@ Figur 13. Bilde eksportert til C-kildekode fra GIMP
> **VGA text mode** was introduced in 1987 by IBM as part of the VGA standard for its IBM PS/2 computers. Its use on IBM PC compatibles was widespread through the 1990s and persists today for some applications on modern computers. The main features of VGA text mode are colored (programmable 16 color palette) characters and their background, blinking, various shapes of the cursor (block/underline/hidden static/blinking), and loadable fonts (with various glyph sizes). The Linux console traditionally uses hardware VGA text modes, and the Win32 console environment has an ability to switch the screen to text mode for some text window sizes.
>
-> \- [VGA_text_mode, Wikipedia](https://en.wikipedia.org/wiki/VGA_text_mode)
+> > \- [VGA_text_mode, Wikipedia](https://en.wikipedia.org/wiki/VGA_text_mode)
+> {: class="quote-cite"}
VGA text mode lar deg bruke et 8x16 font-atlas til å tegne på skjermen. font-atlaset består av et enkelt bitmap, du velger selv hvilke farger som skal være i forgrunnen og bakgrunnen.
Kommunikasjon med en VGA text-mode enhet skjer i 16-bit ord, hvor hvert ord representerer en karakter.
diff --git a/_posts/2025-02-22-implications-of-OOP.md b/_posts/2025-02-22-implications-of-OOP.md
@@ -1,12 +1,12 @@
---
layout: post
-title: "Implications of inheritence: OOP is Bad"
+title: "Implications of inheritance: OOP is Bad"
description: The one feature that is properly unique to OOP is terrible, this is why.
comments: true
tags: [writing, programming, C]
---
-Although the main premise of Object Orianted Programming may be simple, it forces certain design decisions which you otherwise wouldn't do.
+Although the main premise of Object Oriented Programming may be simple, it forces certain design decisions which you otherwise wouldn't do.
Structuring your program with an OOP mindset already restricts your thinking, but these extra implications make thinking outside the ~~object~~ box a lot harder.
Modern programming languages which "support" OOP **forces** you to use these restrictions all throughout your program.
@@ -47,11 +47,11 @@ my_class object = {1, 2, 3};
int res = object.calculate_sum();
```
-So this isn't the whole story, something being "OOP" imples other things, mainly **inheritence**.
+So this isn't the whole story, something being "OOP" implies other things, mainly **inheritance**.
-### What is inheritence?
+### What is inheritance?
-Inheritence is the ability for a class to extend one classes.
+Inheritance is the ability for a class to extend one classes.
This allows you to have some "generic base class", and then add new methods and members on top of it.
It looks something like this
@@ -81,11 +81,11 @@ The only difference here is that you have to explicitly type `object.base.a + ob
The "non-OOP" way is so far superior:
- Control over memory layout
- More explicit without being cumbersome
-- Allows composability (although some languages allow for "multiple-inheritence")
+- Allows composability (although some languages allow for "multiple-inheritance")
## So what's the catch
-OOP inheritence allows you to *override* functions.
+OOP inheritance allows you to *override* functions.
```
// OOP
class my_base_class {
@@ -99,8 +99,8 @@ class my_class : my_base_class {
}
}
```
-The "magic" part about OOP is that when you *override* a method with an inherited class, when you cast the object to parent class, it retains the overrided functionality.
-
+The "magic" part about OOP is that when you *override* a method with an inherited class, when you cast the object to parent class, it retains the overridden functionality.
+ * [ ]
```
void print_string(my_base_class obj) {
print(obj.to_string());
@@ -114,12 +114,12 @@ print_string(object); // prints "my_class"
Did you notice something?\
In order for this functionality to work, we have to create `object` with a constructor, which is called through `new my_class();`.
-So RAII, *Resource acquisition is initialization*, that's the catch that makes OOP unique.
+So RAII, *Resource acquisition is initialisation*, that's the catch that makes OOP unique.
## Other ways which don't use RAII
### 1. Function pointers
-This will essensially manually do what the RAII and virtual methods does "automatically" for us.
+This will essentially manually do what the RAII and virtual methods does "automatically" for us.
```
typedef string to_string_function_pointer_t(void* self);
@@ -225,7 +225,7 @@ Because the enum solution doesn't use any language features, this should drive h
If you looked closely, you might also have noticed that I never created a `my_struct` in the enum example. This is because we simply don't need multiple types anymore.
-The enums let us compose all our behavior in a single type!
+The enums let us compose all our behaviour in a single type!
```
struct entity {
entity_type type;
@@ -241,12 +241,12 @@ struct entity {
} common_enemy;
}
```
-If you have never done this before, it is **increadibly** useful. Now everything is one function, the different data members simply toggle the branches which are related.
+If you have never done this before, it is **incredibly** useful. Now everything is one function, the different data members simply toggle the branches which are related.
-This also allows us to exploit all the benefits of the *non-OOP* strategies above, namely composing as opposed to "multiple-inheritence".
+This also allows us to exploit all the benefits of the *non-OOP* strategies above, namely composing as opposed to "multiple-inheritance".
You have no idea how much more obvious the code becomes with this.
-All the struct members are clearly laid out. All the branches and composed behavior get placed next to each-other.
+All the struct members are clearly laid out. All the branches and composed behaviour get placed next to each-other.
Additionally, if you're concerned about memory usage of having one large struct, you can use a "tagged union".
@@ -290,10 +290,10 @@ src="https://www.youtube.com/embed/xt1KNDmOYqA" title="HMH N+2">
Want more videos like the one above? [My list of software rants worth watching]({% post_url 2025-02-21-Software-Rants %}).
Just because OOP languages want to support one single feature, namely poor automation of function pointers, they force your entire program to be written in a suboptimal way.
-Some languages like C++ allow a hybrid approach, due to it's history as an extesnion of C, but this has some problems of it's own.
+Some languages like C++ allow a hybrid approach, due to it's history as an extension of C, but this has some problems of it's own.
Most OOP languages are not like this.
-When I use a language with native OOP features, I find myself searching "How to do struct literal in X". Only to realize I have to write a constructor, despite not even using virtual functions.
+When I use a language with native OOP features, I find myself searching "How to do struct literal in X". Only to realise I have to write a constructor, despite not even using virtual functions.
### What about encapsulation
You might have noticed that I didn't mention encapsulation.
diff --git a/_sass/_main.scss b/_sass/_main.scss
@@ -176,6 +176,12 @@ blockquote {
border-left: 5px solid #bcd1cf99;
padding-left: 1rem;
}
+.quote-cite {
+ border-left: none;
+ padding-left: 2rem;
+ margin-bottom: 0px;
+ margin: 0px;
+}
strong, b {
font-weight: bold;