Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. I don't wanna talk about it, but I wanna talk about it...

I don't wanna talk about it, but I wanna talk about it...

Scheduled Pinned Locked Moved The Lounge
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #1

    Yes, it's Zig. Forgive me because I'm becoming a wordle post. :laugh: But, I just gotta say, this is how extremely easy it is to use C code in Zig...

    // this is it, just do @cImport instead of @import
    const c = @cImport({
    @cInclude("unistd.h");
    });

    pub fn main() void {
    // as a bonus the C functions are already namespaced too
    const res = c.write(2, "Hello C from Zig!", 17);
    }

    Jeremy Falcon

    M P J 3 Replies Last reply
    0
    • J Jeremy Falcon

      Yes, it's Zig. Forgive me because I'm becoming a wordle post. :laugh: But, I just gotta say, this is how extremely easy it is to use C code in Zig...

      // this is it, just do @cImport instead of @import
      const c = @cImport({
      @cInclude("unistd.h");
      });

      pub fn main() void {
      // as a bonus the C functions are already namespaced too
      const res = c.write(2, "Hello C from Zig!", 17);
      }

      Jeremy Falcon

      M Offline
      M Offline
      Mike Hankey
      wrote on last edited by
      #2

      You almost got me ready to learn it. When it will run on ARM, I will definitely consider.

      A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator

      J 2 Replies Last reply
      0
      • M Mike Hankey

        You almost got me ready to learn it. When it will run on ARM, I will definitely consider.

        A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #3

        Mike Hankey wrote:

        You almost got me ready to learn it.

        You're in luck, it already supports ARM cross compilation. [Zig cross compilation](https://zig.guide/build-system/cross-compilation/) I haven't tried it for ARM yet, but that's what the site says. The main reason I'm learning it, is it's meant to be a direct successor to C... not C++ but C. You have projects like D or even Rust that creep into the overly complicated theory territory. Zig is like, nah screw that, this be C 2.0. Don't get me wrong, you can kinda mimic interfaces in Zig as an example, but it just feels way more like C than most other languages out there. But, with some newer features that came about since the 70s... like a standard package manager that every other language besides C has standardized by now and built in unit testing. Which IMO is awesome. It's still a young language (only started 8 years ago), but they recently got 21 million in funding for their series B. So, it's gonna continue to mature and evolve. Probably take several years to finally get to 1.0 though, so just be aware. The current release version is 0.13.0 and it'll be a bit before 0.14.0 is out. But, still... gotta start somewhere.

        Jeremy Falcon

        M 1 Reply Last reply
        0
        • M Mike Hankey

          You almost got me ready to learn it. When it will run on ARM, I will definitely consider.

          A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          Oh, I should say there aren't any beginner books on it yet. It's all still so new. There are some scam books that are AI generated and wrong on Amazon, but not legit ones. [One](https://kristoff.it/blog/note-about-zig-books/) is being worked on though, and I'm sure others will arrive in the future. So, for right now, it's gonna be online resources like [ziglings](https://codeberg.org/ziglings/exercises/src/branch/main/exercises), ziglang.org, zig.guide, reddit, Google, etc. Here's a list of projects using Zig, including editor plugins, etc. [Zig Learning Guide & Project Lists](https://github.com/C-BJ/awesome-zig) Reminds me of getting in on Linux during the early days though. Kinda exciting.

          Jeremy Falcon

          1 Reply Last reply
          0
          • J Jeremy Falcon

            Mike Hankey wrote:

            You almost got me ready to learn it.

            You're in luck, it already supports ARM cross compilation. [Zig cross compilation](https://zig.guide/build-system/cross-compilation/) I haven't tried it for ARM yet, but that's what the site says. The main reason I'm learning it, is it's meant to be a direct successor to C... not C++ but C. You have projects like D or even Rust that creep into the overly complicated theory territory. Zig is like, nah screw that, this be C 2.0. Don't get me wrong, you can kinda mimic interfaces in Zig as an example, but it just feels way more like C than most other languages out there. But, with some newer features that came about since the 70s... like a standard package manager that every other language besides C has standardized by now and built in unit testing. Which IMO is awesome. It's still a young language (only started 8 years ago), but they recently got 21 million in funding for their series B. So, it's gonna continue to mature and evolve. Probably take several years to finally get to 1.0 though, so just be aware. The current release version is 0.13.0 and it'll be a bit before 0.14.0 is out. But, still... gotta start somewhere.

            Jeremy Falcon

            M Offline
            M Offline
            Mike Hankey
            wrote on last edited by
            #5

            Damn another project. :)

            A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator

            1 Reply Last reply
            0
            • J Jeremy Falcon

              Yes, it's Zig. Forgive me because I'm becoming a wordle post. :laugh: But, I just gotta say, this is how extremely easy it is to use C code in Zig...

              // this is it, just do @cImport instead of @import
              const c = @cImport({
              @cInclude("unistd.h");
              });

              pub fn main() void {
              // as a bonus the C functions are already namespaced too
              const res = c.write(2, "Hello C from Zig!", 17);
              }

              Jeremy Falcon

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Sooo... it really just wants to be C when it grows up?

              J 1 Reply Last reply
              0
              • P PIEBALDconsult

                Sooo... it really just wants to be C when it grows up?

                J Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #7

                I mean I know this is a joke... so the obligatory har har har... har har har. :laugh: :laugh: :laugh: Buuutttt, and I know I'm sounding like a fanboi, but it's doing things that apparently the peeps behind C are too old to care about. Like, I mean, Zig sounds silly in name but I'm sure C is ran by grandpas still using an outhouse. Let me just give you a simple example here, every other modern language has a concept of lambda type expressions (using C# nomenclature), but not C. Now, Zig doesn't do that 1 for 1, but let me just show you with code.

                for (0..10) |i| {
                // variable 'i' will have each value 0 to 9
                }

                Of course you can do that in C by manually declaring crap, but it's so much more verbose and a waste of typing. Or what about a while block that supports a counter.

                while (n <= 20) : (n += 1) {
                // stuff
                }

                Or and this is where things get crazy, being able to name blocks and break out of them.

                namedBlock: {
                // do stuff
                break :namedBlock 42; // 42 is a return value if you want to assign this block to variable
                // no stuff done because of break
                }

                I could go on, but I'd be writing a book here. But stuff like `comptime` makes C macros look like a joke. I say this as a dude who loves C. I'm not a hater; I'm just a realist. I mean like it or not man, history has shown us that things die out if they don't evolve. Nobody is speaking much Latin these days despite the fact it used to dominate the world. We're just too close to C to realize it's gotten very little love for a long time. Been 50 years man. That's half a century. The world has moved on.

                Jeremy Falcon

                C 2 Replies Last reply
                0
                • J Jeremy Falcon

                  Yes, it's Zig. Forgive me because I'm becoming a wordle post. :laugh: But, I just gotta say, this is how extremely easy it is to use C code in Zig...

                  // this is it, just do @cImport instead of @import
                  const c = @cImport({
                  @cInclude("unistd.h");
                  });

                  pub fn main() void {
                  // as a bonus the C functions are already namespaced too
                  const res = c.write(2, "Hello C from Zig!", 17);
                  }

                  Jeremy Falcon

                  J Offline
                  J Offline
                  Jorgen Andersson
                  wrote on last edited by
                  #8

                  Jeremy Falcon wrote:

                  Forgive me because I'm becoming a wordle post.

                  Could be worse, could be a CCC post.

                  Wrong is evil and must be defeated. - Jeff Ello

                  1 Reply Last reply
                  0
                  • J Jeremy Falcon

                    I mean I know this is a joke... so the obligatory har har har... har har har. :laugh: :laugh: :laugh: Buuutttt, and I know I'm sounding like a fanboi, but it's doing things that apparently the peeps behind C are too old to care about. Like, I mean, Zig sounds silly in name but I'm sure C is ran by grandpas still using an outhouse. Let me just give you a simple example here, every other modern language has a concept of lambda type expressions (using C# nomenclature), but not C. Now, Zig doesn't do that 1 for 1, but let me just show you with code.

                    for (0..10) |i| {
                    // variable 'i' will have each value 0 to 9
                    }

                    Of course you can do that in C by manually declaring crap, but it's so much more verbose and a waste of typing. Or what about a while block that supports a counter.

                    while (n <= 20) : (n += 1) {
                    // stuff
                    }

                    Or and this is where things get crazy, being able to name blocks and break out of them.

                    namedBlock: {
                    // do stuff
                    break :namedBlock 42; // 42 is a return value if you want to assign this block to variable
                    // no stuff done because of break
                    }

                    I could go on, but I'd be writing a book here. But stuff like `comptime` makes C macros look like a joke. I say this as a dude who loves C. I'm not a hater; I'm just a realist. I mean like it or not man, history has shown us that things die out if they don't evolve. Nobody is speaking much Latin these days despite the fact it used to dominate the world. We're just too close to C to realize it's gotten very little love for a long time. Been 50 years man. That's half a century. The world has moved on.

                    Jeremy Falcon

                    C Offline
                    C Offline
                    charlieg
                    wrote on last edited by
                    #9

                    "the peeps behind C are too old to care about" sigh... that's racist. lol. Not really, but I'm trying to fix something that works in the real world. I already have some thoughts about your posts.

                    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                    J 1 Reply Last reply
                    0
                    • J Jeremy Falcon

                      I mean I know this is a joke... so the obligatory har har har... har har har. :laugh: :laugh: :laugh: Buuutttt, and I know I'm sounding like a fanboi, but it's doing things that apparently the peeps behind C are too old to care about. Like, I mean, Zig sounds silly in name but I'm sure C is ran by grandpas still using an outhouse. Let me just give you a simple example here, every other modern language has a concept of lambda type expressions (using C# nomenclature), but not C. Now, Zig doesn't do that 1 for 1, but let me just show you with code.

                      for (0..10) |i| {
                      // variable 'i' will have each value 0 to 9
                      }

                      Of course you can do that in C by manually declaring crap, but it's so much more verbose and a waste of typing. Or what about a while block that supports a counter.

                      while (n <= 20) : (n += 1) {
                      // stuff
                      }

                      Or and this is where things get crazy, being able to name blocks and break out of them.

                      namedBlock: {
                      // do stuff
                      break :namedBlock 42; // 42 is a return value if you want to assign this block to variable
                      // no stuff done because of break
                      }

                      I could go on, but I'd be writing a book here. But stuff like `comptime` makes C macros look like a joke. I say this as a dude who loves C. I'm not a hater; I'm just a realist. I mean like it or not man, history has shown us that things die out if they don't evolve. Nobody is speaking much Latin these days despite the fact it used to dominate the world. We're just too close to C to realize it's gotten very little love for a long time. Been 50 years man. That's half a century. The world has moved on.

                      Jeremy Falcon

                      C Offline
                      C Offline
                      charlieg
                      wrote on last edited by
                      #10

                      "I'm sure C is ran by grandpas still using an outhouse." Okay Mr. Falcon, you're getting edgy here and somewhat triggered me. I would point out that there is beaucoup code out there happily running all written in C. The good news is that we - us grandpas and great grandpas - have a STABLE compiler. It's only worked for decades. But lets take a look at your code examples. Now, I don't know anything about "zig" other than it's another open source compiler to continue to confuse crap... so fair disclaimer. "pub fn main() void {" Great, so for decades the suggestion has been to make your variable names readable in whatever language is native to you. Looks like zig has reduced public to pub and function to fn. Not a good start. "const res = c.write(2, "Hello C from Zig!", 17);" does not impress me. Why? I'm supposing c.write assigns the output to res. - Is res a dnamically allocated variable? String? Buffer of x bytes? Again, I don't know zig, but I have further issues. - What does the 2 do? - 17. Hmm, why not let the compiler handle the null terminated string? If I change the string, boom, the # is wrong. Fights on :) Everything I just posted is meant in technical respect.

                      Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                      J 1 Reply Last reply
                      0
                      • C charlieg

                        "the peeps behind C are too old to care about" sigh... that's racist. lol. Not really, but I'm trying to fix something that works in the real world. I already have some thoughts about your posts.

                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                        J Offline
                        J Offline
                        Jeremy Falcon
                        wrote on last edited by
                        #11

                        charlieg wrote:

                        sigh... that's racist. lol

                        Touché, buddy. :laugh: :laugh:

                        Jeremy Falcon

                        1 Reply Last reply
                        0
                        • C charlieg

                          "I'm sure C is ran by grandpas still using an outhouse." Okay Mr. Falcon, you're getting edgy here and somewhat triggered me. I would point out that there is beaucoup code out there happily running all written in C. The good news is that we - us grandpas and great grandpas - have a STABLE compiler. It's only worked for decades. But lets take a look at your code examples. Now, I don't know anything about "zig" other than it's another open source compiler to continue to confuse crap... so fair disclaimer. "pub fn main() void {" Great, so for decades the suggestion has been to make your variable names readable in whatever language is native to you. Looks like zig has reduced public to pub and function to fn. Not a good start. "const res = c.write(2, "Hello C from Zig!", 17);" does not impress me. Why? I'm supposing c.write assigns the output to res. - Is res a dnamically allocated variable? String? Buffer of x bytes? Again, I don't know zig, but I have further issues. - What does the 2 do? - 17. Hmm, why not let the compiler handle the null terminated string? If I change the string, boom, the # is wrong. Fights on :) Everything I just posted is meant in technical respect.

                          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                          J Offline
                          J Offline
                          Jeremy Falcon
                          wrote on last edited by
                          #12

                          charlieg wrote:

                          The good news is that we - us grandpas and great grandpas - have a STABLE compiler.

                          I should say, C is and will always be my favorite language. It's served me well over the years and will always have a special place in my heart. I promise I'm not one of these zealot hater types. But, ya know... I will joke about it. :-D

                          charlieg wrote:

                          Great, so for decades the suggestion has been to make your variable names readable in whatever language is native to you. Looks like zig has reduced public to pub and function to fn. Not a good start.

                          I'm a realist, so there are things in Zig I'm not crazy about. IMO they should've made the syntax a bit more C-like to be C 2.0. But, the good outweighs the bad. So, I overlook stuff like `fn` instead of `function`. I totally agree with the point that we should be moving away from too many abbreviations though, 100%.

                          charlieg wrote:

                          Is res a dnamically allocated variable? String? Buffer of x bytes? Again, I don't know zig, but I have further issues.

                          It's the same as using that C function in C. No different. Zig just allows you use that C function so you don't have to abandon decades of code on the C side. So, [write](https://pubs.opengroup.org/onlinepubs/007908799/xsh/write.html) would return the number of bytes.

                          charlieg wrote:

                          - 17. Hmm, why not let the compiler handle the null terminated string? If I change the string, boom, the # is wrong.

                          Actually, the compiler does handle that. I was just being lazy and writing a simple example.

                          charlieg wrote:

                          Fights on :) Everything I just posted is meant in technical respect.

                          Fair enough. :laugh: Just know I love C. I do wish it evolved a bit more in the past 50 years though. Adding new features doesn't mean you have to break compatibility.

                          Jeremy Falcon

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups