Results 1 to 40 of 389

Thread: ChatGPT

Threaded View

  1. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: ChatGPT

    Now I want touch on something else. I know that some people have been testing it on VB6 and VBA and they haven't been getting the same mileage as I have been with VB.Net. Firstly, I am using GPT-4 not the free 3.5 for this. GPT-4 is far better at writing code than the normal free 3.5 version.

    But that's not all, even with GPT-4 I don't expect VBA and VB6 programmers to get as much out of it. After this latest bout I think I understand why now. I've been paying close attention to what it's good at and what it's bad at. VB6 and VBA requires you to be clever, even with simple problems. Modern languages do not require cleverness to solve basic problems. Many simple problems in Python or .Net require a single call to a library function whereas in VB6 it requires a lot more plumbing. What this means is that there is a greater chance for it to get things wrong.

    Let me illustrate what I mean with a very simple example. I gave GPT-4 this query:-
    Write a function that takes a file name and asyncronously reads it. The file is expected to be a text file encoded in UTF-16 BE format. Let the function read the UTF-16 BE contents and return a String of those contents. Make the function as compact as possible.

    Write a version of this function in each of the following languages, VB.Net, C#, Python, and VB6.
    Here is what it gave me:-

    VB.Net:-
    Code:
    Imports System.IO
    Imports System.Text
    
    Async Function ReadFileAsync(fileName As String) As Task(Of String)
        Using reader As New StreamReader(fileName, Encoding.BigEndianUnicode)
            Return Await reader.ReadToEndAsync()
        End Using
    End Function
    C#:-
    Code:
    using System.IO;
    using System.Text;
    using System.Threading.Tasks;
    
    async Task<string> ReadFileAsync(string fileName)
    {
        using var reader = new StreamReader(fileName, Encoding.BigEndianUnicode);
        return await reader.ReadToEndAsync();
    }
    Python:-
    Code:
    import asyncio
    from pathlib import Path
    
    async def read_file_async(file_name: str) -> str:
        async with aiofiles.open(file_name, mode='r', encoding='utf-16-be') as f:
            return await f.read()
    VB6:-
    Code:
    Option Explicit
    
    Dim Stream As New ADODB.Stream
    Dim FileName As String
    Dim FileContents As String
    Dim ChunkSize As Long
    
    Sub ReadFileAsync(ByVal FileName As String)
        Stream.Open
        Stream.Type = adTypeBinary
        Stream.LoadFromFile FileName
        Stream.Position = 0
        
        Stream.Type = adTypeText
        Stream.Charset = "UTF-16BE"
        
        FileContents = ""
        ChunkSize = 2 ' Read 2 bytes at a time (1 UTF-16 character)
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        If Not Stream.EOS Then
            FileContents = FileContents & Stream.ReadText(ChunkSize)
        Else
            Timer1.Enabled = False
            Stream.Close
            MsgBox FileContents
        End If
    End Sub
    In all 3 modern languages, it doesn't have to be clever, it just does what I ask it but look at how it handles the VB6 version. It's trying to be clever by using ADODB Stream objects to read text file and Timers to fake asynchronous behavior. It's not that good at being clever so the chances of it getting something wrong here is much higher.

    Also note it gave me exactly what I asked for in VB.Net, C# and Python but not in VB6. I asked it for a function that returns a String. It didn't know how to accommodate that request while also giving me asynchronous behavior so it settled on using a Sub and giving me the return value through a module level variable.

    Have no fear though, I actually did a fair bit of testing with VB6 and GPT-4 does quite adequately overall but it not going to perform nearly as good as it would writing code for a modern language. Also, I'm fairly certain that by the time GPT-5 comes around, it would be able to handle even the most complex VB6 problems as adequately as any other language..
    Last edited by Niya; Apr 1st, 2023 at 06:07 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width