Danya🔥
"it's your fault" - this is the motto of C language
%Nikita
So what? We do not actually get to know about the computer architecture while programming in C, right?
Maybe not such fundamental things. But memory heap, allocation stuff, and so on. Not alu of course
Danya🔥
Maybe not such fundamental things. But memory heap, allocation stuff, and so on. Not alu of course
So, this is not computer architecture stuff, but OS But we learn how to use it, but not how it works You can learn to allocate memory in the C# the same way
%Nikita
This is not UB, it is VALID C
I had once experienced segfault while writing to string declared by string literal and pointer. So now I do not do it, and this is no longer a trouble. My compiler puts this kind of strings into readonly section and it explains why writing to it causes error
Danya🔥
So what?
%Nikita
So, this is not computer architecture stuff, but OS But we learn how to use it, but not how it works You can learn to allocate memory in the C# the same way
But what about microcontrollers? You can write directly to registers on AVR for example. Registers are a part of architecture
Danya🔥
How does it prove that the language is WELL designed if it allows to do such stupid stuff?
%Nikita
So what?
So after this I don’t write to strings declared that way
%Nikita
How does it prove that the language is WELL designed if it allows to do such stupid stuff?
But it is only one example, and I am sure it’s somehow written in standard
%Nikita
Registers are not part of the C language :)
Yes, but part of architecture :) avr library gives you interfaces and macros to work with it
Danya🔥
But it is only one example, and I am sure it’s somehow written in standard
Yeah, in the standard it is written that it is legal > But it is only one example Yet you never provided any example what is good about C Maybe implicit conversion? :)
Danya🔥
Yes, but part of architecture :) avr library gives you interfaces and macros to work with it
So we get to know about computer architecture more when we are working with the specific architecture, not while we are learning C :)
Danya🔥
Ok, I can provide such example. The variable declaration is mirror of how you use it
I do not understand you Do you mean that C invented variable declarations?
Danya🔥
I do not understand "mirror of how you use it"
%Nikita
I do not understand you Do you mean that C invented variable declarations?
No, it’s not. But even if it’s not. There are a lot of stuff in C from Fortran for example. It doesn’t make it bad
Danya🔥
I do not understand "mirror of how you use it"
Can you please elaborate your thought?
%Nikita
I do not understand "mirror of how you use it"
When you declare an array of pointers for example int *p[2]; In declaration you can see the same sequence of operators like if you will use it: *p[0]
%Nikita
Can you please elaborate your thought?
Sure. It’s clear how to use variable when you see it’s declaration
%Nikita
Sure. It’s clear how to use variable when you see it’s declaration
Also some people are talking about hard declarations. But there are strict rules describing how to read such complicated decls. But it isn’t a good practice to create them :)
Azadi
You should initialize it before dereferencing the array pointer.
Danya🔥
When you declare an array of pointers for example int *p[2]; In declaration you can see the same sequence of operators like if you will use it: *p[0]
It doesn't help after you pass your lessons on pointers and arrays void (*foo[])(void (*)(int), int(*)[42]); But now, if you're praising variable declaration style in C, can you without a bottle of vodka say what's the type of foo?
%Nikita
You should initialize it before dereferencing the array pointer.
If you take an element on index [0] you’ll get a pointer. You get the int by dereferencing it. Declaration tells you how to reach that int
Danya🔥
I can say, but it’ll be too long to write it there :)
So you think that it is a good variable declaration style?
%Nikita
It doesn't help after you pass your lessons on pointers and arrays void (*foo[])(void (*)(int), int(*)[42]); But now, if you're praising variable declaration style in C, can you without a bottle of vodka say what's the type of foo?
Let me try btw. An array of function pointers. Each function returns nothing. Each function takes a pointer to another function, which returns nothing, and accepts int. The second parameter is a pointer to an array of 42 ints
%Nikita
So you think that it is a good variable declaration style?
The good declaration style is use of typedefs
Danya🔥
Tommaso
Hi all, I have a problem using a handler for a SIGINT, when I click ctrl+d it prints the message put in a printf many times, even though there is no loop, has anyone ever had the same problem?
Danya🔥
It’s simple to read this: typedef void (*func1)(int); typedef int (*arr1)[42]; typedef void (*func2)(func1, arr1); extern func2 f[];
using func1 = void (*)(int); using arr1 = int (*)[42]; using func2 = void (*)(func1, arr1); That's easier, don't you think?
%Nikita
using func1 = void (*)(int); using arr1 = int (*)[42]; using func2 = void (*)(func1, arr1); That's easier, don't you think?
It’s kinda the same, except the names come in the beginning. For me typedef version is comfortable
Harshit
I never thought about this while doing function pointers
%Nikita
You're just old school
Maybe) But not old school enough to use K&R. I prefer C11
Dima
based
%Nikita
I prefer C++20 :)
I have very small experience with C++, but I remember C with classes :)
Ehsan
I prefer C++20 :)
is Modules ready yet?
%Nikita
using func1 = void (*)(int); using arr1 = int (*)[42]; using func2 = void (*)(func1, arr1); That's easier, don't you think?
But, at the end, you still can cast it to void* and nothing will change. But it’ll be harder to get some element from it
Danya🔥
And I hate C
Danya🔥
So..
%Nikita
And I hate C
But there is no C++ without C)
Ehsan
c++ is c with classes lol
Azadi
If you take an element on index [0] you’ll get a pointer. You get the int by dereferencing it. Declaration tells you how to reach that int
That's right, but, just to be sure, did you mean using it like the way you wrote? int* a[2]; *a[0]; // eg, *a[0] = 5; or like that?
Ehsan
c++ is c with classes lol
Joking Danya don't show your wrath 😂😂 C++ is the greatest language it should be worshipped by everyone
Azadi
Yea, *arr[]
You should initialize a pointer before dereferencing it.
%Nikita
c++ is c with classes lol
It was c with classes when Bjarne introduced it. But it’s no longer c with classes. It’s two completely different languages, but syntax looks kinda the same
%Nikita
You should initialize a pointer before dereferencing it.
I mean if you already initialized it you can use it this way
%Nikita
Yeah I know just Joking
C with classes nostalgia …
Anonymous
What if i don't know anything about coding then how can I code -_- ?
Bro start learning python so that u can learn it online it will be easy If u directly jump c++ and in online 🥲then gonna be hard
Anonymous
i only know a little coding
Bro u are at 6 video that doesn't mean u know coding It's just ur starting When u get ur basics done then u can say i know coding little bit In my opinion
Azadi
True 👍 He will left coding after he get into pointers concept or oops He must start with python or Java i think And he even have not done c🥲🥲
There're some facilities in modern C++ that make it easier persistently. concept (and requires to get rid of SFINAE and its stuff), fold expressions, auto , and many more tools are great helpers. There's also a considerable number of different containers that assist you much in different situations. There're references, raw and smart pointers in C++. (While there's only raw pointers in C I guess) So using modern C++, say, C++23, you will have less worries.
Mar!o
But both languages are not great
C definitely has its place for really low level software like kernels vms or jits
Talentless guy
guys, i dicided to start c language . is it good for a beggining
Mar!o
GraalVM and V8 don't agree with you
True but LuaJIT does And it’s faster than both I think a reduced C++ feature set is the best way to go. C++ makes it hard to see what’s going on behind operations sometimes. I prefer C for really low level stuff, there are less pit falls. For high performance applications or other stuff C++ is amazing.
Mar!o
I even use modern C++ in my game engine and it’s amazing fast and clean
Mar!o
But for really low level stuff I either prefer C or reduced C++
Pavel
guys, i dicided to start c language . is it good for a beggining
Depending on what you are aiming for and what is interesting for you, it is good if you want to learn more about hardware and low level stuff
Mar!o
GraalVM and V8 don't agree with you
Also C has no name mangling so embedding VM is easy possible and it’s easy to create FFI bindings for other languages like Python oder Java with C++ it’s harder That’s why C is sometimes great 😊
SID
Hey, where can I find the c++ programming language videos ?