C is The MOST Beautiful Language!

Sdílet
Vložit
  • čas přidán 22. 08. 2024
  • This is a short video that seeks out old civilizations. To boldly go where no man doesn't wanna go today!
    Let's see my old code for one of the programming challenges written in C.
    Used icon from:
    commons.wikime...
    commons.wikime...
    Link to exercise: pl.spoj.com/pr...

Komentáře • 59

  • @telotawa
    @telotawa Před měsícem +11

    imagine not knowing how long your integer primitives are because it depends on the platform
    nice elegance bud

    • @matgla95
      @matgla95  Před měsícem

      thanks, It's even worse when types promotion come to case when you have different type sizes on different platforms.

    • @redcrafterlppa303
      @redcrafterlppa303 Před měsícem +2

      stdint.h...
      Anyone not using them is just stupid or has an old codebase.

    • @tiranito2834
      @tiranito2834 Před 23 dny

      Ah yes, because we sure do love writing non portable code! are we forgetting about the fact that C is a systems language? if you need code specific to a certain platform, then use stdint.h types, if you need portable code that works between platforms where you don't know what the width will be, then use standard integer types.
      I thought this was figured out like 50 years ago, we can't have devolved that much, right...?

    • @redcrafterlppa303
      @redcrafterlppa303 Před 23 dny

      @@tiranito2834 why should normal ints be more portable?
      There is no real point in using normal ints over standard int.
      Platform dependent types are only necessary for system level interfaces and working with pointers. And in most cases the explicitly platform dependent size_t is all you need.
      Having the possibility that your int might be "arbitrarily" long depending on the platform might even cause bugs in form of unexpected integer overflow or compile errors in case of to large literals.
      Tldr always use stdint.h if possible. It makes the code more stable and compatible and portable.

  • @tuxorizon
    @tuxorizon Před měsícem +5

    I'm an absolute beginner in C programming, watching your video gave me the impetus I need to learn C language upto becoming a master. Thank you and have a felicitous intellectual journey ahead!

    • @matgla95
      @matgla95  Před měsícem

      Thanks! let's do it! Keeping fingers crossed!

  • @a.v7998
    @a.v7998 Před měsícem +3

    My First Programming language was python, then I moved to C. When I was Learning python i struggled with logic building. But After learning C im getting better with Logic, and Also Better at JavaScript.

    • @matgla95
      @matgla95  Před měsícem

      Yup, different languages due to different paradigms enforce to improve the skill set and it seems you have a win-win outcome :)

  • @natam1616
    @natam1616 Před měsícem +2

    But it is defined as 'undefined behaviour' the part of the code >>k++*k/2

    • @matgla95
      @matgla95  Před měsícem +1

      Sure! Good point and that one is even reported by GCC, when using the -Wall flag :) but the goal of that exercise is to abuse whatever you can in the provided compiler to achieve the smallest possible source code

  • @hugoandres5937
    @hugoandres5937 Před měsícem +2

    Answering your question about what languages I want to learn are: I've been trying to learn Rust for months, I took courses and read books but I haven't made any progress, I feel stuck, my goal with Rust is the backend, even in the same book it tells you that before that you must know C++. My biggest dream is to master Rust and then C++. that's why I started following your channel, thanks

    • @matgla95
      @matgla95  Před měsícem +2

      Yes, Rust/C++ require a lot of time invest. They are really hard to master, but still you can write good code without mastering each piece of a particular language.

    • @hugoandres5937
      @hugoandres5937 Před měsícem +1

      very thanks, greatings
      saludos desde Bolivia, querido amigo.

    • @thecoolnewsguy
      @thecoolnewsguy Před měsícem

      There are better languages for backend

    • @hugoandres5937
      @hugoandres5937 Před měsícem

      @@thecoolnewsguy For the niche I am aspiring to, they are the fastest and what I need to learn. Thanks for your comment, greetings

  • @cyrusol
    @cyrusol Před měsícem +2

    Erlang, any ML, any Lisp and Haskell are beautiful.
    If someone finds C beautiful they also find spoiled foods yummy.

    • @matgla95
      @matgla95  Před měsícem

      I think beauty is subjective and depends on context. Here I used it a little bit ironically, since you can still do things that should not be allowed, at least by default. Hopefully compilers are evolving and, i.e. GCC 14 rejects such code by default which is good in my opinion!

  • @i_isak1451
    @i_isak1451 Před měsícem +1

    I guessed correctly but I liked anyways! Good video

  • @ethical-not-evil
    @ethical-not-evil Před 16 dny +1

    it will works cuz of gcc it set variables and funcs to type int as default

    • @matgla95
      @matgla95  Před 14 dny +1

      Yes, but it uses more than that :)

  • @Shnaypur
    @Shnaypur Před měsícem +2

    Swietny material. Wiecej tego sortu filmikow :) Jakbys jeszcze tylko wrzucal regularnie materialy to mozna by pomyslec o jakies formie wspierania kanalu

    • @matgla95
      @matgla95  Před měsícem +1

      Dziękuję! Regularność niestety aktualnie nie wchodzi w grę, choć marzy mi się przyspieszenie montażu (pewnie kwestia wprawy). Kanał rozwijam w swoim wolnym czasie, a do tego dopiero uczę się nagrywania i montażu :) Póki co wystarczy lajk lub miłe słowo :)

  • @hugoandres5937
    @hugoandres5937 Před měsícem +2

    Any advice for learning to program, without staying in the infinite loop of the courses, any tips that were useful to you, thank you

    • @matgla95
      @matgla95  Před měsícem +2

      I always recommend doing actual programs instead of courses. To be honest I almost always boycott most of course, it's too boring for me instead I am using them as a "what to learn next" list. Then think about what program you could wanna write and try to do it. It won't be perfect for the first time, but you can gain real experience and continuously improve it. It could be big or many small ones, but always think how you can improve them after all. When I was taking part in interviews in my previous company always the best candidates were with people that came with projects on GitHub that they prepared by themselves and it was easier for them to adapt to project.

    • @hugoandres5937
      @hugoandres5937 Před měsícem +1

      @@matgla95 very thanks 🙏🏻

    • @hugoandres5937
      @hugoandres5937 Před měsícem

      @@matgla95
      Let's say I want to learn how like you, where would I start, if there is a lot of information, like the basics without having to go through the courses, the githubs are huge and there are topics in a single repository of different things, the documentation is technical and difficult, as you did at the beginning to later be able to extricate yourself from c, this answer would help me a lot more. greetings

    • @matgla95
      @matgla95  Před měsícem +2

      I don't mean to completely drop courses, they are necessary to learn basics. I also started with a course something like " from zero to games coder". And with each exercise I did a similar one on my own. Like it was a random number generation section with exercise with solution, so I did it, but then wrote my own program that also uses random number generation. With some basics I started writing game, since it was fun for me, step by step. With no knowledge it required a lot of internet research, like the first goal: select library, then render black window in OS... Trying to move from courses to reading reference manuals for language and documentation for libraries. Today all those GPT/Copilot could help to speed up information searching on given topic.
      Starting you may want to write as much as possible on your own, it's reinventing a wheel, but needed if you want to get deep knowledge.
      But most important is to find a way of learning that makes you fun. If it's not fun most probably you won't be able to spend enough time to grow fast, so the whole road will be longer. Keeping fingers crossed :) Which language you are trying to learn?

    • @hugoandres5937
      @hugoandres5937 Před měsícem

      @@matgla95 I've been trying to learn Rust for months, I took courses and read books but I haven't made any progress, I feel stuck, my goal with Rust is the backend, even in the same book it tells you that before that you must know C++. My biggest dream is to master Rust and then C++. that's why I started following your channe

  • @thefanboy3285
    @thefanboy3285 Před měsícem +1

    What does the tilde ~ symbole mean in C ? Just before the scanf

    • @matgla95
      @matgla95  Před měsícem

      It just performs bitwise negation on value returned from scanf function to break loop when got EOF ( which normally is -1 ).

  • @qy9MC
    @qy9MC Před měsícem

    main(k){while(scanf("%d"))printf("%d
    ",k++*k/2);}
    is it a valid solution? It is 3 characters shorter.
    Also the original version with "%d " gave me segfault so I went with "%d
    ".
    I would like to try more but I really don't understand the coding challenge here. Why do we even scan for numbers? The rules are unclear to me, perhaps it's due to traduction from polish.

    • @matgla95
      @matgla95  Před měsícem

      So, let me clarify a little bit.
      The code is on SPOJ and is executed for 10 test cases.
      Test data is provided on STDIN in the form:
      1

  • @jindrichcapek9836
    @jindrichcapek9836 Před měsícem

    Why is there a space between %d and
    ?

    • @matgla95
      @matgla95  Před měsícem

      Originally that code doesn't contain
      . It was added just to better presentation of execution. The testing from SPOJ is executed for many inputs from stdio and space is necessary to separate outputs for test cases.

  • @HoangNguyen-nz4xe
    @HoangNguyen-nz4xe Před měsícem +1

    That is so cool 😂

    • @matgla95
      @matgla95  Před měsícem +1

      Imagine my face when I found that type is not needed in the main function argument :)

  • @CodingWithDox
    @CodingWithDox Před měsícem +1

    can u give us a link to the challenge

    • @matgla95
      @matgla95  Před měsícem

      Sure, pl.spoj.com/problems/SUMAN/
      And more exercises and challenges like this are here: www.spoj.com/

    • @CodingWithDox
      @CodingWithDox Před měsícem +1

      @@matgla95 I have a 52 letter solution but how do I make it use the correct compiler :c

    • @matgla95
      @matgla95  Před měsícem

      And that was one of the reasons that I decided to publish that video :) it's an old challenge and the current solution is easy on the internet to find, so I hoped someone will try to reduce it more!
      Unfortunately since the whole website is old and I am not even sure it is maintained, the latest compilers are not available.

    • @CodingWithDox
      @CodingWithDox Před měsícem +1

      I lied, I misscounted, sorry for my ignorance :D

    • @matgla95
      @matgla95  Před měsícem

      @@CodingWithDox I am glad you tried. Someday someone for sure will find a better solution :)

  • @callisoncaffrey
    @callisoncaffrey Před měsícem

    I see Windows, I leave.
    Edited to get rid of the heart sticker.

    • @matgla95
      @matgla95  Před měsícem

      Yes you're right, I have a problem with recording on Linux ( my camera interface produces crazy delays, most probably Nvidia again broke their driver xd ) which I haven't solved yet, so I temporarily switched to windows.

    • @callisoncaffrey
      @callisoncaffrey Před měsícem

      @@matgla95 That's no excuse to have it running in the background. Honestly, I'd be embarrassed. You do you though. I'm sure your excuses will safe you from the social credit system you help implement by running spyware. Oh, and don't get me started on the smart phone which I'm pretty sure you have too.

    • @matgla95
      @matgla95  Před měsícem

      No no, I am only using pigeon post :)

    • @callisoncaffrey
      @callisoncaffrey Před měsícem

      @@matgla95 You sound like a smoker telling me that smoked meat takes longer to go bad. I guess the copium is always real. Anyway, you keep making excuses for being the corporations' female canine.
      Another thing though. Are you actually in Poland? We are always looking for Team Fortress people in Europe. I wrote a fork of the original for the Darkplaces engine with more emphasis on tactics and stealth.

    • @thecoolnewsguy
      @thecoolnewsguy Před měsícem

      Jerk