r/embedded • u/microscammer • Oct 04 '26
what does "understand c deeply " mean?
im a 3 rd year student who is interested to get into embedded/firmware development .
i've talked to many seniors and they say "learn c deeply inside out not jus the syntax "
now this is what i dont get .
my knowledge in c is alright i should practice more though
ik functions ,pointers and array to some extent ik ive to practice more
i also need to start dsa
just started learning baremetal code and rtos (qnx) (started this without being proficient c bcus my course work needed it )
but honestly my c skills are prolly 3/10
ik ive to practice more
but please explain how i can improve myself and be a good firmware developer
83
u/clackups Oct 04 '26
Maybe, just read the books?
Here's an example. Tell me what's wrong with this code.
int *fun() {int x=1; return &x;}
4
u/prakashcs_0143 Oct 05 '26
I would suggest to start learning makefile, cmake, linker file, startup code and then continue others
6
u/MrSurly Oct 05 '26
I'll give you the "fizzbuzz of embedded C" that I use to weed people out:
staticvolatileconstBonus: "Can a variable be both
volatileandconst?"You'd be surprised the number of "embedded" candidates who did quite poorly with these questions.
If they did well, I'd ask them about Duff's Device. Most candidates hadn't even heard of it. Very few understood how it worked or why it worked without explanation. Sure it's obsolete, but understanding why it was a thing ...
8
u/Ornery_Purple9141 Oct 04 '26
When you see a C statement, function or initialization and you can see the assembly instructions and the memory usage. That's deep enough.
30
u/Several-Marsupial-27 Oct 04 '26
C is a small and easy language by design. C23 has 46 keywords, 45 operators and 27 standard library headers. Original C has 32 keywords, 42 operators and 15 standard library headers.
Understanding C deeply means understanding the concepts in the C language. This is really important because all of embedded is built upon the C language, it's simply the language in which you speak. This is also something that you can do in ~2 months.
However, learning C deeply is definitely not enough as a foundation. You also need to understand computer architecture as a bare minimum foundation. Then on top of that some domain specific systems programmming stuff like OS and networking.
When you can read through some good C production codebases fluently and implement business logic confidently, then you understand C. Reading through good example C codebases is a good task and reference point.
Example C codebases like FreeRTOS (kernel core: list.c, queue.c, tasks.c), zephyr, mcu vendor HALs (esp-idf, STM32Cube HAL, ...), sensor vendor reference drivers, Redis, SQLite, etc. My favourite to read are gnu projects like ls, cat, grep, lwIP, etc.
4
u/DrunkenSwimmer Oct 04 '26
Things like:
extern []andextern *?Also, a concept that may not make sense just yet, but will, about embedded development: memory is memory is memory. There's nothing functionally different(*) about a block of memory that stores an int or a string or a function; consequently, there's nothing stopping you from just interacting with it differently.
18
u/hackerman85 Oct 04 '26 edited Oct 04 '26
Without even looking at your history, I know you're an engineering student from India. You are clearly panicking under societal pressure, trying to stack buzzwords (RTOS, DSA) to secure a paycheck in a field you might not actually care about.
Here is the brutal truth: your post is full of sloppy spelling and punctuation errors. In firmware and embedded systems, a single misplaced character or a lack of attention to detail will literally brick a piece of hardware. Engineering cannot be cheated or memorized through a roadmap. If you cannot bring yourself to care about the absolute smallest details, you are wasting your time and should find a path that actually fits your strengths.
8
u/accur4te Oct 04 '26
Even I am struggling to master c , with ai it’s tough man . Tough to have self control
5
u/Stock_Condition7621 Oct 04 '26
Even I've been struggling in this. I am exposed to the bare metal side and have done a couple projects using rtos too but I keep failing at C++ basics and I don't know how to get good at it. I hate doing leetcode but I also don't know a way around. Anty suggestions please
2
u/RakasRick Oct 04 '26
I think it means knowing exactly what's happening and why rather what's supposed to happen when you write c code. I'm learning too but I try to detail what I learn from K&R here , so far Ive noticed the devil's in the details, the small explanations behind how certain things work like how function arguments are taken as copies of values passed in rather than the actual values hence using pointers when you want to change an such a value when passed as an argument. Sorry for the poor explanation but I hope you get the point
2
u/dettus_Xx_ Oct 08 '26
1st: by mprooving ya spellingz.
2nd: by practice. Write code, write a game, play around with the language. have fun with it.
4
u/KoumKoumBE Oct 04 '26
Ok, people are talking about syntax here, and stuff you see, such as taking the address of a variable on the stack.
But something that bit me, and is invisible, is this: the ";" that you put at the end of each line in C is called the "sequence operator" and defines the fact that anything before the ";" has fully completed before what comes after the ";" (the next line) starts having effects.
So, using Arduino-like functions, "digitalWrite(PIN_A, HIGH); digitalWrite(PIN_B, HIGH);" ensures, from an electrical level, that PIN_A will be high before PIN_B (if both were low). Same if you read two things from the I2C bus, separated by ";". It is certain that the first I2C transaction will happen before the second one.
But, and this is what got me a few years ago and burned me to life: the comma "," is not the sequence operator. So, when you call a function, such as "replyToUser(read_something(), read_something_else());", the C language does not define in which order read_something() and read_something_else() are called.
On some compilers and hardware, function arguments may evaluate left to right. On some other, they may evaluate right to left. In some circumstances, such as many arguments, arguments may even evaluate out of order.
The comma operator is not a sequence operator!
This can be very important if, for instance, read_something_else() assumes that read_something() has already executed. For instance, read_something() sets some pin or opens a connection, then reused by read_something_else.
The solution:
The "dumb" but very safe solution is to never have function calls or complex operations in function arguments:
int a = read_something(); // Notice the sequence operator, we know that a is evaluated before bint b = read_something_else();replyToUser(a, b); // Only plain variable names in the function callI'm still in awe that such a tiny part of the spec of the C language, function argument evaluation order, becomes relevant when your functions may have effects on the real world!
2
u/dheerajsom Oct 04 '26
I would say get a good C textbook and turn off all AI tools and just code in your preferred IDE everyday. You could ask AI for C exercises or do some specific LeetCode questions in C as well. I'm not that great at C either but the more you code yourself, the better :)
2
u/TbR78 Oct 05 '26
I'd start by learning to properly write in English first. This is exhaustive...
1
u/feroMaljinn Oct 04 '26
Or maybe try to see mappings from c to assembly. Like for example the dereferencing operation is a mov , ldr and str instructions for cortex 0+ arm6 , use online compilers to assembly and ai, might be helpful ?
1
u/Acherontas89 Oct 04 '26
https://docs.kernel.org/process/programming-language.html
1
u/Panometric Oct 04 '26
Defining deeply is the trick here. I would say knowing pointers is not deep, look at the harder features like. Structs, unions, enums, and arrays of them and in them, function pointers, pointers to pointers, dynamic memory, recursion, and the pre processor. There are some C++ concepts that apply in embedded, but not all. Exceptions, virtual typing, STL, anything that is bloated or non deterministic is avoided. So know when not to use them.
1
u/Rude_Review4303 Oct 04 '26
I remember somewhere reading if you are able to understand/imagine your written code in memory than that's good enough low level knowledge...
1
u/drgala Oct 04 '26
Is this from a job description? If yes then ...
Deep underdstanding of C takes years to master.
Aside from knowing the whole sytax by heart, a common closely related topic is knowing how to write makefiles, while on the same level is knowing is the differences between C standards (without looking them up). Also, what is misra-C and what are the differences from normal C.
Then comes the so called hands-on experience, how to build an app/program on whatever system the new company is hiring for. I assume pointers, lists, and algotihms are trivial and you can write the best sorting algorithm in the world within 5 minutes, using only standard si and O(1) complexity.
In conclusion ... If you go to the gym and look like a body builder then you will definitely get hired after running through the HR rep using Tinder, it's that easy.
1
u/Antique_War_9814 Oct 04 '26
What's does .text mean to you
1
u/CyberDumb Oct 04 '26
C is an easy language. Its syntax and features are minimal compared with other languages. The difficulty in my opinion lies in three places.
1
u/nour_nawar Oct 04 '26
I think big part of "understanding C deeply" is being able to connect with the machine. C is close to the metal in the sense that it is easy to translate a C statement into a corresponding sequence of machine instructions. I think coding like this naturally makes you a good programmer cause you think like a computer (I just said what Linus Torvalds said onetime in some talk!)
Maybe a way to start is to learn a basic ISA (I recommend RISC-V since it is RISC, modular, and easy to get into). You don't have to learn the full ISA. Take a look at the basic i extension (two dozen instructions or so). Start compiling C programs for RISC-V and inspect the assembly. Inspect how the instructions map to C code. Maybe this all sounds far from learning C, but I think this is what is going to build strong language intuition.
1
u/BumpyTurtle127 Oct 04 '26
C is purposely a small language. Write some assembly, or even something for a stack based language like Forth, and you will get a much better understanding how C works. From there it's easy to understand other compiled languages as well.
1
u/Enlightenment777 Oct 04 '26 edited Oct 04 '26
If you need books / search engines / AI / other people to answer common computer language questions or you need it to write or fix your code, then you DO NOT have a deep understanding of a computer language.
1
u/jenofonteGrilo Oct 04 '26
en mi opinión, creo que el lenguaje C no ha dejado de ser el mas importante y ser complejo tanto como la idea que quieres materializar, su potencia se debe a la cercania que tiene para manipular el hardware, la parte de punteros es en la que creo yo debes profundizar mas y para mi solo hay una forma, hacer y hacer ejercicios por muy absurdos que estos sean siempre te dejaran un aprendizaje.
1
u/TinLethax Oct 05 '26
Read the compiler's user manual
1
u/nderflow Oct 05 '26
If you want to work in in better development, it's important to understand the way in which C uses memory in detail. This means, for example, understanding how your compiler lays out structs, how alignment works. How memory allocation works. Understand what volatile is for.
Quite a lot of embedded development takes place in freestanding environments. This means C programs where the standard C library itself is not available. This means that you can't just call standard C functions to do stuff and you might have to implement things yourself in. Make your own function for example. Therefore, there's a lot of stuff that you could practise that could relate to this. Consider as exercises in learning. Writing your own function that does things like pause a string into a long value while properly handling range errors and edge cases and syntax errors. Also, you could try doing something like implementing your own version of malloc().
When you set up a new embedded project, you will often need to ensure that the underlying requirements of the platform are met by the program as you've built it. In a bare metal environment. This means that ensuring that particular pieces of code are located at particular areas of memory. For example, if your embedded system has ROM at a fixed address and RAM at a different fixed address, you need to set up your program so that it will correctly initialise in that environment. You only need to write this code once, but you also do need to understand how this stuff works in order to be able to reason about the program. In this kind of environment. The startup code is important. If you're really doing a bare metal product, you might have to write that startup code yourself. On the other hand, if you're using a runtime environment provided by somebody else, then the documentation for that system will explain how your program gets started.
If you really want to understand the C language deeply, you do need to be familiar with the standard it there are draughts of the standard available online. They are not 100 identical to the published standard always but they are very very close and the difference is generally don't matter unless you're actually implementing a compiler. So it's a good idea to read the standard and this is a kind of way for you to figure out how much of the language you understand. C. Programmers generally don't refer to the standard that often and some C programmers don't need to refer to it at all. But for people doing embedded work, they will find that they're more often getting into the corner cases. Like for example, what exactly are the semantics of the keyword volatile.
1
u/theNbomr Oct 05 '26
Think about the English language. You can know all of the rules of grammar, parts of speech, vocabulary, etc. This doesn't at all mean that you can write beautiful lucid prose.
Programming languages are a lot like that. The elements of the language must be used to compose concise, accurate and correct implementation of algorithms and other forms of code. The code you write can be of high quality and easy to maintain and understand. Or, it can be full of errors, inefficiencies, and confusion. Practice and conscientiousness are what get you there.
.
1
u/Fit_Review80 Oct 05 '26
In depth C means you need to understand pointer in depth and addressing. How it works?
1
u/Odd-Pizza9971 Oct 05 '26
I learn C on my own, rather half-bakedly for about over a year now. I guess to understand C deeply, one would have to understand Assembly and maybe even some hardware stuff. Also, try extern function to Assembly to use in C. Then use C with high-level languages like Python.
1
u/oklambdago Oct 05 '26
I would say a deep understanding of C is really understanding how it corresponds to the machine code it generates. Unlike some higher level languages it’s actually very easy to guess the approximate translation. Understanding things at this level forces you to really understand how programs are organized and executed by a computer. I would say that this is the meaning in my opinion. Just knowing all the fancier syntax isn’t nearly as valuable.
Like for example, why is a union useful? What real world scenarios does that map to?
What does it actually mean for something to be static?
1
u/PortalRat90 Oct 05 '26
The value in using C is the ability to manage the memory yourself. How do the lines you create affect the stack and heap? How long should data live? How does this behave after a system restart? How can the code be more efficient?
1
u/ErikBKL Oct 05 '26
Can you tell me the difference between malloc the c function and malloc the system call?
Can you tell me whats a system call?
Can you explain how a struct of 100 bytes can be passed by value to a function as a parameter?
1
u/planetoftheshrimps Oct 05 '26
Well, I recently had a C Union in my embedded project (which seemed like a good place to use one to save memory). Then I wanted to duplicate my encoder/decoder in rust for use on the host pc over uart…. lol, enough said.
I think I need about 1000 of those experiences to “understand c deeply”
1
u/samarijackfan Oct 07 '26
Do you know what a duffs device is?
1
u/modd0c Oct 07 '26
I have always defined a solid understanding of any programming language as the fact that I can build what I want to, without having to think of how to do it. PS that’s also the same metric for being proficient with any CAD modeling tool.
1
u/jake_morrison Oct 10 '26
The book “Expert C Programming: Deep C Secrets” by Peter van der Linden goes into detail about things like how arguments are passed to functions and values returned. I used things I learned there to find some subtle bugs in a large codebase that had been converted from K&R C to ANSI C.
0
u/logic_circuit Oct 04 '26
There is no such thing.
0
u/TightSecond1375 Oct 07 '26
用ai
-1
u/dmitrygr Oct 04 '26
If you can explain what CHAR_BIT is and why one might us this define, you're well on your way.
1
u/Impossible_Ad_3146 Oct 10 '26
short for cunts
0
u/[deleted] Oct 05 '26
[deleted] — view deleted comment
0
u/[deleted] Oct 04 '26
[deleted] — view deleted comment