Re: D to Javascript converter (a hacked up dmd)
"Adam D. Ruppe" wrote in message news:uhqgqgsyzzxrctbef...@forum.dlang.org... > On Tuesday, 28 February 2012 at 03:06:12 UTC, Daniel Murphy wrote: >> Cool, please do. > > I suck at using git, but I think it works now: > > https://github.com/adamdruppe/dmd/tree/dtojs > > > The backend refused to die in the last 45 minutes, > so I just left it there. > > > I'm pretty sure it is up to date to real dmd > now too... i hope. Anyway there it is. Lol, I think you revered a bunch of stuff when you rebased it. But so long as future changes are done with git it should be possible to fix the history later. I'll try and fix this for you sometime this week. Hopefully this makes some sense.
Re: D to Javascript converter (a hacked up dmd)
On Tuesday, 28 February 2012 at 03:06:12 UTC, Daniel Murphy wrote: Cool, please do. I suck at using git, but I think it works now: https://github.com/adamdruppe/dmd/tree/dtojs The backend refused to die in the last 45 minutes, so I just left it there. I'm pretty sure it is up to date to real dmd now too... i hope. Anyway there it is.
Re: D in Academia
On 3/3/12 1:02 PM, Chuck Allison wrote: FYI: TDPL is a required text for CS 4450, Analysis of Programming Languages, at Utah Valley University starting Fall 2012. We'll study ML and D (and Prolog if time allows). Great! Chuck, as discussed privately, feel free to address to the main forum for any help and support you might need. Andrei
d.puremagic.com downtime
The server that hosts the mailing lists, bugzilla, and the auto-tester is moving to a new data-center. I intend to do the move tomorrow afternoon. Hopefully it won't take terribly long, but it's hard to estimate since I don't know how long it will take slicehost to do the migration. The first host I did, went much faster than I expected, but it's also a tiny fraction of this server. I intend to start it around 3pm pacific time. If that time is particularly bad for you, please let me know (privately, no need to hold a conversation on the announce group): a) the reason, and b) when a better time would be. I have a good bit of flexibility, with a deadline of March 6. Thanks, Brad
Re: D to Javascript converter (a hacked up dmd)
On Sunday, 4 March 2012 at 00:05:19 UTC, James Miller wrote: Hmm, does your DOM library compile with this? No. I want do a port of some of the functions to it, though. (Even if I fix it to not use goto, so it compiles to JS, I don't actually need a parser in the browser - it should use native methods when possible. So, my strategy will be to port convenience functions instead of the whole thing.) For Javascript dom stuff, I'm generally happy enough with the browser's api alone, but my little js file ports some of my convenience functions: addChild insertAfter prependChild hasClass toggleClass removeClass addClass getParent appendText replaceText removeFromTree All as free functions in Javascript. Together with what the browser already has, that covers everything I want, well, except for dataset which is beautiful on the server, but meh on the client since you have to use getAttribute for compatibility. But, that's not a big deal. I didn't port most of my form functions in dom.d because I just don't do that kind of stuff client side anyway. (Other stuff in my js lib are some functional programming helpers and an event compatibility set.) But, for the D->JS DOM additions, these functions are pretty much what I want. My strategy I'm considering is to make a separate document module, that replaces the browser.document. Using alias this magic, I'll make extension classes that are compatible with the real thing, without any runtime wrapping. It'll be like a homemade UFCS: final class BetterElement { JSElement __js_this; alias __js_this this; BetterElement addClass(string c) { className ~= " " ~ c; } } /* do the same for document */ auto be = document.querySelector("#foo > p"); be.addClass("test"); When this is compiled, it comes out as: function addClass(c, d_this) { d_this.className += " " + c; } var be = document.querySelector("#foo > p"); addClass("test", be); Which is about as minimal as you can get in JS (it's about the same as I wrote by hand), while keeping the beautiful syntax in D. Anyway, bottom line is my goal is indeed to have a compatible version of my dom library for D->JS too, but it will have almost a completely separate implementation to be more efficient in the browser environment.
Re: D to Javascript converter (a hacked up dmd)
On 3/3/12, Adam D. Ruppe wrote: > Oh another thing: global variables in D are module scoped. Could export help?
Re: D in Academia
On 4 March 2012 09:04, Walter Bright wrote: > On 3/3/2012 11:02 AM, Chuck Allison wrote: >> >> TDPL is a required text for CS 4450, Analysis of Programming Languages, at >> Utah >> Valley University starting Fall 2012. We'll study ML and D (and Prolog if >> time >> allows). > > > > Awesome! Frickin' Sweet! Nice to see D get some high-level love. -- James Miller
Re: D to Javascript converter (a hacked up dmd)
On 4 March 2012 05:40, Adam D. Ruppe wrote: > On Saturday, 3 March 2012 at 12:10:47 UTC, Jacob Carlborg wrote: >> >> No, we don't want to do it like Dart: >> 17260 lines of code for Hello World. > > > Wow. I thought I was a bit on the bloated side with > ~100 lines of boilerplate (before running the unused > function stripper). > > $ ../dmd -md object.d > DMD v2.058 DEBUG > $ wc object.js > 108 472 11843 object.js > > > > Then again, when giant things like jQuery is considered > a "necessity" when I get by just fine with my 10 KB > (source, not minified, not gzipped) custom library, > if even that, it shows there's a big disconnect between > me and most other web people nowadays. Hmm, does your DOM library compile with this? Also, is it smaller than jQuery? And how easy would it be to make it work with the browser dom? This is mostly because I pretty much use jQuery for AJAX and Dom manipulation, everything is just extras. -- James Miller
Re: We have a GSoC mentor already: David Simcha
On 3/3/2012 2:04 AM, Andrei Alexandrescu wrote: Mentors are chosen before students and projects. As we all know, David has a variety of interests, with scientific programming at the top. Andrei I'm open to a variety of projects, but scientific computing and garbage collection are at the top of my list.
Re: We have a GSoC mentor already: David Simcha
On 3/2/2012 9:38 PM, Trass3r wrote: Am 03.03.2012, 00:43 Uhr, schrieb Andrei Alexandrescu : David Simcha applied for a second gig as a GSoC mentor. Needless to say, his application was approved :o). Please join me in welcoming him! Yay! Time to ask about the status of the last GSoC project, i.e. the LinAlg one. If it still needs lots of work, maybe there could be another round on that. The status is that the debugging and polishing is slowly happening. I've used the library for real work and while rough around the edges, it's quite good. I've also worked on adding some Lapack wrapper stuff that Cristi (the student I mentored) didn't get to and improving the test suite. The key todos are: 1. Fix a few nasty bugs that are more design flaws than run-of-the-mill bugs. This is hard for me to do without Cristi's input because I am unclear on a few design decisions. 2. Documentation. 3 More LAPACK wrappers. 4. More real-world testing. I'm not comfortable submitting something this large and complicated for Phobos inclusion until a few people have used it extensively for real work and found all the bugs and design flaws. 5. Some serious profiling/performance optimization. 6. Get allocators into Phobos, since Cristi's SciD fork depends on them.
Re: D forums now live!
Fabulous! Great work by Vladimir. Go D! On Tuesday, 14 February 2012 at 22:00:06 UTC, Walter Bright wrote: http://forum.dlang.org/ This should replace the old miserable web interface to the forums. Thanks to Vladimir Panteleev for an awesome job writing this!
Re: D in Academia
On 3/3/2012 11:02 AM, Chuck Allison wrote: TDPL is a required text for CS 4450, Analysis of Programming Languages, at Utah Valley University starting Fall 2012. We'll study ML and D (and Prolog if time allows). Awesome!
Re: D in Academia
On 03-03-2012 20:02, Chuck Allison wrote: FYI: TDPL is a required text for CS 4450, Analysis of Programming Languages, at Utah Valley University starting Fall 2012. We'll study ML and D (and Prolog if time allows). Wow, that's great news! -- - Alex
D in Academia
FYI: TDPL is a required text for CS 4450, Analysis of Programming Languages, at Utah Valley University starting Fall 2012. We'll study ML and D (and Prolog if time allows).
Re: D to Javascript converter (a hacked up dmd)
On 2012-03-03 17:29, Adam D. Ruppe wrote: On Saturday, 3 March 2012 at 12:12:53 UTC, Jacob Carlborg wrote: Wouldn't you save a lot of characters by properly scoping the variables instead of using unique names? There's no such thing as proper scoping in Javascript. The next best thing is the nested functions, but that's really just trading one poison for another. Ok, I see. D mangled names do a lot more than scoping, too, anyway. Mangled names overload properly: void a(int, int); void a(int, string); a(1, "one"); // which one gets called? With dmd's name mangling, it Just Works. Well, functions are different. Now, there might be something to gain by using prettier local variable names, but it is a lot of extra work and IMO the benefit is still very small. Note that local variables are still local variables 95% of the time (and the other 5% is a bug that I'm hoping to fix today), so its already scoped almost as well as it can be on the function level. The biggest benefit is readability and size. Size is handled by running it through a string replacer (tools/mangledown.d). Readability is a nice gain, but not an essential one I think; it is readable right now if you want to. -- /Jacob Carlborg
Re: D to Javascript converter (a hacked up dmd)
On Saturday, 3 March 2012 at 16:29:25 UTC, Adam D. Ruppe wrote: There's no such thing as proper scoping in Javascript. Let me expand a bit. consider this D: if(1) { int a = 3; } In JS, right now, that'd output: if(1) { var mangled_a = 3; } which, to the interpreter, is: var mangled_a; if(1) { mangled_a = 3; } thanks to declaration hoisting. If you want it to be scoped literally like D, it'd look more like this: if(1) { function() { var a = 3; }(); } I really doubt that'd help performance. Another option is to reuse declarations: if(1) { int a = 0; } string a = ""; could become: var a; if(1) { a = 0; } a = ""; // we know the old a is out of scope, so we'll reuse it but I don't see a big benefit there either. Now, the JS compiler will definitely see a as a dynamically typed var, and may not be able to do the same optimizations it could if it had a consistent type. When you consider the bug-pronedness of me doing this instead of relying on dmd's well debugged mangling process to do it all for me, I really think it is a net loss, despite the slightly more readable names. Oh another thing: global variables in D are module scoped. The mangledness again handles that for me. Just another bug opportunity. Perhaps a smarter helper tool could make pretty names, but I don't want to put it in the compiler.
Re: D to Javascript converter (a hacked up dmd)
On Saturday, 3 March 2012 at 12:10:47 UTC, Jacob Carlborg wrote: No, we don't want to do it like Dart: 17260 lines of code for Hello World. Wow. I thought I was a bit on the bloated side with ~100 lines of boilerplate (before running the unused function stripper). $ ../dmd -md object.d DMD v2.058 DEBUG $ wc object.js 108 472 11843 object.js Then again, when giant things like jQuery is considered a "necessity" when I get by just fine with my 10 KB (source, not minified, not gzipped) custom library, if even that, it shows there's a big disconnect between me and most other web people nowadays.
Re: D to Javascript converter (a hacked up dmd)
On Saturday, 3 March 2012 at 12:12:53 UTC, Jacob Carlborg wrote: Wouldn't you save a lot of characters by properly scoping the variables instead of using unique names? There's no such thing as proper scoping in Javascript. The next best thing is the nested functions, but that's really just trading one poison for another. D mangled names do a lot more than scoping, too, anyway. Mangled names overload properly: void a(int, int); void a(int, string); a(1, "one"); // which one gets called? With dmd's name mangling, it Just Works. Now, there might be something to gain by using prettier local variable names, but it is a lot of extra work and IMO the benefit is still very small. Note that local variables are still local variables 95% of the time (and the other 5% is a bug that I'm hoping to fix today), so its already scoped almost as well as it can be on the function level. The biggest benefit is readability and size. Size is handled by running it through a string replacer (tools/mangledown.d). Readability is a nice gain, but not an essential one I think; it is readable right now if you want to.
Re: D to Javascript converter (a hacked up dmd)
"Jacob Carlborg" wrote in message news:jit2r7$rlu$2...@digitalmars.com... >> I thought unrecognized pragmas were supposed to just be ignored? (Or >> maybe I >> have it backwards?) >> >> > > No, they're not: > > "Compilers must diagnose an error for unrecognized Pragmas, even if they > are vendor specific ones. This implies that vendor specific pragmas should > be wrapped in version statements". > > http://dlang.org/pragma.html > > -- > /Jacob Carlborg There's a switch to ignore them.
Re: D to Javascript converter (a hacked up dmd)
On 2012-03-03 06:56, Nick Sabalausky wrote: "Adam D. Ruppe" wrote in message news:sazpaicrjwzchqcfw...@forum.dlang.org... On Friday, 2 March 2012 at 18:28:15 UTC, Nick Sabalausky wrote: Suggestion: Allow all D features even if it requires...inefficient-er...boilerplate, BUT then have a system [...] Eh. A problem there is those pragmas or whatever would be unrecognized by the real dmd. A command line switch, maybe, though. I thought unrecognized pragmas were supposed to just be ignored? (Or maybe I have it backwards?) No, they're not: "Compilers must diagnose an error for unrecognized Pragmas, even if they are vendor specific ones. This implies that vendor specific pragmas should be wrapped in version statements". http://dlang.org/pragma.html -- /Jacob Carlborg
Re: D to Javascript converter (a hacked up dmd)
On 2012-03-02 19:13, Nick Sabalausky wrote: "Jacob Carlborg" wrote in message news:jiptfu$qrg$1...@digitalmars.com... On 2012-02-29 18:46, Nick Sabalausky wrote: "Alex Rønne Petersen" wrote in message news:jilnie$1fsr$1...@digitalmars.com... On 29-02-2012 18:32, Andrei Alexandrescu wrote: On 2/26/12 9:51 PM, Adam D. Ruppe wrote: https://github.com/downloads/adamdruppe/dtojs/dtojs.zip [snip] That's interesting. So the idea is to make an entire subset of D convertible to Javascript? What use cases do you have in mind? Andrei Avoiding writing JS directly in web apps comes to mind. Yea, creating JS without having to actually *write* JS is a huge use-case in and of itself. (I still can't believe the web has standardized on such an absolute shit langauge. Hell, two of them if you count PHP on the server.) Five if you count HTML, CSS and SQL as well. Very true, but a far as shittiness goes, JS and PHP are in a whole other league (IMO). Yeah, I agree. I'm just saying, thank god I don't have to use PHP in my job. I'm using CoffeeScript instead of JavaScript whenever I can which makes it a bit more bearable. Yes I know many people here don't like CS, specially the syntax, but it fixes several of the most annoying things about JS. Actually, HTML/CSS for what they are - *document* description formats - really aren't all that bad. The only real *major* problem with HTML/CSS is not the formats themselves, but the fact that people keep abusing them as application presentation layers, which they clearly aren't and were never intended to be. (And basing an entire application around the deliberately-stateless HTTP? Seriously? WTF?) Latex isn't bad (from what little I've seen), but if people started pretending it was a presentation layer for programs, then yea, it would completely blow for that. But that's exactly what people did with HTML/CSS. So HTML and CSS get a bad reputation when really the true blame lies with the people pushing for their misuse. (Not that HTML/CSS couldn't be improved even as pure document formats.) Yes, I think both HTML and CSS could be improved a lot. One of the most annoying things is there's no good way to handle scoping. SASS (regardless of which syntax you choose to use) makes this problem less annoying and fixes several other issues with CSS. The fact that you most likely uses a server side language to output HTML fixes many of the problems with HTML. -- /Jacob Carlborg
Re: D to Javascript converter (a hacked up dmd)
On 03/03/2012 12:12, Jacob Carlborg wrote: On 2012-03-02 15:57, Adam D. Ruppe wrote: On Friday, 2 March 2012 at 09:33:44 UTC, Alix Pexton wrote: Have you considered faking scopes in JS using anonymous functions? Yeah, though right now I'm trusting the D compiler to keep it straight, and it is doing a pretty good job while being really simple to code. What happens is all the local variables are mangled with respect to their full scope too (which leads to ridiculously long, but unique names). Wouldn't you save a lot of characters by properly scoping the variables instead of using unique names? The compile JavaScript code would also be more readable. and potentially faster! A...
Re: D to Javascript converter (a hacked up dmd)
On 2012-03-02 15:57, Adam D. Ruppe wrote: On Friday, 2 March 2012 at 09:33:44 UTC, Alix Pexton wrote: Have you considered faking scopes in JS using anonymous functions? Yeah, though right now I'm trusting the D compiler to keep it straight, and it is doing a pretty good job while being really simple to code. What happens is all the local variables are mangled with respect to their full scope too (which leads to ridiculously long, but unique names). Wouldn't you save a lot of characters by properly scoping the variables instead of using unique names? The compile JavaScript code would also be more readable. -- /Jacob Carlborg
Re: D to Javascript converter (a hacked up dmd)
On 2012-03-02 15:38, Adam D. Ruppe wrote: On Friday, 2 March 2012 at 05:58:03 UTC, Nick Sabalausky wrote: You make it sound as if there's another kind of JS. Horribly inefficient relative to the environment :P I just don't want 100 kb of crap to download just to write a hello world. A lot of people prefer to use gzipped sizes, but I don't because the browser still has to parse the whole thing, and that takes time after the download, even if you don't actually run any of it. (On some browsers, it parses it again on every page load!) This generated D code gzips very, very well, but I still want to keep it small in general for general speed. The fastest code is no code at all. Less to parse, less to run. No, we don't want to do it like Dart: https://gist.github.com/1277224 17260 lines of code for Hello World. -- /Jacob Carlborg