How I program C

preview_player
Показать описание

On twitter i am: @eskilsteenberg // private
and: @quelsolaar // work.
Рекомендации по теме
Комментарии
Автор

"In the beginning you always want the results. In the end all you want is control." These two lines more or less sum up my 10 years of programming experience.

henrykkaufman
Автор

0:00 intro
5:00 garbage collection is not suitable for high performance scenarios
6:20 prefer stable & concise language features & technology stack
8:25 avoid ambiguity
11:00 don't be "clever"
11:45 be explicit
14:40 static-type language can catch more errors
16:00 early crashes are better than hidden bugs
17:30 improve your developing tools
20:20 general naming convention & coding style
27:20 prefer imperative & sequential code, long functions are OK
31:40 function naming
35:20 API design
36:00 how to organize .h & .c files
38:40 C & OOP-style APIs
41:00 void pointer is your friend to hide internal data
44:18 macros: __FILE__, __LINE__
49:40 a custom allocator for memory debugging
53:10 macro utilities for binary data packing/unpacking
57:10 memory control & pointers
1:03:00 malloc
1:06:00 arrays
1:09:20 struct
1:11:15 inheritance via C pointer casting
1:16:35 struct packing, padding, memory alignment
1:22:55 memory pages, realloc, gflags.exe
1:33:42 memory caches
1:42:30 don't store data twice
1:45:25 trick to reduce allocations: Flexible Array Member
1:48:30 trick to reduce allocations: joint malloc (dangerous)
1:50:48 use "stride" for better handling of Array Of Struct (AOS)
1:53:15 architecture on top of small & flexible primitives
1:55:45 prefer incremental progress
2:00:00 fix code ASAP
2:01:55 UI application design
2:08:50 Carmack's fast square root algorithm
2:09:56 magical random number generator
2:10:30 closing, contacts

jiayu
Автор

I've been trying to learn C++ and have realised that C is actually the place for me

billowen
Автор

As a beginner I can't explain how much I appreciate this video. Clear, concise and simplified without sacrificing content. I started with python and am struggling with picking up C. Learning syntax is one thing, learning HOW to apply it is another

mannycalavera
Автор

Wow. this guy doesnt even use powerpoint. he uses C for slides :D.

potatoxel
Автор

"the compiler is your friend when it tells you something is wrong."
This is very true, but the problem with that is that C compilers give the least detailed or useful error messages out of any language I use, not to mention that managed languages give you actual error info at runtime instead of just "segmentation fault."

Edited for clarity.

gazehound
Автор

The video is nearing 6 years, yet one of the most profound video on C programming.

randomrfkov
Автор

pretty dissapointing video, no indian accent

Stillow
Автор

I come back to this presentation from time to time. It's given me some good ideas for my own work. Thanks!

andrew
Автор

You are a legend! I've been writing C code for 20 years and you've taught be a few ticks I just hadn't realised until now. Thank you.

Krakatou
Автор

12:15
Not a compelling argument at all in my opinion.
Operator overloading mostly makes sense when it's used to define real mathematical operators. (With the exception of string concatenation i guess, and maybe other types)

Operators *ARE* functions. They take data in, they spit data out.
If you're smart enough to understand that "strcat" concatenate two strings together, you're smart enough to understand that '+' concatenate two strings together. Its just another notation to mean the exact same thing.

Using the example of vector multiplication is dishonnest : its ambiguous because there's no clear definition of what a multiplication of vector is. Not because '*' is not explicit in and of itself. And that's why half the people say parwaise mult, and the other half say dot product : They don't know because there's no good anwser.
In fact, i'd like for you to elaborate on why you think "mult_vec (&vecA, vecB, vecC)" is somewhat more explicit than "vecA = vecB*vecC". there's no sementic difference between them... they mean the *exact* same thing. They're Just written differently. Therefore if "mult_vec" is explicit, so is '*'.

I suppose you *DO* use operators on primitive data types ? Why ? Why are they explicit enough ? Because you know what '+', '-', '*', '/', '%' mean on numbers.
In reality, no operator is explicit. You **HAVE** to know what they do to know what to expect from them.
If I'm able to know what an operator does to primitive data types, I don't see why I wouldn't be able to do the same for other data types.

jean-naymar
Автор

Nobody overloads the multiplication with vectors. Every math lib I saw uses explicit names: dot, cross, scale. The * operator is sometimes used to multiply a vector by a scalar (uniform scale) but that's all. C++ programmers are less dumb that you think.

fredg
Автор

1:42:00 - If you already know the index to remove, you can just use memmove. It's much faster than most people realize because it will invoke SIMD operations and hardware intrinsics to move multiple chunks of memory per cycle. It can actually be faster to memmove an array to remove an element than to remove an element from a linked list using pointer reassignment. Pointers can make things very slow if they aren't used correctly.

LagMasterSam
Автор

I would really love to see a whole C tutorial. I have been searching someone like you, who can really teach C. Please, I really insist you to make aa whole tutorial series for C. I am a new CS student. And I absolutely love C. I also want to do some networking, system programming. You tutorials will help me a lot and others too. Please make a series.

raihankhan
Автор

This is fantastic. So much experience condensed into an easily digestible format. Thank you for sharing!

Having a bit of (theoretical) background in C and C++, just from reading mostly, I've always been hesitant to work in C. Most of that hesitation comes from what I learned in school about OOP and all the do's and don'ts. I've already started doubting much of that since, I always felt it made programming so much harder than it had to be and your video just gave me that extra push.

rayboblio
Автор

This boosts my self esteem to program in a way that !not strictly uses design patterns, but the way you understand best! Thanks for sharing!

seabass
Автор

There is some sexy code. I suppose the guide really reveals the philosophy of c. That’s so satisfying

tianned
Автор

Thank you for this. I wish there was more of this kind of content available, but nowadays it's full of "Learn X in 2 hours", "How to make a CLI tool in X", etc. This was something I watched closely and took notes.

heapslip
Автор

"Typing is not a problem"
proceed to make lots of typo LOL
but I agree, that's why we have an editor

koktszfung
Автор

“Fuck macros!”

*proceeds to discuss benefits of macros for ten minutes*

danflurry