Some days ago, I asked GPT-4 to create a website for a programming language presentation, and asked a few questions about Nim. Indeed, GPT-4 was able to construct a simple website with HTML, CSS and Nim source code highlight. But I finally decided to use a more professional Hugo theme (doks v0.5) and just fill in the text produced by GPT-4. Its answers seems to be not that bad, but I have read only parts. In the generated FAQ, "Carbon, on the other hand, is a language designed for the Ethereum blockchain." seems to be very wrong. But the other answers are not that bad. Compared to old chatGPT, GPT-4 does not invent information, which is much better. It just said that it knows nothing about the two more recent books, while chatGPT produced a lot of nonsense. For the Manning book, it gave a detailed description, but I am not sure how reliable it is. About 90 percent of the content of the website is generated by GPT-4. I have still to check the code examples they provided. I should also check the links in the tutorial page, maybe some important links are missing. If you have more interesting (tutorial like) links, let me know, I can add them manually. And of course I can also remove links, when you desire. But that page may change, maybe I will remove it again, it was initially intended for a different purpose :-)
Note, the page has a dark mode, see moon symbol on top right.
As of my knowledge cutoff in September 2021, Nim had not reached version 1.0, but it was approaching stability, with version 0.20.2 being the latest release.
That's some dangerous misinformation right here.
We used to have a phrase for that, the phrase was "that's wrong".
But yeah, @Stefan_Salewski you really need to read through everything it says and make sure it's correct. It makes up loads of nonsense. Also make sure all the code it outputs will compile and do what you wanted it to. I once asked for some Nim program and it made up several libraries and procs that simply didn't exist and talked very confidently about them.
Beautiful website by Mr Salewski.
It’s worth noting that 90% of the page content is currently generated by GPT-4, and we haven’t checked it for accuracy yet. Perhaps we should. Alternatively, we could ask GPT to proofread and correct the content itself – maybe that will be possible soon.
Quis perscrutabit ipsos perscrutatores?
The site looks really nice and could be useful to people and generally increase Nim's visibility, if attracts attention.
However, what the world needs today is more of carefully compiled, edited, eloquent and 100% correct information. Anybody with a few bucks to spare can flood the web with a fire-hose of highly-probable junk (or less-probable, without the $).
What's the point? If an LLM was properly used just as a combined "lorem ipsum" generator + a search engine with a natural language interface but then everything went trough thorough editing and verification, is there even a point mentioning the source? It would be an underselling of the human editor's work. The tool is not important in evaluation of the product. If the human dues were not paid, however, I personally wouldn't dare to publish it at all.
Currently the site looks like a kind of an alternative home page, and there's been precedents. Sometimes an official page features only a few hand-picked and approved resources, while the community-driven one is much more inclusive. This site could be the latter, but then it probably needs a blessing and an invitation for the community to engage.
Regarding the link directories: The Iron Triangle for them is: "not short - not outdated - crowdsourced". If it's not a wiki or a git repo or some other collaborative thing, it's doomed.
That's just my opinion and some thought to consider when starting a project like this, I'm not trying to diminish anyone's efforts. It's a free world after all (supposedly).
If it's not a wiki or a git repo or some other collaborative thing, it's doomed.
I completely agree. Otherwise, if you're going to be maintaining it only by yourself, you'll cut off a lot of possible contributions and the ability for it to be kept active after you've lost interest or don't have the time you wish you had.
How does "Computer Programming with the Nim Programming Language" by some dude qualify as a book? It is neither in print nor it does have a PDF/ebook variant, from what I can tell. (While some other resources have those, and are qualified as tutorials)
Also, this:
less developed regions such as Africa and Asia
Makes it quite obvious that the ChatGPT didn't know nor write about that book, AI isn't (not so) subtly xenophobic like some Dr. Dude.
How does "Computer Programming with the Nim Programming Language" by some dude qualify as a book. It is neither in print nor it does have a PDF/ebook variant, from what I can tell.?
Wow so just saving a webpage as a PDF you too can own a book, the future of book making is now! Really though I appreciate the effort to meaninglessly differentiate, if something is nearly 400 pages (freely accessible even) information and considers itself a book... maybe it's a book. Especially in the age that publishing is so democratized anyone can self publish(and I mean anyone).
You are right though we should purposely write obnoxious comments about "some dude" just to illicit a response from them. From my recollection you have been referred to as a 'Community Manager' who is presently saying "dude" at someone cause they had a misunderstanding due to a language barrier. I really do not understand all the hate for Stefan from you lot. Based off Stefan's statements, the common targeted comments is the reason he thought "dude" was a pejorative.
subtly xenophobic like some Dr. Dude
Hehe let's make fun of someone's lack of understanding English colloquialisms such as 'dude', that totally cannot be misconstrued as 'xenophobic'.
As someone that was not here when the strife was formed, but has contributed to many parts of the community perhaps it's very much time to rethink if this disdain is sensible. Given this view it just appears as petulant childish behaviour. We are all adults working on a common goal of getting more Nim programmers through education, interest, and stability.
PS: I will not be engaging with any further argumentative statements so if you want to write a response to me send it to /dev/null
The expression being imprecise can feel offensive.
It's a very common term and usually implies the strength of economy, as measured by GDP. However, the fact is, you'd be hard pressed to find some other general economy criterion by which an average African country, for example, would lead compared to an average European country. That's very unfortunate, but it's just how the things are.
This doesn't change the fact that providing examples in that phrase is totally unnecessary and singling out some places for making an example is an invitation for taking offense. I agree with @dlesnoff, "…will continue to be freely and universally accessible." sounds much better and clear without any additional clarifications.
If impersonal facts are offensive to someone, it's probably their problem, though.
I don't get the Xenophoby lunge above at all.
This Co2 thing maybe ?
Not really. I think they hate me from the beginning, that is spring 2014. Maybe because I said that I would like tabs for indentation. Well they have been unfriendly from the beginning, but not only to me, so I took it not too serious. Then maybe two years ago, just after I donated 500 $ to the Nim project, some serious insults starts. I can and do not to remember details. I had a lot of private discussions in the last 18 months. It' s a fact that Nim is a nice language, I recently tried hard to find a replacement. But Rust or Julia are just not what I really want. And I recently summed all the work that I put into Nim in the last 8 years, all still unpaid:
cat nimwork
oldgtk3 600
gintro >1600
nim book 1000
gtk4 book 300
cdt 500
rtree 350
hull of disks 250
chess 400
ned 250
sdt EDA >1000
600+1600+1000+300+500+350+250+400+250+1000 = 6250 hours.
And then there is still the CAD/EDA project with the topological autorouter, which I started in 2012 in Ruby, and ported to Nim. Works partly not that bad now, I wish I could find some motivation to continue. I think I have not the energy to port to another language again.
To the Co2 thing. Well, I never said that I am always a very friendly guy. But I am not the leader of a community, or part of another organization. So I should be allowed to say what I think. Of course we should always care to not offend other, which can be difficult online, and for a non native speaker.
I was unaware this thread would end up being about the Computer Programming with the Nim Programming Language book, I also didn't make the connection that the author of that book is also this thread's OP. I recommended that book to my friend who I'm trying to get into Nim. I think it's very well written for what it's worth, although I haven't read all of it.
What is this "Co2" thing? I'm missing a lot of context here and am now very confused. Was there some nonsense that happened before regarding this book and OP?
Well, to get back to examining working with GPT4 as a software developer, I recently tried, with gpt3.5 the following prompt. Can you try this in GPT4? I don't have ready access yet.
Hello, I would like to understand and gauge how much AI's are accelerating work in society. For that I would like to use a context I am fairly familiar with, software programming. I would try with several tasks, from very easy to very hard, even tasks that are considered overly ambitious or "impossible" for an independent dev to complete on his own. All these are tasks to build from scratch.
The requirements are as follow:
- if I haven't given the design tell what you intend to do, the purpose and how to achieve it.
- research stage: if similar libraries exist in languages such as Go, C#, python, please examine their api for inspiration and know-how. List their names as well as decisions about their api or their way of solving the problem. It is ok to just port it over.
- using the graphviz dot format, show the dependencies of the final code as you envisage it, showing all the different parts of the project (including usage of external libraries)
- from now on, output code only:
- continue with API and interfaces, as well as the relevant types, formats, and structs (the objects). The first iteration is just the skeleton, maybe with a minimal example that uses this mechanism.
- afterwards, write a few unit tests to verify the API you just wrote.
- then we continue with code. The code should be procedural, elegant and natural, very readable, simple, low cyclomatic complexity. please try to avoid design patterns, lowest reasonable complexity. use high level idiomatic Nim code, with regular Nim conventions for style.
- For performance, simply use the most suitable data structures for the task. Use a fast algorithm if you know one for that task. Use idiomatic code, do not try to overly optimize for performance.
- output the already refactored code.
- bugless code is important.
- act as a critic to make sure there are no security vulnerabilities, bugs or exploits. improve such code before output.
- good parameter names and function names as self documenting. Add comments where necessary.
- do not use exec or run a process, instead we require to either use an available library or write one.
- prefix every line with a line number, (so I can tell you to continue from that line, in case your answer is cut in the middle)
That's it.
The code will be in the Nim programming language.
If you understand write OK and I will give you the next harder task in this made-up exam
Here is a sample output (this is with chatgpt), note that you can write specific details about the app or lib in question. In any case, it helps to get a roadmap of tasks going.
me: A winzip clone
Sure, here's what I intend to do:
Purpose: The purpose of this task is to build a WinZip clone in Nim that can compress and decompress files and folders.
How to achieve it: To achieve this, we will use the zlib compression library, which is a popular and widely used compression library available in Nim. We will create a command-line interface for the user to interact with, where they can specify the files/folders to compress/decompress, and the output location of the compressed/decompressed file.
Research: We will use the "zlib" library in Nim for compressing and decompressing files. We will also use the "commander" library in Nim for creating a command-line interface.
Dependencies:
zlib.nim (compression library)
commander.nim (command-line interface library)
(1-2) We will be using these libraries in our code to implement the compression and decompression functionalities as well as the command-line interface.
API and Interfaces:
compressFile(srcFile: string, dstFile: string): void
This function will compress a single file specified by srcFile and save the compressed output to the file specified by dstFile.
compressFolder(srcFolder: string, dstFile: string): void
This function will compress all the files in a folder specified by srcFolder and save the compressed output to the file specified by dstFile.
decompressFile(srcFile: string, dstFolder: string): void
This function will decompress a single file specified by srcFile and save the decompressed output to the folder specified by dstFolder.
decompressFolder(srcFile: string, dstFolder: string): void
This function will decompress all the files in a folder specified by srcFile and save the decompressed output to the folder specified by dstFolder.
Unit Tests:
compressFile():
Test that a valid source file is compressed and the output is saved to the destination file.
Test that an invalid source file raises an error.
compressFolder():
Test that all valid source files in a folder are compressed and the output is saved to the destination file.
Test that an invalid source folder raises an error.
decompressFile():
Test that a valid compressed file is decompressed and the output is saved to the destination folder.
Test that an invalid compressed file raises an error.
decompressFolder():
Test that all valid compressed files in a folder are decompressed and the output is saved to the destination folder.
Test that an invalid compressed folder raises an error.
Procedural code:
1. import zlib
2. import commander
3. proc compressFile(srcFile: string, dstFile: string) =
4. # Use zlib library to compress srcFile and save the output to dstFile
5. proc compressFolder(srcFolder: string, dstFile: string) =
6. # Use zlib library to compress all files in srcFolder and save the output to dstFile
7. proc decompressFile(srcFile: string, dstFolder: string) =
8. # Use zlib library to decompress srcFile and save the output to dstFolder
9. proc decompressFolder(srcFile: string, dstFolder: string) =
10. # Use zlib library to decompress all files in srcFolder and
---- response was cut off
me: continue from line 10
Sure, here's the code for the WinZip clone with the compression functionality implemented:
import zstd
type
CompressionAlgorithm = enum
lz4, gzip, zstd
proc compress(input: string, algorithm: CompressionAlgorithm): string =
case algorithm of
CompressionAlgorithm.lz4:
# TODO: Implement LZ4 compression
CompressionAlgorithm.gzip:
# TODO: Implement Gzip compression
CompressionAlgorithm.zstd:
return zstd.compressString(input)
proc decompress(input: string, algorithm: CompressionAlgorithm): string =
case algorithm of
CompressionAlgorithm.lz4:
# TODO: Implement LZ4 decompression
CompressionAlgorithm.gzip:
# TODO: Implement Gzip decompression
CompressionAlgorithm.zstd:
return zstd.decompressString(input)
proc main() =
# Example usage
let input = "Hello, world!"
let compressed = compress(input, CompressionAlgorithm.zstd)
echo "Compressed: ", compressed.len, " bytes"
let decompressed = decompress(compressed, CompressionAlgorithm.zstd)
assert input == decompressed, "Decompression failed"
main()
This code defines a CompressionAlgorithm enumeration with the possible compression algorithms: lz4, gzip, and zstd. The compress procedure takes an input string and a compression algorithm and returns the compressed string using the selected algorithm. For lz4 and gzip, the implementation is still pending (marked with # TODO). The zstd implementation is provided using the zstd library.
The decompress procedure takes a compressed string and a compression algorithm and returns the decompressed string. Again, the implementation is still pending for lz4 and gzip.
The main procedure demonstrates example usage by compressing a string using zstd, printing the size of the compressed data, decompressing the data, and verifying that the decompressed data matches the original input.
Note that the code is just a skeleton and requires further testing and refactoring to ensure bug-free and efficient code.
me: If we want this to be a gui program, what options do we have in Nim?
Nim has several options for creating GUI programs. Here are some of the most popular ones:
NimQT - a binding for the Qt GUI framework.
Nimx - a widget toolkit for creating GUIs.
GTK+ bindings for Nim - a binding for the GTK+ GUI toolkit.
Nimgl - a binding for the OpenGL graphics API.
Nuklear - a small, efficient, immediate-mode UI library.
WxWidgets bindings for Nim - a binding for the cross-platform GUI toolkit.
Electron-nim - a Nim wrapper for Electron, which allows you to create desktop applications using web technologies.
You can choose the one that best fits your needs and experience with GUI programming.
me: show me an example winzip graphics interface (for just one window) with the nuklear library
Sure, here's an example GUI program using the Nuklear library for a single window WinZip-like interface:
import nuklear
proc main() =
# Initialize Nuklear context
var ctx = initNuklear()
# Define window properties
const WIN_WIDTH = 640
const WIN_HEIGHT = 480
const WIN_FLAGS = nk_window_flags.NK_WINDOW_BORDER or nk_window_flags.NK_WINDOW_MOVABLE or nk_window_flags.NK_WINDOW_CLOSABLE or nk_window_flags.NK_WINDOW_TITLE
# Start GUI loop
while true:
# Poll events and update GUI
nk_input_begin(ctx)
while true:
event = pollEvent()
break if event.type == nk_evt_type.NK_NONE
handleEvent(ctx, event)
nk_input_end(ctx)
# Begin GUI layout
if nk_begin(ctx, "WinZip", nk_rect(100, 100, WIN_WIDTH, WIN_HEIGHT), WIN_FLAGS):
nk_layout_row_dynamic(ctx, 30, 2)
if nk_button_label(ctx, "Compress"):
# TODO: Handle compression
echo "Compression button pressed"
if nk_button_label(ctx, "Decompress"):
# TODO: Handle decompression
echo "Decompression button pressed"
# End GUI layout
nk_end(ctx)
# Render GUI
nk_render(ctx)
# Shutdown Nuklear context
shutdownNuklear(ctx)
when isMainModule:
main()
This example creates a single window with two buttons for compression and decompression. When the buttons are pressed, the program will output a message to the console. You can replace the echo statements with the appropriate compression and decompression code using the functions we defined earlier.I also agree with @Zoom. Using LLMs to generate documentation is fine assuming one proofreads, edits, and validates. Which means you are just using it as a fancy writing aid instead of relying on it being right. Especially given I have seen multiple people act like LLMs are gospel and ask questions like "Why did ChatGPT generate incorrect code?" or "Did this work in a previous version?". It is best to avoid publishing any generated content without this barrier as it is actively distributing misinformation.
If anything though this website Stefan has put together does demonstrate that it would be nice to expand the official FAQ and have it easily accessible on the website. For instance @DemoTomohiro's https://internet-of-tomohiro.netlify.app/nim/faq.en.html is quite fantastic as it's easily searchable for common issues.
one last note, some people have gone much further. If you're interested, you can read here:
https://lukebechtel.com/blog/gpt4-generating-code
I think the potential is skyrocketing, and the implications of how it might change society are worrying to say the least. I am unsure what to think about all this, it's thought provoking for sure, and it is certainly interesting to follow and see if it leads to good or bad.
How does "Computer Programming with the Nim Programming Language" by some dude qualify as a book? It is neither in print nor it does have a PDF/ebook variant, from what I can tell. (While some other resources have those, and are qualified as tutorials)
That some dude earned themselves a PHD and just because you don't understand how books and publishing books works, doesn't make their work any less impressive of valuable. Plenty of books go unpublished and just because he hasn't produced it in some electronic format you would prefer, doesn't disqualify it from being considered a book.
I don't understand why Stefan gets continuously shitted on in these forums. Those in positions of leadership in this community definitely should not be the ones doing the shitting on of anyone, or replying to people in this way - regardless of their accomplishments. Stefan is contributing his time and energy, free of charge, to enabling new Nim users - why is this a bad thing? Maybe you're just jealous?
Also, this:
less developed regions such as Africa and Asia
Makes it quite obvious that the ChatGPT didn't know nor write about that book: AI isn't (not so) subtly xenophobic like some Dr. Dude.
Is this even debatable? You're going to tell me that Africa and Asia are as developed as the Global North? How is anything about that sentence xenophobic?