Live data from Hacker News

Failing to Learn Zig via Advent of Code

forrestthewoods.com

101–110 of 338 posts

Re: Failing to Learn Zig via Advent of Code

#101
post #89

Earlier quoted context omitted.

If you're going to compare that way (and I contend you shouldn't) at least normalize by programmer hours, or take into account growth.

Why? This doesn't make sense to me, for a few reasons reasons: 1) I'm looking for the best, not the best by programmer hours or growth. Zig has accomplished a lot and I'm impressed by the work of people on it. But it's still a strictly worse option than many others. I think it's poised to be great in the future, but right now it's not good enough. 2) Organizations always become less effective as they grow, Zig being…

> if you're looking for a supplier right now

literally only you introduced this 'looking for a supplier right now' concept. I hope you enjoyed knocking down this strawman.

Re: Failing to Learn Zig via Advent of Code

#102
post #96

Earlier quoted context omitted.

The trouble is, when you say it's OK to infer "from the current code" that includes your function call, which is the thing where you're surprised it happens. There's no coherent reason why it'd be OK for Rust to conclude that x is a u64 from let x = some_u64.add(6); // the u64 type implement Add returning a u64 and yet not OK for Rust to conclude that x is a u64 from let x = someFunction(); // someFunction was define…

That isn't the problem. This is the issue: let x = str.parse()?; someFunc(x); The function called here is dependent on what `someFunc` will accept. That means that I can change what values will be accepted here by changing a completely different piece of code.

Only if you think of other code in the same function as 'a completely different piece of code'.

With global type inference, the whole program is inferred for example.

Re: Failing to Learn Zig via Advent of Code

#103
Would there by any interest in an imperative language with a basic Standard ML type system?

Personally, while I find the imperative paradigm more intuitive than the functional paradigm, I believe functional type systems are simpler and more "right" than imperative ones are (which have been taken over by OOP). There are multi-paradigm languages, but these have large numbers of features, and complicated type systems, and I want something simple. Is there interest in this? Thanks.

By SML type system, I'm thinking:

  - Algebraic data types
  - Anonymous functions
  - Pattern matching
  - Simple generics
  - Type inference
  - Simple modules and implementation hiding
combined with some approach to operator overloading (which SML doesn't consider at all). And to remind you, the paradigm should be imperative, not functional.

I'm thinking a use case might be in numerical linear algebra, but with support for multiple different scalar types including floats, ints, complex floats, dual numbers (for autodiff), "codual numbers" (for better autodiff), bignums, quaternions, symbolic algebra, etc. The functional paradigm is not suitable here, but Julia is perhaps overcomplicated.

Re: Failing to Learn Zig via Advent of Code

#104
post #79
post #24

I like zig, but agree with many of the points here. A couple of thoughts below, > Zig reference documentation badly needs examples. Can't figure out how to use std.fmt.parseInt. While yes, Zig documentation badly needs examples, I'm not sure this particular criticism is justified. I would have thought that the usage of parseInt, was fairly obvious from the type-signature: parseInt(comptime T: type, buf: []const u8, r…

> ArrayList explicitly manages a contiguous region of memory, so I don't see the problem with exposing it as a slice as part of the interface. It used to be that you'd get an allocator by taking a pointer to the allocator field (&gpa.allocator), in 0.9.0 that was changed to a function call (gpa.allocator()) and thus broke _a lot_ of things. Exposing all these fields seems like it'll cause challenges when trying balan…

In most cases I would agree with you, but I think ArrayList is simple enough that backwards compatibility won't be a major concern. It's literally just a wrapper around slices that handles resizing for you, and there's no real reason for that to change. Exposing the slice underneath is a necessary part of its interface.

Re: Failing to Learn Zig via Advent of Code

#105

I don't understand people recommending reading the source code to learn. Source codes can be really daunting because there are so many things going on. There can also be "tricks" using advanced language features, which defeats the purpose if you're trying to learn as a first timer. Also, "read the source" is, at least to me, an admission that there is no valid documentation 90% of the time. Reading the source of a to…

> "read the source code" comments always strike me as unhelpful.

I can understand why people would recommend reading the source code of projects like Redis or SQLite (and here Zig's std lib) to learn, simply because the code quality is so high.

It's also not like anyone is proposing that there will be no documentation when Zig turns 1.0 (as if high quality documentation and code quality were mutually exclusive!) simply that Zig is not YET at that stage [1].

There's much to love about Zig, and it's always a good time to be reading code, and all the more so while it's growing and shaping because you end up with a deeper knowledge and understanding of what makes a great project great.

[1] Personally, I do find the language documentation to be pretty much excellent and the IRC and Discord helpful—hey, you might even bump into Mitchell Hashimoto also asking questions there. It's the std lib that's a little less, but again, that's in flux and files like `std/mem.zig` are enough of a pleasure to read and learn from. Zig's definitely a swell worth paddling.

Re: Failing to Learn Zig via Advent of Code

#106
I don't think it is that hard to learn

I'm not a professional programmer, this is all a hobby for me and i managed to pick and write an entire game with it

maybe you are just bad as a programmer (nothing wrong with that)

you have to learn how to learn, not everybody can do that (and it's fine)

that being said, zig is a language in the making, some areas are rough, but that's to be expected

Re: Failing to Learn Zig via Advent of Code

#107
post #89

Earlier quoted context omitted.

Why? This doesn't make sense to me, for a few reasons reasons: 1) I'm looking for the best, not the best by programmer hours or growth. Zig has accomplished a lot and I'm impressed by the work of people on it. But it's still a strictly worse option than many others. I think it's poised to be great in the future, but right now it's not good enough. 2) Organizations always become less effective as they grow, Zig being…

> if you're looking for a supplier right now literally only you introduced this 'looking for a supplier right now' concept. I hope you enjoyed knocking down this strawman.

What are you talking about? We're talking about the current state of Zig. From this thread of comments, on your messages:

> It's important to consider that for zig at this stage, "not having valid documentation" is expected. At some point not having valid docs will become considered to be unacceptable.

> Seriously, comparing by timeline like that is an unfair comparison.

The article is about failing to learn right now. The first comment was about the absence of documentation right now. You're defending Zig being worse than other languages by saying that Zig is younger, which is a fair point. But you also said that comparing by timelines is unfair, which I think is wrong, which is why we're having this conversation. My point is that comparing by timeline is totally fair, because people are evaluating a language on what it is, and not what it can be.

To speak in more precise terms: the current position of Zig is worse than other languages, especially in terms of documentation. The position adjusted for the timeline of Zig is also worse than many other languages at that point. You're asking us to not compare by position or position adjusted for the timeline, but by position relative to the ressources invested, and/or position adjusted for the timeline relative to the ressources invested. I'm saying that this comparaison is useless, because 1) those relation doesn't scale linearly, and 2) because people are interested in the actual position and position adjusted for the timeline, not the efficiency.

Since you reject comparing the evolution of the documentation of Zig through time ("Seriously, comparing by timeline like that is an unfair comparison.") and right now ("It's important to consider that for zig at this stage, "not having valid documentation" is expected."), your only argument seems to be about the future: "At some point not having valid docs will become considered to be unacceptable.". The vast majority of people, when faced with a language that looks not great at the moment but could have a bright future, will react with "I'll take a look again in a year or two". You argue for the opposite, that people should contribute to Zig instead: "You should probably kick a few dollars into the zig foundation as penance for having made it publically. ;)". That is a weak point, and won't convince the people that have seen languages come and go. Especially these days when new languages have great documentation, error messages, and onboarding in general.

Re: Failing to Learn Zig via Advent of Code

#108

Earlier quoted context omitted.

Read the language reference, use ziglings, use ziglearn.org, use zls (don't trust it too much tho, but it will help a bit) and vscode or any text editor that supports jumping to the source, and of course, RTFS

Read The Fabulous Sources?

Well yes, they're nice, but how would they help with Zig?

https://github.com/fsprojects/Fabulous

Re: Failing to Learn Zig via Advent of Code

#109
Zig is a very low level language. I think the fancy type system can trip up people into thinking they are working with a high-level language.

Zig is basically C with a fancy type system, so you should not expect things like special String types, overloading of index based access etc.

I think the author was thinking that Zig was very close to Rust or C++, when in reality it is much closer to C. I had to keep reminding myself of that many times as I was learning Zig.

I had my own struggled with Zig, but not quite as much as the author. I think will probably have a much better experience if you don't try to jump and code right away but read some articles or listen to some videos to get a sense of the overall philosophy of Zig.

I am normally against having to look at source code, but with Zig that is kind of needed but also not quite as bad as it sounds. Zig code base is not that large and it is relatively easy to search. You can lookup a Zig function signature very easily. You need to do this if you are going to use any of the standard library apart from the most basic stuff.

Re: Failing to Learn Zig via Advent of Code

#110
post #107

Earlier quoted context omitted.

> if you're looking for a supplier right now literally only you introduced this 'looking for a supplier right now' concept. I hope you enjoyed knocking down this strawman.

What are you talking about? We're talking about the current state of Zig. From this thread of comments, on your messages: > It's important to consider that for zig at this stage, "not having valid documentation" is expected. At some point not having valid docs will become considered to be unacceptable. > Seriously, comparing by timeline like that is an unfair comparison. The article is about failing to learn right no…

> The vast majority of people, when faced with a language that looks not great at the moment but could have a bright future, will react with "I'll take a look again in a year or two". You argue for the opposite, that people should contribute to Zig instead.

I'm trying EXACTLY to do that, and it's not logically inconsistent. I'm not sure why you are deliberately conflating "using a language" with "putting a (small) amount of money into a project". The exact point is "if you can't afford be present-focused in one way, be future-focused in a different way". I really don't have the energy to parse the rest of what you wrote.

Post reply on HN