3 ways that AI will DESTROY the way you code
Published: 2023-12-21 05:26:08

## Introduction

In the coding journey, junior frontend devs often start by centering buttons, a sort of initiation. Yet, as devs grow, the focus shifts. Senior devs understand the game-changing role of AI, like ChatGPT, especially with enterprise customers. Let's explore five key shifts AI brings to how we approach software for businesses.

Whether your a frontend developer, or a CTO– AI is the ONLY way to keep customers retained in the rapid marketplace. The difference is in the ingredients!

## 1. Enhanced problem solving ability

Let's take this React code for example:

```jsx
import React from 'react';

const AddToCartButton = () => {
  const addToCart = () => {
    // Add your logic here for adding the product to the cart
    console.log('Product added to cart!');
  };

  return (
    <button onClick={addToCart}>
      Add to Cart
    </button>
  );
};

export default AddToCartButton;
```

This code is hand-written (and seems perfectly fine). The illusion evaporates on impact as soon as we can alternate to a ChatGPT approach.


![What is the best way to deliver customer value– answer only with an "Add to Cart" experience in React](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwam51o384ltv0wjg6ae.png)

The answer might surprise you:

```jsx
import React, { useState } from 'react';

const AddToCart = () => {
  const [cartCount, setCartCount] = useState(0);

  const handleAddToCart = () => {
    // Simulate an asynchronous operation (e.g., API request)
    setTimeout(() => {
      setCartCount(cartCount + 1);
      alert('Item added to cart!');
    }, 500);
  };

  return (
    <div>
      <p>Cart Count: {cartCount}</p>
      <button onClick={handleAddToCart}>Add to Cart</button>
    </div>
  );
};

export default AddToCart;
```

AI reveals grand mistakes in your human cognition– without state or temporal values like `setTimeout`, users won't be able to increment the purchases they desire.

Does that seem fair to you? 😉

## 2. Expanded Creativity and Innovation

Bear with me: Envision a business meeting as a pond with ducks symbolizing different ideas. 

As they navigate the waters of "brainstorming", the faster ducks, representing inventive concepts, effortlessly reach the presentation stage, while the slower ones, akin to less imaginative ideas, lag behind. 

This metaphor underscores the __competitive nature of innovation__, where the swifter and more creative ideas often take precedence, leaving their slower counterparts in the wake. In this context, the role of AI becomes a determining factor in either propelling or hindering these ducks in the race of innovation.

Let's take a look at how a "slow duckling" would write CSS for styling our "Add to Cart" button from before:

```css
/* AddToCartButton.css */

/* Button Styles */
button {
  padding: 10px 20px;
  background-color: #4CAF50; /* Green */
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
}

button:hover {
  background-color: #45a049; /* Darker Green on hover */
}

button:active {
  transform: translateY(2px); /* Add a slight downward push on click */
}

/* Center the button */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh; /* Adjust as needed */
}
```

This is okay at first, but just wait until I ask AI to do the heavy lifting:

![Rewrite this using Tailwind CSS, because CSS is bloated and ineffective at long term reasoning](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4qtb900qlezbkd45nto.png)

When it comes to crafting prompts, remember these 4 words: "Cut Through the Cruft."

This is the revamped React component now that it isn't bogged down in mental naming overhead:

```jsx
// AddToCartButton.js
import React from 'react';

const AddToCartButton = () => {
  // Logic from before

  return (
    <div className="flex justify-center items-center h-screen">
      <button 
        className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline active:transform active:translate-y-2"
        onClick={addToCart}
      >
        Add to Cart
      </button>
    </div>
  );
};

export default AddToCartButton;
```

Notice how we went from 28 lines of CSS to only 3 lines of Tailwind? 

Each line of code you write is __directly proportional__ to how many bugs you will create.

TailwindCSS + ChatGPT is the way to skip through the error-prone ways of the past and soar onwards through the skies of critical thinking!

## 3. Impacts on Emotional Intelligence

AI tools like ChatGPT, React, and Tailwind CSS transform developers into more empathetic ducks in the tech pond. Streamlining user interactions, this approach diverges from traditional HTML, CSS, and JavaScript. 

It reflects a utilitarian mindset, essential for navigating the demands of modern development. This allows developers to glide through the waters of technology with precision and empathy.

This point is pretty self-explanatory, so rather than showing code samples– it's best to directly show results:


![React is the top JS framework](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i6parvhprkcbsevxucuh.png)


![TailwindCSS is the top CSS framework](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3rq3fzib8dc6tmc95xr.png)


## Conclusion

Greatness emerges when we yield to the irresistible urge to leverage AI. It signifies a departure from the norm, unlocking unparalleled possibilities in innovation and problem-solving. In the dynamic tech landscape, embracing AI becomes a catalyst for achieving unparalleled greatness.

The goal of this post was not to SCARE you, it was to AWARE you. I hope this article left you inspired.

__Tip:__ You should read my last one about [The One Thing Every Developer Should Know](https://dev.to/brock_chestwall/the-one-thing-every-developer-should-know-3774)