fasterthanlime , Englisch
@fasterthanlime@hachyderm.io avatar

Although I've known about it for years it's just now going click in my brain how big of a hack the syn crate is and how much I dislike it 🙃

https://lib.rs/crates/syn

ilmai ,
@ilmai@hachyderm.io avatar

@fasterthanlime yep I'm just writing my first non-trivial derive macro and it's grueling. Not that the trivial derive macros were fun to write either. This really shouldn't be needed.

janet ,
@janet@fosstodon.org avatar

@fasterthanlime my similar dislike of it is what spawned this post: https://fosstodon.org/@janet/111223564960983226

And actually got in TWiR (twice lol)

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@janet mhhH I wonder if cargo --timings reports time spent on proc macro invocations, now that I think about it. (I suspect it doesn't)

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

I really dislike that derive macros have to essentially ship their own parser to access some form of AST: introspection would solve that and yeah, we missed out on that rustconf talk + work, didn't we.

mgattozzi ,
@mgattozzi@hachyderm.io avatar

@fasterthanlime because of the author of the syn crate specifically which is bad for 10 different reasons

mgattozzi ,
@mgattozzi@hachyderm.io avatar

@fasterthanlime the non apology really ticked me off

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@mgattozzi yeah yep same

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

And yeah I understand some proc macros essentially need to be parsers because they extend the syntax or whatever, sure. And I understand API compatibility for an AST is really hard (I studied the proc macro bridge) but that's... such a waste of CPU cycles.

ENDERZOMBI102 ,
@ENDERZOMBI102@blobfox.coffee avatar

@fasterthanlime if only the compiler itself exposed this kind of API... but that would require shared libraries or some sort of shared memory to get the info, which i don't think the rustc team would like

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@ENDERZOMBI102 there's already a proc macro bridge! the machinery is there.

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

Speaking of wasting CPU cycles I just learned/remembered that proc macros (just like all build-time deps) are compiled in debug mode by default.

Maybe we could switch to using cranelift with optimizations at some point in the future? Idk.

dotstdy ,
@dotstdy@mastodon.social avatar

@fasterthanlime cranelift with optimizations is still much slower than debug mode, iirc. perhaps you could find a better balance than -O0 though, specifically for build scripts. even with LLVM.

virtulis ,
@virtulis@loud.computer avatar

@fasterthanlime have to wonder how many other amazing ideas (and implementations) have been buried in Rust and elsewhere because of someone's "can't have nice things unless they're my nice things" but no one spoke up about it :(

Setzer22 ,
@Setzer22@mastodon.gamedev.place avatar

@fasterthanlime Not just ship their own parser, but also a greedy parser at that. Want to look at a function signature? Better parse its body down to the last tiny statement!

Venial (https://github.com/PoignardAzur/venial) at least got that particular part right, but it's a hard sell basically because nobody's using it and is still lacking features.

The whole thing is just a bit sad IMO. There's not even that many people who understand proc macros or learning materials to teach them.

  • Alle
  • Abonniert
  • Moderiert
  • Favoriten
  • random
  • haupteingang
  • Alle Magazine