Coder Social home page Coder Social logo

sammi-turner / assorted-golang Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 523 KB

Example code, Codewars katas and a compiler for the Monkey programming language.

Go 97.13% HTML 2.71% Monkey 0.16%
codewars-kata-solution monkey-programming-language

assorted-golang's Introduction


Assorted-Golang

Example code, Codewars katas and a compiler for the Monkey programming language.


Installation

Ben Davis has a nice video walk through on how to install Go and set up the path variable


Syntax primer

"Learn X in Y minutes" has a good introduction to Go


To run a single main.go file

go run main.go

To create a go.mod file for a project

go mod init name-of-project

To compile a project that has a go.mod file

go build

To run a project

./name-of-project

To compile and run a project

go build && ./name-of-project

Video course

The FreeCodeCamp YouTube channel has a beginners course to get you started.


AI Code Generation

Large Language Models (LLMs) are only effective for me because I don't trust their output.

I always test the code that they generate!

However, given that Go is a mature language, backed by Google, there is a suprising amount of training data available.


Function Generation With LLMs

I have had good results with prompts using the following template

Write a [name] function in Golang that takes
[name the parameters and their types] and returns
a [type] such that [describe what the function does].
Then show me the code.

Another strategy is to provide the LLM with a list of function signatures for a particular utility or feature and ask the LLM to implement the function bodies, one by one, asking for your feedback at each step.


Example of Program Generation with Chat-GPT4

I asked the LLM to generate a TUI (Text User Interface) todo app using the gorm ORM and sqlite.

In this lengthy conversation with Chat-GPT I was given the basic functionality I needed.


Hacking the context window limit

Although feeding errors back to Chat-GPT4 can yield good results, sometimes a conversation will drag on so long that the LLM "forgets" what you are talking about and the chatbots answers rapidly become useless.

This is because of a fundamental limit built into the LLM. Namely the maximum size of its context window. The size of the context grows as the conversation progresses.

To avoid running up against this limit when you are working on a code generation task, simply delete the chat you are using, start a new one, attach the source code that needs fixing to the chat (the "Advanced Data Analytics" plugin should be enabled), tell the chatbot that there are syntax errors or unexpected behaviour and ask for its help.

This process can be repeated as often as necessary!


assorted-golang's People

Contributors

sammi-turner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.