Published: January 19, 2024
Generative AI is the most hyped topic these days.
You'll see a lot of people saying things like: "GenAI is the future". Should we believe them? Or are those ideas better be discarded just like how Metaverse was hyped some years ago?
Programming seems to be a job at danger as it seems like ChatGPT can write code just like any other programmer. E.g. you can see it programming Flappy Bird with the help of a human here.
The truth is that ChatGPT is at its infancy when it comes to coding. And I'd like to higlight that with a recent coding task I gave to ChatGPT:
As a part of effort for another article, I asked ChatGPT to tell me how to determine the device (Desktop, mobile, etc.) of a visitor to my website. And it provided below response to me:
// Detecting device type
function detectDevice() {
const isMobile = /iPhone|iPad|iPod|Android|Windows Phone/i.test(navigator.userAgent);
const isTablet = /iPad|Android|Windows Phone/i.test(navigator.userAgent);
if (isMobile) {
return 'Mobile';
} else if (isTablet) {
return 'Tablet';
} else {
return 'Desktop';
}
}
Average manager looks at this response and think, "Look, GenAI is writing code. This will make our programmers so much more efficient! YAY! "
But if you are visiting my website, then you should be thinking: "Not so easy..." It's not that straightforward.
Why?
The thing is programming languages are much more strict than natural language when it comes to syntax.
E.g. you can greet someone in multiple ways in English:
But there are only limited ways to achieve a desired objective in coding. If you want to write elegant, efficient code, there is usually ONE way. E.g. we call it the "Pythonic" way in Python.
Let's say you want add up 2 variables in Python. You can achieve this only in 2-3 ways in Python
1. Do it on the spot
a+b
2. Create a function for that purpose
def add(a,b):
return a+b
3. Overkill: Create a class
class Numbers:
def __init__(self, a, b):
self.a = a
self.b = b
def add(self):
return self.a + self.b
numbers = Numbers(10, 5)
numbers.add()
There are only 3 ways at most to do addition in Python. However there are 1000 ways to ask ChatGPT add 2 numbers:
Don't add all your eggs in the same basket... Unless you have one stong basket.
Danyel Koca
So what's the issue with the response I got from ChatGPT?
Please take a look at the code provided by ChatGPT for 2-3 minutes and try to identify what's wrong with it.
You don't have to be a seasoned programmer, an average one will see that the conditions for "Mobile" encapsulates those of "Tablet". So there is no way a device will be tagged as Tablet using the code provided by ChatGPT.
This is only the syntax error.
There is more to be said when you look at code. E.g. you can ask whether "Android" and "Windows Phone" qualifies for Tablet. No!
Dumb ChatGPT. At least for now.
If you are a programmer, be at ease my friend, as your job is not going anywhere in the next 5 years.
Guarantee is only for the next 5 years though.
Happy hacking!
Leave comment
Comments
Check out other blog posts
2024/06/19
Create A Simple and Dynamic Tooltip With Svelte and JavaScript
2024/06/17
Create an Interactive Map of Tokyo with JavaScript
2024/06/14
How to Easily Fix Japanese Character Issue in Matplotlib
2024/06/13
Book Review | Talking to Strangers: What We Should Know about the People We Don't Know by Malcolm Gladwell
2024/06/07
Most Commonly Used 3,000 Kanjis in Japanese
2024/06/07
Replace With Regex Using VSCode
2024/06/06
Do Not Use Readable Store in Svelte
2024/06/05
Increase Website Load Speed by Compressing Data with Gzip and Pako
2024/05/31
Find the Word the Mouse is Pointing to on a Webpage with JavaScript
2024/05/29
Create an Interactive Map with Svelte using SVG
2024/05/28
Book Review | Originals: How Non-Conformists Move the World by Adam Grant & Sheryl Sandberg
2024/05/27
How to Algorithmically Solve Sudoku Using Javascript
2024/05/26
How I Increased Traffic to my Website by 10x in a Month
2024/05/24
Life is Like Cycling
2024/05/19
Generate a Complete Sudoku Grid with Backtracking Algorithm in JavaScript
2024/05/16
Why Tailwind is Amazing and How It Makes Web Dev a Breeze
2024/05/15
Generate Sitemap Automatically with Git Hooks Using Python
2024/05/14
Book Review | Range: Why Generalists Triumph in a Specialized World by David Epstein
2024/05/13
What is Svelte and SvelteKit?
2024/05/12
Internationalization with SvelteKit (Multiple Language Support)
2024/05/11
Reduce Svelte Deploy Time With Caching
2024/05/10
Lazy Load Content With Svelte and Intersection Oberver
2024/05/10
Find the Optimal Stock Portfolio with a Genetic Algorithm
2024/05/09
Convert ShapeFile To SVG With Python
2024/05/08
Reactivity In Svelte: Variables, Binding, and Key Function
2024/05/07
Book Review | The Art Of War by Sun Tzu
2024/05/06
Specialists Are Dead. Long Live Generalists!
2024/05/03
Analyze Voter Behavior in Turkish Elections with Python
2024/05/01
Create Turkish Voter Profile Database With Web Scraping
2024/04/30
Make Infinite Scroll With Svelte and Tailwind
2024/04/29
How I Reached Japanese Proficiency In Under A Year
2024/04/25
Use-ready Website Template With Svelte and Tailwind
2024/01/29
Lazy Engineers Make Lousy Products
2024/01/28
On Greatness
2024/01/28
Converting PDF to PNG on a MacBook
2023/12/31
Recapping 2023: Compilation of 24 books read
2023/12/30
Create a Photo Collage with Python PIL
2024/01/09
Detect Device & Browser of Visitors to Your Website