The Brave New World of AI

44 views
Skip to first unread message

Gilad Bracha

unread,
May 14, 2024, 7:36:44 PMMay 14
to Newspeak Programming Language
Last year, I did some experiments with Newspeak  in Chat GPT.  The results were at once mixed yet impressive. I discussed them in a talk in Lausanne last fall:
https://youtu.be/xsrppIyrrwA%22

Basically, had trouble remembering the syntax, but showed real understanding of the language and its ideas.

With the release of GPT-4o, I decided to give another whirl.  I gave it a PDF of the Newspeak grammar, and a few paragraphs abut Newspeak semantics (really a lot less than I did last time). I also showed it an example of UI code - classes CounterUI and CounterApp. I asked it to explain what these do and it did. Them I asked it write TodoMVC. It produces syntactically valid  Newspeak code. It doesn't know the exact APIs, but came pretty close. Arguably, it hallucinated improvements to the Hopscotch library. Style could be improved (it needs to be told more about factories). 

Here is the code it wrote:

'Root'
class TodoMVCUI usingPlatform: p  = (
  |
  private Subject = p hopscotch Subject.
  private Presenter = p hopscotch Presenter.
  private List = p collections List.
  |
) (
  public class TodoItem = (
    | public title <String> ::= ''. public completed <Boolean> ::= false. |
  ) (
  ) : (
  )

  public class TodoList = (
    | public items <List> ::= List new. |
  ) (
    public addItem: title = (
      items add: (TodoItem new title: title).
    )

    public removeItem: item = (
      items remove: item.
    )

    public toggleItem: item = (
      item completed: item completed not.
    )

    public clearCompleted = (
      items removeAll: [:item | item completed].
    )

    public remainingCount ^ <Integer> = (
      ^items count: [:item | item completed not].
    )
  ) : (
  )

  class TodoListPresenter onSubject: s <TodoListSubject> = Presenter onSubject: s(
  ) (
    definition = (
      ^column: {
        textInput: 'New Todo' onAccept: [:title | subject addItem: title].
        list: {
          subject items do: [:item |
            row: {
              checkbox: item completed action: [subject toggleItem: item].
              label: item title.
              button: 'Remove' action: [subject removeItem: item].
            }
          ].
        }.
        button: 'Clear Completed' action: [subject clearCompleted].
        label: 'Remaining: ', subject remainingCount printString.
      }.
    )
  ) : (
  )

  public class TodoListSubject onModel: m <TodoList> = Subject onModel: m(
  ) (
    createPresenter ^ <TodoListPresenter> = (
      ^TodoListPresenter onSubject: self.
    )
  ) : (
  )
) : (
)

and

'Root'
class TodoMVCApp packageUsing: manifest = (
  |
  private TodoMVCUI = manifest TodoMVCUI.
  |
) (
  public main: platform args: args = (
    | ui = TodoMVCUI usingPlatform: platform. |
    platform hopscotch HopscotchWindow openSubject: (ui TodoListSubject onModel: ui TodoList new).
  )
) : (
)

Looks like it's time to look at integration into the IDE.

Milan Zimmermann

unread,
May 16, 2024, 11:48:05 PMMay 16
to newspeak...@googlegroups.com
Impressive. Especially considering it was given only one sample. I am wondering if you gave it a more detailed description of how the TODOMvc should contain and how to behave (use cases or something like that), or if it figured out a todo application behavior from external sources (etc).

Thanks, 
Milan 


--
You received this message because you are subscribed to the Google Groups "Newspeak Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to newspeaklangua...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/newspeaklanguage/9a011c83-c7b4-49c8-adac-f60eb3f5b7f1n%40googlegroups.com.

Gilad Bracha

unread,
May 16, 2024, 11:53:43 PMMay 16
to newspeak...@googlegroups.com
All it had was CounterUI.ns and CounterApp.ns. Unlike the last time, no explanation of how platforms and imports work. No explanation of Hopscotch at all.  It did miss one thing on the first try - it forgot to import List. I pointed it out and it figured out the rest. I'm not sure how much it has read about Newspeak on the web. But there isn't very much in any case. It designed TodoMVC from scratch, with no guidance.



--
Cheers, Gilad

Milan Zimmermann

unread,
May 19, 2024, 5:42:28 AMMay 19
to newspeak...@googlegroups.com
That is quite amazing. I have now tried to find a Newspeak TODO app on the web, there seems to be only the Newspeak Github TodoMVC. The Chat GPT version does not seem like a direct derivative of the Github version, rather an independently designed code. Probably impossible to guess the innards of "it's process", useful to enviable either way :)



Reply all
Reply to author
Forward
0 new messages