Hacker News new | past | comments | ask | show | jobs | submit login

Very interesting. A couple of notes here on the C# version.

Its using the old format where the Program.cs file has an actual class, whereas as of .NET 6 thats not required.

You said barebones, but for any real server you would want to use the generic host https://learn.microsoft.com/en-us/dotnet/core/extensions/gen... which gets you a lot of the boilerplate and enables you program to be wrapped in a windows or systemd service.

Finally, parsing can be simplified since ASCII is a proper subset of UTF-8, you can just parse the entire string as UTF-8. IMHO I am disappointed that the AI didn't point that out.




This is a perfect example of the llm producing an answer that a novice finds useful and an expert takes issue with.


> You said barebones, but for any real server you would want to use the generic host

True, I intentionally said barebones as I wanted a minimal example. I asked it to modify the code to use the generic host, and updated the chat link (so refresh). Keep in mind this is the free ChatGPT, but I still think it did reasonably good. The example compiles as-is, and is very close to functional. I've not used the generic host stuff before either, so again this would save me time searching and piecing together code.

> Finally, parsing can be simplified since ASCII is a proper subset of UTF-8, you can just parse the entire string as UTF-8.

I don't think that would work, because the free-form text message part at the end must contain a BOM if it's UTF-8 encoded, according to the specification. AFAIK you can't have the BOM in the middle of a string.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: