You are not logged in.
Pages: 1
Why i see C the programming language everywhere in GNU/Linux, Pacman is C, Fastfetch is C, Entire Linux Kernel is C. Why? I starded coding in C few days ago its so annoying why there is no strings? WHY? Why they would torture them self's with C?
Last edited by Materac (2025-08-27 19:12:08)
Offline
Because it's around since ever, it allows you to do really stupid things, really cleaver things and some insane things.
The real question is: why do *you* torture yourself if you experience it as torture?
School?
From a didactic POV, the syntax has been emulated everywhere else and you get around to understand some basic concepts instead of relying on black magic doing stuff for you under the hood.
If you have a remote grasp on C it's super-easy to transition into most hip languages because
a) the syntax is actually never important to learn, you pick it up as you go
b) if it was and as mentioned: a lot of languages are modeled after C anyway
c) coding isn't a series of tricks, it's to understand the machine - how it "thinks", where the pitfalls might be, what matters and what's just noise (like two items in this list) - you need to understand some basic concepts about its nature…
Otherwise nobody really forces you to learn or use it, no?
Offline
you are right but if we wanna found how machines think we should use asembly
Offline
That's (almost) how the machine "works", not "thinks".
https://en.wikipedia.org/wiki/High-leve … ve_meaning
Offline
throwing my couple cents
as you ask about strings I assume you experience in other languages? if so: which?
but to focus on strings: what are strings anyway? in pretty much every language it's a sequence of characters
what is a sequence? it's a somehow terminated series of following items
how is such a series terminated? either by given length or by a special terminator
so what are strings then? a series of chars that is terminated either by a given length or by a terminator - and C, given its age, chose to use a terminator
why? because back then memory was expensive! much expensive! even so much more expensive that one could express the amount of additional bits to express a length and the additional logic to keep track of that in dollars - both in terms of actual storage as well as time and complexity
it was just far simpler and therefore cheaper just to define: "a string is 7--bit ascii terminated by NUL"
the difference can still be seen today:
pretty much everytime when data are exchanged they're either split into fixed blocks with additional padding or have a length preceeding them
and this can cause security issues when nit implemented properly - look up ssl hearbleed vulnerability
that's also the reason why there're so many similar overloaded functions like print:
in its most simplest version it takes a NUL-terminated string and prints it until it encounters NUL
but: what will happen when you feed it a pointer to something that doesn't end with a NUL? the simple print will spitting out whatever follows in memory - until it either finally hits a NUL - or, more likely, runs into a segfault because it tries to access invalid memory which modern hardware and kernel can detect and prevent
this is also how most buffer overflow attacks work: you specify an invalid length and just flood the buffer with a NO OP slope and hope that the cpu somehow falls into executing whatever bad input you give it as code
C is quite a hard language
I have a couple if years of experience with java and php - and when I got my hands on a K&R it still blew my mind although I already understood what I was reading and what is it up to with those evil pointers
would I recommend it to someone without prior knowledge of higher languages? no! but back when unix was invented there were no simpler higher languages - and yet people still made it to the moon
if you worry already about strings - wait until you get to indirect pointers
Offline
C was literally created for the Unix kernel and low level utilities. Quite honest, that's the major reason you still see it everywhere, it was purpose built for this ecosystem.
Offline
The true story [it's real BTW I'm not joking, just a little]:
Once upon a time, in the bell labs:
Ken Thompson: Coming to home after work, probably a Friday.
Ken Thompson's wife: Hey I'm going this weekend to my parents house, I'm going to take out our son to the trip.
Ken Thompson in the weekend: I'm bored, no wife no kid here around, I'm going to make an OS. Creates the entire Unix in assembly in the weekend.
Kent Thompson in monday during work: Hey I made this shit in the weekend.
Dennis Richie: Bro this shit is so great, what are you smoking [probably not, I'm making fun here], I'm making A "HIGH LEVEL LANGUAGE CALLED C" because it's inspired by B language. With that thing we can make your OS PORTABLE TO ANNNYYYY DEVICEEE.
Ken Thompson: Oh so nice, see you in the evening to help you in that.
Brian Kernighan steps in the room: Hi guys what are you doing ? today I just met OH god what is that thing, I'm going to create AWK immediately with my dudes in the office!
And so, the knights of the Bell labs started to rewrite and create everything in C. So say thanks to Thompson's wife because without it we could probably not being talking here [The story is real, I'm not kidding, it's in a interview of Ken Thompson]
The C language now days [and also C++ from a certain point of view] are the only true languages apart of assembly where total freedom of the system resources and hardware is allowed. The only limit is your mind.
The other thing: Rewriting software is expensive for companies and for projects which are big, like the Linux Kernel is hard to do. So most of the time you are not going to rewrite the software where you are working, the company expects that you can adapt to the language in current usage. There must a be a real valid reason to do the rewriting. It's expensive as in money, and as in time effort. It's far more better and cheap to keep the people who had been working with the code for decades to just maintain it. If you need to patch in ASAP, those guys knows that so well that in the day they are going to make it happen. That' could not be the case in the rewritten way, since the order of the program is going to be different. Imagine that even Linux Torvalds himself doesn't understand the Linux kernel 100% in now days. There is no single human being, that know the entire Linux C code 100% well. It's to big, so the guys works in a modular way, there are experts in certain areas. So because of that imagine just to throw away all the previous effort and knowledge of the people involved in writing the Linux kernel, to just say, hey now when we print, the printing is more nice to code it, not more printf string syntax shit. In some way you are risking that the entire project is going to die in the long run. You can create rewrites in simple projects, obviously, that's the case of the Rust based Linux traditional core utils, like sed, ps, lsblk, etc. But for complex system is another history, even worse when you start to use micro services architecture, instead of monolithic.
Probably now days most people just work in a higher level like Java script or python, but many language [I'm talking to you python, you are just c++ single thread in disguised ] are just C++ under the hood. C and C++ are just the language to build applications to build applications. You don't see that programmers to often because they are the real heroes so you can use your daily day applications, because some of it requires an dependency made in C or C ++. Now days if the project is new probably is in C++, that's because object programming was not invented as a concept where C was made, but you can emulate it using structs and arrays of structs. So in the end also C is a object programming language if you study it very hard to reproduce those behaviors on it.
So that's it. Hope it helps you understand all of it.
Last edited by Succulent of your garden (2025-08-28 00:53:44)
str( @soyg ) == str( @potplant ) btw!
Online
Why i see C the programming language everywhere in GNU/Linux, Pacman is C, Fastfetch is C, Entire Linux Kernel is C.
It is an very small and simple language that is insanely fast, gives you 100% control over CPU cycles and memory usage, is very fast to compile, portable (Every platform that exists has a C compiler).
It is literally the perfect language... when you are a good programmer. The worse programmer you are, the more problems you have with C, something that you are not allowed to say out loud because people who don't like C will you kill you for it.
I wrote a whole game engine in C (basically the whole game, not just the engine).
C is still, to this day, one of the best languages that exist that can do literally everything you can imagine, it has no limitations. Most features other languages have is to prevent bad programmers from shooting their own leg, and this is exactly what happens. If you look at projects written in more high level languages you'll usually see that code quality reduces drastically. There are exeptions, but the higher level the language, the worse the code simply because these languages attract people who can not/don't want to write good code.
Again, never ever say that out loud or be stupid enough to write that on an forum
Why? I starded coding in C few days ago its so annoying why there is no strings? WHY? Why they would torture them self's with C?
Strings are a fundamental concept of C, strings existed in C since the very beginning.
char *bla = "Hello World";
There you go, a string. It is called "String Literal" in the C language. C has support for strings since it exists.
What do you think is the string.h for? What do you think does the str in functions like strpcp() strlen() and strcat() stand for?
Here are the current string functions in the glibc: https://sourceware.org/glibc/manual/2.4 … ities.html
Whoever told you that C doesn't have strings is telling you bullshit. Of course it has, since it exists (By the point of writing this, counting the C89 standard, 36 years)
And yes, object orientation does exist in C too. There are OOP fundamentals with typedef struct and opaque pointer, and there are full blown OOP libraries like GObject (For people who hate themself). The only thing that does not work without lots of effort are overloaded methods which are bad to begin with (Lets make 5 functions that are all called the same but do different things depending on the parameters, that will make code readable and failure proof....)
Here is an overly simplified (almost pseudo-code) example on how to implement your own OOP-like String Class in C
$ cat main.c
#include "mystr.h"
void main()
{
Mystring *str = mystring_new("Hello World\n");
if (!str)
return;
mystring_print(str);
mystring_delete(&str);
}
$ cat mystr.h
// Your own datatype called Mystring. This will be the ""Class""
// Forward declaration in the header so other files who include the header know this
typedef struct _Mystring Mystring;
// Constructor
Mystring *mystring_new(char *string);
// Method
void mystring_print(Mystring *this);
// Destructor
void mystring_delete(Mystring **this);
$ cat mystr.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mystr.h"
// ""Class"" definition
typedef struct _Mystring {
// Member of the class
char *string;
} Mystring;
Mystring *mystring_new(char *string)
{
Mystring *this = (Mystring*)malloc(sizeof(Mystring));
// malloc() returns NULL if an error occurred, check for it
if (!this)
return NULL;
// use the strlen() function to allocate as much memory as large as the string
this->string = malloc(strlen(string));
if (!this->string) {
free(this);
return NULL;
}
// Copy the content from one string to another
stpcpy(this->string, string);
return this;
}
void mystring_print(Mystring *this)
{
printf("%s", this->string);
}
void mystring_delete(Mystring **this)
{
// There are several ways to implement an destructor (Freedom! Thanks to C)
// I personally like the ** variant, so you can set it to NULL inside the destructor
// which keeps the main clean and nice
if (this && *this) {
if ((*this)->string)
free((*this)->string);
free(*this);
*this = NULL;
}
}
In theory you could use function pointer to make the methods a member of the class too, but this causes overhead and i think it looks ugly. I use the OOP parts that make code nice/clean and i leave out everything that i think is ugly. Thanks to C, i have the choice.
In my game engine, i didn't even use opaque pointers because even with GCC optimization, directly accessing members can be faster in certain situations than using get()/set() methods.
And then there are some nice things as ternary operators that make (if used properly) code nice and small and clean https://mastodon.ikaros.space/@vamp898/ … 5760884702
If you know how to properly use BASH with grep/sed/awk, the only other thing you'll ever need is C. If you ever need C support, feel free to contact me on matrix @vamp898:ikaros.space and i'll help you.
And yes, i know, a lot of people are scared away by pointers, but that is because a lot of books make an horrible job of teaching them. I hated pointers in the past too but to be honest, they are the best feature of C! Pointers are amazing, you just have to understand them and then its so cool. A lot of people have the "You have to manage pointers in C" mindset, but its the opposite. You "want" to manage pointers in C, its a good thing, it solves so many problems and gives you so much freedom. Its a dangerous tool, but a very powerful one. You just need someone who is able to properly explain them to you and as soon it clicks, its like "Oh my god, what did i miss out all the time!"
Last edited by Vamp898 (2025-08-31 06:42:52)
Offline
In theory you could use function pointer to make the methods a member of the class too, but…
if you find yourself re-implementing glib or objective-c, just use c++
Offline
In theory you could use function pointer to make the methods a member of the class too, but…
if you find yourself re-implementing glib or objective-c, just use c++
I did use C++ in the past (For Qt mostly so... you could argue if that really was C++ ) and i always like to compare it with art.
Writing Code in C with typedef struct and/or opaque pointer is still elegant and beautiful C code. Its like an drawing of an landscape scene that, when you look at it, instantly make you feel deep rooted emotions that make you sentimental, feel happy and sad at the same time and just make you think "That's beautiful, i want to be able to do that too".
The code that results with C++ is the type of art where people pour paint buckets over their body and roll over canvas. I mean.... its art and... it will probably cause whatever emotion looking at the result. But its not the art i am looking for^^
Last edited by Vamp898 (2025-08-31 07:06:28)
Offline
Lets make 5 functions that are all called the same but do different things depending on the parameters, that will make code readable and failure proof...
This whole phrase made my day , but the paragraph also involved was so true to read. I was thinking, YES, oh my god that is so java.
and then...
In my game engine, i didn't even use opaque pointers because even with GCC optimization, directly accessing members can be faster in certain situations than using get()/set() methods.
Your post really made my day, probably you are going to make cry in the corner a person who likes developing in java after reading it .
And yes, i know, a lot of people are scared away by pointers, but that is because a lot of books make an horrible job of teaching them. I hated pointers in the past too but to be honest, they are the best feature of C! Pointers are amazing
It's not hard to understand, I think is the handling of it is more difficult if you are newbie, because for some reason people tend to forget the free and nulling of the pointer, but if you are into it probably valgrind is going to tell you. And probably new people doesn't know valgrind.
C was my first language , I miss programming in C :C, I still remember it but I started to learn more of IT, web programming, ML and devops, so in the end I started to do less programming in low level languages. But I really like it and probably going to do it again in the future
t is literally the perfect language... when you are a good programmer. The worse programmer you are, the more problems you have with C, something that you are not allowed to say out loud because people who don't like C will you kill you for it.
Well I understand your issue, but you should definitely make a book or a document about all the things you wrote here, I'll definitely buy it or read it
May I ask to you: Do you have any reason to avoid using the c++ already made data structures and instead creating it in C apart for the "artistic" thing ? I mean, most of the people who loves low level programming are: yeii we love C but when we are going to create a project then we are going to make it in c++. Most of the time I think is because of avoiding to rewrite all the OOP abstractions and data structures that C++ offers just instantly. But since you created your whole game in C: Do you think is that the case? Or do you really can see some advantages in creating the data structures by your own ? As for me you can talk this as freely as you like
Last edited by Succulent of your garden (2025-08-31 11:10:11)
str( @soyg ) == str( @potplant ) btw!
Online
C fills a niche, and higher-level programming languages fill a different niche. C is incredibly mature, allows you to do basically anything, is supported everywhere, and allows you to deeply understand and comprehend your program's behaviour, which is often useful, especially where performance is a concern. C is also "simpler", in the sense that its standard is shorter than those of other languages, thus making it easier to master.
Also, I think Materac thought there were no strings in C because they're not their own type (the strings are character arrays).
would I recommend it to someone without prior knowledge of higher languages? no! but back when unix was invented there were no simpler higher languages - and yet people still made it to the moon
C was not the pinnacle of luxurious abstraction even at the time. Lisp is from the 50s. Object oriented programming, in some form, is also older than C.
this->string = malloc(strlen(string));
Can you tell me what's wrong with this line of code? :^)
"Don't comment bad code - rewrite it." - The Elements of Programming Style (1978), Brian W. Kernighan & P. J. Plauger, p. 144.
Offline
May I ask to you: Do you have any reason to avoid using the c++ already made data structures and instead creating it in C apart for the "artistic" thing ? I mean, most of the people who loves low level programming are: yeii we love C but when we are going to create a project then we are going to make it in c++. Most of the time I think is because of avoiding to rewrite all the OOP abstractions and data structures that C++ offers just instantly. But since you created your whole game in C: Do you think is that the case? Or do you really can see some advantages in creating the data structures by your own ? As for me you can talk this as freely as you like
C++ takes (much) longer to compile, is harder to optimize for the compiler and will ultimately end up with code that needs more CPU cycles/memory.
But I am well aware that I am too cautious about CPU/RAM usage. I try to use array over pointer whenever possible because array land on the stack while pointer end up on the heap. Also when using an unsigned 8bit int, you basically waste 8 array elements just to store the address with the pointer (on an 64bit system).
So I actively try to avoid pointer when storing small data and rather copy variables between functions unless the duplication of the copies take up more RAM than the pointer would. And as you would need at least two pointer, that's already 128bit.
Very likely i am way to cautious about resource usage and I assume, there would be pretty much no difference in runtime and/or memory usage in the real world in my engine in C++, but for me, that is part of the fun. I like optimizing and enjoy it, I don't see it as an burden.
It's always fun after checking some parts of the code to notice like "Oh, this enum will no longer have >=255 elements after the last change, an uint8 is more than enough for it.
Yes, I am one of the few people who is very happy that C23 introduced data types for enum^^ 99% of my enum are uint8_t because I rarely (if ever at all?) need more than 255 elements in an enum.
Basically, I prefer C over C++ (overall), and I do not need the OOP features C++ offers. There was not one single instance where I thought "Oh that would be easier in C++". For me, using typedef struct doesn't feel like implementing C++ features in C, it's just a natural basic C feature that was always there and hence long before C++. For me, it's the other way around.
C++ extends C by features I don't see myself using.
Can you tell me what's wrong with this line of code? :^)
I don't understand the question, I am efficiently saving 8bits
But jokes aside, for someone who really wants to know, the glibc manual even explains it (I am positively surprised, the glibc docs are pretty good)
https://sourceware.org/glibc/manual/2.4 … ation.html
And strlen() doesn't count it
https://sourceware.org/glibc/manual/2.4 … ength.html
I assume the code would still work... Maybe. I guess printf() just stops when it reads the end but the correct answer is, the result would be undefined. But yes, strlen() is 1 byte too short.
I missed the chance for an nice macro there^^
Offline
Very likely i am way to cautious about resource usage and I assume, there would be pretty much no difference in runtime and/or memory usage in the real world in my engine in C++, but for me, that is part of the fun. I like optimizing and enjoy it, I don't see it as an burden.
I like how you see it. Also I didn't knew that C++ compilation is slower compared to C. I'm surprise by the detail level that you have in C, I was reading your post like, yes, yes, that makes sense to me, yes, yes . I'm also surprise by your good and efficient level of English language if you are native from Japan. Does these kind of knowledge around there is more discussed ? Seems that over there you really like this kind of stuff. Or that's not truth ?
Do you recommend some books or resources to learn C & C++ ? Or you just went learning while programming ?
Last edited by Succulent of your garden (2025-08-31 18:44:03)
str( @soyg ) == str( @potplant ) btw!
Online
I assume the code would still work... Maybe. I guess printf() just stops when it reads the end but the correct answer is, the result would be undefined. But yes, strlen() is 1 byte too short.
It is indeed undefined behaviour, but what I'm worried about isn't printf() not seeing a null terminator, but the memory allocator being interfered with. In my experience this usually leads to errors when you least expect it.
Replace your main.c with this:
#include "mystr.h"
#define MAXLEN 10000
void main()
{
char buf[MAXLEN];
for(int i=0;i<MAXLEN;i++)
buf[i] = 'A';
for(int i=1;i<MAXLEN;i++){
buf[MAXLEN - i] = '\0';
Mystring *str = mystring_new(buf);
if (!str)
return;
//mystring_print(str);
mystring_delete(&str);
}
}
On my system, running this gives this error:
double free or corruption (!prev)
Aborted (core dumped) ./str-test
And here's the back-trace in gdb:
#0 0x00007ffff7c9894c in ?? () from /usr/lib/libc.so.6
#1 0x00007ffff7c3e410 in raise () from /usr/lib/libc.so.6
#2 0x00007ffff7c2557a in abort () from /usr/lib/libc.so.6
#3 0x00007ffff7c26613 in ?? () from /usr/lib/libc.so.6
#4 0x00007ffff7ca2d65 in ?? () from /usr/lib/libc.so.6
#5 0x00007ffff7ca4d8c in ?? () from /usr/lib/libc.so.6
#6 0x00007ffff7ca4ebd in ?? () from /usr/lib/libc.so.6
#7 0x000055555555533b in mystring_delete (this=0x7fffffffc1d8) at mystr.c:43
#8 0x0000555555555224 in main () at main.c:19
Of course, adding +1 gets rid of the bug.
"Don't comment bad code - rewrite it." - The Elements of Programming Style (1978), Brian W. Kernighan & P. J. Plauger, p. 144.
Offline
Leads to errors because your previous free frees into the next memory segment.
When people say "but C is insecure" they mean the C in "malloc" and imply a pun about the offset char* pointer (i think )
https://man.archlinux.org/man/strdup.3.en
https://man.archlinux.org/man/strncpy.3.en
Just ooc, if you're not using the return value anyway, why would you go w/ stpcpy itfp?
Offline
I personally think, but that is just my opinion, that rather pseudo-code written as an forum comment maybe should not be too over analyzed But i am the one to blame because it probably is too close to actual code you might experience (i hope not), i just wanted to highlight the concept of typedef struct and opaque pointer and how it could be used to get you enough OOP fundamentals for most cases. There was no real reason for using strpcpy other than, it was the first that came to my mind
and not caring for its return value is by far not the only issue with the code^^
I'm also surprise by your good and efficient level of English language if you are native from Japan. Does these kind of knowledge around there is more discussed ? Seems that over there you really like this kind of stuff. Or that's not truth ?
I was born in Germany and move to Japan.... 3 years ago? Something like that^^ almost 3 years. So my English proficiency is due to learning the original version of that language as my mother tongue but its by far not perfect. Especially when writing, i tend to uppercase substantives that sometimes gives off the impression i am highlighting random words
Do you recommend some books or resources to learn C & C++ ? Or you just went learning while programming ?
I personally recommend "The C Programming Language Second Edition" as a base. Even though it covers an older C standard, i personally do not think that is an issue as 1. What changed is easily available on Wikipedia and 2. Also available in form of a book called "Modern C" which is available as a free PDF.
But i am not sure if that is the best method, its the one that worked for me and i would not call myself a highly skilled C programmer at all. Most of my knowledge is in simple desktop applications using GTK+ and the game engine i wrote. And the first version of that game engine was written for the SEGA MegaDrive. The biggest reason to switch over to SDL and write it for modern systems was, that it gets a player base outside of an tiny niche.
So i started from scratch using SDL and because i have no limitations anymore, i started doing things that would not have been possible on the MegaDrive, but i still use the overall concepts that are used on that console. So for example, i display text using a bitmaps. For example for font-size 16 (which means 16x16 tiles for letters) i have a bitmap containing all "letters" (numbers, kana, kanji too) and and the number corresponds to the position in the bitmap file. So my strings are uint8 (for Englisch/German) and uint16 array with an font rendering engine that displays 16x16 tile at position x/y on the screen depending of the number.
The game runs at an native resolution of 320x240, so TTF Fonts are a bad idea for several reasons. No font (especially japanese ones) are optimized to be really usable at that screen size. Most of the characters in the bitmap font-file are hand drawn (especially in the 8x8 size), even with disabled hinting and everything, most TTF fonts do not just look ugly because they need manual optimization, they waste tons of storage space too (especially Japanese ones, the TTF file would be larger than the whole game) and rendering them on screen wastes tons of CPU cycles and needs a lot of memory.
Would i ever recommend anyone doing that? Hell no! Its stupid! Don't do that! Don't write your own font-rendering engine using your self-made character encoding. But i'll do it because its fun and i like it^^ And lots of stuff like that.
When i wrote the first version for SDL, because i am free of hardware limits, i wrote an scripting language for events with an interpreter... then i thought "that is too much bloat" and optimized it (after finishing it... again, don't do that ) by writing the syntax directly into headers using enum because then, i have the type-safety of C and i do not have to waste resources reading the script from a file.
And after finishing that and got that working just fine, what did i do? Continue writing events? No. I did profiling and said to myself, this is just a waste of resources, i am going to directly code the events in C.
So i wrote an scripting language with interpreter, threw that away, wrote a stripped down version using array/enum (Which was not a far stretch as i used that concept for the interpreter anyway) and threw that away and i am now writing all events directly in C. Every single event in the game is a C function and yes, it was a headache coming up with a nice way to name them and structure them in headers so it is not going to be a mess. I make stupid decisions but i still do care that the result looks nice, clean and is manageable^^
So except for basic concepts i do not think, anyone should learn how things work from the code i write^^ its highly optimized for my personal pleasure and most people would hate you for writing such code. But the game engine is 55kb in size (after stripping) and 99.9% of the used RAM is taken up by the music and sound effects that play (as i care a lot about sound, i do not use lossy compression, so sound files tend to be large and i am not streaming them from the storage. The current song is always fully represented in memory). Playing the game on the Switch gives you longer battery life than just having the Switch Main Menu open and do nothing^^ In scenes where nothing happens/changes (especially in menus or most of the dialog) i do not re-draw the screen. So as long nothing happens, almost all of the time is spend in an sleep() waiting for the next frame that does nothing but checking if something changed on screen and if not, does nothing. As soon something does happen, the game does into an "drawing state", draws everything how it should be and then goes back to sleep until something happens again.
So i know i am doing it wrong, but i love the result^^
Last edited by Vamp898 (2025-09-01 16:16:09)
Offline
I was born in Germany and move to Japan.... 3 years ago?
That explain a lot , I was thinking: How I can't see any Engrish in this person ? There must be something wrong
So in reality Japanese characters does take more space by obvious reasons. But does also the rendering is more harder than Latin based characters ? I mean I know that Hiragana and katakana must be more simple, but Kanji not sure. In simple words: If I play a japanese game in japanese characters is going to be more demanding for the system than If I just went to just use japanese audio with english subs ? Btw, I know that in someway the translation is going to be impossible 100% perfect, but I guess for me in some sense I have good ear and I know the just enough japanese to understand the words well. Like for example the most obvious O genki desu ka? it's more like are you with energy, than how are you, because genki means "energy". Well it's funny to catch that "miss translations" in german it does also happend, like with Tut mir Leid, as far as I know is more like [ for me]: It does me pain [it gives me pain], and Entschuldigung is more like forgive my insolence or forgive my mistake[guilty, I know, edit], so you get the point, I'm sorry is not enough, you can go forward in translating but not in backwards, at least for general public. I had meet at least three people who speaks japanese in my life for different reasons, and I went and do my research to understand how the language works, more like how the syntax and semantics works, but never learned the language, it was not my primary goal. So probably you know what I'm talking, and now more cases than I, but I know the enough to listen and with subs in another language so I can break the semantic walll in the words, because Tut mir leid doesn't mean I'm sorry Imagine that I'm native Spanish speaker also seeing of all this stuff
, sometimes my brain just explodes and mix word order between language. One day some friend just ask me: Why are you talking like Yoda dude
? After that It never went that far
. German just destroy my brain['m still learning it], I also knew a case of a German here that went in the same but backwards, it was learning spanish, and for both was: We are so tired let's start talking in English using words of the other languages in between, someday I just went full 404 and I was: Oh no, I forget how to say this thing in my native language, and in English, but I know how to do it in German, So speaks one phrase in german, then english back again
It was a mess, but was very funny and nice
as i care a lot about sound, i do not use lossy compression, so sound files tend to be large and i am not streaming them from the storage
Probably you know this but just in case: Did you know FLAC format [Free Lossless Audio Codec] ? Probably if you are doing everything with wav is going to reduce the size a lot. Back many years ago, I change many wav files into FLAC and as for me, You didn't feel the change, sometimes I just felt that It just sound better. I was not the only person thinking or believing that.
. Especially when writing, i tend to uppercase substantives that sometimes gives off the impression i am highlighting random words
I totally get it, since your native language does that a lot
I really enjoyed your last post, It was so pleasant to read after a very hard and heavy day. Thanks so much for the information ^^
Last edited by Succulent of your garden (2025-09-01 23:42:00)
str( @soyg ) == str( @potplant ) btw!
Online
About Character rendering... it depends, it is a very complicated topic that is not easily explained
If you're talking about real font rendering (not the crazy garbage i do for my game engine), you would usually use 32bit for UTF-8 to get access to all characters.
No Matter if you print a 0 or an 龍, you would use 32bit for both, that is the nature of UTF-8. In theory it would be possible to mix 8bit, 16bit and 32bit, but that would be even more insane than the stuff i am doing, absolutely do not do that ever^^ Pretty much all libraries expect an 32bit anyway in the end, so you would use 32bit for UTF-8 normally.
About TTF Font Rendering, TTF uses vectors. The more vectors you have, the more calculation do you have to do to display them on screen. Every stroke is basically a formula that needs to be calculated so the more strokes you have and the more not-straight they are, the more math you need and hence more CPU cycles.
Usually this all is done by comfortable libraries. SDL, GTK+, Qt and so on, they all have ready-to-go support for UTF-8 and TTF Font rendering. I did choose not to use that, but as said, that is stupid and you should not do that^^ If you want to display fonts on an screen, use 32bit UTF-8 Support and TTF Fonts.
So in theory, yes. Japanese characters will be more demanding on your system when you use TTF (Doesn't matter for bitmap fonts because an 16x16 image is an 16x16 image, no matter whats inside), but the difference is marginal and it is really not worth thinking about at all. You can safely ignore that difference. I use LabWC without an Panel but i still use TTF fonts^^
About translations, yes, its impossible to translate some things and i do fail often too. I can say things in Japanese where i do not know how to say the same things in English and/or German. When i am talking/writing Japanese, its like a switch that i flick and i do not translate back/forth or think about "What would that be in my native language" or stuff like that. German, English and Japanese are basically different parts of my brain that work separated from each other
My whole music collection (I am one of the people who buy music, so i have all my music offline) is in FLAC but, fun fact, you need WAV in the end. The libFLAC library will convert from FLAC to WAV so you can play the WAV file. It is similar to PNG/JPG and BMP. FLAC/PNG is compressed, you need to decompress it to work with the data which means, in the RAM, it will end up using the same amount of RAM.
Actually it will need more RAM as you have to put the FLAC into RAM, then convert it to WAV (actually PCM but i don't want to get too deep into the topic) and then play the resulting WAV. So even though WAV uses the highest amount of disk space, it needs the least amount of RAM/CPU to be loaded and played as you do not have to decompress/convert anything. The same is true for BMP. For 100% utmost performance and highest optimization, you would have to use WAV and BMP.
Probably you could use IO Streams to decompress in chunks to save RAM, but that would cause a lot of CPU cycles to constantly stream the file from the storage media into the RAM. When coding in C (but this is true for other languages too) you will often have to decide "Do i want to hog the CPU or the RAM", its usually pick your poison. I try to keep RAM usage as low as possible, but do save CPU cycles over RAM.
I do that for my game (also because i want to have as less dependencies as possible. I am only using Core SDL, no SDL_image, no SDL_ttf and so on) but i would never ever use WAV/BMP outside that scenario. I use FLAC/PNG like a sane person for music and images^^
And thanks for the last paragraph, i do enjoy this conversation too (of course, all contributions to it from all members)
Last edited by Vamp898 (2025-09-02 12:15:50)
Offline
I too have, on numerous occasions, failed to resist the urge to implement bitmap font rendering. You always have to be realistic about it, though, especially if you're trying to implement Unicode and everything it contains, which is probably not possible for a single person to do well. This article goes over just some of it. I think Vamp898 has the right idea using a custom encoding.
I hate anti-aliasing so much. I have my window manager and browser set to use bitmap fonts (mostly Adobe Helvetica) and I went out of my way to write my own SDL bitmap font rendering code because TTFs with anti-aliasing disabled look ugly and the only bitmap font rendering library I could find for SDL was terrible (it rendered things wrong, messed up the encoding, and the makefile wasn't even properly configured so I had to compile one of the files manually). I wouldn't have bothered if bitmap support were more common-place. I still haven't figured out how to fully configure Firefox to use bitmap fonts; the GUI elements still just use a TTF font with anti-aliasing off.
To be fair, anti-aliasing looks good for large text, just not for small text. Also, apparently TTFs can have built-in bitmaps specified for certain sizes; are there fonts that do this? I don't think I've ever encountered any. I wonder how this was handled back when anti-aliasing was less universal, like how Windows XP used it just for title bars.
"Don't comment bad code - rewrite it." - The Elements of Programming Style (1978), Brian W. Kernighan & P. J. Plauger, p. 144.
Offline
Thanks vamp898 for the message. I was also yes,yes,yes, that's seems true, and yes yes yes in the last one
I didn't knew the whole process around FLAC, it does make sense to me, thanks for all that new info for me, I also try to have the three brains separated when using languages. And you remind me when the world wasn't around UTF-8. this conversation probably was very common back in those days ,
My brain can't write too much, I'm so tired but you made my day with your post. I really like it, you know so much in detail and I'm glad you have your music in off line. I do sometimes have music in cd. I have a lot of cds but now days I just don't listen too much music. More like in someway I'm a bit tired about music in general, I do want to buy some Bill Evans piano records in the future, so I can FLAC them I have it in my computer , but now days most of the people just launch their music in internet. I get it most of the time they earn more money with that business approach, and for some people they can create without the label record telling what to do. But the cd/ vinyl thing is a plus to me. I think is a plus because I'm the kind of person who in reality doesn't like to hear music without doing other things, I want to focus in listening. So the retro approach force me in some way to get in the couch and take a moment. But now days is so hard to me to do that, also when I'm tired I put some music to distract me from my tiredness , but that one is not something that I like to do, is more like a mean to solve something that I must attend. 100% I'm the couch music listener in my hearth, I really don't get it how people can listen music in the metro or walking, When I was 10 I just stopped making that. I think I started to dislike in someway overstimulated life. It's not like stop doing things that you enjoy, is more like keep time in your life where you do nothing. I think is good for your health in some way.
You remind me about koyaanisqatsi, the film that uses Philip Glass soundtrack, I believe that thing in someway explain the over stimulation issue.
Okey time for sleep here, I really can't write no more ZZZZ.... ^^
str( @soyg ) == str( @potplant ) btw!
Online
Pages: 1