×

Dynamic AI
Co-Creation

A Human-Centered Approach
by Will Luers

Created through the Digtal Pubishing Initiative at The Creative Media and Digital Culture program, with support of the OER Grants at Washington State University Vancouver.

publisher logo

Chapter 8: AI Coding

1. Generative AI Coding

“Wasn’t it odd that the machines needed us humans to learn their maddeningly precise secret languages to get the most out of them? If they’re so smart, shouldn’t they try to understand what we’re saying, rather than us learning how to talk to them?” - Farhad Manjoo
Is Code Generation with AI the New Programmer Tool of Choice? | IBM Technology

The traditional approach to programming requires humans to master the precise syntax and rules of coding languages, a task that can be daunting for beginners and time-consuming for experienced developers. However, with the advent of Generative AI, this paradigm is shifting. GPTs (Generative Pre-trained Transformers) and other advanced models have been trained on vast codebases drawn from public repositories, forums, and other sources. These models possess an understanding of various programming languages, coding patterns, and the complexities of software development.

Natural Language Programming (NLP) aims to bridge the gap between human linguistic expression and machine-readable code, making programming more intuitive and accessible. Rather than requiring individuals to conform to the rigid structure of code, NLP allows for the expression of coding intent through natural language. AI systems then translate this intent into executable code.

This approach makes programming more approachable, enabling rapid prototyping and enhancing interaction with codebases, documentation, and development tools through conversational inputs. NLP leverages techniques such as machine translation, language modeling, and semantic parsing to map natural language instructions to programming constructs. AI coding assistants can understand contextual cues, resolve ambiguities, and even ask clarifying questions, leading to functional code being generated iteratively from user inputs.

While NLP is still an emerging field, it has made significant strides thanks to advancements in deep learning and large language models pretrained on extensive codebases. Major tech companies like Amazon, Google, and IBM, as well as innovative startups like Anthropic, are heavily investing in conversational AI coding assistants.

Despite its potential, NLP faces challenges such as the ambiguity inherent in human languages, ensuring precision in programming instructions, and maintaining the efficiency and performance of the generated code. However, as AI continues to evolve, the vision of a future where coding is as simple as having a conversation is rapidly approaching reality.

Large Language Models and The End of Programming - CS50 Tech Talk with Dr. Matt Welsh

2. Development with AI

10 Developer Productivity Boosts from Generative AI | IBM Technology

The integration of AI into software development is transforming how developers approach coding tasks, making the process more efficient, accurate, and accessible. AI tools are now capable of automating complex tasks that once required significant human effort, from generating code to optimizing performance. By leveraging these AI-driven capabilities, developers can not only speed up their workflows but also enhance the quality and security of their software projects. Below are some key ways AI is reshaping the development landscape:

  • Automated Code Generation: AI models can generate full programs or code snippets based on text descriptions or just a few lines of seed code.
  • Bug Detection and Correction: By analyzing existing codebases, AI can identify potential bugs, logic errors, and suggest fixes proactively.
  • Code Optimization: AI systems can refactor code to improve its performance, memory usage, maintainability, etc.
  • Documentation Generation: AI can auto-generate documentation from code comments and structure.
  • Language Translation: AI can translate code between programming languages, enabling cross-platform development.
  • Learning and Training: AI tutoring systems can provide interactive coding lessons tailored to each student's level.
  • Security: AI can scan code for potential vulnerabilities and suggest remediation steps.
  • Automated Testing: AIs can generate test cases automatically based on the program specification and run comprehensive testing.

The capabilities listed above are just the start - AI is being explored for nearly every aspect of the software development life cycle. However, human oversight is still required to validate the AI-generated outputs.

AI Tools for Coding

  • GitHub Copilot - https://github.com/features/copilot

    GitHub Copilot is an AI-powered code assistant that suggests real-time code completions based on context. It integrates with popular IDEs like Visual Studio Code and JetBrains, making coding more efficient by suggesting entire lines or blocks of code as you type.

  • Tabnine - https://www.tabnine.com/

    Tabnine offers intelligent code completion and contextual suggestions for a wide range of programming languages. It integrates with multiple IDEs and helps developers by improving code quality, providing code snippets, and even assisting with code refactoring.

  • Replit Ghostwriter - https://replit.com/site/ghostwriter

    Replit Ghostwriter is a coding assistant integrated within Replit’s collaborative IDE. It provides code generation, debugging, and transformation features, making it easier to work across multiple programming languages with real-time suggestions and refactoring options.

  • Kite - https://www.kite.com/

    Kite assists in Python development, offering smart completions and documentation. It helps developers write code faster by providing relevant snippets and learning from your coding patterns to offer more precise suggestions.

  • OpenAI Codex - https://openai.com/blog/openai-codex/

    OpenAI Codex powers tools like GitHub Copilot. It allows developers to generate working code from natural language prompts and is proficient in multiple languages such as Python, JavaScript, and Go. Codex is useful for automating code generation, debugging, and even refactoring tasks.

  • Amazon CodeWhisperer - https://aws.amazon.com/codewhisperer/

    Amazon CodeWhisperer is an AI-based tool integrated with AWS that suggests relevant code snippets, especially for cloud-based projects. It assists with debugging, providing code suggestions and documentation for services within the AWS ecosystem.

3. Web Design with AI

Learn to Code using AI - ChatGPT Programming Tutorial (Full Course) | FreeCodeCamp.org

While markup languages like HTML, XML, and Markdown are essential for creating and managing digital content, the process of manually writing markup can be tedious and repetitive. It often requires memorizing a vast array of tags and syntax rules, which leaves little room for creative thinking. Designers, however, excel in the realm of creativity, where they can bring a unique vision to life—something that AI, which primarily mimics existing patterns, struggles to replicate.

Web design with AI shifts the focus from the monotonous task of tagging and coding to the more creative aspects of design. AI-powered tools can handle the repetitive and error-prone work of writing markup, allowing designers to concentrate on refining the visual and functional aspects of their projects. These tools leverage machine learning on large datasets of existing markup to provide intelligent autocompletions, suggestions, and error-checking, making the process of coding more efficient and less error-prone.

Some key AI-assisted markup capabilities include:

  • Auto-closing tags
  • Syntax error highlighting
  • Tag/attribute descriptions
  • Previewing rendered output
  • Converting between formats (e.g., Markdown to HTML)
  • Accessible markup recommendations

Designers still need to understand HTML, but with AI taking care of the more mundane aspects, they can devote more time to CSS, where their creative decisions have the most impact. By using AI for tasks like auto-closing tags, syntax error highlighting, and previewing rendered output, designers can focus on what they do best: creating innovative and visually compelling designs. The integration of AI into web design not only enhances productivity but also ensures that the human touch remains at the forefront of the creative process.

4.Server and Site Maintenance

While AI can help significantly during the development stage, its benefits extend to maintenance and operations of live websites/servers as well. Running web applications at scale requires continuous monitoring, updating, provisioning resources, scanning for vulnerabilities, and more.

AI systems can analyze usage patterns, performance data, and make predictions about future traffic demands to automatically scale server capacity as needed. For cloud deployments, AI can recommend optimized instance sizing and resource provisioning.

In the area of cybersecurity, AI models are trained to detect anomalous activity patterns that could indicate hacking attempts, DDoS attacks, and other threats. AI can also automatically scan application codebases and system configurations for known vulnerabilities and compliance issues.

For an idea of how AI an help with site/server maintenance, here a list of just some tools:

By leveraging AI for operations tasks, development teams can ensure their apps remain secure, performant, and cost-optimized without sacrificing engineering cycles.

5. The Future of Programming

Mark Zuckerberg: The future of programming | Lex Fridman Podcast Clips

AI is transforming the landscape of software development, reducing the need for large teams of developers by enabling small, agile groups to accomplish what once required dozens of professionals. With robust AI tools, projects that used to demand 20-50 developers can now be managed by a handful of people, or even a single individual in the case of smaller-scale tasks like building a website. This shift places a greater emphasis on design and writing—skills often nurtured in the arts and humanities—rather than traditional programming expertise.

AI-powered code editors and integrated development environments (IDEs) are now capable of providing real-time suggestions, auto-completions, and refactoring assistance across major programming languages like Python, Java, JavaScript, and C++. These tools analyze the code being written and leverage patterns learned from extensive codebases, making the development process more efficient and reducing the need for extensive coding teams.

For beginners, AI tutoring systems offer personalized learning experiences, using natural language processing to understand and address the specific challenges students face. These systems provide customized hints, examples, and practice exercises, allowing for self-paced learning tailored to individual needs.

As AI continues to evolve, the vision of collaborative human+AI software development is becoming a reality. AI coding assistants are poised to become as commonplace as spellcheckers in writing, acting as ever-present copilots that understand user intent, ask clarifying questions, provide suggestions, and proactively surface relevant information from documentation, prior projects, or forums like StackOverflow.

In web development, AI tools are advancing to the point where a single web designer, equipped with a clear vision and the ability to articulate it in prompts, can build an entire website. These visual AI tools can auto-generate the necessary HTML, CSS, and JavaScript based on the designer’s description, while also optimizing the site for performance, responsiveness, accessibility, and SEO.

AI-driven code reviews and automated testing are becoming standard practices, ensuring that software releases are thoroughly validated before going live. Additionally, AI planning tools can predict project timelines and budgets with greater accuracy by analyzing all relevant project artifacts.

However, as AI becomes more integral to programming, key challenges remain. Reducing ambiguity, ensuring that AI outputs meet requirements, and making these outputs reliable and robust are critical to the success of AI-augmented programming. Ethical considerations, including data privacy, labor impacts, and accountability, must also be addressed.

As AI advances, the distinction between programmers and non-programmers may blur, allowing more people to build software simply by describing their needs to an AI assistant. Yet, human creativity will become increasingly crucial. The demand for creative individuals who can effectively use AI to develop digital publications, tools, and experiences will rise, even as the need for traditional programmers diminishes. Ultimately, human ingenuity will remain essential for pushing the boundaries of innovation and guiding AI systems in meaningful directions.

6. Unit Exercise

Objective: Create a simple website using AI tools to generate HTML and CSS code, while learning about the structure and functionality of the code through iterative development and guided AI comments. The website can be based on previous projects (e.g., an image gallery, world-building site, video, or audio showcase) or on any topic of your choice if no prior projects exist.

1. Plan Your Website:

  • Collaborate with Your Group/Partner: Sketch a simple layout or wireframe for your website. Consider including the following:
    • A header section for the title or branding.
    • A main section with areas for different types of content (e.g., text, images, video, audio).
    • A footer for additional information, such as contact details or links.
    • Optionally, include a navigation bar with anchor links for easy page navigation.
    • Think about whether you want to incorporate JavaScript for animations or special effects.
  • Discuss the Design Vision: Clarify the aesthetic and functional goals of your website. What kind of user experience do you want to create?

2. Set Up Your Project:

  • Create a Project Folder: On your computer, create a new folder to organize your website files. Name it appropriately (e.g., "MyWebsiteProject").
  • Create the Main HTML File: Inside the folder, create a file named index.html. This will serve as the homepage of your website.

3. Generate the Initial Code with AI:

  • Craft a Detailed Prompt: Write a clear and detailed prompt to describe the layout, typography, color scheme, and overall structure you want for your website. Be specific about how you want content to flow on the page and mention that the code should include HTML and CSS.
  • Generate the Code: Use an AI tool to generate the HTML and CSS based on your prompt. The AI will create the basic structure of your website.
  • Understand the Code: As the code is generated, ask the AI to include comments within the code that explain what each section does. This will help you understand how the website is built and what each part of the code achieves.

Example Prompt for the Homepage: "Use HTML5 to code a one-page website with a header, navigation menu, main content area introducing your band, and a footer. In the main content area, include a placeholder for a catchy headline with the band’s name and a short paragraph summarizing the band’s music style and history, followed by a two-column grid with an image placeholder on the left and text on the right."

4. Implement and Test the Code:

  • Copy and Paste the Code: Use a text editor like Sublime Text to paste the AI-generated code into your index.html file.
  • Preview and Troubleshoot: Open the file in a web browser to preview your website. If there are layout issues, use CSS debugging techniques (like adding borders to elements with * { border: 1px solid red; }) to identify and fix problems.

5. Customize and Design the Website:

  • Review the Generated CSS: Look over the AI-generated CSS to understand how it styles your website. Pay attention to the color scheme, typography, spacing, and layout. Identify areas where the design doesn’t align with your vision.
  • Modify the CSS: Start tweaking the CSS to better match your design goals. Adjust the fonts, colors, margins, and padding. Consider adding or changing background images, altering the layout, or refining hover effects. Remember, the AI provides a starting point, but you should shape the final design.
  • Add Custom Styles: Introduce new CSS rules or modify existing ones to make the website uniquely yours. Experiment with creative elements like custom fonts from Google Fonts, transitions, and animations. The goal is to learn by doing—experiment with changes and see how they affect the design.

6. Integrate and Customize Content:

  • Add Text and Media: Replace placeholder text and images with your actual content. Ensure that the text is readable, images are correctly sized, and media (sound and video files) are properly integrated.
  • Style the Website: Adjust the CSS to refine the look and feel of your website. Experiment with different styles to match your design vision.

7. Iterate and Improve:

  • Review the Website: After each round of updates, review the site to ensure consistency in navigation, styling, and content presentation.
  • Make Iterative Changes: Use AI to refine or generate additional sections, adjust layout, or enhance styling based on feedback. Focus on improving the user experience and visual appeal of the site.

8. Deploy Your Website:

  • Prepare for Deployment: Ensure that all files are correctly named (lowercase with no spaces) and organized within your project folder.
  • Upload to the Server: Use an FTP client like Cyberduck to upload your project folder to the server. Test the site online to ensure everything works as expected.
  • Share Your Project: Link the live site in a blog post or share it with your group. Reflect on the process, what you learned, and how AI assisted in the development.

7. Discussion Questions

  • How might AI coding assistants change the skills required for programmers in the future? Will the focus shift more towards problem decomposition and high-level design versus low-level implementation?
  • What are some risks and limitations of over-relying on AI for coding tasks? How can we ensure AI outputs are robust, secure, and faithful to requirements?
  • How could the advent of natural language programming impact computer science education and curricula? Will visual programming tools enabled by AI make textual coding obsolete?
  • What ethical considerations should companies weigh when developing and deploying AI coding technologies? For instance, impacts on programmer jobs/wages, intellectual property concerns, lack of accountability, etc.

8. Bibliography

  • Amershi, Saleema, et al. "Guidelines for Human-AI Interaction." Proceedings of the 2019 CHI Conference on Human Factors in Computing Systems, ACM, 2019, pp. 1-13.
  • Chen, Mark, et al. "Evaluating Large Language Models Trained on Code." arXiv preprint arXiv:2107.03374, 2021. https://arxiv.org/abs/2107.03374.
  • Jain, Shweta, et al. "A Comprehensive Study on the Role of AI and ML in Software Development." Journal of Systems and Software, vol. 182, 2021, p. 111069. https://doi.org/10.1016/j.jss.2021.111069.
  • Omri, Manel, and Mohamed Chiheb Ben Amor. "A Survey on the Applications of AI in Software Engineering." Journal of King Saud University-Computer and Information Sciences, 2021. https://doi.org/10.1016/j.jksuci.2021.01.002.
  • Sadowski, Caitlin, and Thomas Zimmermann. "Rethinking Productivity in Software Engineering." Communications of the ACM, vol. 62, no. 11, 2019, pp. 70-78.
  • Shneiderman, Ben. "Human-Centered AI." ACM Interactions, vol. 26, no. 4, 2019, pp. 76-81.
Dynamic AI Co-Creation: A Human-Centered Approach
by Will Luers | Sept. 2024