Published Jun 21, 2022

Episode 517: Jordan Adler on Code Generators

Jordan Adler delves into Pinterest's seamless Python 2 to 3 migration, offering deep insights into code transformation and generation strategies, emphasizing incremental changes and effective handling of complex, large-scale projects to maintain code functionality and efficiency.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Code Generation

    Code generation is a technique in software engineering where software produces code as an output, rather than executing user behavior. explains that a common example is transpilation, where code is translated from one language to another, such as Typescript to JavaScript 1. This process can enhance productivity by reducing repetitive coding tasks and ensuring consistency across different systems or languages 2. highlights that tools can generate code for complex systems like Kubernetes YAML, making development quicker and less error-prone 2.

    You can test for correctness. You can duplicate code. So you can kind of produce multiple different versions of the same input.

    ---

    This approach not only saves time but also minimizes errors by allowing pre-generation checks for correctness.

       

    Benefits & Challenges

    Code generation significantly boosts productivity by automating repetitive tasks, but it also introduces complexity, especially in the build tool chain. notes that while it saves developer time, it can extend the build process, requiring careful consideration of the trade-offs involved 3. The technique can be applied in various ways, from CLI-based tools to GUI applications, and is often used in projects like API client libraries 4. adds that the choice of tools and processes should consider the users' technical capabilities and the project's specific needs 5.

    You have to be conscious of that. But other than that, I would say there's no kind of hard and fast rule. Really depends on the situation.

    ---

    Ultimately, the benefits must outweigh the added complexity and time costs.

       

    Best Practices

    Best practices in code generation involve manual inspection and strategic version control to ensure quality and maintainability. emphasizes the importance of reviewing generated code, even when using automated processes, to catch potential errors 6. Documentation should be integrated at various stages, from the generation specifications to the final output, ensuring clarity for developers and users alike 7. suggests that the choice of documentation methods should align with the project's needs and the tools available to contributors 5.

    You can't say for certain what the changes will be. So that is more of a manual kind of review process.

    ---

    These practices help maintain a balance between automation benefits and the need for human oversight.

Related Episodes