Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In the age of AI, is writing clean code worth it?
- =================================================
- Author:@CodingComputing Word Count: 923
- ---
- Artificial Intelligence (AI) is transforming all walks of life today,
- and the field of software development is also feeling this wave of
- change; AI is now able to assist in writing code. A valued skill in
- software development is to write clean code: code that is easily
- understandable and maintainable. Such developments in AI lead to a
- question, that, if AI assists in writing code, does it make clean code
- obsolete? In this essay, I explore the ways in which AI can help in
- coding, and argue that writing clean code is very much a necessity, in
- spite of AI assisting us in coding.
- Let us take a closer look at some characteristics of AI, and of clean
- code.
- ChatGPT, a recently developed AI system, has demonstrated capabilities
- of producing code, commenting on code, and even explaining the working
- of certain code snippets. Although it is capable of remarkable feats, AI
- is limited in certain respects. The limitations are:
- 1. it does not have real-life experiences,
- 2. it does not have a fundamental understanding of the world. Due to
- these limitations, it can only process its training data, and
- synthesize it as per the input request.
- Clean coding is about understanding and following certain principles,
- that make the code easier to read and maintain. The principles include
- practices such as factoring code appropriately, and using correct
- indentation. Writing clean code takes time, effort, and discipline.
- Developers often shy away writing clean code, and ultimately pay the
- price of dealing with bad code [1].
- The question we are trying to address is: Now that AI can assist in
- writing code, do human developers still need to learn and follow the
- principles of clean code?
- Let us examine in what way AI can assist in writing code. Primarily, AI
- can help with the following tasks, which might raise the question of
- relevance of clean code:
- 1. Producing code from a given prompt
- 2. Explaining what certain pieces of code do
- Let us now explore some objections against clean code that can arise
- from the above points, and address the objections.
- 1) AI can produce code for us
- -----------------------------
- Some might think that if AI can produce code for us, human developers
- need not learn and practice the principles of clean code. However, there
- are two points as counter-arguments to this:
- 1. AI's results are only as good as the training data it gets. It can
- produce low-quality code that has bugs. The code may appear to be all
- right in spite of being wrong [2]. This will make it hard for humans
- to debug and maintain such code. It is a common observation that it
- is harder to debug and maintain code that someone else has written,
- compared to code that you wrote by yourself.
- 2. Programming is a creative process. At a very basic level, a
- programmer has to understand the requirements of a real-world
- problem, and develop a solution based on their understanding of the
- underlying mathematics, algorithms, and domain-specific experience.
- Since AI has no inherent understanding of any of these, it cannot be
- expected to produce programs on novel problems. At best it can mimic
- some solutions from its training data.
- The above two points imply that although AI can produce code, it is
- still not at a stage where it can produce code that is guaranteed to
- work. Therefore, human intervention is required at some stage.
- Coding is about understanding a problem and implementing it in software.
- It will have to continue to be done by humans for some time to come.
- Clean coding remains important as long as humans have to deal with code.
- 2) AI can explain what any code does
- ------------------------------------
- Some others might think that if AI can explain what any piece of code
- does, why should a human bother with writing clean code? Whatever is not
- understood, can be explained by the AI.
- The point to understand here is that AI is fundamentally ignorant of the
- purpose of the program.
- AI can perhaps describe what a piece of code does. However,
- understanding code is not limited to understanding only *what* the code
- does. To really understand the code, it is important to grasp the intent
- of the programmer. It is necessary to understand *why* a programmer
- wrote the code that way. What logic has he implemented?
- In the clean code paradigm, the answers to these questions are
- communicated by means of properly named objects, and by comments. The
- code is written such that it is clear to the reader what the intent of
- the programmer was.
- Therefore, even if AI can explain what any piece of code does, a
- programmer can understand the code better if the code is written well.
- It is essential to understand the logic behind a program. That is what
- helps to effectively debug, test, and maintain the code in question.
- clean code can do that better for us than AI can.
- Conclusion
- ----------
- Clean code communicates the logic of the program, and that is what helps
- understand and maintain the code. AI is, as of now, not able to produce
- perfectly working code, nor is it able to understand the programmer's
- intent. Thus, in spite of the ability of AI to help us with programming,
- it is still essential for developers to learn writing clean code.
- ---
- References
- ----------
- [1] Robert C. Martin, *Clean Code*
- [2] Rodrigo (Twitter:@mathsppblog), *Running Python inside ChatGPT*.
- Online: https://mathspp.com/blog/running-python-inside-chatgpt
Advertisement
Comments
-
- Your essay is spot on regarding A.I. it simply can't do everything. Even though everyone likes to assume it can be used on any subject. I'd prefer human written code.
Add Comment
Please, Sign In to add comment
Advertisement