C in 100 Seconds

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 มิ.ย. 2024
  • The C Programming Language is quite possibly the most influential language of all time. It powers OS kernels like Linux, Windows, and Mac and many other low-level systems. Its syntax has inspired many other languages, including Cpp, Csharp, Java, JavaScript, Go, Perl, and more.
    #programming #compsci #100SecondsOfCode
    🔗 Resources
    C Manuel www.gnu.org/software/gnu-c-ma...
    GCC compiler gcc.gnu.org/
    C History en.wikipedia.org/wiki/C_(prog...)
    🔥 Get More Content - Upgrade to PRO
    Upgrade to Fireship PRO at fireship.io/pro
    Use code lORhwXd2 for 25% off your first payment.
    🎨 My Editor Settings
    - Atom One Dark
    - vscode-icons
    - Fira Code Font
    🔖 Topics Covered
    - C programming basics
    - C pointers
    - Memory safety and segmentation faults
    - C syntax
    - What is C used for?
    - History of C
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 2.7K

  • @Beebo
    @Beebo 2 ปีที่แล้ว +16457

    My professor had a saying: "You will die but C will live."

    • @awuuwa
      @awuuwa 2 ปีที่แล้ว +334

      that's a good saying

    • @xCwieCHRISx
      @xCwieCHRISx 2 ปีที่แล้ว +403

      Yea C wont die out because of embedded systems.

    • @RainMan52
      @RainMan52 2 ปีที่แล้ว +543

      so long as there is electricity, C will be forever

    • @awuuwa
      @awuuwa 2 ปีที่แล้ว +366

      ​@@Afterburn7 c is used in kernels and stuff.

    • @yoshiguy35
      @yoshiguy35 2 ปีที่แล้ว +116

      @@Afterburn7 C++ is C with AIDS

  • @codegambit2507
    @codegambit2507 2 ปีที่แล้ว +8948

    "Use prinffffff" 🤣🤣🤣🤣
    And those "C" puns at the end 👏🏾

    • @melekRebai
      @melekRebai 2 ปีที่แล้ว +55

      Exactly what I wanted to comment 😁

    • @pss_crs
      @pss_crs 2 ปีที่แล้ว +18

      You committed on behalf me.😁😁

    • @oamioxmocliox8082
      @oamioxmocliox8082 2 ปีที่แล้ว +3

      ;)

    • @Dave-oi4fx
      @Dave-oi4fx 2 ปีที่แล้ว +66

      That's what "C" said...

    • @sdprolearning
      @sdprolearning 2 ปีที่แล้ว +3

      I love that

  • @xpkareem
    @xpkareem ปีที่แล้ว +1738

    Becoming a programmer these days is like coming in to a movie theater halfway through the movie. Computer Science history weighs heavy over everything. After decades of messing around with computers and programming I understand the approach of learning things in the order they were invented- everything builds on what came before. Everyone should learn C first if they want everything that follows to be many time easier- because you will have context and won't need to constantly ask: "Why TF did they do it that way?" you'll already know.

    • @anthonyobryan3485
      @anthonyobryan3485 ปีที่แล้ว +161

      I went from BASIC to assembly to C back in the late 80's and early 90's. By the time I got to C, I already knew what "i++" and "++i" meant, how they were different, and why that difference was significant. I had already programmed position independent and re-entrant systems, and understood the benefits and costs involved. I understood why Motorola CPU's were/are far better at it than Intel.
      I agree with you that learning programming history is a huge, highly underrated benefit.

    • @yvvxn
      @yvvxn ปีที่แล้ว +55

      I studied the history of computing for 2 weeks straight before actually learning how to program.

    • @mansbjork5721
      @mansbjork5721 ปีที่แล้ว +44

      It would be insane to teach 15 year olds C, which is when we start learning some programming where I'm from. We start with Python. As someone whose first language was Python, I haven't struggled that much with C honestly.

    • @foodiusmaximus
      @foodiusmaximus ปีที่แล้ว +17

      Seems similar to the way one learns studio or fine art at the professional level. Nothing exists in a vacuum and the best artists reference what came before. Ongoing dialogue

    • @dipper5151
      @dipper5151 ปีที่แล้ว +9

      EXACTLY! I keep asking myself the same question: "WHY DID THEY DO IT THIS WAY". I can't focus due to this. Can somebody tell me how I can overcome this?

  • @chbrules
    @chbrules 2 ปีที่แล้ว +863

    C is beautiful in its simple complexity. I started in C++ 18 years ago, but I've come to find warmth and love in the C language experience.

    • @harleyspeedthrust4013
      @harleyspeedthrust4013 ปีที่แล้ว +16

      I love C. Definitely one of my favorite languages, up there with ocaml and rust

    • @chbrules
      @chbrules ปีที่แล้ว

      @Joltacks You just have to be touched by Dennis Ritchie to know. And he knows how to touch a man very well ;)

    • @thehammurabichode7994
      @thehammurabichode7994 ปีที่แล้ว +42

      Your toxic relationship with C++ has been discarded, and your heart has been soothed by the warmth of -"holy"- C 🖤

    • @usernotfound342
      @usernotfound342 ปีที่แล้ว +9

      @Joltacks It's simple: I started coding in C. I can now easily comprehend any other programming language.

    • @JerehmiaBoaz
      @JerehmiaBoaz ปีที่แล้ว +9

      18 years ago? Modern C++ is nothing like the C++ you experienced. C++ is a living language that is in constant development and from 2011 on gets a feature update every 3 years. The latest standard C++20 (introduced in 2020) is so different from the C++03 or even C++98 you experienced that it should be barely recognizable to you. C++17 is what got me back into C++ and C++20 is so much better.

  • @jencruz21
    @jencruz21 2 ปีที่แล้ว +6544

    Everybody: use print-F to print the value
    Jeff: *Use printfffff*

    • @evertonalmeida1165
      @evertonalmeida1165 2 ปีที่แล้ว +331

      It's not Jeff it's Jefffffff

    • @quazar-omega
      @quazar-omega 2 ปีที่แล้ว +116

      @@evertonalmeida1165 Je-F

    • @mmti1010
      @mmti1010 2 ปีที่แล้ว +3

      😂😂😂 lol

    • @_prothegee
      @_prothegee 2 ปีที่แล้ว +9

      Ffffffff

    • @tarangpatil6952
      @tarangpatil6952 2 ปีที่แล้ว +8

      @@_prothegee Ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

  • @notgin
    @notgin 2 ปีที่แล้ว +15865

    Love how it ends with a seg fault, describes the C experience perfectly

    • @diskyariajetmiko
      @diskyariajetmiko 2 ปีที่แล้ว +120

      What does it mean?

    • @mberoakoko24
      @mberoakoko24 2 ปีที่แล้ว +767

      Seg fault almost cost me my last semester

    • @loganhello
      @loganhello 2 ปีที่แล้ว +700

      @@diskyariajetmiko A seg fault is when you try to read or write to somewhere that you haven't allocated memory for.

    • @beefbox
      @beefbox 2 ปีที่แล้ว +792

      @@loganhello not necessarily, it's read or write in memory that you are not allowed to read from/write to. You can read garbage from memory that you haven't allocated but that is undefined behaviour.

    • @aldi_nh
      @aldi_nh 2 ปีที่แล้ว +62

      Ah, the memory

  • @Koubles
    @Koubles ปีที่แล้ว +604

    Being a CS student, transitioning from classes where C is the only language to now building modern apps with Kotlin/Swift and other various API's and languages. I now really appreciate the simplicity of C.

    • @liveinthecity11211
      @liveinthecity11211 11 หลายเดือนก่อน +35

      Agree 100%. But I'm also grateful we have languages like Java that have garbage collection. Haha.

    • @onlinealias622
      @onlinealias622 7 หลายเดือนก่อน +22

      I work as a software engineer writing C code on embedded linux, and while the C language may be simple, the bugs can be some of the worst ever. I'm finding I much prefer higher level languages. Also, the lack of a string type or decent string library (string.h is trash IMO) really hurts its usability. Also, legacy C code written by EEs who didnt know good programming practices is some of the nastiest stuff ever created lol

    • @justaway_of_the_samurai
      @justaway_of_the_samurai 6 หลายเดือนก่อน +14

      If you ever programmed anything more advanced than an introduction to programming "Hello World" program in C, you would appreciate the simplicity of higher level languages.

    • @unheilbar
      @unheilbar 6 หลายเดือนก่อน +16

      How long did it take you to turn from being heterosexual to kotlin developer?

    • @Koubles
      @Koubles 6 หลายเดือนก่อน +4

      @@unheilbar AHAHAHAHA! Oh that's good. About one college course that praised AGILE and OOP like they were made by the second-coming of Jesus himself dude.

  • @manuchatterjee8809
    @manuchatterjee8809 2 ปีที่แล้ว +502

    C is challenging to master because to truly use it well, one must understand fundamentally understand how computers work. This means having some ideas about registers and ASM syntax, while not required, greatly enhances interpreting why certain design choices were made in C.
    C allows interfacing to hardware in straight-forward ways (custom registers, memory mapped peripherals) which don't really make sense in higher level languages. So C excels at low and mid level tasks where performance and resource allocation are the most important criteria. But it is difficult to be time efficient if you have to mix complex dynamic data, such JSON or web content.

    • @alexeynezhdanov2362
      @alexeynezhdanov2362 2 ปีที่แล้ว +9

      Well, it's true about almost(?) every language. If you want to master it - you MUST understand, what happens under the hood. Without understanding you can get relatively far, but other people will point at you and laugh.

    • @bf945
      @bf945 2 ปีที่แล้ว +21

      Yep. C is just a high level form of Assembly. The output from many C compilers is an Assembly program which is then fed to the Assembler to create object code and then to the Linker to create executable code.

    • @arkeynserhayn8370
      @arkeynserhayn8370 ปีที่แล้ว +6

      @@bf945
      That the case with many (all?) compiled languages, but the thing specific to C is that since C is simple (not necessarily easy), its easy to reason about generated Assembly, specially if you have habit of reading Assembly listing file of some compiler, you get a general idea what assembly instructions your compiler might generate from some C code.
      This is what makes C so joyful to work with in Systems programming.

    • @traveller23e
      @traveller23e ปีที่แล้ว +6

      @@alexeynezhdanov2362 As a C# dev...no you don't. I routinely have trouble where I can't find anyone on my team who knows whether the performance of a LINQ statement will be better written one way over another, for example. In that environment, performance almost never comes up in consideration, it's all about how clear and maintainable the code is, and if it follows a set of arbitrary style guidelines that are defined vaguely enough no one can agree on (or even really cares) what they mean. Java's the same way...and when you add in front-end web development and consider a lot of backend stuff is written on the assumption that microservices or other tech magic will do all the optimization you need (I mean, to be fair most of the time is spent executing web calls anyway), that's a sizeable chunk of the industry that doesn't require any low-level knowledge for better or for worse.

    • @carltone
      @carltone ปีที่แล้ว +3

      @@traveller23e the discussions is about C not C# which is abstracted!

  • @leoaso6984
    @leoaso6984 2 ปีที่แล้ว +12734

    C is such a simple language that you could learn the syntax in a day, learn the important parts of the standard library in less than a week, and learn how to use pointers.... eventually.

    • @saeedbaig4249
      @saeedbaig4249 2 ปีที่แล้ว +2030

      You can learn pointers... you never master pointers

    • @vaisakhkm783
      @vaisakhkm783 2 ปีที่แล้ว +650

      @@saeedbaig4249I loved c and hated all other languages when i studying
      After my school, i had learned so many other langs, and I never even used c in my job or higher studies, but nothing same as c

    • @betterthanb4r
      @betterthanb4r 2 ปีที่แล้ว +68

      @@vaisakhkm783 depends where u work

    • @vaisakhkm783
      @vaisakhkm783 2 ปีที่แล้ว +90

      @@betterthanb4r yes, i ment that, eventhough i never used it.... i still love it....

    • @SteelHorseRider74
      @SteelHorseRider74 2 ปีที่แล้ว +436

      ...once you see the pointer, which points to the pointer of the pointers' pointer

  • @hitlerssecondcoming2523
    @hitlerssecondcoming2523 2 ปีที่แล้ว +1006

    2:14 "Segmentation fault" - classic

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 2 ปีที่แล้ว +64

      ​@Z3U5 Different compilers have different behaviour, but GCC allows the implicit conversion, so (char*) isn't necessary. Plus, char on most systems is 1 byte, so though a good practice, not multiplying by sizeof(char) wasn't the cause of error either.
      The only thing I can think of is that his malloc failed to allocate memory, and hence he tried to access null + 1 address, which failed.

    • @NoNameAtAll2
      @NoNameAtAll2 2 ปีที่แล้ว +59

      @@VivekYadav-ds8oz char is 1 byte on ALL systems, cause it's the "single byte"
      it's in the standard :)

    • @NoNameAtAll2
      @NoNameAtAll2 2 ปีที่แล้ว +20

      @Z3U5 casting malloc result is not canonic C

    • @int16_t
      @int16_t 2 ปีที่แล้ว +19

      @ZRU There is no problem with the original code he wrote unless he change it somewhere and didn't included it in the video.
      He never access any illegal memory address. void* can be safely cast to any type except a function pointer.

    • @Fireship
      @Fireship  2 ปีที่แล้ว +495

      I left out the code that caused the seg fault, it was an intentional joke

  • @oliverdixon4660
    @oliverdixon4660 2 ปีที่แล้ว +505

    "Platform-dependent" in the context of compilers doesn't really imply dependence on a particular operating system; it means the native code is generated for a specified processor architecture, such as ARM or x86.

    • @Tachi107
      @Tachi107 2 ปีที่แล้ว +100

      I'm theory you're right, in practice if you're going to use the standard library you'll likely be bound to the architecture AND the OS

    • @tiagodmota5840
      @tiagodmota5840 2 ปีที่แล้ว +19

      Platform is OS + processor architecture. No?

    • @Unit_00
      @Unit_00 2 ปีที่แล้ว +16

      I'm 99% sure this is wrong, since compiled code will use subroutines defined in ram by the OS, so an executable for linux won't work on Windows even if they are run by machines with the exact same specs

    • @oliverdixon4660
      @oliverdixon4660 2 ปีที่แล้ว +6

      @@Unit_00 Well that's a different matter of binary formats and position dependency.

    • @davawen9938
      @davawen9938 2 ปีที่แล้ว +6

      Well it depends, if what you want to do is emcompassed by the architecture, then the resulting assembly will be the same:
      (adding two numbers from the stack together)
      mov edx, DWORD PTR [rbp-4]
      mov eax, DWORD PTR [rbp-8]
      add eax, edx
      But if you need anything provided by the OS (so most things done by the standard library), the compiler output will probably be different:
      (exiting program, Linux vs Windows)
      mov eax, 60 ; sys_exit system call
      mov edi, 0 ; return code
      syscall ; equivalent to int 0x80
      mov ecx, 0 ; return code
      call ExitProcess ; WinApi function
      add rsp, XXX ; clean up stack

  • @peppi69
    @peppi69 ปีที่แล้ว +133

    I still think C is the most perfect programing language. It's easy to understand to begin programing but has unlimited possibilities on what to build with it and it really runs on anything

    • @petergibbons607
      @petergibbons607 9 หลายเดือนก่อน +19

      it's like driving a manual transmission, only the people actually good at it will be able to understand its greatness.

    • @shadowchasernql
      @shadowchasernql 9 หลายเดือนก่อน +7

      yes compared to something like js it's a godsend

  • @scattonsimon6992
    @scattonsimon6992 2 ปีที่แล้ว +3628

    Quick remark, gcc actually means GNU Compiler Collection and not GNU C Compiler, the name GNU C Compiler was dropped around 1999 (in April to be precise) because C was only one of gcc's frontend.

    • @Fireship
      @Fireship  2 ปีที่แล้ว +993

      Good call, thanks for the correction

    • @scattonsimon6992
      @scattonsimon6992 2 ปีที่แล้ว +181

      @@Fireship No problem! Keep up the good content!

    • @puppergump4117
      @puppergump4117 2 ปีที่แล้ว +21

      @@Fireship You could pin him or something but everyone who searches for it will just type gcc anyways I guess

    • @pearz420
      @pearz420 2 ปีที่แล้ว +14

      Yeah details like that aren't included in the first paragraph of a wiki page, so the youtuber missed it.

    • @wealthmaster69
      @wealthmaster69 2 ปีที่แล้ว

      @@pearz420 😂

  • @orco3847
    @orco3847 2 ปีที่แล้ว +3237

    Actually, as opposed to C's neighbours, one can really learn all C's syntax in 100 seconds... 😂

    • @orco3847
      @orco3847 2 ปีที่แล้ว +85

      @@naltun4702 💯 percent agree.. I had my suffering from C, then I moved to JS. Thanks GOD 🎶🎶

    • @socketbyte5348
      @socketbyte5348 2 ปีที่แล้ว +203

      @@naltun4702 C is one of the few languages that require you to develop your own standard library to even use the language efficiently. Libc is just way too basic to be reasonable.

    • @schniemand
      @schniemand 2 ปีที่แล้ว +110

      I think the *type* syntax of C is quite complicated and I've seen plenty of people get confused by it. I mostly mean declaration and use of anything that has to do with pointers.
      Pointers aren't complicated but the C syntax without proper explanation can make people think that they are.

    • @orco3847
      @orco3847 2 ปีที่แล้ว +17

      @@schniemand That is why I wrote "C's syntax"..

    • @sadhlife
      @sadhlife 2 ปีที่แล้ว +43

      @@orco3847 js is worse when it comes to complex stuff :^)

  • @martinstent5339
    @martinstent5339 7 หลายเดือนก่อน +12

    One of my all-time favourite things is Exercise 1-23 at the end of chapter 1 in “The C Programming Language” It says “Write a program to check a C program for rudimentary syntax errors like unbalanced parentheses brackets and braces.” This at the end of the first chapter!! We only learned the very basics, and now Kernighan/Ritchie expect us to do that! I think I actually went back and did this exercise after reading chapter 5. But it still remains with me 40 years later as something that just seemed so “Wow!” …

    • @neutral_positron
      @neutral_positron 3 หลายเดือนก่อน +1

      Same experience. Actually really like the book, by the time you read it you feel like you can actually write useful progtammes

  • @Brawlstriker89
    @Brawlstriker89 7 หลายเดือนก่อน +1

    I love that I can actually understand every bit of this video now! I watched this when I first started learning c++ about a year ago. I’ve now taken two computer science classes and a web authoring class for html, css, JavaScript. As well as a course in Microsoft power shell. Nice to see I’ve progressed. Lol

  • @victorpinasarnault9135
    @victorpinasarnault9135 2 ปีที่แล้ว +1674

    12/10/2011: 10 years ago, Dennis Ritchie past away, leaving the world the legacy of the operational systems and the internet that we use today.
    He is the true legend, not Steve Jobs.

    • @cobaltno51
      @cobaltno51 2 ปีที่แล้ว +19

      and alot of insecure, messy legacy codebases. C is certainly a huge accomplishement, but couldn't we just have bounded buffers? real strings? were those couple of bytes really too much? even as an optional addon?

    • @fredrickdenga7552
      @fredrickdenga7552 2 ปีที่แล้ว +30

      He passed on with steve jobs yet few acknowledged him as compared to jobs

    • @adrianorocha-dev
      @adrianorocha-dev 2 ปีที่แล้ว +297

      @@cobaltno51 Yes, those couple of bytes were too much in many cases back then. Today we are spoiled by super fast and high memory computers, but people literally counted the bits back in the day. Even C was considered a "heavy" language at some point.

    • @rajveersingh2056
      @rajveersingh2056 2 ปีที่แล้ว +14

      Steve jobs is even lesser know than iron man.
      Point is, Having more than one legend is not a necessary for the world's existence.

    • @Supergecko8
      @Supergecko8 2 ปีที่แล้ว +89

      @@cobaltno51 bro it's a 50 year old language

  • @pragyan394
    @pragyan394 2 ปีที่แล้ว +558

    Ah yes the classic functions, print-fff and scan-fff

    • @mananasi_ananas
      @mananasi_ananas 2 ปีที่แล้ว +35

      And fprintf, and sprintf, and fnprintf, and snprintf, and vprintf, and vfprintf, and vsprintf, and....

    • @whythosenames
      @whythosenames 2 ปีที่แล้ว +14

      @@mananasi_ananas i love these now im going to call it ffffprintfff

    • @alexrenoki8366
      @alexrenoki8366 2 ปีที่แล้ว +3

      @@whythosenames sssnnprintfff

    • @devilbob
      @devilbob 2 ปีที่แล้ว +2

      Useless functions. All my homies use write() and read()

  • @yeahthebois3617
    @yeahthebois3617 ปีที่แล้ว +124

    Tip with malloc: if you cant remember how much bytes u need to store u can do malloc(sizeof([datatype here]) * [how much of those datatypes you want]) e.g:
    char* word = malloc(sizeof(char)*4)
    Now with chars its easy (1 char = 1 byte) however this technique works well when ur making struc arrays

    • @TheLoveMario
      @TheLoveMario ปีที่แล้ว +7

      If you need to initialize a string and know its length at compile-time just avoid the heap-allocation and do
      char word[4];

    • @unpatientes1562
      @unpatientes1562 ปีที่แล้ว +2

      i think in this case it's better to use calloc:
      str* word = calloc(4, sizeof(char))

    • @yeahthebois3617
      @yeahthebois3617 ปีที่แล้ว +2

      @@TheLoveMario that's cool until you have to access that variable outside of the function its initialised in.

    • @TheLoveMario
      @TheLoveMario ปีที่แล้ว +1

      @@yeahthebois3617 In a header file: char* word;
      Inside the function: static char a[4]; word = &a;

    • @yeahthebois3617
      @yeahthebois3617 ปีที่แล้ว

      @@TheLoveMario completely forgot abt that one there 😂😂😂

  • @GuimoTheGizo
    @GuimoTheGizo ปีที่แล้ว +9

    C was my second language I ever learned. I find it kind of funny that your explanation of C is mostly what happens in the machine for _every language_ but that most people take for granted since so many popular languages have an interpreter and/or sandboxed environment holding their hand.

  • @shanebenning3846
    @shanebenning3846 2 ปีที่แล้ว +519

    It blows my mind how much of the technology we depend on everyday came from Bell Labs

    • @thedrunknmunky6571
      @thedrunknmunky6571 2 ปีที่แล้ว +68

      Truly a place with so many of the smartest people in the world.

    • @PhilipAlexanderHassialis
      @PhilipAlexanderHassialis 2 ปีที่แล้ว +63

      Indeed Bell Labs and Xerox Parc technologies and invented paradigms are still either directly or indirectly used today - these people were the knee's bees. Amazing visionaries and engineers all of them.

    • @KookoCraft
      @KookoCraft 2 ปีที่แล้ว +7

      @@PhilipAlexanderHassialis What I saw at Xerox Parc's graphical user interface demonstration was a regression. Its no longer "normal" to use a command line to get exactly what you want done, fast. It's all point and grunt like cave men.

    • @jeffesoncosta14
      @jeffesoncosta14 2 ปีที่แล้ว +31

      @@KookoCraft If you dont like just dont use it.

    • @kanjakan
      @kanjakan 2 ปีที่แล้ว +12

      @@KookoCraft GUI is better though.

  • @justapugontheinternet
    @justapugontheinternet 2 ปีที่แล้ว +894

    I remember writing an employees management system using C during my first year of university. Learnt a lot, including the fact that I don't wanna write C code for work.

    • @justapugontheinternet
      @justapugontheinternet 2 ปีที่แล้ว +34

      @@mattmurphy7030 I admire your kind. The guys who write C code and do embedded stuff. I love it, but I just haven't had a chance to do it extensively. I feel like that's where the real stuff is at.

    • @gamerk316
      @gamerk316 2 ปีที่แล้ว +39

      @@justapugontheinternet It is. That's pretty much what I do for a living. It takes time to get used to. That being said, with embedded processors being a lot more powerful than they used to be (the Cortex A53 is an industry favorite right now) we're able to splurge a lot more and go C++ rather then straight C, since we aren't as performance constrained as the days when we used 286's and 68000k's as our embedded processors of choice.

    • @toby9999
      @toby9999 2 ปีที่แล้ว +16

      @@gamerk316 Not sure about you but I loved the 68000 architecture. It was so elegant compared to the x86 stuff. I've been fortunate to have been working with C and C++ for 25 years but now being pushed into the Java world, I'm hating it.

    • @MaxiJabase
      @MaxiJabase 2 ปีที่แล้ว

      @@toby9999 Go C# my friend.

    • @nerd2544
      @nerd2544 2 ปีที่แล้ว +1

      @@toby9999 what's your job

  • @tvman7868
    @tvman7868 4 วันที่ผ่านมา

    Such an efficient overview, as someone with familiarity with languages built on top of C but no experience in C this sheds a lot of light for 100 seconds. Thank you Fireship!

  • @jaydenhenry8083
    @jaydenhenry8083 ปีที่แล้ว

    This helped me understand character arrays better and how pointers can be used for memory allocation that’s accessed through indexes

  • @poglord._
    @poglord._ 2 ปีที่แล้ว +840

    If we look at the algorithm, next would be C++ in 100 seconds, C# in 100 seconds, Assembly in 100 seconds and finally Binary in 100. Last time in the react native, flutter and kotlin series, I predicted correct

    • @patrickmullot73
      @patrickmullot73 2 ปีที่แล้ว +193

      that would be "Binary in &1100100 seconds"

    • @sharkinahat
      @sharkinahat 2 ปีที่แล้ว +82

      If C was 100 seconds, clearly C++ must be 101 seconds, or 5 in base 10.

    • @PrimalCoder
      @PrimalCoder 2 ปีที่แล้ว +3

      What about Eiffel and Ada? Maybe, Pascal and Lisp even. Not to mention Algol and Smalltalk.

    • @rickdev1922
      @rickdev1922 2 ปีที่แล้ว +14

      Quantum Mechanic inside Processor & Silicon Transistor in 100 Second

    • @joel9909
      @joel9909 2 ปีที่แล้ว +1

      @@patrickmullot73 epicccc

  • @ShashotoANur
    @ShashotoANur 2 ปีที่แล้ว +63

    Being the mother, C deserves beyond 100 seconds

    • @salsamancer
      @salsamancer 2 ปีที่แล้ว +6

      C is the big sister, assembly is the mother

    • @OriMoscovitz
      @OriMoscovitz 2 ปีที่แล้ว +2

      It is beyond 100 seconds. It's 145 second to be exact.

    • @borgir6368
      @borgir6368 2 ปีที่แล้ว +3

      @@salsamancer assembly is not even a high level language you can call it grandma

    • @praveenawesome2182
      @praveenawesome2182 2 ปีที่แล้ว +1

      @@OriMoscovitz hehe

  • @Tabvn
    @Tabvn ปีที่แล้ว +1

    C, c++ , and Go that is simple to learn and training your mindset and programming skills. Thanks for quick video but really useful!

  • @jimmyvo1667
    @jimmyvo1667 8 หลายเดือนก่อน

    Love videos like this to just get a general idea of what something is

  • @rifkyniyas122
    @rifkyniyas122 2 ปีที่แล้ว +131

    Everyone: print ef
    Jeff: prin(t)ph

  • @abubakrakram6208
    @abubakrakram6208 2 ปีที่แล้ว +691

    I think C’s easier than C++. With C++, you feel like you never actually finish learning the syntax. Ever.

    • @ananttiwari1337
      @ananttiwari1337 2 ปีที่แล้ว +31

      yeah, exactly

    • @purple.requiem
      @purple.requiem 2 ปีที่แล้ว +33

      I really hate it when I get weird errors.

    • @sxs512
      @sxs512 2 ปีที่แล้ว +43

      You do finish learning the syntax. I learned most of c++ when I was in middle school in a couple of months. You just need a good tutorial and a lot of determination.

    • @abubakrakram6208
      @abubakrakram6208 2 ปีที่แล้ว +23

      @@sxs512 I'm glad to hear it's possible. I've only been learning since September, so I think I've still got a bit of time to go. Most online tutorials are anemic, though, so I think I'll need to memorize the class textbook or something.

    • @purple.requiem
      @purple.requiem 2 ปีที่แล้ว +3

      @@mattmurphy7030
      C++ gets freaking confusing when you learn about pointers. Segfault runtime errors are a pain on my arse

  • @immanuelcharles2875
    @immanuelcharles2875 2 ปีที่แล้ว +28

    It should be said that malloc/calloc allocates memory on the heap and you should only use free on heap allocated memory. Stack allocated memory will be deleted automatically after it goes out of scope.

    • @human-ft3wk
      @human-ft3wk 2 ปีที่แล้ว

      Immanuel's talking about 0:52 I assume

    • @WarpRulez
      @WarpRulez 2 หลายเดือนก่อน

      One could nitpick about your use of terminology.
      Objects on the stack aren't "deleted" per se. The language manages the stack automatically, without the programmer having to write code to do so explicitly, and this management is essentially just updating the stack pointer register. In some kind of vague sense when a function is exited and the stack pointer is changed to what it was before the function was called, that stack space is kind of "deleted", but that's a bit of a misnomer.
      (In C++ the use of that term would be more apt because in that case the language actually literally calls destructors for objects on the stack, and in this case "deleting" them would be an appropriate term to use, in a sense.)

  • @ighao6032
    @ighao6032 2 ปีที่แล้ว +1

    pointers get me so confused, I'm glad you could explain then só easily and simple!

  • @manvesh97
    @manvesh97 2 ปีที่แล้ว +454

    This makes me want to revisit C, didn’t like it when I learnt it at uni because struggled with pointers, but that all seems more interesting to me now!

    • @senkogaming4784
      @senkogaming4784 2 ปีที่แล้ว +18

      th-cam.com/video/zuegQmMdy8M/w-d-xo.html I highly encourage you to watch it, I started learning C with this video. It isn't as hard as you think, you could maybe watch 30 minutes of this video everyday and then watch the Data Structures video from the selfsame youtuber. If you want to learn even more about it, then Jacob Sorber's videos are great too.

    • @5cover
      @5cover 2 ปีที่แล้ว +30

      I started programming with C. It's not as hard as people say

    • @gabbagandalfjpr
      @gabbagandalfjpr 2 ปีที่แล้ว +5

      what did you learn in this video that you haven't been taught at university? or is it just that you find it more interesting now?

    • @Supergecko8
      @Supergecko8 2 ปีที่แล้ว +7

      C gives a lot of nostalgia hahahaha

    • @IngwiePhoenix
      @IngwiePhoenix 2 ปีที่แล้ว +16

      C is actually really cool, just absurdly verbose, by design. And you can target just about anything.
      There is even SDCC, a C compiler that can, for instance, compile for the GameBoy!

  • @JoolsParker
    @JoolsParker 2 ปีที่แล้ว +68

    I was brought up on C - I bloody love the language (doing realtime embedded software and device drivers with it is a rollercoaster until you know what you're doing).

    • @Crazy_Diamond_75
      @Crazy_Diamond_75 2 ปีที่แล้ว +2

      The coolest thing I ever had to do in C was implementing sensory input on an Arduino microcontroller. It was a bizarre combination of bit manipulation, machine language, and regular C that you could only do in something as low-level as C itself.

  • @sanctuary_of_soul
    @sanctuary_of_soul ปีที่แล้ว

    2:10 i like that example of program compilation and launching. What a good demonstration and nice example.

  • @q12x
    @q12x 2 ปีที่แล้ว

    wow, superb explanation of what pointers are !!! Please, do more !

  • @engel_e
    @engel_e 2 ปีที่แล้ว +373

    2:04 if needed, you can mimic an object-oriented programming language approach in C by having function pointers inside a structure, which then would be accessible through the arrow operator. An instance of this structure could be compared to an object with its getters, setters and methods.
    Very nice video, I haven't used C lang for quite a few years and that's a great throwback with all those countless segfaults

    • @ccgarciab
      @ccgarciab 2 ปีที่แล้ว +26

      iirc that's what they do in the Linux kernel

    • @dany5ful
      @dany5ful 2 ปีที่แล้ว +11

      How would something like 'private' and 'public' work tho?

    • @IngwiePhoenix
      @IngwiePhoenix 2 ปีที่แล้ว +11

      This is what SDL does, iirc.
      struct some_sdl_interface { func_ptr method; };
      struct some_sdl_interface* create() { ... st->method = method_ptr; ... }
      create()->method();
      I think SDL does that for a lot of its abstractions.

    • @bamberghh1691
      @bamberghh1691 2 ปีที่แล้ว +17

      @@5cover opaque pointers can be used to hide details

    • @hamidcrazy9027
      @hamidcrazy9027 2 ปีที่แล้ว +9

      Yep, do know that a lot of oop features are made using structures and function pointers

  • @DannyBPlays
    @DannyBPlays 2 ปีที่แล้ว +61

    That part about a string being an array of chars brought me wayyy back to early days in my university class learning C

    • @JoolsParker
      @JoolsParker 2 ปีที่แล้ว +1

      But did you ever create an array of characters without remembering to terminate it with a '/0'??? A noob move that everyone learning C has to go through 🤣

    • @raunak1147
      @raunak1147 2 ปีที่แล้ว +3

      @@JoolsParker '\0' not '/0' :D

    • @JoolsParker
      @JoolsParker 2 ปีที่แล้ว +2

      @@raunak1147 🤣 That’s the noob move that comes after realising there’s no terminating character!

    • @raunak1147
      @raunak1147 2 ปีที่แล้ว

      @@JoolsParker :o

  • @Mwa0705
    @Mwa0705 2 ปีที่แล้ว

    This is one of the best, shortest but somehow very thorough explanation of this wonderful language

  • @ZacharyCarthair
    @ZacharyCarthair 2 ปีที่แล้ว +1

    Love your videos. Would love to see one for Ruby too!

  • @mesota2842
    @mesota2842 2 ปีที่แล้ว +172

    Can we get a "Lua in 100 seconds?🔥"

    • @prasannasilva7754
      @prasannasilva7754 2 ปีที่แล้ว +6

      Of course! my favorite programming language persuaded me to learn programming properly.

    • @softwarelivre2389
      @softwarelivre2389 2 ปีที่แล้ว +10

      Oh, the forbidden language technique of the Hidden Brazillian village. A man of culture, I see.

    • @vivzi_sk3
      @vivzi_sk3 2 ปีที่แล้ว +2

      I was about to ask this

    • @ultimaxkom8728
      @ultimaxkom8728 2 ปีที่แล้ว +1

      @@softwarelivre2389 lol

    • @dmitrykargin4060
      @dmitrykargin4060 2 ปีที่แล้ว +1

      @@softwarelivre2389 While other languages were evolving by adding new keywords, the moon of tecgraf evolved by removing them

  • @KonKri
    @KonKri 2 ปีที่แล้ว +27

    1:28 use *printffff* exactly what I thought to myself when I was a firstyear at uni😂

  • @textoffice
    @textoffice 2 ปีที่แล้ว

    very well done ! internet is also write in C . You can put pointer of function into your structure to be nearer of c++

  • @RealValkor
    @RealValkor 10 หลายเดือนก่อน +2

    I am a C# programmer and I recently started learning C to program with arduino. My prior knowledge of C# really helped me understand basic programming fundamentals and syntax. Both are definitely great and useful languages!

  • @oskrm
    @oskrm 2 ปีที่แล้ว +145

    One note, return + any number means non-success exit, you can then check what code was returned (exited) to figure where you returned that number.

    • @E231986
      @E231986 2 ปีที่แล้ว +17

      YES. I was looking for this. Essentially everything in C that is seen as "FALSE" (not always but often defined by pre-compiler) equates to 0 (0x0, etc, not '0' though). Anything NOT "FALSE" (or !0) is seen as "TRUE" or essentially equal to 1. However, anything "TRUE" == 1 is not always true. It's tricky but the only real definition of "FALSE" should always equal 0 and anything non-zero is true.
      In extension to that, the only error code that means "no error" is 0 itself. Meaning your program ran perfectly with no issue/bug. Anything non-zero isn't necessarily an error, but any "non-flawless" execution. The nuance is necessary and this hasn't been stated enough in the comments (to my knowledge).

    • @SIGSEGV_Core_Dumped
      @SIGSEGV_Core_Dumped 2 หลายเดือนก่อน

      yeah for example 137 is SIGKILL

  • @DabbleCache
    @DabbleCache 2 ปีที่แล้ว +5

    Literally began looking into C today for the first time. The timing of these videos has been oddly perfect.
    Thank you so much for these!

    • @xyfurion
      @xyfurion 2 ปีที่แล้ว +3

      Good fuckin luck fam

  • @skullteria
    @skullteria 2 ปีที่แล้ว +2

    I would have liked a comparison of the project development process compared to other languages.
    Going into dependency management and all the other stuff.

  • @RoonyKingXL
    @RoonyKingXL 2 ปีที่แล้ว

    Great video. GCC stands for GNU Compilter Collection. Although it used to stand for GNU C Compiler in the past.

  • @gameglide9811
    @gameglide9811 2 ปีที่แล้ว +30

    Came here in seconds!

    • @scriptkiddie6151
      @scriptkiddie6151 2 ปีที่แล้ว

      Same

    • @fahd2372
      @fahd2372 2 ปีที่แล้ว

      Same

    • @Fireship
      @Fireship  2 ปีที่แล้ว +9

      Gold! 🥇

    • @gameglide9811
      @gameglide9811 2 ปีที่แล้ว

      @@Fireship your videos are always fire, this was just what I needed! You always exceed expectations!!

    • @algogeminus
      @algogeminus 2 ปีที่แล้ว

      same bruhh

  • @valerie4275
    @valerie4275 2 ปีที่แล้ว +13

    That video, like always, was fantastic. I think it'd be quite interesting to see you cover one of the Lisp languages so Common Lisp, Clojure/ClojureScript, or even Scheme (in that case it'd most likely be Racket as many of the other Scheme implementations are too minimalist by themselves or are extension languages instead of general purpose programming languages).

    • @r.t.5767
      @r.t.5767 2 ปีที่แล้ว +1

      Scheme is WONDERFUL! I'd watch a video if he made one

    • @mrocto329
      @mrocto329 2 ปีที่แล้ว +1

      Clojure! Clojure!
      Clojure is one of the BEST languages I've ever seen. It takes the good parts of functional programming & good parts of lisp while getting rid of worse parts. It works on JVM so you can use java libraries. Clojure repl and the tooling around it is amazing, the language really focused on the repl. You can even use the repl with clojurescript to run clojure code that then evaluates ON THE BROWSER IN REAL TIME LIKE BLACK MAGIC.

  • @filmfortbe
    @filmfortbe ปีที่แล้ว +1

    I would love to see a video about CMS's (Headless CMS"s, Wordpress, Drupal, etc.)

    • @user-ts7of5to4e
      @user-ts7of5to4e ปีที่แล้ว

      Helpline📲📥⬆️
      Questions can come in⬆️

  • @bettyswunghole3310
    @bettyswunghole3310 2 ปีที่แล้ว +1

    I *still* get confused by const and const ...

  • @thedrunknmunky6571
    @thedrunknmunky6571 2 ปีที่แล้ว +8

    I had a great lecturer so he helped me (and a bunch of others) through the week or two it took for me to grasp pointers and arrow notation. After this, C became my favourite language to program in as I love how strict it is. And as it’s statically typed you know exactly how the data flows about in your program. And as long as you use them correctly, pointers make for very easy access to variables from anywhere in your program.

    • @JoolsParker
      @JoolsParker 2 ปีที่แล้ว +1

      Erm.... I would not say C is a strict language at all - you can REALLY screw stuff up with it. I saw it almost has a higher-level assembly language in some respects. Try looking at Ada for a strict language.

    • @proloycodes
      @proloycodes 2 ปีที่แล้ว

      @@JoolsParker true

    • @thedrunknmunky6571
      @thedrunknmunky6571 2 ปีที่แล้ว

      @@JoolsParker By strict I meant mostly that it was statically typed and it was my first statically typed language (I started programming only in uni therefore I was very late to programming). Being able to shoot yourselves in the foot is true though, as we all definitely have. However C is far more rigid, compared to vanilla JS, which is what a lot of viewers of this channel (including myself) program in.

    • @lucass8119
      @lucass8119 2 ปีที่แล้ว

      @@thedrunknmunky6571 If you enjoy the strictness of C, C++ is significantly more strict with types and casting. C++ has exceptions as well, so the shooting yourself in the foot stuff can be caught, like accessing outside of array bounds.

  • @achyuthcn2555
    @achyuthcn2555 2 ปีที่แล้ว +6

    Would love a full course on C from you guys

  • @mu11668B
    @mu11668B 2 ปีที่แล้ว +100

    Honestly C is one of the most amazing language I've ever used. Once you get through the concept of pointers, you'll find out how powerful they actually are. It's one of the most easy-to-use language to do simple parallel tasks without blowing up your memory limit.

    • @dtibor5903
      @dtibor5903 ปีที่แล้ว +8

      Don't forget how powerful memory leaks C does. I just did one yesterday.

    • @WarpRulez
      @WarpRulez 2 หลายเดือนก่อน

      One of the most easy-to-use languages to do simple parallel tasks?
      Are you serious?
      Pretty much _any_ other programming language that has support for threads is simpler to use for parallel tasks than C.

    • @mu11668B
      @mu11668B 2 หลายเดือนก่อน

      @@WarpRulez
      The nice thing about C is you can access the same memory chunks in multiple threads more easily. You don't have to call the mutex APIs if the threads are not going to work at the very same position in memory. I'm not sure about Golang though. The synchronization in Java is a bit convoluted but most of the APIs are nicer indeed. Running multi-thread in Python is nonetheless a nightmare. In many cases the GIL gets into the way and makes multi-threading meaningless (e.g. numpy arrays are managed by GIL in the version I used). In my project I had to get both temporal and spatial efficiency and C was the optimal solution to it.

    • @WarpRulez
      @WarpRulez 2 หลายเดือนก่อน

      @@mu11668B
      That doesn't make C the easiest language to run multiple threads. It just makes it easier to access shared memory without mutexes.
      If that's the measure of easiness, then C++ is better on both fronts: It's very easy to create multiple threads (with 100% standard code, no need for non-standard libraries) and you can likewise bypass mutexes if you want. (And, in fact, the C++ standard library also offers support for efficient atomic variables. I don't know how many other programming languages do. And yes, C does too, I know.)

  • @abhisheksathe123
    @abhisheksathe123 ปีที่แล้ว +1

    I still remember when I was in diploma college and our computer lab did not have code editors so there was this Turbo C program installed on all PCs which had like the old school 4:3 aspect ratio and the UI was basically like how old PC BIOS was like everything was operated via keyboard. It was a fun time writing simple addition or find factorial of a given number type codes.

    • @destroreact5706
      @destroreact5706 ปีที่แล้ว +2

      Oh yeah, that thing with blue background....holy sh*t that brings back memories

    • @bwc1976
      @bwc1976 ปีที่แล้ว

      My high school programming class used Turbo Pascal from the same company, so many great memories! Back when a full compiler and IDE could fit on a 3.5" floppy.

  • @sominupadhyaya9026
    @sominupadhyaya9026 2 ปีที่แล้ว +17

    That printf was smooth

  • @franciscogilt
    @franciscogilt 2 ปีที่แล้ว +7

    Fireship videos are like a knowledge pill for your brain. Simply awesome!

  • @nort7214
    @nort7214 2 ปีที่แล้ว

    Love your videos, they are a great wta to learn, Please make a C++ in 100 seconds video!

  • @NotGarbageLoops
    @NotGarbageLoops 3 หลายเดือนก่อน +1

    The segfault in the end is a nice touch

  • @rickbhattacharya2334
    @rickbhattacharya2334 2 ปีที่แล้ว +15

    C is by far one of the best language . Even after so many years and so many languages later it's still very useful .

  • @supernenechi
    @supernenechi 2 ปีที่แล้ว +25

    I always say I love Go, but the elegance of C is something that I just can't get over. It's so beautiful

    • @lucass8119
      @lucass8119 2 ปีที่แล้ว +3

      @pntg0n!kyuu Because they represent two completely different things. (.) is the "access" operator, i.e. access a field in this struct. the "->" operator isn't really unique, its actually a combination of two operators. "->" is equivalent to "(*).", as in "deference this pointer to get a concrete object and then access this element in this object". This is why they're two separate operators. "->" is used exclusively on POINTERS, i.e. references/addresses, while "." is used on CONCRETE objects. It allows you to look at code and quickly figure out if a variable is a reference (pointer) or concrete object. It also lets the compiler easily statically check the program, as it will detect if "->" is used with the wrong type and if "." is used with the wrong type. Languages that only use "." can't do that. Also, languages that only use "." generally don't have pointers. See: C# and Java.

    • @lucass8119
      @lucass8119 2 ปีที่แล้ว +3

      ​@pntg0n!kyuu I didn't know C# has pointers, but I would say that "." and "->" are both used very often and they're definitely not interchangeable because pointers aren't like references in C++, you can arbitrarily access a method without first dereferencing a pointer. I think it makes sense from a technical view, i.e. pointers must be dereferenced before using a method/member variable, and from a user point of view, i.e. "->" clearly indicates a pointer, "." does not.

    • @bigshrekhorner
      @bigshrekhorner 2 ปีที่แล้ว

      @pntg0n!kyuu The majority of people haven't actually done proper programming to know how problematic implicit type declaration is. It's very ambiguous and shouldn't be used when you have lots of incompatible variable types, especially when you want to have multiple *uninitialised* variables of different types.

  • @XX-ue6kj
    @XX-ue6kj ปีที่แล้ว

    🤣🤣🤣🤣🤣🤣. That last part killed me! That caught me off guard. That was so good! Im subbing just for making me laugh so hard. Thank you.

  • @mehmedcavas3069
    @mehmedcavas3069 2 ปีที่แล้ว +4

    C

  • @TheDerpiestSir
    @TheDerpiestSir 2 ปีที่แล้ว +10

    Gcc actually stands for gnu compiler collection, it can compile fortran, ada, obj C, go and more

    • @darkforst17
      @darkforst17 2 ปีที่แล้ว

      That's crazy my dude but who asked

    • @blahajenjoyr
      @blahajenjoyr 2 ปีที่แล้ว +2

      @@darkforst17 I did

  • @TheBeastDispenser
    @TheBeastDispenser 2 ปีที่แล้ว +3

    This was great! Could you also cover how to setup a build file? I always struggle with those for more complex projects that use more a couple of files.

    • @everTriumph
      @everTriumph 9 หลายเดือนก่อน

      Makefiles are a little like a backward chaining AI program.

  • @charina_custodio
    @charina_custodio 2 ปีที่แล้ว +3

    It's my favorite language, plain & simple but still very eloquent to write.

  • @unstoppable_ducky4459
    @unstoppable_ducky4459 2 ปีที่แล้ว +4

    I just love how Fireship
    instantly gets to the point and and stays true to the title.

  • @sharangsharma203
    @sharangsharma203 2 ปีที่แล้ว +12

    I used to hate it in college, but now later I realise that it provides the perfect balance b/w high level and low level stuff. The pointers stuff and similar low level details provide a great gateway to get into OS, linux, Networking and Compiler stuff.

    • @loriswit
      @loriswit 2 ปีที่แล้ว +6

      we're in 2021, there are plenty of languages that provide full control on low level stuff while still being considered high level level languages, and which are also infinitely less painful than C

    • @mccarthymalonza6500
      @mccarthymalonza6500 2 ปีที่แล้ว

      @@loriswit which ones?

    • @loriswit
      @loriswit 2 ปีที่แล้ว +6

      @@mccarthymalonza6500 I'd say it depends on which part of the low level stuff you need to have access to, but I suppose high-level languages like Rust or even C# could satisfy most of the these needs. On the other hand, you could use C when you explicitly need a low-level language that's as close as possible to machine instructions (e.g. when programming for embedded system with very limited resources), but then there's nothing "high-level" about it in my opinion.

    • @borgir6368
      @borgir6368 2 ปีที่แล้ว +5

      @@loriswit literally no one use C# and rust for low level

    • @somebodyelse9130
      @somebodyelse9130 2 ปีที่แล้ว +2

      @@borgir6368 People do use Rust for low-level things. For example, Redox OS is an example of an operating system written in Rust, and the Linux kernel is adopting Rust for writing some drivers in. The point they were making is that most people don't actually need to use C; C# or Java would still give good performance while being much nicer to program with, because they offer garbage collection and built-in conveniences like inheritance and lambda expressions, and they hide pointers from you so you don't shoot yourself in the foot.

  • @IngwiePhoenix
    @IngwiePhoenix 2 ปีที่แล้ว +3

    Do Assembly next.
    Wanna see if you can contain it 100 seconds. Maybe stick to x86 ASM, but most ASMs are kinda similar.

  • @damonmlinaric9254
    @damonmlinaric9254 19 วันที่ผ่านมา

    I just started cs50 earlier this week and hearing that c is one of the more simple languages is definitely not what i wanna hear but are well wish me luck.I feel like once i wrap my head around how to solve problems then everything will kind of be about practice and ill have a much easier time learning

  • @Harthikreddyy
    @Harthikreddyy 3 หลายเดือนก่อน

    Wow this video compresses of everything I've learnt in the past 1 year

  • @QxDEADBEEF
    @QxDEADBEEF 2 ปีที่แล้ว +8

    2:19 I C what you did there.

  • @timboooh
    @timboooh 2 ปีที่แล้ว +13

    "Segmentation fault" ah yes, the C language

  • @HichigoShirosaki1
    @HichigoShirosaki1 6 หลายเดือนก่อน

    Here I was anxious about learning C in my future college courses after having done Java and Python, but if it's really that straightforward, then I am very much relieved.

  • @faseehnaqvi
    @faseehnaqvi 2 ปีที่แล้ว

    that "c" mad me subscribed. great work!

  • @marvinkuznitz6250
    @marvinkuznitz6250 ปีที่แล้ว +3

    I was in college studying computer science circa 1980. For programming we were studying FORTRAN and IBM OS360 assembly language. A friend of mine was interning at Bell Labs and he said he was learning a language that was so much better than FORTRAN called "C" and an operating system so much better than IBM OS 360 called "UNIX". After being a professional FORTRAN programmer for a number of years I started to use C and it was so much better than FORTRAN and the whole developer environment was miles ahead of anything else at the time.

  • @slippydouglas
    @slippydouglas 2 ปีที่แล้ว +9

    `char` is always 0-255. If you want a -128-+127 type, you’ll need the rarely-used `signed char` or more common `int8_t` type.

    • @asuasuasu
      @asuasuasu ปีที่แล้ว +1

      @scum bag worse: as far as gcc goes, on ARM it's unsigned, on x86-family it's signed.
      yet, char remains different from signed char and unsigned char to the type system :)
      nothing in the standard actually prevents `char` from being 16 bits... some obscure platforms (e.g. DSPs) may do that, but it can be assumed to be 8-bit for all typical platforms

  • @debjyotibanerjee6382
    @debjyotibanerjee6382 2 ปีที่แล้ว +1

    This video and the 'in 100 seconds' series is nothing short of magical...

  • @HalfbyteBangla
    @HalfbyteBangla 2 ปีที่แล้ว

    Learnt all these. Forgot all these. Now I'm happy !

  • @kzm1934
    @kzm1934 2 ปีที่แล้ว +10

    Anybody who wants to learn C should read the K&R book. It's brilliant and has everything you need.

    • @forouharp9683
      @forouharp9683 2 ปีที่แล้ว +1

      I kinda want to, but it's so old. I got Effective C which covers c17 and possible C2x.

    • @nivaldolemos5280
      @nivaldolemos5280 2 ปีที่แล้ว +1

      Please, don't recommnend it to beginners.

  • @ogamiitto5642
    @ogamiitto5642 2 ปีที่แล้ว +15

    Nice video!
    One small nitpick though: one should never write functions with completely empty argument lists in „C“, as the compiler takes this to mean that the functions in question can be called with a variable number of arguments (of nearly arbitrary type).
    Taking your example of a completely innocently looking “int main ()” function, this means that it would perfectly valid to recursively call this function-for example-like so: main(1, 'A', 3.7, "unintended consequences");
    Thus, if one is not interested in doing any command line argument processing (at all), a programs entry point should always be written like so:
    int main (void) { ... }
    Admittedly, this may change with the next version of “C”… however, until the final standard for C2x is released, the above rule stands as described.

    • @leofigoboh1611
      @leofigoboh1611 ปีที่แล้ว

      Is It a problem to allow a variable Number of arguments to the main, if you won't use them after?

  • @jamesleecoleman
    @jamesleecoleman ปีที่แล้ว

    This was a very fun video! Any plans for more C content?

  • @hbfl3x50
    @hbfl3x50 ปีที่แล้ว

    did a socket -chat -app in my first year project for this language, it was a pain in the ass but i managed this language opened my way of thinking complex logic code

  • @yapdog
    @yapdog ปีที่แล้ว +52

    Been programming in C for 3 decades, so, at this point, I can't even use a language that doesn't allow me to work with pointers and manage my own memory. And I'm better off for it.

    • @ghosthunter0950
      @ghosthunter0950 ปีที่แล้ว +8

      I learned python then C and now C++.
      It genuinely feels so much better to deal with the memory directly and you can be really creative with it. You have to know what you're doing though.

    • @zonictrout
      @zonictrout ปีที่แล้ว +1

      @@ghosthunter0950 same, I really like C/C++, more than python, even though it is much easier

    • @WarpRulez
      @WarpRulez 2 หลายเดือนก่อน

      It depends completely on what you are doing.
      If I'm writing a shell script, for example, I couldn't care one iota about memory management, and I'm completely fine with the shell script interpreter doing whatever it does, as long as it does it correctly. Manual memory management in this context wouldn't make an iota of sense.

  • @blackfrog1534
    @blackfrog1534 2 ปีที่แล้ว +21

    c is such a wonderful simple language, if you're not new to programming, this video has everything you need to get you started in c. awesome job man!
    p.s.
    i watch these videos even if i don't care or already know the programming language/tool because they are quite fun to watch. awesome job man!

    • @cobaltno51
      @cobaltno51 2 ปีที่แล้ว +2

      but remember, simple != easy

    • @ishdx9374
      @ishdx9374 2 ปีที่แล้ว +1

      @@cobaltno51 neither C is really as simple, numerous UB's and quirks are there in the standard, they are there for a reason though, and you don't usually encounter them

  • @ankurpanda9746
    @ankurpanda9746 6 หลายเดือนก่อน

    Thanks man, I knew nothing about C and I have my Semester Ending Examination for C in 5 minutes time. I hope this will help me pass the exam.

  • @SRPhantoms
    @SRPhantoms 2 ปีที่แล้ว

    the intro course to CS at my college taught the language C. Good move on their part tbh and like half the class dropped out halfway thru that intro class. Haha good times, more like less than 8 months ago

  • @crusaderanimation6967
    @crusaderanimation6967 2 ปีที่แล้ว +6

    Languages with garbage colection: Don't worry about memory management, I got you covered and I will protect you.
    C (and c++) :You're on your own kid... Have fun.

    • @bigshrekhorner
      @bigshrekhorner 2 ปีที่แล้ว

      Honestly, managing memory yourself is kinda fun

  • @gwynbleidd8723
    @gwynbleidd8723 2 ปีที่แล้ว +3

    I joined a programmation school since more than a month and worked 50h per week on C language, I am an absolute noob in programmation, it is an amazing experience and I am glad to see how much things I can do compared to the very beginning but jeez that's hard for me.

  • @gabrielborges7909
    @gabrielborges7909 2 ปีที่แล้ว

    I love your pronunciation of the printf function.

  • @ranjmahmood2429
    @ranjmahmood2429 2 ปีที่แล้ว

    I love your videos, can you do CSS positioning in 100s?
    Thanks,

  • @BibleClinger
    @BibleClinger ปีที่แล้ว +5

    I love C. Sometimes I think it just needs a simple push in the right direction to make it better as a language, but its fundamental essence is that of a language that is just so very simple, fast, and beautifully expressive. It's also incredibly dangerous. I still love it.

  • @henrykkaufman1488
    @henrykkaufman1488 2 ปีที่แล้ว +4

    OO is just one way of creating layer of abstraction in your code. OO languages not only enforce one way of abstraction layering, but also the OO in most of the languages is 'underpowered' compared to the true OO concept as it was executed in SmallTalk.
    Not having obligatory OO in your code and having access to memory granted by language means you can create your own abstraction solutions, tailor fit to your particular needs. It also means that if you write C code, it can always do something useful for your program, there's no noise of boilerplate and excessive naming.
    When you're reading a program, would you rather have to read one file with 5000 lines, or need to understand relations between 100 files 50 lines each?
    When you're programming, do you just want results, or do you need control?

  • @fluffycritter
    @fluffycritter 2 ปีที่แล้ว

    gcc is still the dominant compiler in opensource spaces but these days clang is getting a lot of adoption, with it being the default on macOS, the only option for iOS, and an easy option to select on many Linux distributions. Plus, it's the basis of a lot of new languages' compilers and often the first choice for folks designing new instruction sets due to its much more modular nature than gcc.

  • @CyricRO
    @CyricRO 2 ปีที่แล้ว

    This was actually surprisingly concise.

  • @MrChester114
    @MrChester114 2 ปีที่แล้ว +9

    I love that in C you have no classes. I think separating data from functions makes any program cleaner and easier to understand.

    • @fabricebalan
      @fabricebalan 2 ปีที่แล้ว

      You can implement OOP in C but you should not

    • @lucass8119
      @lucass8119 2 ปีที่แล้ว +1

      I agree for most cases, but I will say containers especially lend to object oriented programming very well. Having lists, vectors, trees, etc. with methods to act on their own data is intuitive and very concise. list.size() and vector.size() have completely different code, but they have the same name and represent the same thing - the size of a container. It really makes it simple to abstract and encapsulate complex data structures with complex memory allocation and traversal into objects as simple and easy to use as arrays. OOP also lends well to GUI parts of applications, as polymorphism and inheritance represent GUI components and widget hierarchies very well.

    • @MrChester114
      @MrChester114 2 ปีที่แล้ว

      ​@@lucass8119 I can agree about containers. I don't know about GUI programming since this is not my field. I guess the best approach is to use classes where they really fit and not everywhere. Having everything as class never works from my experience. Instead of focusing on the task that your program needs to do you focus on creating object hierarchies. So for example whether message should send itself or there should be a sender object that sends messages.

    • @lucass8119
      @lucass8119 2 ปีที่แล้ว

      @@MrChester114 I agree 100%. The "everything is a class" sort of idea that we see in Java and others is dumb and needlessly complicated. Most things don't need classes and objects, and you should only use OOP if it makes sense for that specific problem.

    • @sxs512
      @sxs512 2 ปีที่แล้ว +1

      And I think you've never tried writing anything longer than 100 lines of code. If you did you'd know that using objects and oop concepts like polymorphism and encapsulation is the way to go.

  • @AGBuzz182
    @AGBuzz182 2 ปีที่แล้ว +14

    The video implies that the stack has to be managed manually, but this is not true. If you declare a variable int phone_number, the memory for it will be automatically deallocated when the function containing it returns. This does not require garbage collection.

    • @lucasvillani5484
      @lucasvillani5484 2 ปีที่แล้ว

      I was in doubt with that detail, thanks for explaining!

    • @bur1t0
      @bur1t0 2 ปีที่แล้ว +2

      It isn't deallocated. Such variables are created on the stack, when the function returns that variable is out of scope, but can still be accessed by evil people until something else overwrites it, assuming it wasn't optimized out of existence by the compiler. Accessing something deallocated would cause a segmentation fault on a modern OS, where as accessing an out of scope variable is just evil.

    • @AGBuzz182
      @AGBuzz182 2 ปีที่แล้ว +3

      @@bur1t0 Fair point, and this can be the source of very subtle bugs if you're careless! It isn't deallocated in the sense that it's no longer mapped to the program's address space, but as you point out, it is no longer reserved for the data it contains and can be overwritten by the runtime, meaning it should probably for all intents and purposes be treated as strictly deallocated regardless.

  • @ahmedace4911
    @ahmedace4911 ปีที่แล้ว

    Those majors that give you the room to create....
    JUST BEAUTIFUL .

  • @JorgeEscobarMX
    @JorgeEscobarMX 2 ปีที่แล้ว

    Wow, this is the best explanation on what pointers are the we are going to get.

    • @MrBeanbones
      @MrBeanbones 2 ปีที่แล้ว

      that's the only one, pointers are exactly that, addresses to memory.