Live data from Hacker News

Don't be clever

stitcher.io

221–230 of 231 posts

Re: Don't be clever

#221

Earlier quoted context omitted.

Generating code is fine, if the generated code strictly never evolves independently of what it is generated from. For instance generating libraries from .proto files (or other declarative schema definition solutions) works really well. If the schema changes, you throw away the old generated code and generate brand new code, no problem. But if you want to make even a single tiny modification to one of the generated fi…

As a Lisp guy I find this entire discussion weird

I absolutely prefer code generation over macros. It is a general solution that works for all languages, databases, protocols etc. And you can easily inspect the code generated.

Re: Don't be clever

#223
post #48

The issue at hand is not about cleverness. Code was devised to address a specific problem (DRY), which it did quite elegantly. Then, the situation evolved, rendering the solution inappropriate. When a controller starts to deviate from the standard approach, it's best to refrain from inheriting from the base controller and instead create custom ones. Once all controllers operate independently, the base class can be sa…

What about making all of the "clever" things composable and optional, instead of tightly coupled? That way when you get a special case you can just make that part a special handler. You neither need to throw out the whole "clever" thing nor make the "clever" thing "more clever".

Choosing to inherit from a base class always seems like an optional and intentional choice, no?

Re: Don't be clever

#224

Earlier quoted context omitted.

As a Lisp guy I find this entire discussion weird

I absolutely prefer code generation over macros. It is a general solution that works for all languages, databases, protocols etc. And you can easily inspect the code generated.

You can wrap a code generator by a macro.

Re: Don't be clever

#226
post #133

Earlier quoted context omitted.

> For instance generating libraries from .proto files (or other declarative schema definition solutions) works really well. ...does it ? Generated ones always feel being mismatched with the language paradigms. Maybe that's just my nightmares of dealing with MS Graph generated vomit hose of a library...

Sure, that's true, I'm a heavy user of the standard protobuf library in python, and you certainly won't catch me singing its praises for its style. But that's a different (and less important) kind of problem. It does not exhibit the huge issue with generated-and-then-modified code where you have to maintain all the generated code rather than just the source from which it was generated.

It's trading wasting time by few developers manually writing client, for wasting time of tens of thousands of developers that use said client that doesn't fit language well.

It is IMO very bad tradeoff.

Re: Don't be clever

#227
post #224

Earlier quoted context omitted.

I absolutely prefer code generation over macros. It is a general solution that works for all languages, databases, protocols etc. And you can easily inspect the code generated.

You can wrap a code generator by a macro.

Why would you want to do that? That would be adding unnecessary compile time overhead. And (again) code generation works for any language/framework/OS/… Not just for Lisp.

Re: Don't be clever

#228

Earlier quoted context omitted.

As a Lisp guy I find this entire discussion weird

I absolutely prefer code generation over macros. It is a general solution that works for all languages, databases, protocols etc. And you can easily inspect the code generated.

[deleted]

Re: Don't be clever

#229
post #224

Earlier quoted context omitted.

You can wrap a code generator by a macro.

Why would you want to do that? That would be adding unnecessary compile time overhead. And (again) code generation works for any language/framework/OS/… Not just for Lisp.

You can handle any language with a read-time parser, then work with ASTs, pretty-print the result in another language. In between, it's just Lisp.

Re: Don't be clever

#230
post #229

Earlier quoted context omitted.

Why would you want to do that? That would be adding unnecessary compile time overhead. And (again) code generation works for any language/framework/OS/… Not just for Lisp.

You can handle any language with a read-time parser, then work with ASTs, pretty-print the result in another language. In between, it's just Lisp.

Ahhh you mean using Lisp to write the code generator. Yep makes sense.
Post reply on HN