3 ms·
> That seems kind of non-responsive. The fact that there are technical limitations with Rust's mechanism doesn't invalidate the fact that the existing solutions
by pcwalton 12y ago
> That seems kind of non-responsive. The fact that there are technical limitations with Rust's mechanism doesn't invalidate the fact that the existing solutions work fine when implemented with a cross compiler and yours don't. It's sort of a special case of my point: maybe you did it wrong.
Two of your examples have been template metaprogramming and cpp, both of which are very limited programming environments (technically Turing complete, but both are Turing tarpits). When you actually want a full programming environment, you always hit the cross-compilation issue. It's just fundamental to the problem. But the advantages of a having a full programming environment available, when you need that power, outweigh the downsides of having to write in a separate module.
The other example you gave is writing a Python script, which has all the same problems of writing in a separate module, except now you're writing in a different language in addition to writing in a separate module.
Sometimes you don't need the power of a real programming environment, of course. That's why the macro system, which does not expose a full programming environment, exists in Rust. But C++ templates and (especially!) cpp weren't designed as programming environments either. They're pretty terrible programming environments. If you want that kind of thing, use the macro system. It's technically Turing complete too in just the same way as templates are. But we also expose a full programming environment, if you want it.
I'm mystified by how offering a feature that extends the existing state of the art in addition to offering a feature that reflects the state of the art—the macro system—could possibly be somehow "doing it wrong".
- ajross 12y ago> I'm mystified by how offering a feature that extends the existing state of the art in addition to offering a feature that reflects the state of the art—the macro system—could possibly be somehow "doing it wrong". That's a total strawman (seriously: every time I see you deal with a criticism you pull out this flamage toolkit; please stop). All that stuff in the first half of your sentence? That's the stuff you're doing right. What you're doing wrong is that I can't write that inline in the code and need to write it as essentially an extension library for the compiler. I don't think it's such a strange request that my DSL implementation look like it does in C or Scheme, e.g. "[Define some quirky DSL hackery] [Implement a bunch of code using it]". I'm likewise mystified why you think that's not a useful requirement or a shortcoming (even a minor one -- you're literally refusing to engage me on this) of your design. The example code in the linked article is simply ugly. Ugly APIs are bad, even (especially) for subtle features.
- mbrubeck 12y ago> "[Define some quirky DSL hackery] [Implement a bunch of code using it]" This is the use case for macros, and Rust macros are at least as good as C macros for my common use cases. It's true they are more limited than Scheme macros, and also fairly different from C++ template metaprogramming. Rust macros aren't perfect, and they'll certainly improve as the language matures. Also, for cases where a compiler plugin is needed, I'm not sure why having it in a separate file is such a deal-breaker. Opening multiple editor tabs/windows/frames has never seemed that annoying to me. > The example code in the linked article is simply ugly. Ugly APIs are bad, even (especially) for subtle features. Yeah, Rust syntax extensions at this point are basically just reaching into the guts of the compiler and using APIs that were never meant to be public. That's why they're not part of Rust 1.0, and won't become part of the stable language any time in the near future. Right now I see them partly as a way of prototyping compiler/language features. Hopefully in the long term they will grow into (or be replaced by) something with a stable, well-designed API that still exposes most or all of the current power. By the way, Servo uses Rust macros, Rust syntax extensions, and two different Python script for code generation. (One is a fork of Gecko's WebIDL parser for generating DOM bindings; the other pre-processes a source file writen as a Mako template.)
- oldmanjay 12y agoI'm having a hard time understanding your objection. The nearest I can parse from all of your posts is "you aren't doing things the way I like therefore you are wrong" which isn't a very compelling argument to me.
- ajross 12y agoUh... what other definition is there for thinking something is wrong? I've written DSLs, and code generation hacks, and used the preprocessor, and lisp macros extensively to do it (not templates so much, to be fair). I know the problem area, I know what I like, and I don't like this. It seems that your position is "well, you won't get it so shut up about it". That seems rather uncompelling too. :)
- pcwalton 12y ago