From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from resqmta-ch2-11v.sys.comcast.net (resqmta-ch2-11v.sys.comcast.net [IPv6:2001:558:fe21:29:69:252:207:43]) by hurricane.the-brannons.com (Postfix) with ESMTPS id ACB9577FF6 for ; Wed, 5 Jul 2017 06:50:19 -0700 (PDT) Received: from resomta-ch2-20v.sys.comcast.net ([69.252.207.116]) by resqmta-ch2-11v.sys.comcast.net with SMTP id SkgydAAaUxSSiSkhidVuum; Wed, 05 Jul 2017 13:50:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1499262654; bh=EklRN085hH1aTdLT7TTkqMuPmmhoxJ3/C8WHXlSqVRg=; h=Received:Received:To:From:Reply-to:Subject:Date:Message-ID: Mime-Version:Content-Type; b=NM6nlsGMqEuv53JZgK8bOaFhxZM9pLvmjSPJKVOigVEN8UxCi1nyJGfCTKgcnQANN bkEIGVSzefExKpEHKncQnatyvJZxi7o3PNfcmaYFtLdWsbUHCueL3VLuCKsd1GUsej NEW4QiTnt9keJqO8/jGPCT75IXujb6lPCbggDhmjp5fq5xyILX1jL9YfsyOJC0e+Bf OYonJvWQZeHfxQU5S3Q1VqfPMPJSfFZ5zXGgT5Y/TLySMIPOpdLfbEd39yfE2uB0SV 19Ct7bHTb2tQMPUEPAr7HYWyPzXo9LQaaiOjv6ypzfGFc6cj1ep6bK8elAWlWKFFLz CR5odeHW5O8KA== Received: from unknown ([IPv6:2601:408:c301:784d:21e:4fff:fec2:a0f1]) by resomta-ch2-20v.sys.comcast.net with SMTP id SkhhdihCXULyFSkhhd7Wvn; Wed, 05 Jul 2017 13:50:53 +0000 To: Edbrowse-dev@lists.the-brannons.com From: Karl Dahlke Reply-to: Karl Dahlke User-Agent: edbrowse/3.6.3+ Date: Wed, 05 Jul 2017 09:50:53 -0400 Message-ID: <20170605095053.eklhad@comcast.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=nextpart-eb-759975 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfMTT9D6RWry53cDM3JUeuPXL+naNOj4Ca5wVvNs598W7qjEKayEyWqp/7Bad0rIgs2GYH7VNwwIrl4WP5AKKKCYbWIGlRw0JQ3tCSptV9vxJ/FokYPvW b6oP5LDVF2cAWQaZw+e4tpdL4txY7LjEO3V0Dt13AAdioxD6N6z6cNkL Subject: [Edbrowse-dev] obj = new Foo() X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.24 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jul 2017 13:50:19 -0000 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --nextpart-eb-759975 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable After playing with duktape for a couple days I'm about as far up the = learning curve as I was after a month of moz js. In other words, moz is ungodly complicated, while duktape is clear and = simple. Neither is particularly readable or compact however, but at least = duktape is straightforward, like cobol, where you write add a to b giving c; instead of c =3D a + b; So it's clunky, and takes an entire page of code to do something pretty = obvious, but you can read it through without getting a headache, and = you can write it without too much strain on the brain. More important, you don't get a segmentation fault one time in 100, = nearly impossible to debug, because you didn't root some value on your = C stack and the mozilla garbage collector came along and removed it = just before you used it, or you didn't autocompartment something = properly, etc etc. The moz api just cries out for catastrophic and irreproducible bugs. I worked very hard to eliminate those kinds of bugs on the last = rewrite, e.g. one entry point that sets the autocompartment, so at = least you know you got that right, and rooting or handling everything = else everywhere. Well guess what, we don't have to worry about any of that shit in = duktape! If we get duktape working, and if jsrt passes, and it meets our needs, = I don't think we'll ever go back to mozilla. I can't imagine going back to mozilla. I don't like to talk about burning bridges, but lordy the difference is = like night and day, and I don't think we'd ever go back. Which leads to my next question / observation. You can define a class in C or in js. I gave an example of the TextNode class in an earlier email. TextNode =3D function() { this.data =3D ''; if(arguments.length > 0) this.data +=3D arguments[0]; } This is a simple class with no setters, no side effects, and no = particular reason to write it in C. And of course it's 5 lines of js, and 40 lines of unportable C in = either mozilla or duktape, since, as I say, both APIs make for long and = wordy code. So the advantage of js over c remains. But here's the difference. In mozilla or duktape, a class defined in C can be instantiated in c or = in js - as you would expect. In duktape, a class defined in js (as shown above) can be instantiated = in c or in js, as you might expect, (I just tested this and it works), = but this is not the case for mozilla. A class defined in js cannot be directly instantiated from c. You have to write something really ugly like js_rooted_value val =3D js_execute("new TextNode('elephant')"); js_rooted_object my_text_object =3D js_value_to_object(val); // Thus capturing the instantiated object. Well that works fine, but your brain has to leave the c world, run some = js code, and then jump back to c. Also terribly inefficient if there are a lot of these, and if = performance matters. You can imagine calling up the js interpreter, running the js code, = going back to c, over and over again, etc. So there are a lot of classes that I left in c, because I needed to = instantiate them in c, and I didn't want a bunch of circuitous code as = shown above. But then I have tons of unreadable, unportable, mozilla specific ugly c = code to build some pretty simple classes and methods. Now, on the brink of converting to duktape ... should I take advantage = of the feature that duktape offers, a feature that every engine should = offer in my opinion, that I can instantiate any class, whether created in c or in js, using = either c or js code, and it all works seamlessly? I tell you, it would make things soooooooo much easier. But it would make it a little bit harder to go back to mozilla 5 years = from now if we felt we had to do that. Not impossible, as illustrated by the js_execute("new TextNode") code = shown above, but a bit more awkward to go back. Personally I stand ready to march on and take advantage of this = feature, thus simplifying the code considerably, because I don't think = we're ever going back, but if you-all can convince me that's a bad idea, then I guess I could = leave a bunch of classes in C, where they are now, even though they're = pure and simple and could easily be in js instead. You'll have to do some fast talking though. If I'm the one doing the conversion I'll want to clean things up along = the way, and duktape makes that possible. In other words, I've almost made my mind up already, but I'm trying not = to be a dictator about things, so opening it up for discussion. On a psychological note - depression saps all my energy, wherein the = last thing I want to do is program, but if I start programming it helps = with depression. Kinda like exercise I guess. Karl Dahlke --nextpart-eb-759975--