Re: ApplyYourDLang - A YouTube channel for D introduction videos
On 02/27/2014 12:51 AM, deadalnix wrote: On Sunday, 23 February 2014 at 22:07:39 UTC, simendsjo wrote: The cat's out of the bag.. http://www.reddit.com/r/programming/comments/1ypg91/getting_started_with_d_and_vibed/ We didn't want to announce the site before we had more videos, but it has found its way to reddits frontpage. Watching it right now. Basic but really nice ! Thanks. Aimed at beginners to D. Only the first video might be of interest to people here, the rest are even more basic and probably better suited for people that doesn't know much programming at all.
Re: ApplyYourDLang - A YouTube channel for D introduction videos
On Thursday, 27 February 2014 at 08:15:26 UTC, simendsjo wrote: On 02/27/2014 12:51 AM, deadalnix wrote: On Sunday, 23 February 2014 at 22:07:39 UTC, simendsjo wrote: The cat's out of the bag.. http://www.reddit.com/r/programming/comments/1ypg91/getting_started_with_d_and_vibed/ We didn't want to announce the site before we had more videos, but it has found its way to reddits frontpage. Watching it right now. Basic but really nice ! Thanks. Aimed at beginners to D. Only the first video might be of interest to people here, the rest are even more basic and probably better suited for people that doesn't know much programming at all. keep 'em coming.
Re: DigitalMars' GSoC application has been rejected
On Thursday, 27 February 2014 at 02:34:53 UTC, Andrei Alexandrescu wrote: Unfortunately we won't participate in GSoC this year. The decision was not surprising - our application has been rejected. Sadly there are lots of things we could have done better. Our application has been a low-priority side job for Walter and myself and as such its quality has suffered greatly. GSoC applications are a great example of things where one or more community members can have a large impact on D's well being by offloading a parallelizable work from the two of us. Please consider taking a leadership role for GSoC 2015. Andrei How much time did you spend on the application this year? How much time do you think would be needed to put together a good quality proposal?
Re: DigitalMars' GSoC application has been rejected
On 2/27/14, 10:10 AM, Craig Dillabaugh wrote: On Thursday, 27 February 2014 at 02:34:53 UTC, Andrei Alexandrescu wrote: Unfortunately we won't participate in GSoC this year. The decision was not surprising - our application has been rejected. Sadly there are lots of things we could have done better. Our application has been a low-priority side job for Walter and myself and as such its quality has suffered greatly. GSoC applications are a great example of things where one or more community members can have a large impact on D's well being by offloading a parallelizable work from the two of us. Please consider taking a leadership role for GSoC 2015. Andrei How much time did you spend on the application this year? How much time do you think would be needed to put together a good quality proposal? Walter and I pleaded that the other completes the application, with me saying I don't have the time and him saying he's not suited for the job. In the end I won and he spent a couple of hours drafting a proposal, which was indeed bad. I spent maybe an hour a late evening trying to improve the proposal and that was about it. Made no page on dlang.org and did nothing on the wiki ideas page (which I think was weak as well). But sheer time spent is not essential here as the availability of mental cycles. When I do something right I think of it in small quanta all the time - showering, walking, running, whatever. So by the time I sit down to work on it I have ideas and plans already formed. The GSoC was the exact opposite - unprepared todo work vying for attention at the periphery of an already overflowing plate. There's no way I could have done a good job at it. For better or worse Walter and I are the bottlenecks on a lot of D-related stuff. (Just look at http://goo.gl/jGYzir which is developing a nice tenure as a tab in my web browser.) Kenji wrote me an email months ago asking for my take on DIP49, and has done a lot of legwork before I came back to him saying we need a radical simplification. No wonder he wouldn't answer my emails. Whenever anything comes, I need to act managerial - absorb context quickly, make a decision, delegate details, move on. There's just too much important AND urgent stuff going on right now in D, which gives a whole other perspective on the people who advise us on how to do things better, to dissolve into the shrubs when a very concrete opportunity to do something. From that angle, every single little thing that's parallelizable and off our plate (such as build system, auto tester, release management, GSoC, and such) is a double improvement for the language as a whole: once because that part gets done better, and twice because it frees us to better focus on other things. Concretely: there wasn't much time to work on allocators lately... Thanks, Andrei
Re: ApplyYourDLang - A YouTube channel for D introduction videos
On 2014-02-26 21:23, simendsjo wrote: The video quality is good, isn't it? Or did you mean the content quality (which is pretty poor)? No, not the content, I'm referring to the video quality. Hmm, for some reason Youtube only displays it in 360p. If I download the video it's better. It's ok but not great. Why not 1080p? The audio quality is due to using a laptop microphone. I haven't found a way to increase the volume without uploading another video though. This cannot replace the original, so all links would be invalidated. If you want to do this a lot you should really get a real, external, microphone. -- /Jacob Carlborg
Re: ApplyYourDLang - A YouTube channel for D introduction videos
On Thursday, 27 February 2014 at 20:25:50 UTC, Jacob Carlborg wrote: On 2014-02-26 21:23, simendsjo wrote: The video quality is good, isn't it? Or did you mean the content quality (which is pretty poor)? No, not the content, I'm referring to the video quality. Hmm, for some reason Youtube only displays it in 360p. If I download the video it's better. It's ok but not great. Why not 1080p? 360p is default for embedded widget. You can chose better quality manually in player. Also after going full screen it will also adjust quality to screen resolution in a few seconds.
Re: ApplyYourDLang - A YouTube channel for D introduction videos
On 02/27/2014 09:25 PM, Jacob Carlborg wrote: On 2014-02-26 21:23, simendsjo wrote: The video quality is good, isn't it? Or did you mean the content quality (which is pretty poor)? No, not the content, I'm referring to the video quality. Hmm, for some reason Youtube only displays it in 360p. If I download the video it's better. It's ok but not great. Why not 1080p? The audio quality is due to using a laptop microphone. I haven't found a way to increase the volume without uploading another video though. This cannot replace the original, so all links would be invalidated. If you want to do this a lot you should really get a real, external, microphone. It's available in 1080p on YouTube. If I plan to do more of these, I should probably learn how to edit the videos too rather than using pause :)
Re: DigitalMars' GSoC application has been rejected
On 2/27/14, 11:11 AM, Craig Dillabaugh wrote: One more question. Do you feel this is a job that someone who isn't necessarily well versed in the various technologies could take on (in a sort of manager role), or would you need someone who has the expertise to evaluate various proposals. Any motivated individual with little to moderate expertise can do it. The application is for the most part filling forms and creating prose. A person who's on top of things can prod contributors into submitting ideas, rally mentors, make sure the related web pages are in good shape, etc. etc. etc. To put things into perspective, we could have missed the deadline if the thing didn't bubble up to my level of consciousness. Andrei
Re: DigitalMars' GSoC application has been rejected
On 2/27/14, 1:42 PM, Craig Dillabaugh wrote: On Thursday, 27 February 2014 at 21:37:03 UTC, Andrei Alexandrescu wrote: On 2/27/14, 11:11 AM, Craig Dillabaugh wrote: One more question. Do you feel this is a job that someone who isn't necessarily well versed in the various technologies could take on (in a sort of manager role), or would you need someone who has the expertise to evaluate various proposals. Any motivated individual with little to moderate expertise can do it. The application is for the most part filling forms and creating prose. A person who's on top of things can prod contributors into submitting ideas, rally mentors, make sure the related web pages are in good shape, etc. etc. etc. To put things into perspective, we could have missed the deadline if the thing didn't bubble up to my level of consciousness. Andrei In that case, as Yoda would say: Volunteer to prepare GSoC 2015 proposal I shall. Do you have copies of past submissions as a guideline, or is it just what is on the Wiki. Congratulations and good luck! Stay tuned to the general GSoC process and I hope you'll be around in December :o). Google doesn't save past submissions. We have our older gsoc pages on dlang.org and the wiki. I think Walter saved some form data. Andrei
Re: DigitalMars' GSoC application has been rejected
On Thursday, 27 February 2014 at 22:25:27 UTC, Brad Roberts wrote: We can still do #2 without #1. And we don't need google to make it happen. How about trying a practice run despite not having google tossing in the funding? If someone would want to contribute, what would be the right person to contact, or the right resource to turn to ? I was looking to fix a (probably simple) bug in DMD but it's quite hard to grok (http://www.prowiki.org/wiki4d/wiki.cgi?DMDSourceGuide helps but it's a bit outdated). Also, searching contributing in the wiki only yield GDC / LDC links.
Re: DigitalMars' GSoC application has been rejected
On Thursday, 27 February 2014 at 18:47:37 UTC, Andrei Alexandrescu wrote: For better or worse Walter and I are the bottlenecks on a lot of D-related stuff. I would really like to help with this, and (I think) others would too. The ideas for GSoC 2015 could start now. I took the liberty of adding the ideas page (http://wiki.dlang.org/GSOC_2015_Ideas). Add your ideas today! Deadlines, call for mentors, link to GSoC application instructions should all be added now, if possible. Help me help you: The recent CONTRIBUTING.md for DLang.org helped me make a few updates to neglected areas of the website, and I have more coming. The GDC Project Ideas page (http://wiki.dlang.org/GDC/ProjectIdeas) helped me add a little value to that project. I revisit it periodically to find out What can I do today? I realize the last thing you need is another suggestion, but perhaps something like these could be created for the D effort as a whole. For example, what needs to be done to help prepare for DConf 2014? Mike P.S. Forgive me if all this has been beaten to death before. My sincere thanks for all you and Walter have done to give us D. I'm hoping for a career changer with this language. God knows I need one.
Re: DigitalMars' GSoC application has been rejected
On Thursday, 27 February 2014 at 23:21:29 UTC, Craig Dillabaugh wrote: https://community.kde.org/Getinvolved/development (at the bottom) Experienced D developers, who feel they could use on a specific project, or who would be otherwise interested in taking on an 'apprentice' could list projects they would like to see someone take on. Interested developers could browse through and see if any of the proposed projects piqued their interest. IMO this is EXACTLY what this effort needs. I don't know what happened to the apprenticeship custom, but it needs a comeback...badly. This is a great idea. The apprentices this year will likely become the mentors of next year, and it will only accelerate. Make a wiki page to get started. Post an announcement. People may be apprehensive at first, but I think it will catch on. If it doesn't, no harm done. However, that doesn't entirely fulfill #2 in your list. The 'student' needs some motivation to complete the project I suppose. Perhaps a DConf T-shirt autographed by Walter and Andrei or something :o) I would do it simply for the benefit of education. Lord knows it'd be a better return on my investment than an overpriced university. It would also help my career to say that I worked under some of the prominent names in this community. Mentors would benefit as well. I'm sure Iain would love some help doing the 2.065.0 merge, yes? They would learn some valuable leadership skills as well, and may actually enjoy the experience. I greatly enjoyed the little mentoring I've done in my career. I can only see good things coming out of such an effort, if it takes hold. It's a superb idea. Mike
Re: DigitalMars' GSoC application has been rejected
On Friday, 28 February 2014 at 01:02:11 UTC, Mike wrote: On Thursday, 27 February 2014 at 18:47:37 UTC, Andrei Alexandrescu wrote: For better or worse Walter and I are the bottlenecks on a lot of D-related stuff. I would really like to help with this, and (I think) others would too. The ideas for GSoC 2015 could start now. I took the liberty of adding the ideas page (http://wiki.dlang.org/GSOC_2015_Ideas). Add your ideas today! Deadlines, call for mentors, link to GSoC application instructions should all be added now, if possible. Help me help you: The recent CONTRIBUTING.md for DLang.org helped me make a few updates to neglected areas of the website, and I have more coming. The GDC Project Ideas page (http://wiki.dlang.org/GDC/ProjectIdeas) helped me add a little value to that project. I revisit it periodically to find out What can I do today? I realize the last thing you need is another suggestion, but perhaps something like these could be created for the D effort as a whole. For example, what needs to be done to help prepare for DConf 2014? Mike P.S. Forgive me if all this has been beaten to death before. My sincere thanks for all you and Walter have done to give us D. I'm hoping for a career changer with this language. God knows I need one. Thanks for setting up the idea's page for GSoC 2015, that is a start. As you suggested it would be good to have a general Help Wanted page, possibly with links to willing mentors. It would seem to add some such thing to the Wiki, possibly under the Get Involved section, then role some of these ideas into the GSoC projects.
Re: DigitalMars' GSoC application has been rejected
On 2/27/14, 3:22 PM, Mathias LANG wrote: On Thursday, 27 February 2014 at 22:25:27 UTC, Brad Roberts wrote: We can still do #2 without #1. And we don't need google to make it happen. How about trying a practice run despite not having google tossing in the funding? If someone would want to contribute, what would be the right person to contact, or the right resource to turn to ? Probably kickstarter or similar would be a good possibility for well-defined projects of broad interest. Andrei
Re: http://www.rust-ci.org/
On 2014-02-26 05:50, Brad Roberts wrote: Later, Brad Now I've received your email but it seems I can't reply :) Instead, I'm receiving mail delivery error: The mail system bra...@puremagic.com: host mail2.puremagic.com[99.179.5.161] said: 451 4.7.1 Please try again later (TEMPFAIL) (in reply to RCPT TO command)
Surprised by hashes of arrays of arrays
Dear list, I stumbled over odd behavior which took quite some time of debugging. Sharing my results may help find a solution or just make others aware and reduce their debugging time. To illustrate consider the code: auto array1 = [ [1, 2], [3, 4] ]; auto array2 = array1.dup; array2[0] = array2[0].dup; Does either hash(array1) == hash(array2) hold or hash(array1) != hash(array2) where hash is defined as auto hash = (typeid(array1).getHash); ? So I may be totally off here (please tell me), but it turns out that that both arrays have different hashes due to the way hashing is implemented. This, e.g., implies that equal arrays may be hashed to different values. Hence when you are using them as keys in an associative array results may be surprising. Note that I can make the problem more difficult to spot by using a struct that uses pointers or an array internally which is hidden by encapsulation. I find the behavior non-obvious but maybe there is reason. The current implementation considers only the direct contents of the struct's memory (the memory starting at array.ptr to array.length * size(array[0]) in case of dynamic arrays) and does *not* follow indirections (e.g. via pointers). This implies that a hash can be computed without considering all memory occupied by a value. In my current mental model of hashing I assumed that all bytes should be read by default. As you may conclude from this post I find this behavior odd. I expect a hash implementation to follow indirections by calling the hashing functions recursively. It looks to me as a case where the default is badly designed/implemented. Jens
Dart and D: features that could be used in D, D-dart for web programming
A1) Google's Dart (https://www.dartlang.org) looks like a very promising replacement for javascript. It can compile to javascript to ensure portability (but chromium runs it natively) but the language itself reminds more of D to a surprising extent. Dart language has features such as: static typing (but can also have dynamic typing, akin to std.variant, with better support/syntax than D) ahead of time compilation unicode support built in serialization/deserialization via json annotations mixins (used to emulate multiple inheritance) generics vector/AA litterals alias (called typedef in dart), is, assert try/catch/finally operator overloading properties (same parenthesis-less caller syntax as in D) delegates (called closures) nesting functions, 1st class functions, lambda = syntax DDOC (called dartdoc) D-like syntax and nesting comments, introspection (runtime only AFAIK) A2) Also features that would be nice to have in D or were better designed than in D: * cascade operations: they perform a series of operations on the members of a single object: foo.bar(1)..baz(3) equivalent to: foo.bar(1) foo.baz(3) * better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. * named constructors * distinguish integer divide (~/) vs divide (/), so that 5/2=2, 5~/2=2 * shorthand function declaration with = (used not just for lambdas) * for (var x in collection) //better syntax than foreach(var;collection) * better syntax for optional positional arguments: void fun(int x, [int y, int z=3]){...} Thinking of which, this would actually solve a long standing problem in D, that of specifying optional parameters AFTER a variadic template: void fun(T...)(T args, [string file=__FILE__,int line=__LINE__]){...} * export for libraries * async/wait etc * great IDE/debugger/package manager/static analyzer also the following which I've previously proposed adding to D: * string interpolation $variableName (or ${expression}) assert('foo. ${s.toUpperCase()} bar' == 'foo. STRING INTERPOLATION bar'); * optional named parameters arguments (with simplest possible syntax) * import all except specified symbols: import 'package:lib2/lib2.dart' hide foo; // Import all names EXCEPT foo. A3) And then some design decisions which wouldn't work for D: everything is an object, no struct (just class), VM, etc. A4) there were may previous threads regarding using D on the web via compiling to javascript. In light of this it would seem a lot easier to compile D to dart.
Re: Dart and D: features that could be used in D, D-dart for web programming
What needed to create language that can be run everywhere? I mean would it be hard to add support of running D code in web-browser? it's better to write all logic at one language, that on 2 or 3.
Re: Dart and D: features that could be used in D, D-dart for web programming
Timothee Cour: * better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. A variant of this idea was discussed, and I think it's a good idea. * distinguish integer divide (~/) vs divide (/), so that 5/2=2, 5~/2=2 * shorthand function declaration with = (used not just for lambdas) Both good. But for the first you need a different syntax in D. * optional named parameters arguments (with simplest possible syntax) * import all except specified symbols: import 'package:lib2/lib2.dart' hide foo; // Import all names EXCEPT foo. Probably both good, if well designed. Bye, bearophile
Re: Surprised by hashes of arrays of arrays
On Thursday, 27 February 2014 at 10:12:46 UTC, Jens Mueller wrote: As you may conclude from this post I find this behavior odd. I expect a hash implementation to follow indirections by calling the hashing functions recursively. How shall it work with cycles in object graphs?
Re: Dart and D: features that could be used in D, D-dart for web programming
I don't like any of the syntax changes mentioned. I do like the suggestions for better IDEs and similar tools. We can always do more to improve these.
Duals or ranges and reactive D
C#'s IObservable/IObserver made me think how would a dual [1][2] of a range concept look in D. Since D has no equivalent IEnumerable (as it is no needed thanks to templates) it is only about IEnumerator / IObserver part which relates to a D range. Ranges/enumerators are models of 'pull' style interface whereas their duals represent models of 'push' style enabling reactive programming [3] techniques which are really nicely solving issues of asynchronous / event - based programming. I suppose OutptRange is similar in concept, although it has 'OnCompleted' / 'OnError' missing. What do you think? Rx along with LINQ is a really clean solution to the problem of asynchronous ranges of values. I think it would be very nice to have in D too. [1] http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf [2] http://josemigueltorres.net/index.php/ienumerableiobservable-duality/ [3] https://channel9.msdn.com/Shows/Going+Deep/Expert-to-Expert-Brian-Beckman-and-Erik-Meijer-Inside-the-NET-Reactive-Framework-Rx
Re: Duals or ranges and reactive D
On Thursday, 27 February 2014 at 12:41:14 UTC, Szymon Gatner wrote: C#'s IObservable/IObserver made me think how would a dual Topic should of course be: Duals OF ranges and reactive D
Re: Typed GC
Having precise GC in D eventually would be cool. Not having to worry about false pointers is always good.
Re: Minor std.stdio.File.ByLine rant
On Wed, 26 Feb 2014 18:44:10 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: First of all, the way ByLine works is kinda tricky, even in the previous releases. The underlying cause is that at least on Posix, the underlying C feof() call doesn't actually tell you whether you're really at EOF until you try to read something from the file descriptor. This is not a posix problem, it's a general stream problem. A stream is not at EOF until the write end is closed. Until then, you cannot know whether it's empty until you read and don't get anything back. Even if a primitive existed that allowed you to tell whether the write end was closed, you can race this against the other process closing it's write end. I think the correct solution is to block on the first front call. We may be able to do this without storing an additional variable. -Steve
Re: A Proposal to Add 2D Graphics Rendering and Display to C++
On Wednesday, 26 February 2014 at 16:40:59 UTC, NA wrote: This is an updated document and is quite interesting. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3888.pdf NA Don't we already have it? Called gtkD. Steve
Re: Surprised by hashes of arrays of arrays
thedeemon wrote: On Thursday, 27 February 2014 at 10:12:46 UTC, Jens Mueller wrote: As you may conclude from this post I find this behavior odd. I expect a hash implementation to follow indirections by calling the hashing functions recursively. How shall it work with cycles in object graphs? That's probably the rational behind the implementation. Probably also the reason why Tuple and VariantN implement no toHash, i.e., it is impossible to provide an efficient implementation for toHash for some generic types. But the consequences are rather dramatic because whenever I need hashing for a type (with indirections but no cycles are created at runtime) I must implement my own types because generic ones cannot provide it. It may be useful to provide a generic hash function for these cases in Phobos. Jens
Safe Navigation Operator “?.” for D2 ?
Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ?
Range proposals from Eric Niebler
Eric Niebler did a very interesting discussion targeting Range proposals for C++17. I think it would be great inspiration for future improvements on D ranges: The shortcomings of classical C++ (begin, end) ranges: http://ericniebler.com/2014/02/16/delimited-ranges/ The shortcomings of infinite ranges represented by (begin, end) ranges: http://ericniebler.com/2014/02/18/infinite-ranges/ Fixing ranges by allowing begin type to be different from end type, allowing Sentinel Ranges: http://ericniebler.com/2014/02/21/introducing-iterables/ Making this new Range (called by the author as Iterable) capable of dealing with infinite ranges: http://ericniebler.com/2014/02/27/ranges-infinity-and-beyond/ How this discussion touches D ranges design decisions?
Re: Typed GC
Would be so nice if we finally fix issue 12256 (https://d.puremagic.com/issues/show_bug.cgi?id=12256). I hate it...
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I was just thinking to create this topic but you did first, haha. I like that, to me +1 for implement.
Re: Minor std.stdio.File.ByLine rant
On Thu, Feb 27, 2014 at 07:55:59AM -0500, Steven Schveighoffer wrote: On Wed, 26 Feb 2014 18:44:10 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: First of all, the way ByLine works is kinda tricky, even in the previous releases. The underlying cause is that at least on Posix, the underlying C feof() call doesn't actually tell you whether you're really at EOF until you try to read something from the file descriptor. This is not a posix problem, it's a general stream problem. A stream is not at EOF until the write end is closed. Until then, you cannot know whether it's empty until you read and don't get anything back. Even if a primitive existed that allowed you to tell whether the write end was closed, you can race this against the other process closing it's write end. I think the correct solution is to block on the first front call. We may be able to do this without storing an additional variable. [...] Unfortunately, you can't. Since Phobos can't know whether the file (which may be a network socket, say) is at EOF without first blocking on read, it won't be able to return the correct value from .empty, and according to the range API, it's invalid to access .front unless .empty returns false. So this solution doesn't work. :-( T -- All men are mortal. Socrates is mortal. Therefore all men are Socrates.
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thursday, 27 February 2014 at 10:27:41 UTC, Timothee Cour wrote: A1) Google's Dart (https://www.dartlang.org) looks like a very promising replacement for javascript. It can compile to javascript to ensure portability (but chromium runs it natively) but the language itself reminds more of D to a surprising extent. Dart language has features such as: static typing (but can also have dynamic typing, akin to std.variant, with better support/syntax than D) ahead of time compilation unicode support built in serialization/deserialization via json annotations mixins (used to emulate multiple inheritance) generics vector/AA litterals alias (called typedef in dart), is, assert try/catch/finally operator overloading properties (same parenthesis-less caller syntax as in D) delegates (called closures) nesting functions, 1st class functions, lambda = syntax DDOC (called dartdoc) D-like syntax and nesting comments, introspection (runtime only AFAIK) A2) Also features that would be nice to have in D or were better designed than in D: * cascade operations: they perform a series of operations on the members of a single object: foo.bar(1)..baz(3) equivalent to: foo.bar(1) foo.baz(3) * better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. * named constructors * distinguish integer divide (~/) vs divide (/), so that 5/2=2, 5~/2=2 * shorthand function declaration with = (used not just for lambdas) * for (var x in collection) //better syntax than foreach(var;collection) * better syntax for optional positional arguments: void fun(int x, [int y, int z=3]){...} Thinking of which, this would actually solve a long standing problem in D, that of specifying optional parameters AFTER a variadic template: void fun(T...)(T args, [string file=__FILE__,int line=__LINE__]){...} * export for libraries * async/wait etc * great IDE/debugger/package manager/static analyzer also the following which I've previously proposed adding to D: * string interpolation $variableName (or ${expression}) assert('foo. ${s.toUpperCase()} bar' == 'foo. STRING INTERPOLATION bar'); * optional named parameters arguments (with simplest possible syntax) * import all except specified symbols: import 'package:lib2/lib2.dart' hide foo; // Import all names EXCEPT foo. A3) And then some design decisions which wouldn't work for D: everything is an object, no struct (just class), VM, etc. A4) there were may previous threads regarding using D on the web via compiling to javascript. In light of this it would seem a lot easier to compile D to dart. I've hear that Microsoft's equivalent so-called TypeScript was more successfully than Google's one, more people like much more TypeScript syntax and features, like I do.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I like it. At my previous job, I extended std.json with an array index operator just to end up replacing it with a variadic getter to get around the problem of incomplete paths. Like that, there are some ways to get around this sort of issue, but I wouldn't complain about having it right out of the box. Perhaps there should also be a ?[] operator. foo?[a]?[0]?[llama]
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Wish I could locate bearophile's post on the topic, sadly ?. isn't easy to search for.
Re: Differences between D2 and TDPL wiki page
On 24/02/2014 22:26, Brad Anderson wrote: I threw this together from an old post by Jonathan. http://wiki.dlang.org/Differences_With_TDPL People are always asking about what has changed since TDPL was released and I think it'd be good to have a single resource we can point people at. The items still need to be verified (Jonathan's post was 2 years ago) and I haven't done anything but wikified the post a tiny bit but it's a start at least. Any help assembling this page would be welcome. Great idea. I added some links for the subsections, and added one for the new alias syntax.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? D doesn't need this, you can implement monadic null checking in the library: http://forum.dlang.org/post/kcrqyvddilteyhyyg...@forum.dlang.org There's no need for a special operator for this. See the other posts in that thread for more information. Robert
Re: Minor std.stdio.File.ByLine rant
Are the peek routines standard? I'm on my phone so I can't easily check right now. Barring that, there's an ioctl call that can tell whether data is available, though I'm not sure offhand what the result would be for a file if you haven't read anything yet.
Re: Manual Memory Management Example for dlang.org Docs (Code Review)
On Wednesday, 26 February 2014 at 15:00:13 UTC, Dicebot wrote: On Wednesday, 26 February 2014 at 04:43:30 UTC, Mike wrote: Please review this (http://dpaste.dzfl.pl/2377217c7870) instead. throw new Exception(Out of memory); I don't think it is a good thing to do. Of course GC is likely to have some memory left in hs internal pools but in general once you hit out-of-memory state last thing you want is not allocate even more. For certain standard errors, the proper approach is probably to call the appropriate handler in core.exception.
Re: Minor std.stdio.File.ByLine rant
On Thu, 27 Feb 2014 10:04:47 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: On Thu, Feb 27, 2014 at 07:55:59AM -0500, Steven Schveighoffer wrote: On Wed, 26 Feb 2014 18:44:10 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: First of all, the way ByLine works is kinda tricky, even in the previous releases. The underlying cause is that at least on Posix, the underlying C feof() call doesn't actually tell you whether you're really at EOF until you try to read something from the file descriptor. This is not a posix problem, it's a general stream problem. A stream is not at EOF until the write end is closed. Until then, you cannot know whether it's empty until you read and don't get anything back. Even if a primitive existed that allowed you to tell whether the write end was closed, you can race this against the other process closing it's write end. I think the correct solution is to block on the first front call. We may be able to do this without storing an additional variable. [...] Unfortunately, you can't. Since Phobos can't know whether the file (which may be a network socket, say) is at EOF without first blocking on read, it won't be able to return the correct value from .empty, and according to the range API, it's invalid to access .front unless .empty returns false. So this solution doesn't work. :-( Yes, you are right! Thinking about it, the only correct solution is to do what it already does -- establish the first line on construction. empty cannot depend on front, and doing something different on the first empty vs. every other one makes the range bloated and confusing. The issue really is, to treat the construction and popFront as blocking. Streams are a tricky business indeed. I think your solution is the only valid one. Unfortunate that you have to do this. An interesting general solution is to use a delegate to generate the range, giving an easy one-line construction without having to make a wrapper range that lazily constructs on empty, but just using a delegate name does not call it. I did come up with this: import std.stdio; import std.range; void foo(R)(R r) { static if(isInputRange!R) { alias _r = r; } else // if is no-arg delegate and returns input range (too lazy to figure this out :) { auto _r(){return r();} } foreach(x; _r) { writeln(x); } } void main() { foo(() = stdin.byLine); foo([1,2,3]); } The static if at the beginning is awkward, but just allows the rest of the code to be identical whether you call with a delegate or a range. -Steve
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence I don't need D.
Re: Minor std.stdio.File.ByLine rant
On Thu, 27 Feb 2014 11:22:45 -0500, Sean Kelly s...@invisibleduck.org wrote: Are the peek routines standard? I'm on my phone so I can't easily check right now. Barring that, there's an ioctl call that can tell whether data is available, though I'm not sure offhand what the result would be for a file if you haven't read anything yet. Peek doesn't help. You can't, in a non-blocking way, tell if input will be forthcoming without actually receiving the input. -Steve
Re: Differences between D2 and TDPL wiki page
On Thursday, 27 February 2014 at 15:56:48 UTC, Nick Treleaven wrote: On 24/02/2014 22:26, Brad Anderson wrote: I threw this together from an old post by Jonathan. http://wiki.dlang.org/Differences_With_TDPL People are always asking about what has changed since TDPL was released and I think it'd be good to have a single resource we can point people at. The items still need to be verified (Jonathan's post was 2 years ago) and I haven't done anything but wikified the post a tiny bit but it's a start at least. Any help assembling this page would be welcome. Great idea. I added some links for the subsections, and added one for the new alias syntax. Great! Thanks. Linking to David Nadlinger's purity article was a good idea.
Re: Range proposals from Eric Niebler
On Thursday, 27 February 2014 at 14:46:25 UTC, Alessandro Stamatto wrote: Eric Niebler did a very interesting discussion targeting Range proposals for C++17. I think it would be great inspiration for future improvements on D ranges: The shortcomings of classical C++ (begin, end) ranges: http://ericniebler.com/2014/02/16/delimited-ranges/ The shortcomings of infinite ranges represented by (begin, end) ranges: http://ericniebler.com/2014/02/18/infinite-ranges/ Fixing ranges by allowing begin type to be different from end type, allowing Sentinel Ranges: http://ericniebler.com/2014/02/21/introducing-iterables/ Making this new Range (called by the author as Iterable) capable of dealing with infinite ranges: http://ericniebler.com/2014/02/27/ranges-infinity-and-beyond/ How this discussion touches D ranges design decisions? Reddit discussions on these are interesting too. Eric talks about why he doesn't like D's ranges a bit. http://www.reddit.com/r/cpp/comments/1y60bk/range_concepts_part_1_of_4_delimited_ranges/ http://www.reddit.com/r/cpp/comments/1yc03d/range_concepts_part_2_of_4_infinite_ranges/ http://www.reddit.com/r/cpp/comments/1yk89k/range_concepts_part_3_of_4_introducing_iterables/ http://www.reddit.com/r/cpp/comments/1z37m9/range_concepts_part_4_of_4_to_infinity_and_beyond/ (no comments yet, just posted)
Re: Dart and D: features that could be used in D, D-dart for web programming
On 2/27/14, 7:19 AM, Timothee Cour wrote: And then some design decisions which wouldn't work for D: everything is an object, no struct (just class), VM, etc. In a programming language you can make everything look like an object but implement it as a primitive type. So that could work in D (but I think nobody would like it, although it can make the language much simpler).
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 16:32:18 UTC, Chris Williams wrote: On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence I don't need D. I'm not sure I understand your point. I'm simply stating that in D, right now, without adding any complexity to the language, you can do: just(myObject).method1().method2().method3() Which would have the same effect as: myObject?.method1()?.method2()?.method3() in C#. Is a special operator really needed for this? Robert
Re: Dart and D: features that could be used in D, D-dart for web programming
Am 27.02.2014 17:48, schrieb Ary Borenszweig: On 2/27/14, 7:19 AM, Timothee Cour wrote: And then some design decisions which wouldn't work for D: everything is an object, no struct (just class), VM, etc. In a programming language you can make everything look like an object but implement it as a primitive type. So that could work in D (but I think nobody would like it, although it can make the language much simpler). Yep, that is how for example .NET, Eiffel, Smalltalk, Lisp and many other languages work.
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thursday, 27 February 2014 at 10:27:41 UTC, Timothee Cour wrote: A1) Google's Dart (https://www.dartlang.org) looks like a very promising replacement for javascript. It can compile to javascript to ensure portability (but chromium runs it natively) No, neither Chromium nor even Chrome run it natively. Only Dartium which is a separate browser. * cascade operations: they perform a series of operations on the members of a single object: foo.bar(1)..baz(3) equivalent to: foo.bar(1) foo.baz(3) In D we can use with(foo) { bar(1); bar(3); } Pretty close. Dart looks like a very nice language for front-end web development indeed. If I was doing web-dev I would choose vibe.d + Dart combo. Some features like its constructors and short form of methods I would love to see in D too. As for compiling D to Dart I'm not sure that's feasible. You'll have to chop off lower half of it.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 17:02:02 UTC, Robert Clipsham wrote: On Thursday, 27 February 2014 at 16:32:18 UTC, Chris Williams wrote: On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence I don't need D. I'm not sure I understand your point. I'm simply stating that in D, right now, without adding any complexity to the language, you can do: just(myObject).method1().method2().method3() You can't do that. You're reducing your example code - which was several dozen lines and only applied to objects for which you had added the special handler code - to the end result. After you've laid the framework for doing this, yes, you can do it. But there's a bunch of work that has to go into it before you get to that point. (Also, your implementation is far less efficient than something which rewrites the code as a bunch of nested if (not null) checks.) If your argument was that there are more important things for the compiler team to work on, or that the syntax of the language was already large enough without adding more things for people to remember, then sure. But if we lived under the premise that there's no reason to add features to a compiler that abstract code down into a simpler syntax, then we'd have never developed variables or functions.
Re: Minor std.stdio.File.ByLine rant
On Thu, Feb 27, 2014 at 11:26:42AM -0500, Steven Schveighoffer wrote: On Thu, 27 Feb 2014 10:04:47 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: On Thu, Feb 27, 2014 at 07:55:59AM -0500, Steven Schveighoffer wrote: On Wed, 26 Feb 2014 18:44:10 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: First of all, the way ByLine works is kinda tricky, even in the previous releases. The underlying cause is that at least on Posix, the underlying C feof() call doesn't actually tell you whether you're really at EOF until you try to read something from the file descriptor. This is not a posix problem, it's a general stream problem. A stream is not at EOF until the write end is closed. Until then, you cannot know whether it's empty until you read and don't get anything back. Even if a primitive existed that allowed you to tell whether the write end was closed, you can race this against the other process closing it's write end. I think the correct solution is to block on the first front call. We may be able to do this without storing an additional variable. [...] Unfortunately, you can't. Since Phobos can't know whether the file (which may be a network socket, say) is at EOF without first blocking on read, it won't be able to return the correct value from .empty, and according to the range API, it's invalid to access .front unless .empty returns false. So this solution doesn't work. :-( Yes, you are right! Thinking about it, the only correct solution is to do what it already does -- establish the first line on construction. empty cannot depend on front, and doing something different on the first empty vs. every other one makes the range bloated and confusing. The issue really is, to treat the construction and popFront as blocking. Streams are a tricky business indeed. I think your solution is the only valid one. Unfortunate that you have to do this. An interesting general solution is to use a delegate to generate the range, giving an easy one-line construction without having to make a wrapper range that lazily constructs on empty, but just using a delegate name does not call it. I did come up with this: Actually, now that I think about it, can't we just make ByLine lazily constructed? It's already a wrapper around ByLineImpl anyway (since it's being refcounted), so why not just make the wrapper create ByLineImpl only when you actually attempt to use it? That would solve the problem: you can call ByLine but it won't block until ByLineImpl is actually created, which is the first time you call ByLine.empty. T -- Don't drink and derive. Alcohol and algebra don't mix.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 17:25:22 UTC, Chris Williams wrote: just(myObject).method1().method2().method3() You can't do that. You're reducing your example code - which was several dozen lines and only applied to objects for which you had added the special handler code - to the end result. After you've laid the framework for doing this, yes, you can do it. But there's a bunch of work that has to go into it before you get to that point. (Also, your implementation is far less efficient than something which rewrites the code as a bunch of nested if (not null) checks.) If your argument was that there are more important things for the compiler team to work on, or that the syntax of the language was already large enough without adding more things for people to remember, then sure. But if we lived under the premise that there's no reason to add features to a compiler that abstract code down into a simpler syntax, then we'd have never developed variables or functions. Most of the code I posted would be hidden away in a library, and will work with any type with methods or UDFs. I'll admit it is incomplete (no implicit casting to the original return types for example), but it is possible. End user code would be exactly as that line is. I haven't checked the assembly, but given the simplicity of the generated code I'm fairly certain it will optimise to the same as the if/else chain (feel free to prove me wrong :)). Robert
Re: Dart and D: features that could be used in D, D-dart for web programming
Am 27.02.2014 18:29, schrieb thedeemon: On Thursday, 27 February 2014 at 10:27:41 UTC, Timothee Cour wrote: A1) Google's Dart (https://www.dartlang.org) looks like a very promising replacement for javascript. It can compile to javascript to ensure portability (but chromium runs it natively) No, neither Chromium nor even Chrome run it natively. Only Dartium which is a separate browser. From what I understood on Dart talks last Google IO, work was planned to have V8 and Dart VM play together inside Chrome. Personally, I think unless Google pushes the language fro ChromeOS or Android, it will hardly get any real market size. Like it or not, JavaScript is good enough. On my field of work, it doesn't matter how many cool languages I know, we are usually bound by what the whole team is comfortable using, what the boss allows for and the technologies that are requested by the customers themselves. -- Paulo
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thursday, 27 February 2014 at 18:20:20 UTC, Paulo Pinto wrote: clip Like it or not, JavaScript is good enough. Really? I've been stuck for the past week or so trying to put together a browser based UI using JavaScript + HTML for a work related project. It has been a painful experience. In fairness to JavaScript, I didn't know the language very well coming in, but still I've found working in this setting rather frustrating. If the future of applications is really client-server based applications, where the client is basically a VM (if we consider the browser a VM of sorts) surely there is room for a better development model than this HTML + Javascript mongrel.
Re: Minor std.stdio.File.ByLine rant
On Thu, 27 Feb 2014 12:32:44 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: Actually, now that I think about it, can't we just make ByLine lazily constructed? It's already a wrapper around ByLineImpl anyway (since it's being refcounted), so why not just make the wrapper create ByLineImpl only when you actually attempt to use it? That would solve the problem: you can call ByLine but it won't block until ByLineImpl is actually created, which is the first time you call ByLine.empty. I think this isn't any different than making ByLine.empty cache the first line. My solution is basically this: struct LazyConstructedRange(R) { R r; bool isConstructed = false; R delegate() _ctor; this(R delegate() ctor) {_ctor = ctor;} ref R get() { if(!isConstructed) { r = _ctor(); isConstructed = true;} return r; } alias get this; } Basically, we're not constructing on first call to empty, but first call to *anything*. Actually, this kind of a solution would be better that what I came up with, because the object itself is a range instead of a delegate (satisfies, for instance, isInputRange and isIterable, whereas the delegate does not), and you don't need the static if like I wrote. Any additional usage of the delegate in my original solution creates a copy of the range, but the above would only construct it once. -Steve
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thursday, 27 February 2014 at 18:37:51 UTC, Craig Dillabaugh wrote: On Thursday, 27 February 2014 at 18:20:20 UTC, Paulo Pinto wrote: clip Like it or not, JavaScript is good enough. Really? I've been stuck for the past week or so trying to put together a browser based UI using JavaScript + HTML for a work related project. It has been a painful experience. In fairness to JavaScript, I didn't know the language very well coming in, but still I've found working in this setting rather frustrating. If the future of applications is really client-server based applications, where the client is basically a VM (if we consider the browser a VM of sorts) surely there is room for a better development model than this HTML + Javascript mongrel. I developed 99% of the JavaScript part of an application for a year, and I have extensive JavaScript knowledge. After all that, I wrote this. https://w0rp.com/blog/post/javascript-sucks/
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thursday, 27 February 2014 at 19:54:04 UTC, w0rp wrote: On Thursday, 27 February 2014 at 18:37:51 UTC, Craig Dillabaugh wrote: On Thursday, 27 February 2014 at 18:20:20 UTC, Paulo Pinto wrote: clip Like it or not, JavaScript is good enough. Really? I've been stuck for the past week or so trying to put together a browser based UI using JavaScript + HTML for a work related project. It has been a painful experience. In fairness to JavaScript, I didn't know the language very well coming in, but still I've found working in this setting rather frustrating. If the future of applications is really client-server based applications, where the client is basically a VM (if we consider the browser a VM of sorts) surely there is room for a better development model than this HTML + Javascript mongrel. I developed 99% of the JavaScript part of an application for a year, and I have extensive JavaScript knowledge. After all that, I wrote this. https://w0rp.com/blog/post/javascript-sucks/ Great. Now I have something to go an read for laughs whenever I feel my blood-pressure exceeding safe limits :o)
Re: Dart and D: features that could be used in D, D-dart for web programming
On 27.2.2014 20:54, w0rp wrote: I developed 99% of the JavaScript part of an application for a year, and I have extensive JavaScript knowledge. After all that, I wrote this. https://w0rp.com/blog/post/javascript-sucks/ I think it was someone on Slashdot who posted this wonderful comment: JavaScript is a crap language that can't be fixed. If they ever add an honest garbage collector to the base language then most programs will delete themselves upon execution.
Re: Dart and D: features that could be used in D, D-dart for web programming
Am 27.02.2014 19:37, schrieb Craig Dillabaugh: On Thursday, 27 February 2014 at 18:20:20 UTC, Paulo Pinto wrote: clip Like it or not, JavaScript is good enough. Really? I've been stuck for the past week or so trying to put together a browser based UI using JavaScript + HTML for a work related project. It has been a painful experience. In fairness to JavaScript, I didn't know the language very well coming in, but still I've found working in this setting rather frustrating. If the future of applications is really client-server based applications, where the client is basically a VM (if we consider the browser a VM of sorts) surely there is room for a better development model than this HTML + Javascript mongrel. I didn't say I like it that much, just that it is good enough for what enterprise applications, my field of work, are about. So unless the browser vendors start supporting other languages, our customers will only ask for JavaScript, because it is easier to find guys when doing maintenance support. They don't care about Dart, TypeScript, CoffeScript, or whatever might be the flavour of the month, because it increases their problems to find people and their internal teams usually don't know those languages anyway. The same to any other language out there. Usually when I get to work on a cool language at the enterprise level, it is no longer cool, or it was brought in because some startup belonging to someone close to the CTO managed to sneak it in. The is of course my enterprise world, yours may vary. -- Paulo
Re: Dart and D: features that could be used in D, D-dart for web programming
On 2/27/2014 2:19 AM, Timothee Cour wrote: * optional named parameters arguments (with simplest possible syntax) This comes up now and then. The problem with it is it makes function overloading a near impossibility to untangle.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining . operation is a code smell to begin with, and having everything nullable is dubious as well. This is fixing a problem that shouldn't exists to begin with.
Re: Dart and D: features that could be used in D, D-dart for web programming
On 2/27/2014 2:19 AM, Timothee Cour wrote: * import all except specified symbols: import 'package:lib2/lib2.dart' hide foo; // Import all names EXCEPT foo. As a general rule, negation features are frequently misunderstood, our brains tend to just not see the negation. One should positively import names, not negatively not import some. And there's the maintenance problem - what did the importer mean to do when the imported module adds a 'bar' name?
'dmd -color' flag to colorize error/warning messages
after the success of '-vcolumns', I suggest introducing a flag for colorized error messages, see enhancement proposal: https://d.puremagic.com/issues/show_bug.cgi?id=12273
Re: Safe Navigation Operator “?.” for D2 ?
On 2014-02-27 14:27, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I like it. -- /Jacob Carlborg
Re: Dart and D: features that could be used in D, D-dart for web programming
On 2/27/2014 2:19 AM, Timothee Cour wrote: * cascade operations: they perform a series of operations on the members of a single object: foo.bar(1)..baz(3) equivalent to: foo.bar(1) foo.baz(3) D has ranges and algorithms to conveniently chain operations. * better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. D doesn't allow non-trivial default struct constructors for some good reasons, which are a long discussion we've had many times. These reasons don't apply to javascript. * named constructors I don't see the point of such over using the factory method idiom. * distinguish integer divide (~/) vs divide (/), so that 5/2=2, 5~/2=2 Such are needed so rarely - in C they are done with the modf function, and I've never seen modf used in the wild. * shorthand function declaration with = (used not just for lambdas) tomayto, tomahto :-) * for (var x in collection) //better syntax than foreach(var;collection) tomayto, tomahto * better syntax for optional positional arguments: void fun(int x, [int y, int z=3]){...} Thinking of which, this would actually solve a long standing problem in D, that of specifying optional parameters AFTER a variadic template: void fun(T...)(T args, [string file=__FILE__,int line=__LINE__]){...} Not sure what that is. * export for libraries What does that mean? * async/wait etc Those are a great idea, and we need to do them at some point.
Accelerating domain-specific languages in CTFE
Projects such as Pegged and our CTFE regex engine often serve as poster-children of what is possible in D and many agree they are among the more important projects. I was thinking, after std.lexer is accepted, we have a stable interface, but no matter how great the code is and even if it beats the already superlative DMD lexer, it will _NOT_ be fast during CTFE. It is also often stressed in this very forum that it's paramount for a lexer to be beyond fast. For the above reasons, I propose that the compiler would offer an interface to retrieve an already lexed buffer, similar in concept to the existing token string q{...} Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. By definition they contain only valid tokens... the compiler would only have to create a range compatible with std.lexer...
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining . operation is a code smell to begin with, and having everything nullable is dubious as well. This is fixing a problem that shouldn't exists to begin with. +1 Please no.
Re: Cumulative
On 2014-02-26 16:05:19 +, Steve Teale said: On Wednesday, 26 February 2014 at 13:30:15 UTC, Leandro Motta Barros wrote: Hello, I'm coming late to the discussion, but I believe that you can use the following idiom to achieve the same results in a different way: Yes we went through that, if you go back a page you'll find a post I did that makes the thing work better using a class variable in the base class that is an array of delegates. That way you don't have to do super, super, super back to root, you just have to iterate over the delegates until you find one that accepts the command. It does just what I wanted to do in the first place without compiler assistance ;=). Steve Actually, D has the ability to walk the object hierarchy at compile time, and generate a function call containing all the super classes's handleCommands. You could also even tag them with an attribute structure to list which command #'s they accept to be able to generate a switch, or bunch of if's to avoid function calls. -S.
Re: Safe Navigation Operator “?.” for D2 ?
On Thu, 27 Feb 2014 16:20:47 -0500, Peter Alexander peter.alexander...@gmail.com wrote: On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining . operation is a code smell to begin with, and having everything nullable is dubious as well. This is fixing a problem that shouldn't exists to begin with. +1 Please no. Yes. Taken from the example: parent?.child?.child?.child Given no context, this may make sense. But with context, likely you have verified beforehand the answers to some, if not all, of these question marks. However, even with that, I can't help but expect there should be a way to do this in D without changing the language. Something like: ifnull(parent).child.child.child -Steve
Re: Safe Navigation Operator “?.” for D2 ?
On Thu, 27 Feb 2014 16:45:11 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: ifnull(parent).child.child.child brain fart... ifvalid(parent).child.child.child -Steve
Re: Surprised by hashes of arrays of arrays
On 2014-02-27 10:11:53 +, Jens Mueller said: Dear list, I stumbled over odd behavior which took quite some time of debugging. Sharing my results may help find a solution or just make others aware and reduce their debugging time. To illustrate consider the code: auto array1 = [ [1, 2], [3, 4] ]; auto array2 = array1.dup; array2[0] = array2[0].dup; Does either hash(array1) == hash(array2) hold or hash(array1) != hash(array2) where hash is defined as auto hash = (typeid(array1).getHash); ? So I may be totally off here (please tell me), but it turns out that that both arrays have different hashes due to the way hashing is implemented. This, e.g., implies that equal arrays may be hashed to different values. Hence when you are using them as keys in an associative array results may be surprising. Note that I can make the problem more difficult to spot by using a struct that uses pointers or an array internally which is hidden by encapsulation. I find the behavior non-obvious but maybe there is reason. The current implementation considers only the direct contents of the struct's memory (the memory starting at array.ptr to array.length * size(array[0]) in case of dynamic arrays) and does *not* follow indirections (e.g. via pointers). This implies that a hash can be computed without considering all memory occupied by a value. In my current mental model of hashing I assumed that all bytes should be read by default. As you may conclude from this post I find this behavior odd. I expect a hash implementation to follow indirections by calling the hashing functions recursively. It looks to me as a case where the default is badly designed/implemented. Jens You should get the same answer if in both cases they were static arrays, but I believe array1.dup returns a slice to a heap allocated array instead of the statically-sized array you originally had. -S.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining . operation is a code smell to begin with ... No, it's not a code smell at all and most of this religious OOP/OOD bullshit has been debunked by now.
Re: Safe Navigation Operator “?.” for D2 ?
On Thursday, 27 February 2014 at 21:49:20 UTC, Steven Schveighoffer wrote: On Thu, 27 Feb 2014 16:45:11 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: ifnull(parent).child.child.child brain fart... ifvalid(parent).child.child.child -Steve What you want is a maybe monad, and we can do that with D metaprogramming capabilities already.
Re: Surprised by hashes of arrays of arrays
Shammah Chancellor wrote: On 2014-02-27 10:11:53 +, Jens Mueller said: Dear list, I stumbled over odd behavior which took quite some time of debugging. Sharing my results may help find a solution or just make others aware and reduce their debugging time. To illustrate consider the code: auto array1 = [ [1, 2], [3, 4] ]; auto array2 = array1.dup; array2[0] = array2[0].dup; Does either hash(array1) == hash(array2) hold or hash(array1) != hash(array2) where hash is defined as auto hash = (typeid(array1).getHash); ? So I may be totally off here (please tell me), but it turns out that that both arrays have different hashes due to the way hashing is implemented. This, e.g., implies that equal arrays may be hashed to different values. Hence when you are using them as keys in an associative array results may be surprising. Note that I can make the problem more difficult to spot by using a struct that uses pointers or an array internally which is hidden by encapsulation. I find the behavior non-obvious but maybe there is reason. The current implementation considers only the direct contents of the struct's memory (the memory starting at array.ptr to array.length * size(array[0]) in case of dynamic arrays) and does *not* follow indirections (e.g. via pointers). This implies that a hash can be computed without considering all memory occupied by a value. In my current mental model of hashing I assumed that all bytes should be read by default. As you may conclude from this post I find this behavior odd. I expect a hash implementation to follow indirections by calling the hashing functions recursively. It looks to me as a case where the default is badly designed/implemented. Jens You should get the same answer if in both cases they were static arrays, but I believe array1.dup returns a slice to a heap allocated array instead of the statically-sized array you originally had. The original array is a dynamic array. But interesting that it is obvious that the hashes are not the same. This was really surprising to me, probably still is. Jens
Re: Dart and D: features that could be used in D, D-dart for web programming
Walter Bright: * optional named parameters arguments (with simplest possible syntax) This comes up now and then. The problem with it is it makes function overloading a near impossibility to untangle. Do you have an example of the problem? * better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. D doesn't allow non-trivial default struct constructors for some good reasons, which are a long discussion we've had many times. These reasons don't apply to javascript. The idea of having some syntax like this is nice, it reduces the poilerplace code, making the code less noisy and reducing the probability of the currenty common bugs caused by having fields and arguments with equal or similar names: class Foo { int x; this(this.x) {} void inc(int x) { this.x += x; } } * shorthand function declaration with = (used not just for lambdas) tomayto, tomahto :-) There is an enhancement request on this in Bugzilla. A shorter syntax for simple functions is handy, because one-line functions have become very common in D. Bye, bearophile
Re: http://www.rust-ci.org/
Well, it sounds like one of two issues: 1) you're mail client is sending directly to the mx hosts for puremagic.com mails (ie, mail1 or mail2) and never retrying to send. Neither is a good idea. or 2) your mail transport agent is never retrying. I suspect the former more than the latter, though that'd be highly unusual for a mail client to do. Either way, the 'error' message there is fully descriptive. You need to re-try the send later. This is standard greylisting behavior which both mail servers for puremagic.com use. On 2/27/14, 1:47 AM, Piotr Szturmaj wrote: On 2014-02-26 05:50, Brad Roberts wrote: Later, Brad Now I've received your email but it seems I can't reply :) Instead, I'm receiving mail delivery error: The mail system bra...@puremagic.com: host mail2.puremagic.com[99.179.5.161] said: 451 4.7.1 Please try again later (TEMPFAIL) (in reply to RCPT TO command)
Re: Testing some singleton implementations
On Friday, 7 February 2014 at 20:09:29 UTC, Stanislav Blinov wrote: There's a lot more to these singletons than meets the eye. - It would seem that such usage of raw MemoryOrder in AtomicSingleton would be wrong (e.g. return to acq/rel is in order, which should not pose any performance issues on X86, as Sean mentioned). - The instance references should be qualified shared. This needs more serious review, even if only for academic purposes. I'll see what I can come up with :) In the meantime, if anyone has anything to add to the list, please chime in! Hi Martin, Sean, Stanislav et al I would quite like to code-review atomics.d and maybe think about improving the documentation and adding a few comments, especially for the purposes of knowledge capture in this sticky field. Would that be ok, in principle? There are a few rough edges here and there _in my very unworthy opinion_, and the odd bit that doesn't look quite right somehow especially in the x64 branch. If I could even find the odd bug then that would be good. Or rather bad. A big amount of work has clearly gone into this module. So, many beers to Sean and others who put their time into it. Research can be quite a pig too on a project of this kind, I would imagine. There is quite a list of things that I'm currently unclear about when I read through the D, and this might mean me whimpering for help occasionally..? Best, Cecil.
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thu, Feb 27, 2014 at 12:56 PM, Walter Bright newshou...@digitalmars.comwrote: On 2/27/2014 2:19 AM, Timothee Cour wrote: * cascade operations: they perform a series of operations on the members of a single object: foo.bar(1)..baz(3) equivalent to: foo.bar(1) foo.baz(3) D has ranges and algorithms to conveniently chain operations. cascade != chaining: cascade: a.f1..f2..f3 = a.f1 a.f2 a.f3 chaining: a.f1.f2.f3 = ((a.f1).f2).f3)
Re: Dart and D: features that could be used in D, D-dart for web programming
* better syntax for optional positional arguments: void fun(int x, [int y, int z=3]){...} Thinking of which, this would actually solve a long standing problem in D, that of specifying optional parameters AFTER a variadic template: void fun(T...)(T args, [string file=__FILE__,int line=__LINE__]){...} Not sure what that is. http://d.puremagic.com/issues/show_bug.cgi?id=8687 : Variadic templates do not work properly with default arguments * export for libraries What does that mean? http://wiki.dlang.org/DIP45
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thu, Feb 27, 2014 at 2:40 PM, bearophile bearophileh...@lycos.comwrote: Walter Bright: * optional named parameters arguments (with simplest possible syntax) This comes up now and then. The problem with it is it makes function overloading a near impossibility to untangle. Do you have an example of the problem? Not sure what the problem would be. We could apply the same rules as for template overloading, ie error when there's a potential ambiguity (or even disable overloading for functions with named parameter until details are ironed out). Many languages have this, for good reason (discussed, again, many times).
Re: Range proposals from Eric Niebler
Brad Anderson: Reddit discussions on these are interesting too. Eric talks about why he doesn't like D's ranges a bit. What are the downsides of D ranges he sees? Bye, bearophile
Re: Range proposals from Eric Niebler
On Friday, 28 February 2014 at 00:43:57 UTC, bearophile wrote: Brad Anderson: Reddit discussions on these are interesting too. Eric talks about why he doesn't like D's ranges a bit. What are the downsides of D ranges he sees? Here's what he wrote: http://www.reddit.com/r/cpp/comments/1y60bk/range_concepts_part_1_of_4_delimited_ranges/cfhvl65
Re: Dart and D: features that could be used in D, D-dart for web programming
We could kinda do named parameters today like this: ParameterTypeTuple!foo args; args.named_param = 3; foo(args); It would be nice if we could declare a variable inside a with(auto x = foo) like we can in if() too.
Re: Dart and D: features that could be used in D, D-dart for web programming
* better way to define default constructors: class Point { num x; num y; num z; // Syntactic sugar for setting z and x before the constructor body runs. Point(this.z, this.x){...} } This is more explicit and flexible than D's way for default struct constructors, which can only allow to set all fields in order, without skipping some, and doesn't allow to do anything else in the ctor. D doesn't allow non-trivial default struct constructors for some good reasons, which are a long discussion we've had many times. These reasons don't apply to javascript. I don't recall this syntax 'Point(this.z, this.x){...}' ever being discussed; can you please provide a link? * it avoids the following common bug: struct Point{int x;int y;} auto a=Point(1,2,3); //later on we add a field: struct Point{int x; int a; int y; } //woops! * less boilerplate / more DRY / more explicit: struct Point{ Foo x=32; Bar y; Baz z; this(this.y, this.z){} //instead of this(Bar y, Baz z){this.y=y;this.z=z;} } This is arguably a preferable syntax.
Re: Range proposals from Eric Niebler
On Thu, Feb 27, 2014 at 4:55 PM, Brad Anderson e...@gnuk.net wrote: On Friday, 28 February 2014 at 00:43:57 UTC, bearophile wrote: Brad Anderson: Reddit discussions on these are interesting too. Eric talks about why he doesn't like D's ranges a bit. What are the downsides of D ranges he sees? Here's what he wrote: http://www.reddit.com/r/cpp/comments/1y60bk/range_concepts_part_1_of_4_ delimited_ranges/cfhvl65 I remember we were discussing this last year: http://forum.dlang.org/thread/kd2qok$16e6$1...@digitalmars.com [The rfind challenge] Not sure what came out concretely.
Re: Range proposals from Eric Niebler
On 2/27/2014 4:55 PM, Brad Anderson wrote: On Friday, 28 February 2014 at 00:43:57 UTC, bearophile wrote: Brad Anderson: Reddit discussions on these are interesting too. Eric talks about why he doesn't like D's ranges a bit. What are the downsides of D ranges he sees? Here's what he wrote: http://www.reddit.com/r/cpp/comments/1y60bk/range_concepts_part_1_of_4_delimited_ranges/cfhvl65 Note that Andrei has added a reply to that.
Re: A Proposal to Add 2D Graphics Rendering and Display to C++
On Wednesday, 26 February 2014 at 17:10:01 UTC, Russel Winder wrote: On Wed, 2014-02-26 at 16:40 +, NA wrote: This is an updated document and is quite interesting. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3888.pdf https://groups.google.com/a/isocpp.org/forum/#! msg/std-proposals/IaaG316uPjo/9N4YsRYX4nkJ Is worth a look. It seems to favour Cairo as a starting point. I bet the D community could win a race with the C++ lot to implement it. D makes you much more productive. For any who don't know what Cairo does, the app I'm working on - COMPO - is pretty much a showcase for what it, and the associated text rendering library Pango, can do - britseyeview.com/compo/.
Old Machines and XP for Linux(not really a D topic)
I was in a discussion here recently about 64 bit and how much memory people had in their machines these days. A somewhat unrelated topic is that Microsoft are in the process of dumping XP. Now all those old desktop boxes with only 500k of memory will increasingly migrate in containers to Africa, like the discarded mountain bikes, and old banger cars. When they get here they have traditionally had XP installed, since that is readily available for free - legal or not. Microsoft might do itself a favour in the long term if instead of just dumping XP, it started from the Wine code, and made an XP lookalike Linux distro. That way, the old boxes would have an extended life, Microsoft would have goodwill from a lot of users, and would not have to spend a lot of money keeping the old OS, the spammers would be blocked in their process of taking over all those unprotected XP machines, and lots of young African girls and boys could learn to program in D ;=) Steve
Re: Cumulative
On Thursday, 27 February 2014 at 21:44:20 UTC, Shammah Chancellor wrote: On 2014-02-26 16:05:19 +, Steve Teale said: Actually, D has the ability to walk the object hierarchy at compile time, and generate a function call containing all the super classes's handleCommands. You could also even tag them with an attribute structure to list which command #'s they accept to be able to generate a switch, or bunch of if's to avoid function calls. -S. Yes, I'd been thinking about tagging them at least.
Re: Safe Navigation Operator “?.” for D2 ?
On Thu, 2014-02-27 at 20:49 +, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining . operation is a code smell to begin with, and having everything nullable is dubious as well. This is fixing a problem that shouldn't exists to begin with. From the responses, this is clearly an emotive issue, but chaining . operations and using fluent interfaces is only a code smell to those people who think it is a code smell. Many people think exactly the opposite and that not using chaining where is can be used is a code smell. Groovy has had safe dereferencing for a long time, as have other dynamic languages, C# is coming very late to this game. Any design decision for D needs to look wider than the C# debate, theoretical examples and philosophizing, to actual use in real situations by languages that have chosen to realize this idea. My experience from Groovy, which is relatively limited in that I am not involved in end-client applications only in maintaining and developing Groovy, GPars and Gant, indicates that it is a very helpful tool, analogous to the whole Maybe/Option stuff in pure functional languages. Groovy is now able to probe the issue of whether this operation is as useful/applicable in a statically compiled context as in a dynamic context since the @TypeChecked and @CompileStatic AST transforms allow Groovy to be a static language as Java, Scala, Ceylon, Kotlin are, as well as being a dynamic language as JRuby, Jython, Clojure are. No results as yet though as the experiments have not been explicitly tried. Thus there is no explicit data to reflect on. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Re: Dart and D: features that could be used in D, D-dart for web programming
On Thu, 2014-02-27 at 19:20 +0100, Paulo Pinto wrote: […] From what I understood on Dart talks last Google IO, work was planned to have V8 and Dart VM play together inside Chrome. Dartium is a build of Chromium with both, so this is very much the direction that is possible. Personally, I think unless Google pushes the language fro ChromeOS or Android, it will hardly get any real market size. Like it or not, JavaScript is good enough. On my field of work, it doesn't matter how many cool languages I know, we are usually bound by what the whole team is comfortable using, what the boss allows for and the technologies that are requested by the customers themselves. Dart has a JavaScript translation back end, so could have a role very much like CoffeeScript – which arguably hasn't been that successful given jQuery, Backbone, Ember, Angular, etc. Ceylon has both JVM and JavaScript back ends and is targetted at end-to-end single language working: Ceylon in the browser, Ceylon on the server. If some of the FUD and prejudice that is being put about by innovation haters in the Javaverse can be overcome, I think Ceylon could be a big player in the game of Web applications and services. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
GC for noobs
Hi, I am evaluating D for future projects and coming from C++ I find it really hard to understand semantics of destruction of GC-managed code. After many application-shutdown crashes caused by invalid order of class destructor calls I really think I need to change the way I am thinking about them (and resource management in general I suppose). My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. Adding destroy() calls in parent d-tors helped with some of crashes but I really hate this solution as I was virtually NEVER using 'delete' in C++. I feel like I should be doing things in D very differently than I am doing them in C++. I now think I should be using structs everywhere because I understand them but I do need reference semantics (ideally with unique ownership). Please point me to a literature for C++ programmer that has very little experience with GC/resource management, because at this point I really feel like GC should be easing things and working against me.
Re: GC for noobs
On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. Adding destroy() calls in parent d-tors helped with some of crashes but I really hate this solution as I was virtually NEVER using 'delete' in C++. Parent in the sense of an inheritance hierarchy or in the sense of a successor relation in a graph of objects? In the latter case the order of destruction is undefined (IMO), i.e. if you have class A { B someB; } where B is a class as well, than B might be already destroyed if A's destructor is run.
Re: GC for noobs
On Thursday, 27 February 2014 at 09:55:14 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. Adding destroy() calls in parent d-tors helped with some of crashes but I really hate this solution as I was virtually NEVER using 'delete' in C++. Spec says: -- The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Furthermore, the order in which the garbage collector calls destructors for unreference objects is not specified. This means that when the garbage collector calls a destructor for an object of a class that has members that are references to garbage collected objects, those references may no longer be valid. This means that destructors cannot reference sub objects. --
Re: GC for noobs
On Thursday, 27 February 2014 at 09:57:51 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:55:14 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 09:49:08 UTC, Szymon Gatner wrote: My crashes (still have them and can't track all as debugging D sucks) are caused by the fact that d-tor of parent object can be called before child d-tors. Adding destroy() calls in parent d-tors helped with some of crashes but I really hate this solution as I was virtually NEVER using 'delete' in C++. Spec says: -- The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Furthermore, the order in which the garbage collector calls destructors for unreference objects is not specified. This means that when the garbage collector calls a destructor for an object of a class that has members that are references to garbage collected objects, those references may no longer be valid. This means that destructors cannot reference sub objects. -- Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory management environments would give more and not less guarantees. Anyway, I really need to learn how to design the code for CG and undefined d-tor calls. Any pointers would be welcome.
Switching from Java to D: Beginner questions, multiplatform issues, etc.
Though this post may seem long, my questions are indeed asked. I just kinda started typing and didn't stop; I guess this is both a question post and a vent post. Please bear with me. Hello, I'm a hobbyist programmer, and I'm tired of the way things are going. I'm looking for a change. I must admit, I've been pampered most of my programming life: I've consistently used higher-level languages, like Java (which I have been using as of late), that do all the work for you. But I find it's hard to quickly prototype and implement new ideas and to test new code because of that. Creating a solution to an otherwise simple task takes numerous new and extended classes and lots of time. There's always the option of choosing a dedicated external library or otherwise development environment to build off of a central idea, but I want to keep things simple and work with the core essentials and not resort to learning the ins and outs of another codebase. Sadly, Java's core essentials are absolutely humungous and hard to keep track of. If I feel the need to search for an alternative development environment just to get a more focused feature subset that may or may not already exist in part or in full in a language, I don't really think that language is right for me and what I want to accomplish, whatever that may be at the time. As an example, I would occasionally find myself making some code that does nearly the same thing as an already-implemented class in the JDK/JRE, simply because I forgot to do any research on the topic beforehand or I didn't think there was already a solution for my problem. Overall, using Java takes massive dedication for the language and a large, pre-defined, solidly-built goal, and I may not have some or all of the previous at any point in time while both fleshing out my ideas and working on already-established projects. When programming in Java, there is a large number of classes that are available for one to use, that are fully-featured and complete, and function extremely well for their intended purpose. However, the way Java is set up makes me feel like I have to twist and bend those classes into the idea I see in my head, instead of using them as a base like they're intended to be used. I could always start from scratch and build my classes how I want, using other classes only when necessary, but what's the point in that when there's already classes out there that do what I want, and probably more efficiently? Instead I dig through them until I find something that works how I want it to and may occasionally miss something that works better or fits my desires better because I simply didn't notice it or got fed up with looking and stopped. It's been like that for all of the more expansive higher-level languages I've used, not just Java. (Aside: Don't get me wrong, I am NOT bashing Java. It's an excellent, solid framework that can handle damn near anything you throw at it, and usually in a very skilled, complete, and well-thought-out manner. It's great for both small- and large-scale, enterprise operations, and is able to function at full-capacity in the most intense of circumstances. It certainly has its place, a place it holds firmly and effectively, but I don't really think it's good for me; I'm not exactly some bigwig company that needs XYZ huge projects produced.) It really comes down to what you're looking for. Honestly, I'm still not sure what I'm looking for, but I know I love programming and I want to find my calling for it. I've always wanted to get into general game design but I've never really found anything that truly clicks with me. I've tried other game design-specific solutions, even ones designed for Java like jMonkeyEngine, but development with these types of applications is usually very closed and has that pre-built here use this class feeling like Java does. I must sound pretty hypocritical/demanding here; I want a solid base to work off of but I don't want it to feel pre-built? I suppose what I mean is that I want it to work as-is, but I also want things to be bare enough so that I can create what I want without worrying about what class to use or what method to override. Java isn't just your average framework, it has everything you could ever need... And that's not really what I want. I want a skeleton, so that I can fill in the parts that I need to how I want, without resorting to using X number of classes. Not only do I feel that restricts my creative abilities, but it's generally difficult. That's part of the reason I chose D: It has all the advantages of using a low-level language, mainly in its simplicity, but with the ease of use and completedness that comes from using a higher-level language, or as so I've read about it. I want programming to be challenging and engaging, and moreover fun and enjoyable, while having it not being a chore just to accomplish little goals. Java kinda feels
Re: GC for noobs
Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory management environments would give more and not less guarantees. Anyway, I really need to learn how to design the code for CG and undefined d-tor calls. Any pointers would be welcome. I think that will depend on your use case. Why do you need to refer to child objects in your destructor?
Re: GC for noobs
On Thursday, 27 February 2014 at 10:40:15 UTC, Tobias Pankrath wrote: Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory management environments would give more and not less guarantees. Anyway, I really need to learn how to design the code for CG and undefined d-tor calls. Any pointers would be welcome. I think that will depend on your use case. Why do you need to refer to child objects in your destructor? I don't need to refer to children, I just want them to do their cleanup first as they should. This is basic resource-management stuff, surely there has to be generic advice out there?
Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.
On Thursday, 27 February 2014 at 10:23:40 UTC, DS6 wrote: Okay, down to the questions I have about D: - Why should I use D over another language? What general benefits does it provide me, in relation to the points I made about it above? Is it a solid base to build off of, but still simple in nature? It's a flexible, well designed language. Many things that are complex and/or slow in other languages can be written in a readable and performant manner, with fewer nasty surprises. - How is multiplatform compilation handled by D? Fine as long as you stick with x86/x86_64 CPUs and a normal desktop operating system, i.e. Linux, Windows, OS X, ***BSD Support for other types of systems is work-in-progress, mostly focused around gdc/ldc as dmd is an x86/x86_64 only compiler. Bear in mind that the same frontend is used for all 3 compilers, dmd is the reference compiler, gdc/ldc lag 1 release behind dmd. - How well supported is D? I've read that D is still relatively... Not new, or young, but less known than other languages. Does it have support for major libraries, like SDL? Aside: Whether or not these libs are official or not doesn't matter to me, they usually aren't anyway. You can use any C library from D, but you have to port the headers. This has been done for many libraries, see here: http://code.dlang.org/ There are some nice D-style wrappers that exist as well. Links to other languages include https://github.com/JakobOvrum/LuaD, https://bitbucket.org/ariovistus/pyd C++ libraries are less well supported, but there has been a certain amount of success. - How is D used in the enterprise world? Depends on your definition of enterprise. There are companies that use D (http://wiki.dlang.org/Current_D_Use). - Lastly, and probably most important, is D code scalable and easy to maintain? You never know, something I make could gain popularity and I would suddenly need to mass-produce and heavily modify my code to suit the needs of whatever crowd of people suddenly want my services, whatever services I may offer. Is going large-scale from an initially small-scale project or otherwise prototype at least comparable, say, Java (which is quite easy to manage large-scale if you do things right)? In my opinion, D code is highly scalable and maintainable. In particular, the strength of D's metaprogramming makes for flexible code. Overall, D is a pragmatic language.
Re: GC for noobs
Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile
Re: GC for noobs
On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile In my specific example I am creating OpenGL Renderer. Renderer class instance holds GLContext instance. After context creation GL objects are created like textures and vertex buffers. Those are Texture and VertexBuffer class instances too. It is critical that those child resources are freed before GL context is destroyed. Thing is, even tho Renderer keeps list of Textures , VertexBuffers and Context object, order of their destruction is completely undefined making Context d-tor called first and then child resources d-tors which ends in catastrophe. In C++ (which has a LOT of problems) this is a no-brainer. Order of d-tors is fully defined. Sub-objects are destroyed before parent d-tor is called so only thing to worry about is the order of definition of members. This is just an example but I would think that it is something rather important to have... What about child objects un-registering themselves in d-tors from a list that parent object holds and parent is destroyed first? What about asynchronous completion handler object that should notify some other object that it finished/not finished a job but a notifee is already destroyed because application is being shut-down? I honestly can't imagine how to reason about object graph lifetimes in GC world and I am sure I am missing something very basic. Probably a very different mindset.