From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id BA0367EC6E for ; Tue, 17 Dec 2013 15:17:16 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of monnier.florent@gmail.com) identity=pra; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of monnier.florent@gmail.com designates 74.125.82.47 as permitted sender) identity=mailfrom; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f47.google.com) identity=helo; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="postmaster@mail-wg0-f47.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkEDAKNbsFJKfVIvlGdsb2JhbABZg0JVrzOJNYEWCBYOAQEBAQcLCwkSKoIlAQEBAwEBAj0BGw0BDwEDAQsGBQsNLiIBBQwBBQEOAQ0GiAIBAwkIDaRFjFqDCY0pChknDWSFbxEBBQyNDIFHMweENgEDlUeCT4EwjncYKYRYOw X-IPAS-Result: AkEDAKNbsFJKfVIvlGdsb2JhbABZg0JVrzOJNYEWCBYOAQEBAQcLCwkSKoIlAQEBAwEBAj0BGw0BDwEDAQsGBQsNLiIBBQwBBQEOAQ0GiAIBAwkIDaRFjFqDCY0pChknDWSFbxEBBQyNDIFHMweENgEDlUeCT4EwjncYKYRYOw X-IronPort-AV: E=Sophos;i="4.95,501,1384297200"; d="scan'208";a="49366687" Received: from mail-wg0-f47.google.com ([74.125.82.47]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Dec 2013 15:17:16 +0100 Received: by mail-wg0-f47.google.com with SMTP id n12so5972554wgh.2 for ; Tue, 17 Dec 2013 06:17:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=regPxzBEYe5i7pfYchKYvSxWT/VHeaD0r2kPYdW3f1g=; b=Rwskrl2IPKCezESUOzImrX6ErXGeh3Pt9zZweyzHnlAnAValkC3nDNzbq5yvHaHPRl tTFKb4mkZyxglJIGWuSbCmn/eKwh4+RpDUFwSYpNsUirt/K4+ztGKjnopnJh9OSPPQ7k D5WbGAALo8Q2j80/5mv9bV0adcLeKGYIGtAU8opM7m/oG+rEc279iP4er32AafNmD5tB MA7DtYWcX3I4YFu1HwGoJCMtzfnWW2b++bKZY57huk0Azpb+VT7KDMG+deIvLRnj9Iue mN1I22AR9fspS/Jjw1wo+NW03OTjgvfMlQaPScuYWoSmGtjaHNBR3K4XDYD626sByF4Z Lrzw== MIME-Version: 1.0 X-Received: by 10.195.13.234 with SMTP id fb10mr19402226wjd.50.1387289836121; Tue, 17 Dec 2013 06:17:16 -0800 (PST) Received: by 10.194.77.110 with HTTP; Tue, 17 Dec 2013 06:17:16 -0800 (PST) In-Reply-To: <4DDEBB7487B641C0834F09D522EA9918@erratique.ch> References: <4DDEBB7487B641C0834F09D522EA9918@erratique.ch> Date: Tue, 17 Dec 2013 15:17:16 +0100 Message-ID: From: Florent Monnier To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: caml list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Validation-by: monnier.florent@gmail.com Subject: Re: [Caml-list] SDL2 bindings, testers and feedback welcome 2013/12/17, Daniel B=FCnzli wrote: > Hello, Hi Daniel! Thanks for your previous help for compilations on Raspberry Pi, since then I enjoy so much programming on this small machine, and I've been able to make mini-demos for kids with it, which was such a happy moment for me (and I hope for them too). > I have written thin bindings to SDL 2 using ocaml-ctypes. The binding I don't know anything about "ocaml-ctypes", I will have to add on my TODO list to search for sme blog posts and/or tutorials about it. > is finished but should be considered unstable: it was not thoroughly > tested and may still change as it has not been *used* yet. The purpose > of this unstable release is to: > > 1) Iron out the install procedure and test on a variety of platforms. I can test it on Mageia Linux and on MS/Windows with Cygwin Terminal with MingW's compilator. Should we test SDL 2.0.0 or 2.0.1 (or both?) Can I request you later to test a compilation on OSX? > 2) Get feedback about the design of the binding (see below). The most interesting it there :) > More precisely, apart from the eventual bugs, I'm interested in > getting feedback in the following areas: > > * I used an 'a result =3D [ `Error | `Ok of 'a ] rather than an exception > for functions that return error codes/null is error. I tend to lean > on exceptionless designs but I'm still unsure whether it is a good > idea that case. I also prefer exceptionless designs, but in practice I found that it's more painfull for writting quick and dirty small/mini demos and quick experimentations. And experimentation is important for writting screensavers, mini-games, and various multi-media/infographic things. But I would say (IMHO) that it would be good to have both, an exceptionfull module for beginning, and an exceptionless module for the rewritting of the initial drafts. Being myself a perfectionist, I found interesting to migrate what I felt is perfection, from very well written code, into very quickly written code, I mean as in a race or a challenge :-) > One of the problems is that SDL doesn't make a clear > distinction (at the signature level *and* in the documentation) SDL 1/2 are C libs. We should not expect something tailored for our language. If something is missing there, this our job to provide it, and then to shar= e it. More precisely I found very interesting several initiatives available around, like for example the idea behind the XML description of the API of the XCB C library. http://xcb.freedesktop.org/dist/xcb-proto-1.9.tar.gz I think this could be an interesting project to make an equivalent for SDL = 2. And from there trying to make something that would tend to be a standard for any kind of C libs. These API descriptions could then be used for different purposes by different projects. I would like to elaborate and discuss more on the topic, and to share my experimentations but I have now to go to the state ajency for unemployed people. If someone is interested to sponsor my experimentations, I could allocate more energy on it than when I'm doing it as a volunteer. to be continued... > between programming errors (invalid_arg), exceptional errors > (e.g. out of memory) and non-exceptional errors (e.g. could not > access/setup a resource). Ya we should fork SDL into an SDLERR project that would return proper error codes for every possible type of errors. Maybe there would be some sponsors for such a project. > * The signature/approach of certain binding functions may be disputable > or may need change to achieve reasonable performance. could you elaborate? > * Testing the binding to the joystick/game controller/force feedback api, > I have none of these things in my hands. I bought a 5 euro joypad last year for testing SFML2 and SDL2. I can test the joypad events. > I welcome discussions/ideas about these points and the general design > of the binding on github's issue tracker (http://github.com/dbuenzli/tsdl) Thanks for accepting feedbacks. > Note that the philosophy of the binding is to be "thin", that is a > mostly type-safe(r), minimal, hopefully efficient, one-to-one > binding. This means that I'm not interested in prettyfing the C API > like OCamlSDL does. I share your views and tastes. (Even if I like both ways.) But thin could be understood in different ways, and addapted to the idioms of the language. for example a piece of ocaml--sdl code like: let stuff =3D Sdlmodule.func params in will then be rewritten in C by copy-pasting the func-stub : SDL_t stuff =3D SDL_ModFunc(params); if (stuff !=3D 0) { myprint("Err: %s", SDL_GetError()); myexit() // or myNextLoop(); } On the OCaml formulation my equivalent will be a try on the main entry display function, with the exceptional case to be either nothing or a failsafe handling, that has its own close equivalent in pure C. > I expect tsdl code to look like C SDL code > (including the inconsistent naming schemes) and the binding to be used > by programmers to build higher-level, more OCaml friendly, abstractions. > > To install (only tested on osx and linux so far) you'll need at least SDL > 2.0.1 > installed on your system. Then: > > opam repo add erratique-u http://erratique.ch/software/opam/unreleased > opam update && opam install tsdl > > On osx 10.8.5 with OCaml 4.01.0 there's a heisenbug I couldn't track so f= ar > (see [1] for more info). Use 4.00.1 instead for now but note that the > binding > takes a long time to compile (~8 min on my machine) with that. > > If you want to hack the sources: > > git clone http://github.com/dbuenzli/tsdl > cd tsdl && ./build test.native && ./test.native > > The documentation of the binding is here: > > http://erratique.ch/software/tsdl/doc/Tsdl > > Best, > > Daniel > > [1] http://lists.ocaml.org/pipermail/ctypes/2013-December/000027.html > > P.S. If anyone wonders, the existing OCamlSDL is a very good binding > to SDL 1.X, but SDL 2.0 is an entirely new, incompatible, API. The API is not entirely new. A lot is compatible, and a compatibility layer has been carefully designed to help progressive and painless migrations. Without the Licensing issues on OCamlSDL, we could have migrated it to SDL = 2.X I would still want to try it if only the authors could be reached to ask them permission to switch from the highly restrictive and incompatible current license of OCamlSDL into the more convenient zlib/png license of SDL 2. > Besides > SDL 2.0 changed to a zlib license, tsdl is under BSD3, OCamlSDL is > LGPL. Indeed, and LGPL without exception on static linking needed by ocamlers. Would it be indiscreet to ask you if you wrote this code as a volunteer or if you got paid for it, and how much? If that's indiscreet, please just ignore this question. --=20 Cheers Florent