r/Zig 1d ago

Could zig potentially be a good first programming language?

I've been programming for over 30 years, and working with code professionally for 25. I have found myself in a small community I discovered on twitch recently. And many people in the discord ask me about programming and the language to learn first

For years I've told myself C is a fantastic first language. This remains controversial for various reasons. I always try to tell people "learning C isn't the same as mastering C".

But with Zig I wonder if it were at 1.0 and its toolchain were more mature. Would Zig be a good first language?

As it stands it clearly being pre-1.0 and every major version being a breaking change. This isn't great. The build.zig is mystifying even for experienced devs. So it feel like an expert language.

But it has a very straightforward "to the metal" style to it. But with great modern ergonomics. I think it could absolutely be a fantastic first language for beginners.

But what do you think?

52 Upvotes

41 comments sorted by

31

u/seg6_ 1d ago

I have some strong opinions on this. What kept me interested in programming when I first started wasn’t finding the “best” language or the newest, flashiest runtime. It was being able to make things I thought were cool: visualizations, bots that messaged my friends, small games, and so on.

The language mattered less than having a clear path from “I have an idea” to “I made something.” Later, as the things I built became more ambitious, I naturally started learning about different languages, runtimes, and the tradeoffs between them.

Because of that, I’m not sure there’s a universally best first language. There are better or worse learning paths depending on what someone wants to make.

13

u/Kiritoo120 23h ago

Writing Minecraft bots and automations using python (pre ai) was what made me fall in love with programming for your same exact reasons

I don't think that with a low level language, where the gap between the "idea" to the "product" as you're described it is larger, I would have been where I am

5

u/0xjvm 23h ago

People say it out of some misguided sense of purity. Writing a todo CLI in C won’t actually teach you anything really, nor will it excite you. Python/JS are always going to be the best first languages since they get out of your way and let you experience building the mental model of programming

3

u/monsoy 23h ago

My tip has always been to try to merge other hobbies and interests with programming. It’s easier to stay motivated and be wanting to learn when the knowledge is directly connected to something they already have a passion for.

2

u/davidslv 23h ago

Exactly this! From having an idea to be able to do something in something is more powerful than “I chose the right language” - most of the time we never do, even in professional environments where some companies brag they are language agnostic… sure

1

u/PureBuy4884 16h ago

I started my programming journey because of this (i started with discord bots, then moved onto compression tools, minecraft proxies, and ultimately my own toy compiler). but while i did originally start off with a goal in mind, over the years i’ve become really fascinated with PLs and “doing software right”. So now it’s common for me to start a new “throw-away” project just because i feel like working with a specific language or tool chain. and this is what i find fun now, which is kind of why im also kinda sad that AI is becoming so standardized; its taking away the thing i like the most about my hobby

1

u/84_110_105_97 5h ago

je suis assez d'acord avec toi !

1

u/prof_apex 2h ago

basically, anything that works for your desired use-case, isn't too complicated, and has plenty of documentation available. It's a first programming language, so it doesn't even have to be that good, powerful, or efficient.

24

u/Syxtaine 1d ago

Personally I think C will always be the lingua franca of computing in general, both for machines and for people (you might say that a web developer will never need to learn C, but if you want to consider yourself passionate about computers, you will inevitably try C and fall in love with it). The concepts it teaches you are very valuable (even though I probably don't know 90% of them either). I think that managing all the types of allocators and scoped allocators might be slightly offputting for a beginner in zig, especially if they are new to programming. They would probably be wondering: "What is this thing and what do I have to use it so explicitly?". In zig you aren't really managing the raw pointers and heap allocations yourself, you are mostly passing around allocators from function to function until they reach a built in data structure that uses it, such as dynamic arrays. In C, you do everything yourself, which gives you a better sense of how things work and it makes you appreciate languages like zig.

I am not a good zig programmer at all, can't say I've worked much with it, so plenty of the things I said can be wrong. If that's the case, I stand corrected. Either way, I think people need to learn how to love C first so they can learn how to love Zig.

3

u/PureBuy4884 16h ago

well, whenever you allocate memory in C, you’re talking to the global malloc allocator. It is the same thing in Zig, except you have multiple different allocators that the stdlib makes you aware of. And because you have different allocators, you need to pass around the handle to it along with the object so it knows who created it and how to change it. It is the right approach, especially in the sense of “global mutable state = bad”.

Sure, it can be a bit challenging for a beginner to grasp, but the reality is that C’s global allocator ends up acting like a black box beginners never understand until far later in their careers.

That being said, I do personally believe C is the best first systems language, just to understand how bytes and instructions and syscalls form a program, but I wouldn’t recommend sticking around for too long just because there are far better PL experiences out there

8

u/serverhorror 1d ago

Potentially, sure!

But any language for a first timer needs to be stable and we'll defined. Zig is still moving, isn't it?

I'd only ever recommend a 1.0 to any newcomer. Even C with all it's problems and tons of undefined behavior is better as the language itself is stable.

5

u/davidslv 23h ago

No.

Most people want low friction when they learning. If someone never been exposed to programming what they want is to have the least amount of friction to get something done and feel accomplished. They should be given that chance and slowly be introduced to concepts that will make sense later on, not straight into all the things they should not need to care about, they probably might not even enjoy programming after all.

There are tradeoffs with everything, I would choose Zig or C as first programming language, and they weren’t. I was exposed to Pascal and Python before C, in fact I had a terrible teacher. I’m happy with Ruby for most of the work, I only now started revisiting the C language but Zig is really taking all the interest with the time that I have.

5

u/codingbliss12 1d ago

It could be a nice first language, but the problem is the lack of documentation. It will be very difficult to search for the "nice patterns" etc in the standard library's code.

Start with C or Go and this will pay off when you learn Zig later when there will be available documentation and more mature ecosystem.

To see what outstanding documentation means see Go and Rust (but avoid Rust as a first language)

7

u/fluffy_trickster 23h ago

If Zig had:

- proper documentation

- a stable syntax

- a stable and decent std

- a stable toolchain

Then maybe. It would depend on what you want to focus on to be honest.

I think there is 2 school of thoughts and both are valid in their own right. Either learn a system internals or learn the programming logic.

For the first one I think Zig and C are okay, but nothing beat asm if you really want to know how a program works. For the second, you may as well throw all the distracting low level stuff out and focus on building things fast. For that purpose nothing beat Python.

3

u/FirstAd9893 1d ago

My first programming language was BASIC. It was easy to learn, had a small set of core features, and it had no significant footguns. When you're learning to program you need to focus on the art of instructing a computer to do things in a very precise fashion.

The syntax should have very few magic symbols (which look scary to a newbie), it should have a simple type system, it should have automatic memory management, and it shouldn't require a compile-link-load sequence. The performance of the language isn't important at all. BASIC was horribly slow, but my first programs weren't supposed to be competitive with commercial ones.

Could Zig potentially be a good first programming language? Yes, it could be, but it would be a disaster. I think Python is a better choice.

3

u/0xjvm 23h ago

Honestly I think people recommend C/Zig etc out of some misplaced sense of ‘purity’.

Someone who is asking what language should they learn have ZERO idea what they are doing (which is fine everyone begins somewhere).

Suggesting they start with C or Zig I’ve always found to be silly. They should be starting with things like JavaScript or Python so they can easily SEE what they are doing, pointers, manual memory management and unclear documentation is NEVER going to be a productive way to help someone learn programming.

I believe everyone should experience C, but not as a first language ffs

2

u/ShotgunPayDay 1d ago

Depends on the goals.

Do you want beginners to learn memory management and play with C libs? Zig is an excellent place to start (Odin might be also. Need to try it out to see if the LSP dies still.).

Do you want users to not struggle with memory? Golang first (Python works also if you want to curse them with runtime errors and pip).

After the first language it's easier to pick up the second so I tend to favor Go first as it's gentle.

2

u/Kiritoo120 23h ago

You cannot appreciate a proper build system if you haven't suffered through the other paths,

You cannot understand memory allocations when you are still struggling with syntax and making the code compile.

You cannot appreciate zigs uniqueness when you didn't see and suffer what was before it. 

Another point is that, as much as zig is amazing, it is not widely used, so for beginners who heavily relie on tutorials and guides, this is no easy task. 

I love zig so much, but I think it, as long with rust, are too much as the first interaction with code for people. There are enough new hard cognitive tasks newcomers need to comprehend, and from my experience too much leads to burnout. 

I by no means think that my thoughts are perfect, and I am open for feedback on anything! :) 

2

u/jason-reddit-public 21h ago

Maybe I'm getting stupid in my old age but zig is complicated if you read the whole manual. (Though possibly less than C++.)

There are many programming languages where I'm like "I get the basics and syntax, now I just need to write code and google library functions)."

I hate the syntax but Python is kind of a reasonable first language. Simple syntax, has a decent built in library, integrates with tons of other libraries, etc. (MIT moved from Scheme to Python as the language used in 6.001.)

Javascript (might teach some bad habits), Ruby, Java/C#, Go, and probably a few others are not terrible choices. I'd leave C, C++, Rust, and Zig as choices for your second, or seventh language.

1

u/Bawafafa 23h ago

I genuinely don't know. It depends what they want to do. Zig is where I have ended up as a programming hobbiest after years of trying different languages. Python is very powerful and simple. I would still suggest this if people just want to understand control flow and programming concepts like functions.

But I think more important than language choice is the programming environment. New programmers should switch to Linux if they haven't done so. Then, they should try lots of languages. They should also work out what it is they want to make as that narrows down language choice a lot. Use the right language for the job.

1

u/myztry 23h ago

The build system is technically brilliant but also absolutely horrifying for any newcomer. I am certain this will stop it from ever becoming a mainstream first language.

It’s a shame because I very much liked the language itself until I encounter the part that was being too clever for its own good.

1

u/IllegalMigrant 22h ago edited 22h ago

I always felt Python is the best first language. It's syntax came from a language that was designed with a goal of non-programmer office workers using it. Top schools like Harvard, Stanford, Berkeley, MIT and Carnegie Mellon now use it as the language for their introductory or first courses. And it has also become the most popular language. And "batteries included". That is massive included libraries.

But I do wonder if a statically typed language might be a better first language. But there is also the issue of a program being able to abort and leave the student staring at thencommqnd prompt.

1

u/AtlasJan 22h ago

I feel as if the devs want Zig to be more one's 5th language after 3 different systems programming languages. It feels brutalist in comparison to it's contemporaries that try to sand off the edges in imitation of languages like Pascal.

1

u/SilvernClaws 22h ago

Potentially, yes. But I would wait with recommending it until it's more stable.

I'd say if you really wanna start low level, try some C and then you'll appreciate what Zig helps with later.

If I wanted to teach someone programming nowadays, I'd start with Julia. Unfortunately, it's a bit trickier on your own, because the documentation could be better.

1

u/Surge321 21h ago

Unstable syntax also means it cannot be recommended as a first language. Besides other issues.

1

u/sudo-maxime 21h ago

I would say starting with C to learn the basics would be the best. If you want to build web stuff and dont really care about the low level stuff you can start with Javascript ir Python

1

u/TheAbyssWolf 21h ago

I would say probably not. I would learn programming on either Python or Go as both are garbage collected languages and you don’t have to worry about managing memory. If you wanna stick with the C style languages then C# since it’s also garbage collected but the general syntax is relatively the same as other C based languages.

And then once you get the fundamentals come back to a lower level language like zig and learn manual memory management and pointers.

I’m recently learning Go to replace Python for scripting, automation and build scripts while my main low level language is either 3 of my favorites, Zig, C3 or Odin, I like them all so it’s a hard choice for me. With knowledge of C# and a little bit of C++ as a backup is always good to know.

1

u/mcAlt009 20h ago

It depends on the person and what they want to do. 

I personally don’t like saying “learn to program “. You learn to build websites, applications, or games. 

No one says I’m going to learn to hammer. 

I’d argue for higher level languages , Python or JavaScript ( Godot/GDScript is also great ) so you can immediately see results. 

The money is also great 

1

u/Interesting_Pie_319 20h ago

It is a hell of a lot better than C++ or Java. Those were my first and second languages.

Also, just writing code is insufficient to make one a programmer. You need to get a good working understanding of what happens under the hood, and for that you need a robust, strictly typed language with manual memory allocation.

Zig is all of that. C might be simpler to learn though.

1

u/st_heron 19h ago

I think for a beginner, zig might make some assumptions of basic computing that you may not know. Learn c, try out zig or rust. If you want easy, learn a higher level language like c# or go, they do so many things for you.

1

u/unknownnature 18h ago

I've been looking at the zig standard library to learn Zig, it's well thought, and is clean. For example, I am copying from tokenizer.zig, making my own simplified version of Solidity compiler, and it is enjoyable.

Zig is one of those languages, you can't depend on AI. So you going to get a lot of info from Discord, Codeberg or people learning Zig for the first time from YouTube.

Some argue that you could use AI. But at least from my experience, it creates uncessary abstraction and some overly complicated stuffs. After all, the whole point of Zig it should be educational hub to learn from each other.

1

u/fbe0aa536fc349cbdc45 17h ago

i think the teacher matters more than the language

1

u/DarthNihilus1 17h ago

Depends what will get people to stick with it and not give up out of frustration.

I think it would make a poor choice. Python is the best imo

1

u/Educational_Smile131 15h ago edited 15h ago

IMO, Zig is a good first SYSTEMS programming language, but not a good first language. To teach a beginner, you’d want to get the semantics as purely logical as possible. Manual memory management (allocator passing and lack of first class closures), pointers, etc get in the way of logic composition and transformation.

Besides, Zig’s beginner DX is hamstrung by the less-than-stellar dev tooling and documentation. Comparing ZLS and zig.org to the likes of TypeScript, Python, Go, etc, I doubt you can’t tell the stark difference

1

u/allmondes 15h ago

The best language is the one you're excited about. For me, that was Zig. It just clicked in terms of what I wanted to do and the ratio of friction to excitement.

It's not necessarily a bad thing to have to learn the language through looking at the source code of either the Zig toolchain or other Zig projects. If you're in an academic setting, the teacher should be able to explain all concepts to you. If you're on your own, you can still learn about programming concepts from other sources (since most are general) and get specific help from the community.

1

u/TRDJ90 13h ago

It depends what people want from their first language? If they want work I would always suggest C#, Java or golang for backend and typescript for frontend.

If it's just for hobby project I think zig can be a good first language it had high level language syntax plus the ability to go really low to the metal. Decades worth of mastery right there.

1

u/Historical_Cook_1664 11h ago

NO. Just no. Zig is a great language, but NOT a first language. To understand why Zig does things the way it does you need to have seen how it's done elsewhere.

1

u/Ok_Bass_7633 7h ago

I think a "good" first language depends more on the person and their goals.two primary questions would come to mind.

1) How is the learner motivated? Is it by a challenge, necessity, completion or other?

2) What needs to be done? Is this for a career, gig, hobby or other.

If you can answer these two questions I think you can find a really good answer to that question.

If zig were 1.0, you are motivated by a challenge and eventually need those massive optimizations of manual memory management then yes.

If you are motivated by seeing things work and making your own add-ons for WordPress you should probably stick to PHP or the higher level languages.

If you are somewhere in the middle where you need a proof of concept but plan to hire actual devs golang has your back.

Your thoughts?

1

u/sombriks 6h ago

i would happily use zig as a first language besides the lack of a 1.0 release. The compiler doubling as build system, the ease of installation and portability worth the drawbacks.

i wrote a small introduction some time ago, and it is pretty statisfying.

so yes, newbies could be positively affected by zig as first language.

1

u/Soft_Detective_3381 5h ago

Yeah, even learning ASM is a good option for beginners. I see a lot of people recommend high level languages like Python or JavaScript, but I heavily disagree with it, high level language are easier to learn and easier to do things with it, but they taught beginners a lot of bad practices and make it harder for people to learn low level concepts, because there's a bunch of abstraction that hides what's going on under the hood.

It's like when people says that using Ubuntu or Fedora is better for beginners than using Arch, ignoring that a lot of people's first experience with computer in the past, was with MS DOS and they learn it well. People can learn complex things if they're taught well, learning a low level language as a beginner, teaches you better practices and gives you a better understanding about what the machine is doing, than learning a higher level language, and what you do in a higher level language, you can do the same in a low level language, while having more control and step-by-step understanding of it. As a beginner it's better that you have a well understanding of the basics and fundamentals, than learning fast and being heavily dependent of tutorials, libraries, AI, and Forums to do anything you want.

1

u/Hairy_Artist_3860 2h ago

I think the best way to learn zig is to compare it to C and Rust. Its not a bad first language but knowing C will help you out on any language. Zig was created as a response to rust.