Зарегистрируйтесь сейчас для лучшей персонализированной цитаты!

I used ChatGPT to write the same routine in these ten obscure programming languages

28 апреля 2023 г Hi-network.com

An instructor at the Boston Latin School uses an IBM 1130 computer to teachFortranto students on October 4, 1968. 

Photo by Underwood Archives/Getty Images

A few weeks ago, I took a look at using ChatGPT to write the same routine in a dozen of the most popular programming languages. But as a programming language geek, I wondered just how far ChatGPT would go. Would it program in a language from the 1950s? Would it program in a language that used its own character set? Could it write code in one of the languages that wrote its code?

Also: The best AI chatbots: ChatGPTandalternatives to try

And so, I dove in. I've used many of the languages I'm spotlighting here, so I'll take a little walk down memory lane and include some stories about my experience with those I've used.

While I haven't run the code itself, I've read through all the generated programs. Most look right, and show the appropriate indicators telling us that the language presented is the language I asked for.

Also: How does ChatGPT work?

I'm telling you this because the headers on all the screenshots are wrong. Most are listed as SQL. For some reason BAL is shown as VBNet, andPrologis listed as Rust. ChatGPT didn't make this error last time, but it made today, for all the languages shown here.

And with that, let's dive in.

Fortran

Fortran (or FORTRAN, as it was depicted back then) stands for Formula Translation. It was developed primarily for scientific and engineering calculations. Even though it dates back to the 1950s, it was often the first language taught to engineering students in the 1970s and 1980s.

Also: This new technology could blow away GPT-4 and everything like it

For me, it was my fourth programming language, after BASIC, PDP-8 assembly language, and PDP-8 binary (yes, I wrote binary code so I could toggle it in on the front panel of an early minicomputer). My Dad generously drove me the hour down to Newark College of Engineering (now NJIT) so I could take their first-year programming course while I was still a sophomore in high school.

Fortran was never a favorite, although it would get most calculation-oriented jobs done. A variation of Fortran is still in use today, but it's pretty limited to specialty scientific work since many other modern languages do Fortran-level analytics, and do it better.

Here, because of the use of theimplicitkeyword, it looks like ChatGPT is depicting code written in the Fortran-77 variant.

Even though the label is wrong, the code is Fortran.

Screenshot by David Gewirtz/

COBOL

I was a teenaged COBOL programmer. I didn't know COBOL at the time, but somewhere around 1980 I saw a want ad for a COBOL programmer at the Northeast Regional Data Center of International Paper in Denville, NJ. It was about 40 minutes from my parents' home, and I needed a summer job. As soon as I managed to schedule an interview, I ran to the local bookstore and spent a weekend chowing down on all the COBOL reading material I could find.

Also: How to use ChatPDF: The AI chatbot that can tell you everything about your PDF

COBOL was meant for business-oriented processing. Today, the same type of customers would be SAP or Salesforce users. But COBOL, as you can see from the COBOL-88 code below, was functional, but it sure wasn't elegant.

As it turns out, they wanted a full-time employee. But since I aced their test (apparently my weekend of study beat out the scores of the professionals who applied), they decided to put me to work for the summer. To say there was a cultural mismatch was an understatement. These were the very early days of microcomputers (think pre-PC) and I gloried in that stuff. Meanwhile, these folks were all about the suits and ties and giant data centers. I almost immediately picked up the nickname "Trouble." Hey, I was still a kid.

The defining moment for me came when one of the more seasoned programmers at the company took me aside to explain, and I quote, "COBOL is life." I took that message to heart and decided that I didn't want my life to be about COBOL. That summer was the last time I programmed anything in COBOL.

Even though the label is wrong, the code is COBOL, probably COBOL-88.

Screenshot by David Gewirtz/

RPG (Report Program Generator)

No, it's not a rocket-propelled grenade or a role-playing game. RPG was a program for creating reports. You can see the evolution in the language (and computer language thinking, in general) between the two versions shown below. RPG II dates back to the late 1950s. RPG IV was updated in the 1990s, and is considerably more modern (but still definitely dated).

I did write a few RPG III programs for the AS/400 as a side gig while in college, but it was never anything I followed all that closely.

Two RPGs, both with incorrect labels.

Screenshot by David Gewirtz/

Lisp

I have a long love affair with Lisp. Lisp, named for LISt Processor, was sometimes described as Lots of Insipid Stupid Parentheses. For some reason, those parentheses clicked in my brain. Lisp was my gateway drug into AI programming, and as we've learned from ChatGPT's processing of language, knowledge can be represented as strings of words, or lists.

Also: ChatGPT's intelligence is zero, but it's a revolution in usefulness, says AI expert

Back in the 1980s, I was a product manager for a RISC-based Common Lisp implementation, and coded in it for a while. Based on thedefun greeting and letsyntax generated by ChatGPT, it looks like the code below is also Common Lisp, a later variation of John McCarthy's original Lisp implementation of the late 1950s. McCarthy was one of the founding fathers of AI research, so it's only fitting that an AI should write in his language.

The label is wrong. That issonot SQL. It's Lisp.

Screenshot by David Gewirtz/

Algol

ALGOL (ALGOthymic Language) was ahead of its time. It allowed the passing of functions as parameters, and allowed the use of recursion. These are two key components of modern programming that were absent from popular languages like Fortran and COBOL, which were popular at the same time of ALGOL's introduction.

If Fortran, BASIC, and assembly language taught me top-down programming, ALGOL taught me how to structure my code. It was a foundational language that set the stage for my use of C, Pascal, Java, JavaScript, and most of the modern structured languages we use today.

No, that's not SQL. It's ALGOL.

Screenshot by David Gewirtz/

Simula

Simula, as you might imagine, was developed for simulation and modeling. Like ALGOL, Simula was also ahead of its time, supporting the use of objects and classes. Object oriented programming has since become fundamental for many of today's most effective programming languages.

The use of the keywordOUTFIXtells me that ChatGPT probably wrote the following code in Simula-67.

Not SQL at all, you're looking at some Simula.

Screenshot by David Gewirtz/

BAL (IBM 360/370 assembly language)

BAL, which stands for "basic assembly language," was the assembly language for big IBM iron back in the 1970s and 1980s. Assembly language is considered more "lower level" than "higher level languages," meaning that individual instructions and keywords map to individual processor instructions. In higher level languages (like most we use today), the language is often far removed from the underlying machine architecture, and is designed more for efficiency of programming than efficient use of hardware.

Also: Generative AI is changing your technology career path. What to know

I took a semester of BAL in college. It was rough. The professor spent most days standing with his back to the students, mumbling his lecture in a monotone, while writing nonstop on the blackboard. I sat in the back row next to a girl named Laura. One day, Laura and I decided to sneak out the back window to get coffee. Once we got our java, we climbed back into the window. The professor never noticed.

It's a wonder any of us passed, but it's no wonder that virtually none of us took up BAL programming as our coding weapon of choice.

This time, the AI gave the code the label VBNET. It's not, of course. It's BAL.

Screenshot by David Gewirtz/

APL

APL, or A Programming Language, is another programming language. One of the most striking aspects of APL is that it uses a non-standard character set for some of its operators and coding. You can see that in the image below. The little glyphs are what ChatGPT was able to pull up from the font it was using, but APL is designed to use the APL385 Unicode font, which is unique to programming in APL.

Also: How to use ChatGPT to write Excel formulas

Because of how it has a concise syntax, and manages large datasets well, it's used in a fair number of scientific, financial, and analytical projects.

It's not SQL. It doesn't even use all ASCII characters. It's APL and it marches to its own drummer.

Screenshot by David Gewirtz/

Prolog

Prolog (which is derived from the phrase Programming in Logic) is another AI-focused language. Prolog is a declarative language, listing rules and conditions, and then running queries over those declarations. According to ChatGPT:

Prolog is one of the programming languages used in the development of ChatGPT, specifically for the generation of text. It is used in the Prolog-to-English module, which translates logical forms in Prolog into natural language sentences.

Prolog is a fun language, but it's not Rust. This is Prolog.

Screenshot by David Gewirtz/

Smalltalk

Smalltalk is special. It was developed at Xerox PARC, the same research lab that influenced the development of the mouse and windowed environments. It incorporated some of Simula's innovations in object-oriented programming and went further. It also was one of the first languages that made active use of a GUI-based interactive programming environment. Many of today's top languages, including Java, Python, and Ruby, were highly influenced by Smalltalk.

Also: Okay, so ChatGPT just debugged my code. For real

I only dabbled in Smalltalk, mostly to get to know it. Living in Silicon Valley at the time, I got to know the designers of Smaltalk, who later spun off ParcPlace Systems, in an attempt to commercialize Smalltalk outside of Xerox's corporate stodginess. I have many fond memories of talking programming theory over ribs and coleslaw at a little run-down barbecue joint in Palo Alto.

One of the VPs I worked with at the computer company where I was employed tried to talk me into starting a company with him to apply Smalltalk to the enterprise market, but I hadn't yet been bitten by the startup bug. Smalltalk never made it as a market. Still, as happy as I am with the path my life has taken, I sometimes wonder what would have happened if I had taken him up on his offer.

And, finally, this too is not SQL. It's Smalltalk.

Screenshot by David Gewirtz/

I have thoughts

I didn't run this code, and since I don't have as much recent familiarity with these languages as I do with with PHP and JavaScript, I can't be sure that my visual review guarantees the code shown above would run successfully. As we saw earlier this week with my exploration of Bard's new programming chops, it's possible to write code without that code working.

Also: I asked ChatGPT to write a WordPress plugin I needed. It did it in less than 5 minutes

We do know there's at least one error in each example: the headers are wrong. So while the ability for the AI to generate code in a bunch of relatively obscure languages is cool beyond belief, don't assume it's doing the entire job correctly.

If you decide to incorporate ChatGPT programming into your workflow, you'll need to check, test, and debug the code it generates just as you would if you hired someone to write some basic routines for you.


You can follow my day-to-day project updates on social media. Be sure to follow me on Twitter at @DavidGewirtz, on Facebook at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz, and on YouTube at YouTube.com/DavidGewirtzTV.

More on AI tools

Android 14's AI-generated wallpapers are super fun. Here's how to create themHow to use ChatGPT to plan a vacationHow to use ChatGPT to create an appHow to get rid of My AI on Snapchat for goodHow to use Bing Image Creator (and why it's better than ever)How to write better ChatGPT prompts for the best generative AI results
  • Android 14's AI-generated wallpapers are super fun. Here's how to create them
  • How to use ChatGPT to plan a vacation
  • How to use ChatGPT to create an app
  • How to get rid of My AI on Snapchat for good
  • How to use Bing Image Creator (and why it's better than ever)
  • How to write better ChatGPT prompts for the best generative AI results

tag-icon Горячие метки: Искусственный интеллект 3. Инновации

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.