PMunch / futhark

Automatic wrapping of C headers in Nim
MIT License
393 stars 21 forks source link

Futharked Gtk #63

Closed StefanSalewski closed 1 year ago

StefanSalewski commented 1 year ago

21:30:49 Still amazed by how nice it is to use Futharked Gtk

Dear Mr. Munch,

can your futhark tool at least partly replace gintro already? I would really be happy if I could remove gintro from Github, but unfortunately I may need it myself, when I should find some motivation to work again on my SDT tool (Some form of a very simple KiCad EDA clone with topological rubberband auto-router). And there may be some other gintro users left.

Have you a collection of working GTK4 examples already? For me, it may be sufficient when at least 80% of the examples in the GTK4 book (https://ssalewski.de/gtkprogramming.html) and of https://github.com/StefanSalewski/gintro/tree/master/examples/gtk3 would work, then I may get some motivation to fix the others myself. I had also considered using another GUI tool, like the one of Can Lehman or treeform. May be some fun, but a lot of work for conversion. The Ruby to Nim conversion took me already about 1000 hours, and when I do conversions again and again, there will never be any real progress. Using again a completely different language like Rust, Crystal, VLang may be some fun too, but again, that would prevent any real progress. The current Nim implementation of my tool is still less powerful than the Ruby implementation from 2013. But dropping Ruby was a good choice, dynamically typing is really a bad thing for larger software, and Ruby performance is really too bad. Finally another question, may your futhark support Blend2d well? I would love to replace Cairo by it. Well, you may say that I can use the Treeform tools, but I have seen no benchmark comparing his tools to Blend2d yet. And I don't even know if he may continue with his tools.

I think I will actually try to continue my EDA tool with Nim for now -- there are other nice languages, but I can currently see no one which is really better than Nim. And when I stay away from the forum, issue tracker and IRC, then my mood may become better. Well, it may take some years, but people like C. Blake, I. Doornekamp, Jason B. and "RingAbout" gave me some hope :-)

Best regards,

Dr. Stefan Salewski

PMunch commented 1 year ago

Well, it can replace it at least partially, but emphasis on the partial bit. The reason why I started wrapping Gtk with Futhark to begin with was mainly just because I couldn't find any bindings which included Webkit2. However Futhark is a plain C-in-Nim tool, so the entire interface is completely C-like. You need to do all the memory management parts, all the casting between different pointer types, all the C string handling stuff, etc. For this reason alone I wouldn't recommend anyone who uses gintro to switch to Futhark'd Gtk.

As for examples I don't have anything. The reason I've done it in the first place was as I said primarily to play around with Webkit2 in Gtk. So the only example I have is my currently closed source project. That being said having perfect C bindings in Nim means that the only work left is to build the high-level interface on top. I did this in my CoAP library, and it is indeed one of the intended ways of using Futhark. Currently I don't have any plans on creating a full high-level Gtk wrapper out of my simple bindings, but as I expand my project I will continue to add more and more convenience wrappers, so who knows, it might end up fairly high-level.

While I haven't tried to wrap Blend2D in Futhark I don't see any reason why it wouldn't be able to wrap it perfectly well and completely automatically. However with the same caveat as above, the bindings are C-in-Nim bindings, and not high-level unless manual work is put in. Unless you don't need the performance of Blend2D I would certainly go with treeforms tool. He is an active member, and using Nim in a work capacity at Reddit, I trust his commitments to his projects.

I'm sad to hear that you've had a rough time in the community. I believe it has improved quite a bit, and with fresh blood in the moderator team, along with the moderator team expanding their work to also include more community-related projects, I think the community should be a better place now more than ever.

PMunch commented 1 year ago

Almost forgot, but if you want to play around with the Futhark Gtk bindings here they are:

{.passL: "`pkg-config gtk+-3.0 glib-2.0 webkit2gtk-4.0 gio-2.0 gtksourceview-4 --libs`".}
when defined(useFuthark) or defined(useFutharkForGtk):
  import futhark
  import strutils

  proc renameCallback(name, kind: string, partOf = ""): string =
    result = name
    if name.startsWith("gtk_"):
      result = name[4..^1]

  importc:
    path "/usr/include/gtksourceview-4/"
    path "/usr/include/webkitgtk-4.0/webkit2"
    path "/usr/include/webkitgtk-4.0/webkitdom"
    path "/usr/include/gtk-3.0"
    path "/usr/include/gio-2.0"
    path "/usr/include/glib-2.0"
    compilerarg "`pkg-config gtk+-3.0 glib-2.0 webkit2gtk-4.0 gio-2.0 gtksourceview-4 --cflags`"
    renameCallback renameCallback
    "gtk/gtk.h"
    "glib.h"
    "gobject/gsignal.h"
    "webkit2/webkit2.h"
    "webkitdom/webkitdom.h"
    "JavaScriptCore/JSValueRef.h"
    "gio/gcontenttype.h"
    "gtksourceview/gtksource.h"
    outputPath currentSourcePath.parentDir / "futhark_gtk.nim"
else:
  include "futhark_gtk.nim"

converter cstringToPtrGchar*(str: cstring): ptr gchar = cast[ptr gchar](str)
converter toWidget*(p: ptr WebkitWebView): ptr GtkWidget = cast[ptr GtkWidget](p)
converter toGboolean*(b: bool): gboolean = b.gboolean

proc widget*(x: any): ptr GtkWidget = cast[ptr GtkWidget](x) # {.importc: "GTK_WIDGET".}
StefanSalewski commented 1 year ago

bindings which included Webkit2.

WebKitGTK is part of gintro since a few years and should work fine. One author of the BaconDingle (base of Nim ARC) paper once asked for it, I spent a few dozen hours to make it, then he vanished back to Python, as he like OOP :-(

StefanSalewski commented 1 year ago

Still works fine for me: https://github.com/StefanSalewski/gintro/blob/master/examples/gtk4/webkitgtk.nim

PMunch commented 1 year ago

Well that's a huge shame. I believe I first started toying around with this in 2021, so maybe it had Webkit2 and I opted to do it this way for some other reason. Honestly don't quite remember, but I think it was some issue or other which prompted me to try it this way.

PMunch commented 1 year ago

I think I just remembered what it was. I was trying to get the size of the WebView so that I could have multiple WebView of short rendered markdown snippets below each other in a list. And when I couldn't get it to work in gintro I tried to do it with Futhark in case there was some problem with the binding (or maybe I was missing some random pieces of the Gtk system which I thought I needed). Ended up not being as easy as I thought and I had to use JavaScriptCore to inject JavaScript to calculate the height of the page and then pass that back to Gtk to resize the WebView.

StefanSalewski commented 1 year ago

You need to do all the memory management parts, all the casting between different pointer types, all the C string handling stuff, etc.

In my personal view, I would prefer coding in plain C than in Nim with such a low level interface. I know well what I am saying, I spent 600 hours totally in 2015 for the oldgtk3 bindings, and then tried to write the NEd tool with it. It was so ugly. And harder as in plain C, as in C all works well, we can copy example code, and GTK C macros work well. As you may know, in the past we discussed hiring someone from the Rust or GTK team to create an alternative to gintro, I offered up to 1k Euro to support that. Hope was to find a few hundred of other supporters, so maybe collect 50k to hire someone. But well, no one is still really interested in GTK, I do understand that partly, GTK is too difficult and ugly. I have seen nearly any new GTK projects on GitHub or elsewhere in the last 10 years, not even in Python or Rust or other languages. GTK4 has not improved the situation unfortunately, traffic on GTK (Gnome) forum is very low, mostly populated by a few plain consumer type people, and Mr. Bassi.

I'm sad to hear that you've had a rough time in the community.

Well, I guess you saw https://forum.nim-lang.org/t/9753#64224 and many more insults in all the years? So all the fumn with Nim is gone, not only for me. But yes, it may become a bit better, that guy was not seen that often in forum and IRC any longer, and Picheta, who killed Disruptek, seems to have finally gone. Unfortunately so many bright and friendly people have left Nim. A few are still available, I prefer communication by private email with them for now and the next years.

For Blend2d, yes I would need the performance. Drawing a PCB board needs performance. I guess Cairo with Nim is OK for a 4k screen with a modern x86 CPU, but for a 8k screens with a cheap (ARM) CPU it may become very slow. Blend2D is a few times faster and supports all cores. For now I will continue with Cairo.

Best regards,

Stefan Salewski

StefanSalewski commented 1 year ago

And when I couldn't get it to work in gintro

Yes, I fully agree that gintro does not work perfectly. That is the reason why I would like to have a fine replacement, so that I can drop gintro. Making GTK bindings is much harder than advertised by GTK unfortunately, I think only the Python and Rust bindings work mostly fine. And the Rust people are much smarter than me, and there are a few of them around.

PMunch commented 1 year ago

And harder as in plain C, as in C all works well, we can copy example code, and GTK C macros work well.

Being able to copy examples is indeed very useful for productivity

As you may know, in the past we discussed hiring someone from the Rust or GTK team to create an alternative to gintro, I offered up to 1k Euro to support that. Hope was to find a few hundred of other supporters, so maybe collect 50k to hire someone.

I was not aware of this, would've pitched in if I were. Gtk is indeed a bit under-used, I guess new and flashy UI toolkits came out and stole its spotlight. Many people I think where also turned off by Gtk3 (I know I was).

Well, I guess you saw https://forum.nim-lang.org/t/9753#64224 and many more insults in all the years?

Yes, it's unfortunate, especially when it's coming from him, not exactly someone we could just ban.. But yeah haven't seen him on IRC in the main room in ages, so you should be "safe" there. I know there are some smaller communities of Nim people on IRC (some of the old timers you mention hang around there), might be of interest to you.

For Blend2d, yes I would need the performance.

Well you can give it a go with Futhark and let me know how it goes. As you can see from the above snippet wrapping Gtk, Webkit, JavaScriptCore, and SourceView it is pretty easy to do. The single header Blend2D shouldn't take more than a couple lines to get working.

Yes, I fully agree that gintro does not work perfectly. That is the reason why I would like to have a fine replacement, so that I can drop gintro.

In this case I think it was actually working fine, I just needed access to some low level parts which weren't wrapped. I believe that you should be able to get a pretty decent high-level wrapper up and running with the above snippet as the basis and then build on top of that. Not entirely sure how the interface with the GC would work though.

StefanSalewski commented 1 year ago

I have already seen your article about wrapping C libraries, thanks. I have also included a link to it into the "Recent blog posts" section, see https://nimprogramming.com/tutorials/all/. Earlier, I already had added futhark to the list of "Notable Projects and Applications" in https://nimprogramming.com/about/all/. GPT-4 initially listed a similar older project, something like Nimterop. But I removed that and a few other old and inactive projects. For reading your article or doing some other Nim related work I have currently not the motivation, sorry. So I guess I will never actually try futhark for Blend2D. Best regards, Stefan Salewski.

StefanSalewski commented 1 year ago

Well, I had a very short look at least.

nimterop uses treesitter

So nimterop was indeed that package. I never tried, I think that guy was called shaslik and also had a toast? Well, it is long ago.

While we can’t attach a destructor to a pointer type, we can attach a destructor to a distinct pointer type.

Have you any reliable info about that? Is it just luck or a design decision? Long time ago someone told me, I think I added it to the book, but did not found it in the manual -- later I dared to ask to be sure: https://forum.nim-lang.org/t/9745#64234

PMunch commented 1 year ago

Thank you for adding Futhark to your list. Nimterop is indeed another similar project although I could never get it to work properly. And yes, it does have the toast program which I believe performs a similar duty to opir. The difference between Futhark and nimterop is that nimterop uses a C/C++ parser, but it still needs to implement the C language semantics on top of that. This is still a hard thing to do. Futhark on the other hand just leverages a full C compiler which is able to tell it what the ABI looks like and which is all the information we actually care about (save for C macros).

As for the destructor on pointer types I'm not 100% whether that's luck or a design decision. It was originally ElegantBeef which brought it to my attention.

StefanSalewski commented 1 year ago

With Futhark I've been able to use a complex library like Gtk with WebKit2 support (which none of the existing wrappers had) in a matter of minutes.

I told you that webkitgtk2 was contained in gintro for years.

And it looks that you had similar issues with c2nim than I in 2016 when I did the oldgtk3 wrapper. I had a lot trouble with all the GTK macros as well, and they just told me that I was too stupid when I dared to ask for help. I totally spent 600 hours for oldgtk3, because I started with v3.12, then updated to 3.16 and finally to 3.20. And because I intended to get beautiful wrapper code, not something with all the types at the front as some others did.

PMunch commented 1 year ago

Oh right, forgot about that. Just remember there was something to do with WebKit2Gtk. But you are right, gintro has wrappers for most of it.

Yeah as I said in that post the documentation for c2nim isn't great, and asking for help for it has been pretty hard.

StefanSalewski commented 1 year ago

I just tested the GPT-4 WebPilot plugin. Seems to work better than the BingWebAccess, which was not able to process your full page. You may fix a few of the typos listed at the end of the GPT report.

Can you analyze websites? ChatGPT

Yes, I can analyze websites to a certain extent. I can extract and summarize information from a website, identify its main topics, and provide an overview of its structure and content. However, please note that my ability to analyze a website is based on the text and information available on the site. I can't evaluate the technical aspects of a website like its SEO, back-end code, or server performance.

If you have a specific website in mind, please provide the URL and specify what kind of analysis or information you're looking for. User Please analyze this website: https://peterme.net/setting-up-a-nim-server-for-dummies.html. Report spelling and grammar errors and other issues. ChatGPT Used WebPilot

The website you've provided is a blog post titled "Setting up a Nim server for dummies" on Peter's DevLog. It's a comprehensive guide on setting up a server for running Nim, a statically typed, imperative programming language that focuses on efficiency, expressiveness, and elegance. The guide covers various aspects including setting up a Linux machine, hardening the server, setting up a reverse proxy and HTTPS, and building the Nim server.

Here are some potential issues and recommendations:

Spelling and Grammar: The text seems to be well-written and I didn't find any glaring spelling or grammar errors. However, there are a few areas where the sentence structure could be improved for clarity. For example, the sentence "If you know what you’re doing in terms of Linux stuff feel free to pick any distro, but if you’re new to Linux I would recommend starting with Ubuntu LTS as that is what all these commands are written for." could be rewritten as "If you're familiar with Linux, feel free to pick any distro. However, if you're new to Linux, I recommend starting with Ubuntu LTS, as all the commands in this guide are written for it."

Technical Accuracy: The guide seems technically accurate, but it's important to note that the accuracy of the instructions can depend on the specific environment or system setup.

Clarity: While the guide is detailed and comprehensive, it could benefit from more explanations or context in some places. For example, it might be helpful to explain why certain steps are necessary or what specific commands do.

Formatting: The guide could benefit from better formatting to make it easier to follow. Using headings to separate different sections, bullet points for steps, and code formatting for commands can improve readability.

Accessibility: The guide assumes a certain level of familiarity with Linux and server management. It could be more accessible to beginners if it included more explanations and resources for learning about these topics.

Links: The guide includes a link to a list of HTTP servers in the Nimble directory. It's important to ensure that all links are relevant and working correctly.

Remember, these are just suggestions and the actual changes needed might vary based on the specific goals and audience of the website. User Please list detailed all grammar and spelling errors. ChatGPT

Upon a more detailed review of the text, here are some potential grammar and spelling issues:

"Nim is a great candidate for server development, but if you want to run your own server and is new to the world of server management or Linux there can be a daunting amount of information to consume in order to do it right."
    Correction: "Nim is a great candidate for server development, but if you want to run your own server and are new to the world of server management or Linux, there can be a daunting amount of information to consume in order to do it right."

"You probably also want to set up a domain name, or sub-domain name for you service."
    Correction: "You probably also want to set up a domain name, or sub-domain name for your service."

"Simply SSH into the server (Linode does this as root, we’ll fix that in a second) and run apt install arno-iptables-firewall answer yes when asked to run the configurator."
    Correction: "Simply SSH into the server (Linode does this as root, we’ll fix that in a second) and run 'apt install arno-iptables-firewall'. Answer 'yes' when asked to run the configurator."

"Now lets create a user for your server and disable login as root."
    Correction: "Now let's create a user for your server and disable login as root."

"If you don’t have that, or have a similar line but with %wheel instead then add it or change the group name to whatever comes after the %."
    Correction: "If you don’t have that, or if you have a similar line but with %wheel instead, then add it or change the group name to whatever comes after the %."

"If you don’t have one you can generate one with the ssh-keygen command (on your normal machine, not on the server)."
    Correction: "If you don’t have one, you can generate one with the ssh-keygen command (on your normal machine, not on the server)."

"If the file was placed somewhere SSH is able to find it (such as ~/.ssh/id_rsa on Linux) you can just run your regular ssh command."
    Correction: "If the file was placed somewhere SSH is able to find it (such as ~/.ssh/id_rsa on Linux), you can just run your regular ssh command."

"After doing this you won’t be able to log in to the server without your private key, so make sure to keep a backup of it somewhere safe!"
    Correction: "After doing this, you won’t be able to log in to the server without your private key, so make sure to keep a backup of it somewhere safe!"

"This runs a check every day at noon to make sure that the certificates are up to date."
    Correction: "This command runs a check every day at noon to make sure that the certificates are up to date."

"Nginx is now set up to only allow HTTPS requests on our domain, and to pass all the requests on to localhost:8080."
    Correction: "Nginx is now set up to allow only HTTPS requests on our domain, and to pass all the requests on to localhost:8080."

Please note that some of these corrections are minor and the original sentences are still understandable. However, these changes can improve the clarity and readability of the text.

StefanSalewski commented 1 year ago

Thanks. Please do not only list the corrections, but explain what is wrong. ChatGPT

Absolutely, here are the explanations for the corrections:

"Nim is a great candidate for server development, but if you want to run your own server and is new to the world of server management or Linux there can be a daunting amount of information to consume in order to do it right."
    Explanation: The verb "is" should be "are" to agree with the subject "you". Also, a comma is needed after "Linux" to separate the two independent clauses.

"You probably also want to set up a domain name, or sub-domain name for you service."
    Explanation: The word "you" should be "your" to correctly indicate possession.

"Simply SSH into the server (Linode does this as root, we’ll fix that in a second) and run apt install arno-iptables-firewall answer yes when asked to run the configurator."
    Explanation: The sentence is a bit confusing. It should be clarified that the user should answer 'yes' when asked to run the configurator.

"Now lets create a user for your server and disable login as root."
    Explanation: "Lets" should be "let's", which is a contraction of "let us".

"If you don’t have that, or have a similar line but with %wheel instead then add it or change the group name to whatever comes after the %."
    Explanation: A comma is needed after "instead" to separate the two independent clauses.

"If you don’t have one you can generate one with the ssh-keygen command (on your normal machine, not on the server)."
    Explanation: A comma is needed after "one" to separate the two independent clauses.

"If the file was placed somewhere SSH is able to find it (such as ~/.ssh/id_rsa on Linux) you can just run your regular ssh command."
    Explanation: A comma is needed after the closing parenthesis to separate the two independent clauses.

"After doing this you won’t be able to log in to the server without your private key, so make sure to keep a backup of it somewhere safe!"
    Explanation: A comma is needed after "this" to separate the two independent clauses.

"This runs a check every day at noon to make sure that the certificates are up to date."
    Explanation: The sentence is a bit vague. It should be clarified that it's the command that runs the check.

"Nginx is now set up to only allow HTTPS requests on our domain, and to pass all the requests on to localhost:8080."
    Explanation: The adverb "only" should be placed before the verb "allow" to correctly indicate that only HTTPS requests are allowed.

These corrections improve the clarity and readability of the text by ensuring proper grammar and punctuation. ChatGPT may produce inaccurate information about people, places, or facts. ChatGPT May 24 Version

Website Analysis Requested

PMunch commented 1 year ago

That's quite impressive actually. And points to that I should probably turn on some kind of spell-check when I write these articles..

I have some changes to the technical stuff from federico as well, so I'll include these when I add those.

StefanSalewski commented 1 year ago

Yes, GPT-4 is great. It can help me a lot as a non-native speaker. I have used LangTool, Quillbot, and Grammarly for the book in the past. They found already a lot, mostly comma errors. From time to time I now ask GPT-4 to point me to some more issues. I have just not enough money available to hire a professional lector or proofreader, and so I can learn some better English.

I have just added your latest blog post to https://nimprogramming.com/tutorials/all/

And here are the GPT comments on your 3 other last posts:

Please list 7 grammar or spelling errors for the following website using WebPilot plugin. Show the correction, and explain what is wrong: https://peterme.net/wrapping-c-libraries-in-nim.html ChatGPT Used WebPilot

I'm sorry, but as an AI language model, I'm not able to directly access websites or their content. However, I can help you identify common grammar and spelling errors if you provide me with a text. Please copy and paste the text you'd like me to check, and I'll do my best to identify any errors. User I asked you to use the WebPilot plugin to access the website. Please try again. ChatGPT

I apologize for the misunderstanding. I have now accessed the content of the website using the WebPilot plugin. However, the plugin does not provide a functionality to automatically detect grammar or spelling errors. I can manually analyze the provided content and identify potential errors. Here's what I found:

Error: "As we discovered in my last article, Nim will by default generate C code and then call on a C compiler to actually produce a binary."
Correction: "As we discovered in my last article, Nim, by default, will generate C code and then call on a C compiler to actually produce a binary."
Explanation: The phrase "by default" should be set off by commas as it is an interrupter in the sentence.

Error: "For example you’re able to run Nim anywhere you can run C, which means you can run it pretty much anywhere."
Correction: "For example, you’re able to run Nim anywhere you can run C, which means you can run it pretty much anywhere."
Explanation: A comma is needed after introductory phrases like "for example".

Error: "This compiles just fine from Nims point of view, and will generate C code which calls the procedure hello with a Nim string object."
Correction: "This compiles just fine from Nim's point of view, and will generate C code which calls the procedure hello with a Nim string object."
Explanation: The possessive form of "Nim" should be "Nim's".

Error: "For example a C procedure which should take an int where the special numbers you are allowed to pass are defined using #define will happily accept an enum with cint sized members."
Correction: "For example, a C procedure, which should take an int where the special numbers you are allowed to pass are defined using #define, will happily accept an enum with cint-sized members."
Explanation: A comma is needed after introductory phrases like "for example". Also, compound adjectives like "cint-sized" should be hyphenated.

Error: "Writing all these definitions by hand might work well if you only have a handful of procedures you need."
Correction: "Writing all these definitions by hand might work well if you only have a handful of procedures that you need."
Explanation: The word "that" is missing after "procedures".

Error: "So instead of writing all these definitions by hand it is a good idea to let the computer do these conversions for us."
Correction: "So, instead of writing all these definitions by hand, it is a good idea to let the computer do these conversions for us."
Explanation: Commas are needed to set off the introductory phrase and the dependent clause.

Error: "After all computers are great at doing repetative tasks with high precision."
Correction: "After all, computers are great at doing repetitive tasks with high precision."
Explanation: A comma is needed after the introductory phrase "After all". Also, "repetative" is a spelling error; the correct spelling is "repetitive".

Please note that these corrections are based on standard English grammar rules. In casual or conversational English, some of these rules may not be strictly followed. User Please list 7 grammar or spelling errors for the following website using WebPilot plugin. Show the correction, and explain what is wrong: https://peterme.net/dynamic-libraries-in-nim.html ChatGPT Used WebPilot

Based on the content provided, here are seven grammar or spelling errors I found:

Error: "This is a question which has been asked in various places over the years, and recently on the forum in multiple separate threads."
Correction: "This is a question that has been asked in various places over the years, and recently on the forum in multiple separate threads."
Explanation: In restrictive clauses, where the clause is essential to the meaning of the sentence, "that" is the appropriate word to use instead of "which".

Error: "First of if we want to use procedures from the program that loads us or let the loading program call any of our procedures the signatures must match exactly."
Correction: "First off, if we want to use procedures from the program that loads us, or let the loading program call any of our procedures, the signatures must match exactly."
Explanation: The correct phrase is "first off", not "first of". Also, commas are needed to separate the independent clauses.

Error: "This means that unlike C you don’t have to worry about calling malloc and free to get and release memory."
Correction: "This means that, unlike C, you don’t have to worry about calling malloc and free to get and release memory."
Explanation: Commas are needed to set off the contrasting phrase "unlike C".

Error: "I would also reccomend to compile with what is going to become the new default in Nim 2.0, namely --gc:orc."
Correction: "I would also recommend compiling with what is going to become the new default in Nim 2.0, namely --gc:orc."
Explanation: "Recommend" should be followed by a gerund (verb+ing), not an infinitive (to+verb). Also, "reccomend" is a spelling error; the correct spelling is "recommend".

Error: "During the last two sections you’ve seen a couple of switches that helps with this problem."
Correction: "During the last two sections, you’ve seen a couple of switches that help with this problem."
Explanation: The verb "help" should agree with its subject "switches", which is plural. Also, a comma is needed after the introductory phrase.

Error: "Every procedure you want to call and which will be made available through the dynamic library has to be labeled with {.importc, dynlib.}"
Correction: "Every procedure that you want to call and that will be made available through the dynamic library has to be labeled with {.importc, dynlib.}"
Explanation: In restrictive clauses, where the clause is essential to the meaning of the sentence, "that" is the appropriate word to use instead of "which".

Error: "And it can be compiled with something a bit like this:"
Correction: "It can be compiled with something a bit like this:"
Explanation: Starting a sentence with "And" is generally considered informal and is not recommended in formal writing.

Please note that these corrections are based on standard English grammar rules. In casual or conversational English, some of these rules may not be strictly followed. User Please list 7 grammar or spelling errors for the following website using WebPilot plugin. Show the correction, and explain what is wrong: https://peterme.net/is-nim-a-transpiler.html ChatGPT Used WebPilot

Based on the content provided, here are seven grammar or spelling errors I found:

Error: "Those who ask the question “is Nim a transpiler?” usually means “as opposed to a compiler”"
Correction: "Those who ask the question “is Nim a transpiler?” usually mean “as opposed to a compiler”"
Explanation: The subject "those" is plural, so the verb "mean" should also be in the plural form.

Error: "But before we get into that, what exactly is a compiler?"
Correction: "But before we get into that, what exactly is a compiler?"
Explanation: This sentence is grammatically correct. However, it could be rephrased for better clarity and flow. For example: "Before we delve into that, let's first define what a compiler is."

Error: "This seems to be the misconception that leads to people asking the question which titles this article."
Correction: "This seems to be the misconception that leads people to ask the question that titles this article."
Explanation: The phrase "leads to people asking" is more appropriately phrased as "leads people to ask".

Error: "By compiling C to assembly you’re essentially using information in the C language to make decisions about what assembly code to generate, discarding the information in the process."
Correction: "By compiling C to assembly, you’re essentially using information in the C language to make decisions about what assembly code to generate, discarding the information in the process."
Explanation: A comma is needed after the introductory phrase "By compiling C to assembly".

Error: "The Nim compiler takes Nim code, and outputs C, C++, Objective-C, or JavaScript code."
Correction: "The Nim compiler takes Nim code and outputs C, C++, Objective-C, or JavaScript code."
Explanation: The comma before "and" is not necessary because the clause after "and" is not an independent clause.

Error: "This is done through templates and macros and is a huge part of what makes Nim so flexible."
Correction: "This is done through templates and macros, and is a huge part of what makes Nim so flexible."
Explanation: A comma is needed before the second "and" to separate the two independent clauses.

Error: "In summary the transpiler word has been quite overused lately."
Correction: "In summary, the word 'transpiler' has been quite overused lately."
Explanation: A comma is needed after the introductory phrase "In summary". Also, the phrase "the transpiler word" should be "the word 'transpiler'".

Please note that these corrections are based on standard English grammar rules. In casual or conversational English, some of these rules may not be strictly followed. User Great work, thanks and goodbye. ChatGPT

You're welcome! I'm glad I could assist you. Don't hesitate to return if you have more questions in the future. Goodbye!

StefanSalewski commented 1 year ago

I have just added a link to your latest blog post to https://nimprogramming.com/tutorials/all/.

I have not read your post yet, but GPT-4 did. I recently learned that I can share links to GPT-4 output, hope you can read it. My feeling is that GPT has become even better in grammar correction in the last few months.

https://chat.openai.com/share/7e9cc804-0888-4d6d-ac9b-bcc328c9cc05

PMunch commented 1 year ago

Oh nice, I can indeed see the output. I will try to get the article updated with the suggestions soon.

And thanks for sharing my articles :)