Beginner's Guide to Zig Part 1 - Functions, Variables, Printing, Build system

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 12

  • @CodingWithTom-tn7nl
    @CodingWithTom-tn7nl  4 місяці тому +1

    A link to the code used in this series is in the description

  • @ivolol
    @ivolol 2 місяці тому +5

    Having your camera in the top left instead of top right was definitely a poor choice.
    You might like microsoft-windows-terminal its better version of command prompt

  • @pietraderdetective8953
    @pietraderdetective8953 4 місяці тому +2

    I see Zig, I press like and subscribed!

  • @Kaptime
    @Kaptime 4 місяці тому +3

    When I learned C/C++ years ago, header files always felt like such a prehistoric way to combine multiple source files. At least we have #pragma once to cut #indef etc. but it's a waste of time pasting declarations into a .h every time I write a function.

    • @Alicorn_
      @Alicorn_ 4 місяці тому

      From what I understand, the main utility of header files in the modern day is to provide a convenient way to see how you're meant to interact with an implementation file, particularly when working with closed-source libraries, or in large projects where digging through bloated implementation files could take hours. But I do agree, for solo dev, they're nothing but a nuisance.

    • @julians.2597
      @julians.2597 Місяць тому

      usign #pragma once apparently doesn't work for all platforms and all circumstances, so using it is discouraged x/

  • @nothing-tj9eh
    @nothing-tj9eh 4 місяці тому +1

    lovee the content keep going

  • @wb3904
    @wb3904 3 місяці тому

    i=integer and u=unsigned integer
    . In .{} refers to self/this so I interpret it as a tuple of a type that the function accepts but I’m new to ZIG

  • @raykirushiroyshi2752
    @raykirushiroyshi2752 3 місяці тому

    When i worked with c++ at university i just wrote the code i needed in the header file , why not just do that?
    Also, I've seen you can include a .cpp file as well

  • @privacyvalued4134
    @privacyvalued4134 2 місяці тому

    8:50 "Which gets very annoying when you want to test stuff." This is the sort of thing I do all the time. I already hate Go for this nonsense. If a developer is debugging code, let it just build and run. While someone is developing software, they have all kinds of cruft they are churning out - half finished thoughts/ideas but need to test. It is NOT an error to not use a declared variable. Dump out a warning and then carry on. I'm now out on Zig too. Compilers should get out of developer's way and let them write software however they want to write it.

  • @privacyvalued4134
    @privacyvalued4134 2 місяці тому

    0:58 "But has a lot of flaws. Things like header files." Huh? I've never once considered header files to be a "flaw" of C (or C++). The macro preprocessor that results in nightmarish, unreadable gibberish? Absolutely. The C/C++ macro preprocessor is fundamentally broken by design and should have been redesigned decades ago to not be terrible. The concept of header files themselves are not really an issue. In fact, you have an @import at the top of your code, which is the same basic concept that you are complaining about being in C/C++.

    • @CodingWithTom-tn7nl
      @CodingWithTom-tn7nl  2 місяці тому +3

      My problem with c/c++ is not the fact that you have to import things. That's easy to do (once you've actually made a header file).
      Let's say you have 100 functions in a cpp file and you want to use them all in another file. You will need to manually copy the names of every functions into a header file so you can use them.
      This is unnecessarily tedious.
      Then there are linker errors, the problems with trying to create global variables and the requirement to put functions above other functions that reference them.
      In Zig you just put 'pub' before functions and variables and you can use them in other files. And I've never gotten a linker error.
      Another advantage to zig is everything is separate from each other. If you have two files with a function/variable with the same name, it won't create an error, as you access them similarly to classes.