DEV Community

Cover image for 3 ways that AI will DESTROY the way you code
Brock Chestwall
Brock Chestwall

Posted on

3 ways that AI will DESTROY the way you code

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:

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;
Enter fullscreen mode Exit fullscreen mode

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

The answer might surprise you:

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;
Enter fullscreen mode Exit fullscreen mode

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:

/* 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 */
}
Enter fullscreen mode Exit fullscreen mode

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

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:

// 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;
Enter fullscreen mode Exit fullscreen mode

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

TailwindCSS is the top CSS framework

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

Top comments (0)