Groups | Search | Server Info | Login | Register
Groups > comp.os.linux.misc > #75503
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: AI-Based Coding Taking Over |
| Date | 2025-09-30 23:05 +0000 |
| Organization | Stefan Ram |
| Message-ID | <supervisor-20250930235728@ram.dialup.fu-berlin.de> (permalink) |
| References | <B7Scncrt7okKxUb1nZ2dnZfqn_adnZ2d@giganews.com> <utdsqlx4ta.ln2@Telcontar.valinor> <translation-20250930151915@ram.dialup.fu-berlin.de> <10bhmfu$3vti3$5@dont-email.me> |
Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> wrote or quoted:
>Seems like AIs are just as bad at reading documentation as many human
>programmers ...
That might be why a human supervisor is still needed.
Adding checks for error codes at each and every place has some
drawbacks, like cluttering up the code. Sometimes it matters,
sometimes not. A subordinate programmer or chatbot cannot
know whether it matters /for you/ in the current project.
You have to tell him! That's why humans are still needed to
communicate what actually to do and then verify it was done
just like supervisors in any organisation.
|The hardest single part of building a software system is
|deciding precisely what to build. No other part of the
|conceptual work is so difficult as establishing the detailed
|technical requirements . . . No other part of the work so
|cripples the resulting system if done wrong. No other part is
|more difficult to rectify later.
Brooks, F.P. Jr., The Mythical Man-Month: Essays on Software
Engineering, Addison Wesley, Reading, MA, 1995, Second Edition.
Me,
Please write a file copy program in C. Sunshine path only,
assuming everything will work alright.
, chatbot,
#include <stdio.h>
int main() {
char srcFile[100], destFile[100];
FILE *src, *dest;
int ch;
printf("Enter source file name: ");
scanf("%s", srcFile);
printf("Enter destination file name: ");
scanf("%s", destFile);
src = fopen(srcFile, "r");
dest = fopen(destFile, "w");
while ((ch = fgetc(src)) != EOF) {
fputc(ch, dest);
}
fclose(src);
fclose(dest);
printf("File copied successfully.\n");
return 0;
}
, me,
Now please rewrite it painstakingly checking each and every
thing for what could go wrong.
, chatbot,
. . .
, me,
Please even the `printf`s!
, chatbot,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define MAX_PATH_LEN 260
#define BUFFER_SIZE 4096
// Safe printf wrapper: returns 0 on success, -1 on error
int safe_printf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
if (vprintf(fmt, args) < 0) {
va_end(args);
fprintf(stderr, "Error writing to stdout: %s\n", strerror(errno));
return -1;
}
va_end(args);
// Always flush printf output and check
if (fflush(stdout) != 0) {
fprintf(stderr, "Error flushing stdout: %s\n", strerror(errno));
return -1;
}
return 0;
}
int main() {
char srcFile[MAX_PATH_LEN], destFile[MAX_PATH_LEN];
FILE *src = NULL, *dest = NULL;
size_t bytesRead, bytesWritten;
unsigned char buffer[BUFFER_SIZE];
if (safe_printf("Enter source file name: ") < 0) {
return EXIT_FAILURE;
}
if (scanf("%259s", srcFile) != 1) {
fprintf(stderr, "Failed to read source file name.\n");
return EXIT_FAILURE;
}
if (safe_printf("Enter destination file name: ") < 0) {
return EXIT_FAILURE;
}
if (scanf("%259s", destFile) != 1) {
fprintf(stderr, "Failed to read destination file name.\n");
return EXIT_FAILURE;
}
if (strcmp(srcFile, destFile) == 0) {
fprintf(stderr, "Source and destination file names must be different.\n");
return EXIT_FAILURE;
}
src = fopen(srcFile, "rb");
if (src == NULL) {
fprintf(stderr, "Error opening source file '%s': %s\n", srcFile, strerror(errno));
return EXIT_FAILURE;
}
dest = fopen(destFile, "wb");
if (dest == NULL) {
fprintf(stderr, "Error opening destination file '%s': %s\n", destFile, strerror(errno));
fclose(src);
return EXIT_FAILURE;
}
while ((bytesRead = fread(buffer, 1, BUFFER_SIZE, src)) > 0) {
bytesWritten = fwrite(buffer, 1, bytesRead, dest);
if (bytesWritten < bytesRead) {
fprintf(stderr, "Error writing to destination file '%s': %s\n", destFile, strerror(errno));
fclose(src);
fclose(dest);
return EXIT_FAILURE;
}
}
if (ferror(src)) {
fprintf(stderr, "Error reading source file '%s': %s\n", srcFile, strerror(errno));
fclose(src);
fclose(dest);
return EXIT_FAILURE;
}
if (fclose(src) != 0) {
fprintf(stderr, "Error closing source file '%s': %s\n", srcFile, strerror(errno));
fclose(dest);
return EXIT_FAILURE;
}
if (fclose(dest) != 0) {
fprintf(stderr, "Error closing destination file '%s': %s\n", destFile, strerror(errno));
return EXIT_FAILURE;
}
if (safe_printf("File copied successfully from '%s' to '%s'.\n", srcFile, destFile) < 0) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
The "fprintf(stderr,"s are still not checked, but if they
would be checked and fail, the control would go to "return
EXIT_FAILURE", but it /is/ already on this path in these cases.
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar
AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-09-30 00:12 -0400
Re: AI-Based Coding Taking Over "Carlos E.R." <robin_listas@es.invalid> - 2025-09-30 09:37 +0200
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-09-30 14:25 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-09-30 14:32 +0000
Re: AI-Based Coding Taking Over "Carlos E.R." <robin_listas@es.invalid> - 2025-09-30 19:21 +0200
Re: AI-Based Coding Taking Over Richard Kettlewell <invalid@invalid.invalid> - 2025-09-30 19:35 +0100
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-09-30 22:45 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-09-30 22:41 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-09-30 22:44 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-09-30 23:05 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-09-30 23:46 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-01 00:10 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-01 00:56 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-01 01:06 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-01 01:05 +0000
Re: AI-Based Coding Taking Over Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2025-10-01 03:53 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-01 04:57 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 21:41 -0400
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 21:40 -0400
Re: AI-Based Coding Taking Over candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> - 2025-10-10 18:00 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-11 02:41 -0400
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-10-11 11:00 +0100
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-11 19:39 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-11 22:31 -0400
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-10-12 12:09 +0100
Re: AI-Based Coding Taking Over rbowman <bowman@montana.com> - 2025-10-11 19:03 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-11 22:28 -0400
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-10-12 12:04 +0100
Re: AI-Based Coding Taking Over Richard Kettlewell <invalid@invalid.invalid> - 2025-10-01 18:11 +0100
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-01 17:21 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-01 21:06 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-01 21:28 +0000
Re: AI-Based Coding Taking Over Richard Kettlewell <invalid@invalid.invalid> - 2025-10-03 08:54 +0100
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-10-03 10:02 +0100
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-03 20:41 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 23:24 -0400
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 23:21 -0400
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 23:20 -0400
Re: AI-Based Coding Taking Over Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2025-10-04 17:04 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-01 22:33 +0000
Re: AI-Based Coding Taking Over Nuno Silva <nunojsilva@invalid.invalid> - 2025-10-01 23:45 +0100
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 22:19 -0400
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-10-02 11:15 +0100
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 21:59 -0400
Re: AI-Based Coding Taking Over vallor <vallor@vallor.earth> - 2025-10-02 06:20 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-02 03:05 -0400
Re: AI-Based Coding Taking Over vallor <vallor@vallor.earth> - 2025-10-02 18:41 +0000
Re: AI-Based Coding Taking Over rbowman <bowman@montana.com> - 2025-10-02 07:26 +0000
Re: AI-Based Coding Taking Over vallor <vallor@vallor.earth> - 2025-10-02 18:37 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 00:29 -0400
Re: AI-Based Coding Taking Over rbowman <bowman@montana.com> - 2025-10-03 05:06 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 01:24 -0400
Re: AI-Based Coding Taking Over Bob Vloon <usenet@bananacorp.nl.invalid> - 2025-10-03 11:33 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-03 20:46 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 00:25 -0400
Re: AI-Based Coding Taking Over rbowman <bowman@montana.com> - 2025-10-03 04:44 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 01:18 -0400
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-03 11:38 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-03 20:42 +0000
Re: AI-Based Coding Taking Over ram@zedat.fu-berlin.de (Stefan Ram) - 2025-10-03 20:59 +0000
Re: AI-Based Coding Taking Over Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-03 21:05 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 23:37 -0400
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-03 23:35 -0400
Re: AI-Based Coding Taking Over not@telling.you.invalid (Computer Nerd Kev) - 2025-10-03 08:03 +1000
Re: AI-Based Coding Taking Over vallor <vallor@vallor.earth> - 2025-10-02 22:55 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-09-30 22:06 -0400
Re: AI-Based Coding Taking Over Jason H <jason_hindle@yahoo.com> - 2025-10-01 20:26 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 21:58 -0400
Re: AI-Based Coding Taking Over Farley Flud <fsquared@fsquared.linux> - 2025-09-30 11:25 +0000
Re: AI-Based Coding Taking Over The Natural Philosopher <tnp@invalid.invalid> - 2025-09-30 12:56 +0100
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-09-30 22:48 -0400
Re: AI-Based Coding Taking Over Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2025-10-01 03:53 +0000
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-10-01 21:36 -0400
Re: AI-Based Coding Taking Over c186282 <c186282@nnada.net> - 2025-09-30 22:16 -0400
csiph-web