Hi, CVu is the member magazine for ACCU members – you have to be a member to read it. It is published every other month. In each issue there is a Code Critique. The submissions for the previous Code Critique are presented, analysed by the setter and a book prize given to the winner. The next Code Critique is announced. In the distant past, Code Critiques were all C++ codes, and often dealing with nasty dark corners. I often take it upon myself to totally ignore the C++ (usually because the code is horrible and used in an area where C++ should never be used, e.g. string manipulation) and submit Python and D solutions. In more recent past there have been C++ ones, but also some Python and Java ones. Also fairly recently, the Code Critiques have been published as the publication goes to press on the ACCU General, i.e. a public mailing list, not the member mailing list.
I believe we have a first, Code Critique 112 is a D code. And indeed a vibe.d one. I believe a number of people from this email list should volunteer themselves to do a constructive critique to help educate ACCU members. With the obvious subtext of D being a far, far better language than C++ ;-) Below is the email from accu-general ------------------------------------------------------------------- Code Critique 112 Hello all, Below is the code for Code Critique number 112 As usual, please don't reply to the list with your entry but email [email protected] for collation. ------------------------------------------------------------------------ (Submissions to [email protected] by August 1st) Further to articles introducing D, I am attempting to use the event-driven Vibe.d server library, which I understand to be like a native version of Python's Tornado and potentially a “killer app” of D as I haven't seen any other mature event-driven server library in a compiled language. I would like to build a back-end server that performs some processing on the body of the HTTP request it receives. To begin with, I would like it to simply echo the request body back to the client. My code works but there are three problems: (1) when I issue a POST request with lynx, 3 spaces are added to the start of the response text, (2) I cannot test with nc because it just says 404 and doesn't log anything, and (3) I'm worried that reading and writing just one byte at a time is inefficient, but I can't see how else to do it: I raised a "more documentation needed" bug at https://github.com/vibe-d/vibe.d/issues/2139 but at the time of writing nobody has replied (should I have used a different forum?) --- code --- import vibe.d; void main() { auto settings = new HTTPServerSettings; settings.port = 8080; listenHTTP(settings, (req, res) { ubyte[1] s; while(!req.bodyReader.empty()) { req.bodyReader.read(s); res.bodyWriter.write(s); } }); runApplication(); } -- Russel. =========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part
