Matthew

283 posts

Matthew

Matthew

@matthew_lugg

https://fosstodon . org/@ mlugg

Katılım Nisan 2015
104 Takip Edilen47 Takipçiler
Matthew retweetledi
p2r3
p2r3@p2r3_·
This has to be some terrible joke. It took 5 days since my video's takedown until I found a way to talk to a human, only for them to drop all accountability. @TeamYouTube I genuinely no longer feel safe posting on your platform. Do you employ anyone who doesn't follow a script?
p2r3 tweet mediap2r3 tweet media
English
25
47
140
3K
Matthew
Matthew@matthew_lugg·
@MrWedders I recall some fun times around the 7 era where I would use some repair thing to try and fix my network connection, and it would helpfully inform me "problem detected: you don't have an internet connection", and just sorta leave it at that
English
1
0
1
37
Matthew
Matthew@matthew_lugg·
@MrWedders Is your fleebleflarg broken? Well, never fear; if you open the Fleebleflarg Repair Wizard, all will be fixed.
English
1
0
1
45
Ben
Ben@mrwedders·
Every Microsoft help article is like "1) Right click the dingledoop 2) Choose the weehf option 3) Done!" but nothing tells you how to get the dingledoop in the first place.
English
1
0
1
108
Matthew
Matthew@matthew_lugg·
@onfiv @typesanitizer @Wire_Daemon As of Zig 0.12.0, comptime call memoization has no meaningful impact on language semantics; it's just an optimization. The reference to memoization in the 0.13 language reference (which you linked in a child comment) is just outdated; thanks for pointing that out! 4/4
English
0
0
1
40
Matthew
Matthew@matthew_lugg·
@onfiv @typesanitizer @Wire_Daemon "Captures" in this context are values which are defined outside of the type but referenced within it. In the above example, `x` isn't referenced by the `struct` (since there's nothing in the struct declaration!), so the set of captures is always empty, making the types equal. /3
English
1
0
1
35
Varun / 王潤 / げんじ
Varun / 王潤 / げんじ@typesanitizer·
Does Zig support recursive generic types (e.g. a rose tree)? Based on the docs here (#struct" target="_blank" rel="nofollow noopener">ziglang.org/documentation/…), it seems like the answer is No.
English
3
0
6
946
Matthew retweetledi
Gary Brannan
Gary Brannan@garybrannan·
‘My leadership will be about trying to defeat Doctor Who because he was rude about me that one time’ is an amazing hill to want to die on
Kemi Badenoch@KemiBadenoch

Tomorrow, I launch my @renewal2030 campaign to be the next leader of our great Conservative Party. Join me at 11.00am, here on X!

English
30
155
2.8K
83.4K
Matthew
Matthew@matthew_lugg·
@mitchellh I'll go one further: avoid `else =>` in all switches. It's essentially never a good idea. I fixed some quite nasty bitrot in the compiler recently which was caused by someone optimistically assuming a (256-variant) enum would never change and writing `else => {}`.
English
0
0
1
166
Mitchell Hashimoto
Mitchell Hashimoto@mitchellh·
Years into Zig, some advice: use inferred error sets for rapid development but try to convert them to explicit error sets as soon as you can. Likewise, avoid `else =>` in error switches. Its hugely valuable to discover you introduced new error case from the compiler erroring.
English
9
10
242
22.2K
Matthew
Matthew@matthew_lugg·
@pixqc @archived_videos The slow devloop criticism is valid -- our solution to it is making the compiler speedy! We're getting very close to incremental compilation, meaning the compiler only rebuilds code that changed, turning multiple-second compilations into "updates" on the order of milliseconds.
English
1
0
3
34
pix
pix@pixqc·
@archived_videos one kinda-good answer when I scrolled Zig Discord is "the compiler is your linter" yeah, but taking 3s+ to know my error is slow devloop in my book
English
2
0
2
65
pix
pix@pixqc·
Why is Zig linter not a thing? nektro/ziglint exist but doesn't seem to be widely used like Rust Clippy
English
4
0
17
1.1K
Matthew
Matthew@matthew_lugg·
@owickstrom (I don't personally use ZLS because it chokes on some big files in the compiler itself which is what I'm typically working on, but if you're interested in having a language server that post will probably help you)
English
1
0
1
26
Oskar Wickström
Oskar Wickström@owickstrom·
I'm definitely not friends with the lazy compilation yet, but we're making it work. `zls` seems not that useful, and I've gone towards using `:compiler zig` and `:make ...` in nvim instead.
English
1
0
0
373
Matthew
Matthew@matthew_lugg·
@eriklangille This code has a bug! @ alignCast is unsafe; it asserts that the pointer is more aligned than it necessarily is. The correct thing is to use a `*align(1) T`, so the compiler knows the address is not guaranteed to have any alignment. By the way, this is `std.mem.bytesToValue` :^)
English
0
0
1
23
Erik Langille
Erik Langille@eriklangille·
6/ The first comptime method I wrote is for the common pattern of allocating on the call stack a primitive from a buffer
Erik Langille tweet media
English
1
0
0
88
Erik Langille
Erik Langille@eriklangille·
2/ Multiarraylist - I can store structs in a memory efficient way (no padding) without creating a custom data structure. It is all handle at comptime, built into the standard library
English
1
0
0
91
Matthew
Matthew@matthew_lugg·
@eriklangille Note that it's 8 *words*, not bytes! So, typical (e.g. x86_64) processors have 64-byte cache lines, not 8-byte. Analogously, Apple silicon has 128-bit cache lines.
English
1
0
1
51
Erik Langille
Erik Langille@eriklangille·
What makes Zig code fast? A focus on data-oriented design. A major bottleneck for performance is CPU cache speed. Most common processors store data in 8 byte chunks (except Apple silicon is 16). If you have a struct >8 bytes, it will require multiple cache hits/registers
English
2
0
4
377
Matthew
Matthew@matthew_lugg·
@nilvoid32 @ThePrimeagen The Zig compiler, OTOH, doesn't link to libc, so it has to compile all of the stdlib code to do the printing. It'll also be building the panic and segfault handlers by default, which brings in DWARF parsing! This is a strictly minimal Hello World: zigbin.io/823509 [2/2]
English
0
0
1
30
Matthew
Matthew@matthew_lugg·
@nilvoid32 @ThePrimeagen It's worth noting that the Zig compiler is doing quite a bit more work because it's compiling everything, e.g. the actual printing logic, from scratch. C compilers have the advantage of having libc precompiled, so they only have to compile one trivial call. [1/2]
English
1
0
1
31
ThePrimeagen
ThePrimeagen@ThePrimeagen·
for all of those that want to learn C try zig reasons 1. its build system is much better 2. it has testing built in 3. it will teach you everything that c will teach you other than a couple of base concepts that are not hard to learn without all the suck it really is awesome
English
160
98
2.6K
539.8K
Matthew
Matthew@matthew_lugg·
@nilvoid32 @ThePrimeagen Assuming you're on x86_64, you can try using our self-hosted code generation backend and linker by passing the options `-fno-llvm -fno-lld` to your `zig build-exe` command. With these, I can compile a Hello World in 0.3s, compared to 1.4s with LLVM. [2/2]
English
1
0
0
26
Matthew
Matthew@matthew_lugg·
@nilvoid32 @ThePrimeagen The reason, in short, is LLVM. When you run your build command, you'll see for most of the duration of the build, it says "LLVM Emit Object". That basically means the time is out of our hands at that point -- we're completely in LLVM code. [1/2]
English
1
0
0
49
Matthew
Matthew@matthew_lugg·
@felipec @J03daSchm0 @ThePrimeagen If you seriously think "Zig's debug binary is less efficient than Clang's release binary" is a reasonable argument, or indeed think that considering any debug binary's performance is helpful, then I'm certainly done here lmfao
English
1
0
0
47