Re: Project Elvis
On Tuesday, 7 November 2017 at 13:43:20 UTC, user1234 wrote: On Monday, 6 November 2017 at 20:14:17 UTC, Meta wrote: The functionality is probably a good idea, but a library solution is doable today without any acrobatics. Show me a library solution that works fine with IDE completion (so for the safe navigation operator, not the Elvis one). Well, the IDE can know when a particular standard library symbol is being used. It can detect this case and provide special autocompletion suggestions for it. Yes, this is not perfect. But where standard library symbols are commonly used, it is a workable solution.
Re: Project Elvis
On Monday, 13 November 2017 at 14:44:55 UTC, Nick Treleaven wrote: The commenting out case can be prevented by making ?: an actual operator, so ?/**/: would be an error. Yes, that sounds reasonable. (Also I think it's regressive to argue invalid code becoming valid is a good reason to prevent introducing a feature). In terms of usability you want to catch typos so you want some redundancy, but I don't know whether this is a likely typo. But in general, it is possible to construct a language where all strings are valid programs. That would also mean that all typos would go un-noticed in that language.
Re: Project Elvis
On Saturday, 11 November 2017 at 05:20:39 UTC, codephantom wrote: I just saw this about the new 'damnit' operator, for C# 8. https://github.com/dotnet/csharplang/issues/556 The principle is a good one - by default you cannot dereference something that can be null, you get a compiler error instead. If you are confident it isn't null, you use a special operator to override the compiler check. This is better because: 1. The programmer has to acknowledge that the reference is nullable (except where the compiler may be able to prove it is not null). 2. People reading the code are informed that potentially the reference is null but the programmer thought it wouldn't be, in this particular case, documenting the programmer's understanding. 3. Reviewers are freed from checking r's possible assigned value in all code paths every time r is dereferenced. This solution is probably less disruptive to existing code than removing null altogether like Rust, which encourages the programmer to always handle the not-null and null case for every dereference. (Although half the battle is having non-null types).
Re: Project Elvis
On Monday, 6 November 2017 at 13:02:43 UTC, Ola Fosheim Grøstad wrote: On Monday, 6 November 2017 at 10:12:11 UTC, Jonathan M Davis wrote: All it does is take the expression x ? x : y and make it x ?: y Yes, that is an issue because it means that typos no longer are caught. E.g. if you accidentally comment out or delete the second expression. The commenting out case can be prevented by making ?: an actual operator, so ?/**/: would be an error. (Also I think it's regressive to argue invalid code becoming valid is a good reason to prevent introducing a feature). Which is why I think ?? or some other choice would offer better usability. I think ??= reads better than ?:=, which looks like Pascal assignment.
Re: Project Elvis
On Sunday, 12 November 2017 at 16:47:02 UTC, bauss wrote: I told you once and I'll tell you twice. I'm definitely not a MSFT fan boy. The only thing I have in my development environment that's related to MS is their linker from Visual Studio, but I don't have anything else installed from VS. All projects I have that I currently work on are written in D or C. ok..I'll take you off the list too..for now. I think maybe I need to get a cute gravatar, like you and Satoshi. Maybe a little kitten or something. Then maybe people will be less eager to attack me
Re: Project Elvis
On Sunday, 12 November 2017 at 16:47:02 UTC, bauss wrote: I told you once and I'll tell you twice. I'm definitely not a MSFT fan boy. Well, you were pretty quick to jump into the middle of a conversation, just to have a long..drawn outgo at me, because I had some critical comments to say about C# - a language which I know all to well. Only a MSFT fanboy would defend C# with that level of passion. What else am I meant to assume?
Re: Project Elvis
On Sunday, 12 November 2017 at 04:40:21 UTC, codephantom wrote: On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: I'm tired so I will end my post here. And I'm going to end all my posts here, cause I'm sick of arguing with MSFT fanboys, who want to restrain D's development by tying it into propriatery, closed source, bloatware. Besides being more productive, it also seems like more fun, than responding to MSFT fanboys (although that's been fun too). I told you once and I'll tell you twice. I'm definitely not a MSFT fan boy. If I were one, I wouldn't have written a whole framework to replace my ASP.NET projects with D. I would probably have .NET languges installed too, which I don't. The only thing I have in my development environment that's related to MS is their linker from Visual Studio, but I don't have anything else installed from VS. For the simply fact, I don't write any .NET code privately. I have some projects I still maintain, but I can do that without VS. All projects I have that I currently work on are written in D or C. - On Sunday, 12 November 2017 at 08:59:05 UTC, Satoshi wrote: It's for you! https://i.imgur.com/NNgrSyP.png Laughed really hard.
Re: Project Elvis
On Sunday, 12 November 2017 at 08:59:05 UTC, Satoshi wrote: It's for you! https://i.imgur.com/NNgrSyP.png If you're actually taking bets on that...then put me down for $10_000.00 on the MSFT fanbois that is ;-) Nice stuff with Trinix. I'll cross you off my list of fanboys...for now.
Re: Project Elvis
It's for you! https://i.imgur.com/NNgrSyP.png
Re: Project Elvis
On Sunday, 12 November 2017 at 08:33:34 UTC, Satoshi wrote: I'm going to start focusing my attention on rewriting (some) of FreeBSD userland, using D ..and see what happens. (btw. such programs can easily be migrated to Linux/OSX too...or the new 'System D' ..when it arrives ;-) You should starts from Kernel. And if you don't want to start form scratch, you can use my OS written in D :) https://github.com/Rikarin/Trinix I'm expecting your first pull request in couple of days :)
Re: Project Elvis
On Sunday, 12 November 2017 at 04:40:21 UTC, codephantom wrote: On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: I'm tired so I will end my post here. And I'm going to end all my posts here, cause I'm sick of arguing with MSFT fanboys, who want to restrain D's development by tying it into propriatery, closed source, bloatware. Yeah, I'm MSFT fanboy because I think ?? and ?. operators from C# are useful. Think of a number between 1 and 10 Yes, that's your IQ. I'm going to start focusing my attention on rewriting (some) of FreeBSD userland, using D ..and see what happens. (btw. such programs can easily be migrated to Linux/OSX too...or the new 'System D' ..when it arrives ;-) You should starts from Kernel. And if you don't want to start form scratch, you can use my OS written in D :) https://github.com/Rikarin/Trinix Besides being more productive, it also seems like more fun, than responding to MSFT fanboys (although that's been fun too). How is rewriting the same software from C to D productive? Sorry MSFT fanboys, if you don't know what userland means. Go google it. Yeah, nobody is as smart as you. Good luck with rewriting the same code. It's boring, bug introducing and useless work but do what you want.
Re: Project Elvis
On Sunday, 12 November 2017 at 03:25:47 UTC, codephantom wrote: But everyone wants a more modular, more refined, more modern, more secure operating system ...and a more secure systems programming language. How rewriting Linux from scratch will enhance security of the OS? By introducing more bugs to the new code? But very who's focused on that? Go has some potential, but I don't like many of its design decisions. fakin' D fanboy! So D could take advantage of the fact the big corporates are focused elsewhere (and, also, that they're not very likely to turn their attention to redeveloping their os any time soon). Because nobody spends billions of dollars on something what will not brings anything new. It could take advantage of Go, having made some questionable design decisions. It could take advantage of Rust, seemingly going nowhere (IMHO). So if there was ever a time for 'System D', it's now. Instead, everyones focused on making it compatible..with this..and that...which is great..that will certainly bring attention to D...but I suspect it won't do too much more than that. D needs a grander vision.
Re: Project Elvis
On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: I'm tired so I will end my post here. And I'm going to end all my posts here, cause I'm sick of arguing with MSFT fanboys, who want to restrain D's development by tying it into propriatery, closed source, bloatware. I'm going to start focusing my attention on rewriting (some) of FreeBSD userland, using D ..and see what happens. (btw. such programs can easily be migrated to Linux/OSX too...or the new 'System D' ..when it arrives ;-) Besides being more productive, it also seems like more fun, than responding to MSFT fanboys (although that's been fun too). Sorry MSFT fanboys, if you don't know what userland means. Go google it.
Re: Project Elvis
On Saturday, 11 November 2017 at 12:53:46 UTC, Satoshi wrote: Yeah, stop duplicating what's out there and start writing similar software what already exists. Sounds great. And every man, women... and their 2 dogs...are targetting mobile, web, cloud these days. The idea that D is going to compete with the like of Google/Apple/MSFT in these areas..is..well..unconvincing. The idea that such companies and going to rip up their massive codebases and rewrite them in D...is..well..unconvincing. But everyone wants a more modular, more refined, more modern, more secure operating system ...and a more secure systems programming language. But very who's focused on that? Go has some potential, but I don't like many of its design decisions. Rust is going nowhere, IMHO. So D could take advantage of the fact the big corporates are focused elsewhere (and, also, that they're not very likely to turn their attention to redeveloping their os any time soon). It could take advantage of Go, having made some questionable design decisions. It could take advantage of Rust, seemingly going nowhere (IMHO). So if there was ever a time for 'System D', it's now. Instead, everyones focused on making it compatible..with this..and that...which is great..that will certainly bring attention to D...but I suspect it won't do too much more than that. D needs a grander vision.
Re: Project Elvis
On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: On Saturday, 11 November 2017 at 05:20:39 UTC, codephantom wrote: On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. I just saw this about the new 'damnit' operator, for C# 8. https://github.com/dotnet/csharplang/issues/556 I thought it was a joke at first, but they are serious. C# seem to becoming language of operators. ool? a, b; ... var x = !a! != b! ? a! : !b!; Yeah...lets follow there example...they seem to know better. It's a proposal, not an actually accepted implementation. It's more than a proposal. Mad Torgersen (i.e. mean, Mads Torgersen)...is actually pursuing its integration into C# 8 https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8-with-Mads-Torgersen 15m:08s ...the 'I know better' operator (aks damnit operator) I wonder if you'll have to upgrade your Visual Studio to the next version though...before you can use it...or maybe your .NET version will need upgrading..or maybe the .NET won't work on Win7..or maybe the new VS won't work in Windows 7of maybe they'll release Windows 12, and only make C# 8 available on that platform
Re: Project Elvis
On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: and btw. if you had gone back a few threads (instead of just jumping into a conversation to just have a go at me), then you'd know that it all started because i attempted to inject some humour into the converstation, and used a youtube video that made fun of the design of Windows 10 - in a humerous manner. Hahahah so funny... no. And again, I'd like to point out to everyone, that the attack on me, in this thread, started becasue I dared to poke fun at the design of Windows 10. In another discussion, the attack on me started because i dared to suggest you should be able to compile a 64bit D executable, on Windows, without have to download GB's of propriatey, closed-source, bloatware. That really seemed to pee of the MSFT fanboys on these forums...who then thought it was appropriate to start attacking me personally. I don't mind dishing it out back to them...if they persist.
Re: Project Elvis
On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: and btw. if you had gone back a few threads (instead of just jumping into a conversation to just have a go at me), then you'd know that it all started because i attempted to inject some humour into the converstation, and used a youtube video that made fun of the design of Windows 10 - in a humerous manner. Hahahah so funny... no. Seriously? You didn't find this video funny? https://www.youtube.com/watch?v=KHG6fXEba0A I think you've clearly demonstrated why I felt compelled to use the word 'fanboy'. Microsoft fanboys hate anyone who: - Uses Linux - Rightfully criticizes Microsoft on some of their faults - Dares to pose a different opinion
Re: Project Elvis
On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote: I'm tired so I will end my post here. Great contribution btw. I might actually read it when i have nothing else to do...which will be a long way off...
Re: Project Elvis
On Friday, 10 November 2017 at 23:14:50 UTC, codephantom wrote: On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote: You are judging C#, but looks where is D and where is C#. Where is C#? In about 50% of the corporations doing enterprise programming. - good luck porting it to other (non MS, non .NET environments). .NET Core is getting there. - performance of large code bases can often be sluggish What's your proof of this? I have worked with multiple large code bases written in .NET without bad performance? - VS.NET does most of the coding for you. Uh, what? Because of JIT? Okay. Then "D" does most of the coding for you too then, since you're not writing the assembly code nor are you manually linking your object files. - most C# developers have no idea what's being done behind the scenes. To me, it seems like you have no idea what's being done behind the scenes. - you can't create a function outside of a class (great design decision btw!) Different language, different design choice, different goals. It's not like every decision in D are the best either. Every language has their flaws. I could go on..and on... Yeah, but I'd rather if you didn't. It's had good sides and bad sides. MSFT fanboys are unable to distinguish the difference, and think everything must be great, cause MSFT/C# did it. I'm not even a "MSFT" fanboy. I replaced all my private .NET code with D, but not because I despise .NET at all, but because D is my preferred language of choice. There are certain areas of .NET that D could learn a lot from. MSFT have spent the last 7 years mostly adding useless stuff to C# - but like their design descions about Windows, and their other products. Instead of real innovation, we just get more useless stuff. Different people, different opinions. These forums need more critical thinking, and better justification for new features (other than 'cause MSFT knows best'), or ('cause the language I'm used to using has it'). If I got a dollar for every time you said "MSFT", I'd be able to buy Microsoft. --- On Saturday, 11 November 2017 at 02:52:47 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: best'), or ('cause the language I'm used to using has it'). You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. Any opinion/idea offered by someone who can't take criticism of MSFT products, is not worth very much to me. As far as I'm concerned, it demonstrates a closed mind, incapable of exploring alternative solutions. It invites suspicion. Opinions without facts are pretty useless. Something you should be familiar with. Now...if you're not actually a 'MSFT fanboy', then i dare you to post a link that criticises the C# langauge, or any other MSFT product. Why would anyone waste their time finding that? It's such a petty thing. It's like saying: "If you're not a fan of Justin Bieber, I dare you to find an article that dislikes him." I thought we were more professional on these forums, but I guess kindergarten is all around the internet. - On Saturday, 11 November 2017 at 03:49:24 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. and btw. if you had gone back a few threads (instead of just jumping into a conversation to just have a go at me), then you'd know that it all started because i attempted to inject some humour into the converstation, and used a youtube video that made fun of the design of Windows 10 - in a humerous manner. Hahahah so funny... no. What results from that, was some guy telling me that I was bashing on Adam. That i was anti this and anti that. Then others got involved too, trying to bash on me even further. Nobody is "bashing" anyone. So, if you're all willing to dish it out to me, you better be prepared to take some too! Such a mature thing to do. D's future will depend not on how well it ties into a propriatory o/s, but who well it runs in open source environments. Anyone who doesn't see that, doesn't understand whats going on in the world of software development. Even MSFT get that, and are now trying to port C# as quickly as possibly to other platforms to hold off the competition that's already here, and more to come. And your source of information is? I think D is where it is, because it was developed on Windows (windows 32 bit it seems). Had it been developed on an open source operating system, I expect it would be miles ahead of where it currently is. I'm not even sure what you're referring to in terms of D's issues. Especially when you mention that you think it was developed on Windows. Isn't it
Re: Project Elvis
On Saturday, 11 November 2017 at 12:53:46 UTC, Satoshi wrote: Yeah, stop duplicating what's out there and start writing similar software what already exists. Sounds great. Where is the secure, modular operating system, written in a safe language? And a language that you can use for the rest of the o/s ecosystem too. People are still searching for this holy grail..it hasn't been found.. Why? Perhaps because the right language has come around yet. Maybe D is it, maybe not... ..so it actually *doesn't* already exist.
Re: Project Elvis
On Saturday, 11 November 2017 at 12:53:46 UTC, Satoshi wrote: Yeah, stop duplicating what's out there and start writing similar software what already exists. Sounds great. Dude.. I can only assume you're very young. Why do you think C took off as it did? It wasn't because people spent hours on forums discussing how to integrate this operator, or that operator.
Re: Project Elvis
On Saturday, 11 November 2017 at 16:45:11 UTC, 12345swordy wrote: On Saturday, 11 November 2017 at 02:34:11 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. I'm just dishing out what they've been doing to me, simply cause I dared to critcise something that MSFT produce. You take your snark elsewhere! The fact that you not once, not twice, but three times you reply to the same statement! Wow I must really got underneath your skin when I say that. Well, that was your purpose.. wasn't it. It is afterall, the moda operandi of MSFT fanboys. Thanks for your contribution.
Re: Project Elvis
On Saturday, 11 November 2017 at 02:34:11 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. I'm just dishing out what they've been doing to me, simply cause I dared to critcise something that MSFT produce. You take your snark elsewhere! The fact that you not once, not twice, but three times you reply to the same statement! Wow I must really got underneath your skin when I say that.
Re: Project Elvis
On Saturday, 11 November 2017 at 02:30:50 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: A supported and very popular language. Seriously in it the top ten popular language list for a good reason. You should google it. I don't have to google it. I've been using it for 17 years. Then you should know the current status of it and how it compare it to D. - VS.NET does most of the coding for you. https://en.wikipedia.org/wiki/Just-in-time_compilation Won't be long till they do it ALL for you. You not making any sense here. Every programming language comes with their standard libraries, so that programmers won't reinvent the wheel every time they program. Neither do the majority of developers when it comes to their compilers. Do most C# programmers even know what a compiler is? When was the last time a C# programmer actually compiled anything... I mean really...they just push button and have no idea whats going on. It called "Roslyn", and you can google the information. LOL at your "actually compiled anything"! Really? Do you even understand what Just-in-time compilation even means!? It like you didn't read the link that I posted to you! Do your think you antidote experience applies to every c# programmer out there? That why C# have static classes. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members Not every programming language in existence needed to be Procedural based Language. You need to expand your horizons when it comes to different types of languages. Can't take the criticism of C#? It not that I can't take criticism, is that your criticism doesn't make any sense. That like criticizing Prolog for not having any procedural base language when it designed to be a purely logic programming language.
Re: Project Elvis
On Saturday, 11 November 2017 at 11:18:24 UTC, codephantom wrote: Yeah, integrating gui's into a programming language is complexthere are some gui kits for D in github, but none I find compelling at this stage - even though they're authors are doing a great job. It's not that it's too complex technically, but the corporates I've done work for would never allow you to bring in your own gui anyway. Everything has to be standardised, and look familiar to users. If you target windows and you do not mind to install a free version of Delphi on your pc, you can use the Delphi VCL/Firemonkey gui toolkit, create your ui forms in the Delphi editor while implementing the program logic in D. https://forum.dlang.org/thread/fwsbrmkbqkolrsztx...@forum.dlang.org Kind regards Andre
Re: Project Elvis
On Saturday, 11 November 2017 at 11:18:24 UTC, codephantom wrote: I'd like D to think bigger than just duplicating what's out there, and being 'compatible' with this and that operating system - or just be marketed as a quicker way to compile your slow c++ code. I'd wouldn't mind seeing a new open source operating system, lets call it 'System D'just slips of the tongue doesn't it ;-) Yeah, stop duplicating what's out there and start writing similar software what already exists. Sounds great.
Re: Project Elvis
On 11/11/2017 11:18 AM, codephantom wrote: On Saturday, 11 November 2017 at 09:47:32 UTC, Patrick Schluter wrote: Indeed, the strength of D is that it is portable among the big platforms remaining. One of its drawbacks can be seen somehow as an asset. Its lack of preferred GUI kit means that it is not intimately bound to the user interface of that platform. Swift and Objective-C are glued to Apple and outside of it are niche. Same for C# on Windows. Java is portable but is a bitch to distribute, especially on Windows where more often than not it poses security risks that IT departments do not like. Yeah, integrating gui's into a programming language is complexthere are some gui kits for D in github, but none I find compelling at this stage - even though they're authors are doing a great job. It's not that it's too complex technically, but the corporates I've done work for would never allow you to bring in your own gui anyway. Everything has to be standardised, and look familiar to users. GUI toolkits are definitely complex. Everything from rendering of fonts correctly (bidi layouts) to accessibility (which is basically impossible to do right too) and that's with ignoring more obvious things like how to render a widget.
Re: Project Elvis
On Saturday, 11 November 2017 at 09:47:32 UTC, Patrick Schluter wrote: Indeed, the strength of D is that it is portable among the big platforms remaining. One of its drawbacks can be seen somehow as an asset. Its lack of preferred GUI kit means that it is not intimately bound to the user interface of that platform. Swift and Objective-C are glued to Apple and outside of it are niche. Same for C# on Windows. Java is portable but is a bitch to distribute, especially on Windows where more often than not it poses security risks that IT departments do not like. Yeah, integrating gui's into a programming language is complexthere are some gui kits for D in github, but none I find compelling at this stage - even though they're authors are doing a great job. It's not that it's too complex technically, but the corporates I've done work for would never allow you to bring in your own gui anyway. Everything has to be standardised, and look familiar to users. same with vibe.d - great idea, great implementation - but none of the corporates I've done work for are ever going to do anything with vibe.d - ever. Startups are a good potential market for D - but it still faces a lot of competition. I'd like D to think bigger than just duplicating what's out there, and being 'compatible' with this and that operating system - or just be marketed as a quicker way to compile your slow c++ code. I'd wouldn't mind seeing a new open source operating system, lets call it 'System D'just slips of the tongue doesn't it ;-) (micro) Kernel : written in D Development tools: written in D Userland/Gui : written in D Webserver: written in D ... . ... D is a systems programming language, and has the potential to do all of this, and more. Then let others look at D, instead of D looking to others. Of course, it's easy to have such a grand vision. But I'm really struggling to see any compelling vision at the moment, other than D just being another language to choose from. The vision, based on what I've been reading on these forums, seems to be about 'grabbing stuff from this and that language, and integrating this and that feature, or this and that syntax' - as if all of this will make D more attractive out in the real world. I don't see that mindset leading anywhere. It will just lead to an even more complex language, with even more features. At that is the point where people start to envision something simpler and easier...and the cycle starts all over again... in 2030, Go will be so complex someone will have to invent GoLess. But, I'm happy nonetheless...cause I only program for recreation these days, and D provides a really nice playground for me, with lots of new toys to play withand many are yet to be discovered. And most importantly, it runs on FreeBSD!
Re: Project Elvis
On Saturday, 11 November 2017 at 03:49:24 UTC, codephantom wrote: On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. and btw. if you had gone back a few threads (instead of just jumping into a conversation to just have a go at me), then you'd know that it all started because i attempted to inject some humour into the converstation, and used a youtube video that made fun of the design of Windows 10 - in a humerous manner. What results from that, was some guy telling me that I was bashing on Adam. That i was anti this and anti that. Then others got involved too, trying to bash on me even further. The same thing happened when I mentioned my concern that 64bit D on Windows can only happen if the user is prepared to download GB's of propriatory, closed source, bloatware. When I did that, MSFT fanboys came out to dump on me, instead of saying..yeah..perhaps that might be a good way for D to proceed. So, if you're all willing to dish it out to me, you better be prepared to take some too! D's future will depend not on how well it ties into a propriatory o/s, but who well it runs in open source environments. Anyone who doesn't see that, doesn't understand whats going on in the world of software development. Even MSFT get that, and are now trying to port C# as quickly as possibly to other platforms to hold off the competition that's already here, and more to come. I think D is where it is, because it was developed on Windows (windows 32 bit it seems). Had it been developed on an open source operating system, I expect it would be miles ahead of where it currently is. If D is making Windows its platform priority, then it has to compete with exiting MSFT solutions on the platform, which in my mind, are far superior to anyting D can or will be able to provide. D should focus its attention elsewhere. That's just my opinion. Others can disagree. I don't mind disagreement. But I mind not being allowed to disagree! Indeed, the strength of D is that it is portable among the big platforms remaining. One of its drawbacks can be seen somehow as an asset. Its lack of preferred GUI kit means that it is not intimately bound to the user interface of that platform. Swift and Objective-C are glued to Apple and outside of it are niche. Same for C# on Windows. Java is portable but is a bitch to distribute, especially on Windows where more often than not it poses security risks that IT departments do not like.
Re: Project Elvis
On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. I just saw this about the new 'damnit' operator, for C# 8. https://github.com/dotnet/csharplang/issues/556 I thought it was a joke at first, but they are serious. C# seem to becoming language of operators. ool? a, b; ... var x = !a! != b! ? a! : !b!; Yeah...lets follow there example...they seem to know better.
Re: Project Elvis
On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. This is valid MSFT code, I believe: A?.B?.C?[0] ?? E A?.B?.C?[0] == E I have been coding on and off, since 1992, in various languages. So can you please tell what this code means? Can you please tell me what it was that MSFT learnt (and spent money to do so), so as to enable coders to write such code?
Re: Project Elvis
On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. and btw. if you had gone back a few threads (instead of just jumping into a conversation to just have a go at me), then you'd know that it all started because i attempted to inject some humour into the converstation, and used a youtube video that made fun of the design of Windows 10 - in a humerous manner. What results from that, was some guy telling me that I was bashing on Adam. That i was anti this and anti that. Then others got involved too, trying to bash on me even further. The same thing happened when I mentioned my concern that 64bit D on Windows can only happen if the user is prepared to download GB's of propriatory, closed source, bloatware. When I did that, MSFT fanboys came out to dump on me, instead of saying..yeah..perhaps that might be a good way for D to proceed. So, if you're all willing to dish it out to me, you better be prepared to take some too! D's future will depend not on how well it ties into a propriatory o/s, but who well it runs in open source environments. Anyone who doesn't see that, doesn't understand whats going on in the world of software development. Even MSFT get that, and are now trying to port C# as quickly as possibly to other platforms to hold off the competition that's already here, and more to come. I think D is where it is, because it was developed on Windows (windows 32 bit it seems). Had it been developed on an open source operating system, I expect it would be miles ahead of where it currently is. If D is making Windows its platform priority, then it has to compete with exiting MSFT solutions on the platform, which in my mind, are far superior to anyting D can or will be able to provide. D should focus its attention elsewhere. That's just my opinion. Others can disagree. I don't mind disagreement. But I mind not being allowed to disagree!
Re: Project Elvis
On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: best'), or ('cause the language I'm used to using has it'). You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. Any opinion/idea offered by someone who can't take criticism of MSFT products, is not worth very much to me. As far as I'm concerned, it demonstrates a closed mind, incapable of exploring alternative solutions. It invites suspicion. Now...if you're not actually a 'MSFT fanboy', then i dare you to post a link that criticises the C# langauge, or any other MSFT product.
Re: Project Elvis
On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else. I'm just dishing out what they've been doing to me, simply cause I dared to critcise something that MSFT produce. You take your snark elsewhere!
Re: Project Elvis
On Saturday, 11 November 2017 at 01:37:01 UTC, 12345swordy wrote: A supported and very popular language. Seriously in it the top ten popular language list for a good reason. You should google it. I don't have to google it. I've been using it for 17 years. - VS.NET does most of the coding for you. https://en.wikipedia.org/wiki/Just-in-time_compilation Won't be long till they do it ALL for you. Neither do the majority of developers when it comes to their compilers. Do most C# programmers even know what a compiler is? When was the last time a C# programmer actually compiled anything... I mean really...they just push button and have no idea whats going on. That why C# have static classes. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members Not every programming language in existence needed to be Procedural based Language. You need to expand your horizons when it comes to different types of languages. Can't take the criticism of C#? And your telling me to expand my horizons.. Hahhhaaa. Just another MSFT fanboy..gee..their really coming out now...
Re: Project Elvis
On Friday, 10 November 2017 at 23:14:50 UTC, codephantom wrote: On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote: You are judging C#, but looks where is D and where is C#. Where is C#? A supported and very popular language. Seriously in it the top ten popular language list for a good reason. You should google it. - good luck porting it to other (non MS, non .NET environments). https://en.wikipedia.org/wiki/Mono_(software) - performance of large code bases can often be sluggish Examples? - VS.NET does most of the coding for you. https://en.wikipedia.org/wiki/Just-in-time_compilation - most C# developers have no idea what's being done behind the scenes. Neither do the majority of developers when it comes to their compilers. - you can't create a function outside of a class (great design decision btw!) That why C# have static classes. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members Not every programming language in existence needed to be Procedural based Language. You need to expand your horizons when it comes to different types of languages. These forums need more critical thinking, and better justification for new features (other than 'cause MSFT knows best'), or ('cause the language I'm used to using has it'). You should take your own advice first, when you insult other people by calling them "Microsoft fanboys". Take your snark somewhere else.
Re: Project Elvis
On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote: You are judging C#, but looks where is D and where is C#. Where is C#? - good luck porting it to other (non MS, non .NET environments). - performance of large code bases can often be sluggish - VS.NET does most of the coding for you. - most C# developers have no idea what's being done behind the scenes. - you can't create a function outside of a class (great design decision btw!) I could go on..and on... It's had good sides and bad sides. MSFT fanboys are unable to distinguish the difference, and think everything must be great, cause MSFT/C# did it. MSFT have spent the last 7 years mostly adding useless stuff to C# - but like their design descions about Windows, and their other products. Instead of real innovation, we just get more useless stuff. These forums need more critical thinking, and better justification for new features (other than 'cause MSFT knows best'), or ('cause the language I'm used to using has it').
Re: Project Elvis
On Monday, 6 November 2017 at 12:25:06 UTC, Biotronic wrote: I find I often use this in C# with a more complex expression on the left-hand side, like a function call. A quick search shows more than 2/3 of my uses are function calls or otherwise significantly more complex than a variable. Also, it works great in conjunction with the null conditional: foo.Select(a => bar(a, qux)).FirstOrDefault?.Name ?? "not found"; It seems to be targeted primarily at code that does a lot with classes and is written in such a way that it's not clear whether a class reference should be null or not, whereas most D code doesn't do much with classes. In my C# code, it's used with strings and Nullable more often than with classes. Given my own experience with the ?? operator, I'd argue it's probably not worth it without also including null conditional (?.). A quick search in a few projects indicate roughly half the uses of ?? also use ?.. -- Biotronic Without including ".?", this proposed "Elvis operator" will just be ECMAScript-style "||". I think it will still be useful because "||" is useful, but it would be more elegant to just allow "a || b" to have the common type of "a" and "b" (which wouldn't change the truthiness of the expression) instead of introducing a new operator that is exactly like "||" except it doesn't force the result to be bool.
Re: Project Elvis
On Friday, 10 November 2017 at 19:59:29 UTC, meppl wrote: I wonder what Mr. Bright and Mr. Alexandrescu would say about the request to implement both, `??` and `?:`. Seriously? Implement both? I'm really not sure whether that's just meant to be humour or what. The first things that should be on everyones mind, is to avoid unnesecsary variations in a programming language. It's one of the things that many languages don't get. If D gets both, that'll be the end of my interest in D.
Re: Project Elvis
On Friday, 10 November 2017 at 14:37:13 UTC, bauss wrote: On Friday, 10 November 2017 at 12:48:53 UTC, codephantom wrote: On Friday, 10 November 2017 at 12:42:55 UTC, Satoshi wrote: 99% of Windows users couldn't find how to do basic stuff in Linux .. yeah.. imagine if I had said that...all hell would have broken loose. And 99% of Linux users don't know what the word convenience and user-friendly mean. dude! why is that pointed at me? I was just repeating what someone else said, to demonstrate, that if i had said that, certain people on these forums would feel even more justified to have a go at me. I think you're just demonstrating my point...and I didn't even say it. I'm one of the few people on these forums, i expect, that quad boots into different operating system every day. I have almost everyone os in a virtual machine too. I like and prefer FreeBSD to them all, but I don't limit myself to it. I'm sick of MSFT fanboys on these forums having a got at me!
Re: Project Elvis
On Friday, 10 November 2017 at 19:59:29 UTC, meppl wrote: On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: On 11/6/17 12:20, Michael wrote: I can't quite see why this proposal is such a big deal to people - as has been restated, it's just a quick change in the parser for a slight contraction in the code, and nothing language-breaking, it's not a big change to the language at all. On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: I am all for the Elvis operator, however I have two reservations about it. The first is that I don't see much use for it without a null-conditional. The second is that the current proposed syntax ?: is MUCH to easily confused with ?. This is not easy to read: obj1?.obj2?.prop3?:constant. When designing syntax sugar, ergonomics are very important, otherwise people won't use it. Microsoft spent a LOT of time and treasure to learn these lessons for us. I see no reason to ignore them just because "we don't like Microsoft" My proposal would be to copy what MSFT did, expect that I would I would introduce both operators at the same time. Syntax as follows: obj1?.obj2?.prop3 ?? constant In practice I don't see much use of the idiom outside of null's. The ONLY other thing that would work there is a boolean field and you might as well just return the boolean itself because the return values have to match types. I feel this is kind of embellished somewhat. When you write This is not easy to read: obj1?.obj2?.prop3?:constant. you're not separating it out as you do when you write your preferred version: Syntax as follows: obj1?.obj2?.prop3 ?? constant How is obj1?.obj2?.prop3 ?: constant not as easy to read as obj1?.obj2?.prop3 ?? constant You're right, I didn't, that was intentional, because sometimes people write things like that. And it took a while for anyone to say anything about it. That is my point. But that's the thing. The ?? is significantly more obvious in the condensed version. This is something that a UX designer would recognize instantly, but human factors are very definitely not our strong skill as engineers. FWIW, my human factors experience comes from the deep study of airline crashes that I do as a pilot. to me they are the same in terms of readability, only with ?? you have greater chances of mistyping and adding a second ? in there somewhere, whereas the ?: is just a contraction of the current syntax, I really don't think it's that difficult, so I'm not sure what people's hang-ups are, but I don't think the argument that ?? is easier to read than ?: holds any weight here, because one *is* a change to the language, and the other is a change to the parser and a contraction of a standard convention. Two things. ?: is ALSO a change a to language (lexer+parser). As to the whole "it's no more likely to typo the colon than the question" argument, sure, but that depends on the keyboard layout more than anything else, what works for you may not work elsewhere. And in either case, it's an easy compiler error. So you don't win anything with the ?:, but you win readability with the ??. MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. I still dont get your point. Are you sure `??` isn't more readable for you, because you are just used to it? I think `?:` makes more sense to me and people who learn the D programming language. At least As log as `null` becomes `false` and non-null-pointer becomes `true`. If the operator shall check for `null` only, I would be fine with `??`. Because then it wouldn't be a true shortcut of https://dlang.org/spec/expression.html#ConditionalExpression anymore I wonder what Mr. Bright and Mr. Alexandrescu would say about the request to implement both, `??` and `?:`. ?: is a special case of the ternary operator of C. It is well established as extention in gcc and clang since forever. It is annoying that the C standard didn't incorporate it (afair because of Microsoft which didn't support it in Visual C) as it is quite practical. Someone in the thread claimed its poor value because it only saved 1 character typing but that argument is idiotic as it is not used to replace a?a:b with a?:b but rather with something more like that int code = holyshitbigassfunct(this, wathever, FOO, BAR); if(!code) code = -1; do_something(code); with do_something(holyshitbigassfunct(this, wathever, FOO, BAR) ?: -1); Ok, I made up that example, but it is the kind of things that I was able to replace in my C project when I started to allow the Elvis operator. I don't think that the benefit for D will be as spectacular as a lot of boilerplate can be avoided in other ways, but the message that I would like to bring over here, is that sometimes the benefit of a syntax sugar is not immediatly obvious when using the basic construct.
Re: Project Elvis
On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: On 11/6/17 12:20, Michael wrote: I can't quite see why this proposal is such a big deal to people - as has been restated, it's just a quick change in the parser for a slight contraction in the code, and nothing language-breaking, it's not a big change to the language at all. On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: I am all for the Elvis operator, however I have two reservations about it. The first is that I don't see much use for it without a null-conditional. The second is that the current proposed syntax ?: is MUCH to easily confused with ?. This is not easy to read: obj1?.obj2?.prop3?:constant. When designing syntax sugar, ergonomics are very important, otherwise people won't use it. Microsoft spent a LOT of time and treasure to learn these lessons for us. I see no reason to ignore them just because "we don't like Microsoft" My proposal would be to copy what MSFT did, expect that I would I would introduce both operators at the same time. Syntax as follows: obj1?.obj2?.prop3 ?? constant In practice I don't see much use of the idiom outside of null's. The ONLY other thing that would work there is a boolean field and you might as well just return the boolean itself because the return values have to match types. I feel this is kind of embellished somewhat. When you write This is not easy to read: obj1?.obj2?.prop3?:constant. you're not separating it out as you do when you write your preferred version: Syntax as follows: obj1?.obj2?.prop3 ?? constant How is obj1?.obj2?.prop3 ?: constant not as easy to read as obj1?.obj2?.prop3 ?? constant You're right, I didn't, that was intentional, because sometimes people write things like that. And it took a while for anyone to say anything about it. That is my point. But that's the thing. The ?? is significantly more obvious in the condensed version. This is something that a UX designer would recognize instantly, but human factors are very definitely not our strong skill as engineers. FWIW, my human factors experience comes from the deep study of airline crashes that I do as a pilot. to me they are the same in terms of readability, only with ?? you have greater chances of mistyping and adding a second ? in there somewhere, whereas the ?: is just a contraction of the current syntax, I really don't think it's that difficult, so I'm not sure what people's hang-ups are, but I don't think the argument that ?? is easier to read than ?: holds any weight here, because one *is* a change to the language, and the other is a change to the parser and a contraction of a standard convention. Two things. ?: is ALSO a change a to language (lexer+parser). As to the whole "it's no more likely to typo the colon than the question" argument, sure, but that depends on the keyboard layout more than anything else, what works for you may not work elsewhere. And in either case, it's an easy compiler error. So you don't win anything with the ?:, but you win readability with the ??. MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. I still dont get your point. Are you sure `??` isn't more readable for you, because you are just used to it? I think `?:` makes more sense to me and people who learn the D programming language. At least As log as `null` becomes `false` and non-null-pointer becomes `true`. If the operator shall check for `null` only, I would be fine with `??`. Because then it wouldn't be a true shortcut of https://dlang.org/spec/expression.html#ConditionalExpression anymore I wonder what Mr. Bright and Mr. Alexandrescu would say about the request to implement both, `??` and `?:`.
Re: Project Elvis
On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: On 11/6/17 12:20, Michael wrote: [...] You're right, I didn't, that was intentional, because sometimes people write things like that. And it took a while for anyone to say anything about it. That is my point. But that's the thing. The ?? is significantly more obvious in the condensed version. This is something that a UX designer would recognize instantly, but human factors are very definitely not our strong skill as engineers. FWIW, my human factors experience comes from the deep study of airline crashes that I do as a pilot. [...] Two things. ?: is ALSO a change a to language (lexer+parser). As to the whole "it's no more likely to typo the colon than the question" argument, sure, but that depends on the keyboard layout more than anything else, what works for you may not work elsewhere. And in either case, it's an easy compiler error. So you don't win anything with the ?:, but you win readability with the ??. MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. This is fair, though do we know Microsoft actually put research into their choice on this matter? Either way, it would be a nice addition, and my preference is for ?: but I'm sure the best case will win the others over.
Re: Project Elvis
On Friday, 10 November 2017 at 12:48:53 UTC, codephantom wrote: On Friday, 10 November 2017 at 12:42:55 UTC, Satoshi wrote: 99% of Windows users couldn't find how to do basic stuff in Linux .. yeah.. imagine if I had said that...all hell would have broken loose. And 99% of Linux users don't know what the word convenience and user-friendly mean.
Re: Project Elvis
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: Based on other posts that you've made, you seem interested in bashing anything related to Windows or Microsoft, and that really isn't productive when we're trying to have a technical discussion. - Jonathan M Davis And I see you conveniently don't mention, that I posted on several discussion, that Windows XP is one of my favourite all time operating systems (yeah..made by Microsoft did you know?). And I see you conveniently don't mention, that I posted that I run Windows Mobile on my phone. That's why the only conclusions I can come to, is that MSFT fanboys runs these forums. FORUM RULE 1: Do NOT make a joke about MSFT. FORUM RULE 2: See rule 1. I could go on all night about pathetic the response was, to me making a joke, but I have more intesting thing to atttend to now. Happy to take it up again if necessary.
Re: Project Elvis
On Friday, 10 November 2017 at 12:51:04 UTC, codephantom wrote: So making a joke about MSFT excuses you and others to start bashing on me? Really. That is more of a joke. ohh..anyone don't know what MSFT fanboy is? https://www.urbandictionary.com/define.php?term=Microsoft%20Fanboy
Re: Project Elvis
On Friday, 10 November 2017 at 12:42:55 UTC, Satoshi wrote: You didn't say anything negative about MSFT you just start making jokes about it. Then get rect and start crying and saying you did not troll. I'm not MSFT fanboy, I just find some of the C# features useful, nothing more. So making a joke about MSFT excuses you and others to start bashing on me? Really. That is more of a joke.
Re: Project Elvis
On Friday, 10 November 2017 at 12:42:55 UTC, Satoshi wrote: 99% of Windows users couldn't find how to do basic stuff in Linux .. yeah.. imagine if I had said that...all hell would have broken loose.
Re: Project Elvis
On Friday, 10 November 2017 at 12:42:55 UTC, Satoshi wrote: You didn't say anything negative about MSFT you just start making jokes about it. ok. note taken. no jokes about msft allowed on D forums. got it. thanks for your input Satoshi.
Re: Project Elvis
On Friday, 10 November 2017 at 12:27:22 UTC, codephantom wrote: On Friday, 10 November 2017 at 11:55:52 UTC, Jonathan M Davis wrote: [...] Well, you just got it wrong, and your comments were unfair, and actually, your comment were 'bashing' on me! I simply used a humourous youtube video, as a way to suggest that we reconsider whether we 'should' (as Adam puts it), take advice from MSFT. For that to be taken as 'bashing on Adam', is ridiculous. And to be honest, I find the MSFT fanboys on these forums always seem to react in that way, like MSFT is core part of their personality or something. You can't say anything negative about a MSFT product without them taking it personally, as though your directly insulted them. And then their mates decide to get involved too, and the whole thing just seems ridiculous. You didn't say anything negative about MSFT you just start making jokes about it. Then get rect and start crying and saying you did not troll. I'm not MSFT fanboy, I just find some of the C# features useful, nothing more. I had a go at Visual Studio, because it's ridiculous that D relies so much on it. Some don't agree - ok, but I got bashed on for that by the MSFT fanboys. Then I had a go at Windows 10, cause I tried to install it to use the Ubuntu shell to run D. But I could't even find how to do simple things in Windows 10. 99% of Windows users couldn't find how to do basic stuff in Linux but they are not blaming whole Linux community for it. So please, give some proper 'context' when you next comment about me 'bashing on Microsoft'.
Re: Project Elvis
On Friday, 10 November 2017 at 12:23:06 UTC, Satoshi wrote: I'm comparing C# to D because D is trying to do the same stuff as C#. GUI development and website development. I used vibe.d, I used ASP.NET core and I'm still missing some C# features in D. So I'm sharing my experience and expectations. If you don't want to compare D with C# or other languages, just don't push D to the same place as C# is. Why isn't D standing as a replacement for C++ but pushing into webdev and gui dev? C++ is not used for webdev too, and gui dev in C++ is horrible. And yeah, swift was developed by some volunteers until Apple took it. Why Apple didn't take D instead? Well, I really don't want to argue with you, and I'm not sure we really have much to argue anyway. But I don't see D as a replacement for C#. C# has a hold of its territory pretty well, I don't see D intruding into it, any time soon. It certainly has some good feature that D could consider incorporating. I don't think (personally) the Elvis operator is one of them. Other disagree find. I'm with disagreement. C++ on the otherhand, is certainly where D can showcase it's benefit - and indeed where many focus their attention when it comes to marketing D. And if you had good skill in C++, and switched to D, and was good at D too, then you'll be part of the generation that will replace the C++ language and the C++ programmers ;-) Sorry to the C++ fanboys..if you're listening...don't take it personally.
Re: Project Elvis
On Friday, 10 November 2017 at 11:55:52 UTC, Jonathan M Davis wrote: I "had a go at you," because it seemed like you were bashing on Adam for suggesting that we look at what C# had done and what research Microsoft had done simply because it was Microsoft that had done it. You have been bashing on Microsoft in so many posts that there's no way that I'm going to be able to tell when you're trying to make a joke and when you're simply making fun of Microsoft and putting down information or an idea because it came from Microsoft. - Jonathan M Davis Well, you just got it wrong, and your comments were unfair, and actually, your comment were 'bashing' on me! I simply used a humourous youtube video, as a way to suggest that we reconsider whether we 'should' (as Adam puts it), take advice from MSFT. For that to be taken as 'bashing on Adam', is ridiculous. And to be honest, I find the MSFT fanboys on these forums always seem to react in that way, like MSFT is core part of their personality or something. You can't say anything negative about a MSFT product without them taking it personally, as though your directly insulted them. And then their mates decide to get involved too, and the whole thing just seems ridiculous. I had a go at Visual Studio, because it's ridiculous that D relies so much on it. Some don't agree - ok, but I got bashed on for that by the MSFT fanboys. Then I had a go at Windows 10, cause I tried to install it to use the Ubuntu shell to run D. But I could't even find how to do simple things in Windows 10. So please, give some proper 'context' when you next comment about me 'bashing on Microsoft'.
Re: Project Elvis
On Friday, 10 November 2017 at 12:06:42 UTC, codephantom wrote: On Friday, 10 November 2017 at 11:45:25 UTC, Satoshi wrote: How many corporations is using D right now? 10? Windows is still dominant OS and there are a lot of job opportunities for C#. D is unusable for startups or corporations where are junior programmers hired anyway because it's too complicated to use. And pay senior developers for job what can be done by juniors but in different language is not worth. (e.g. metaprogramming is great stuff but require high skilled programmers to use it correctly.) Yeah..let's use the D forums to bag D. What a great idea. Yeah, because my opinion about D will be more valuable for the language at C# forum :) I'm not bagging D I'm just providing my personal opinions, experience and expectations. And, why are you trying to compare the state of C# to D. I really do not see your point. Besides being completely different languages, with completely different purposes, one is backed by a billion$ corporation, and the other is developed by a group of volunteers. I cannot accept the assertion by some, that we 'should' look to C# for language advice. I'm comparing C# to D because D is trying to do the same stuff as C#. GUI development and website development. I used vibe.d, I used ASP.NET core and I'm still missing some C# features in D. So I'm sharing my experience and expectations. If you don't want to compare D with C# or other languages, just don't push D to the same place as C# is. Why isn't D standing as a replacement for C++ but pushing into webdev and gui dev? C++ is not used for webdev too, and gui dev in C++ is horrible. And yeah, swift was developed by some volunteers until Apple took it. Why Apple didn't take D instead?
Re: Project Elvis
On Friday, 10 November 2017 at 11:45:25 UTC, Satoshi wrote: How many corporations is using D right now? 10? Windows is still dominant OS and there are a lot of job opportunities for C#. D is unusable for startups or corporations where are junior programmers hired anyway because it's too complicated to use. And pay senior developers for job what can be done by juniors but in different language is not worth. (e.g. metaprogramming is great stuff but require high skilled programmers to use it correctly.) Yeah..let's use the D forums to bag D. What a great idea. And, why are you trying to compare the state of C# to D. I really do not see your point. Besides being completely different languages, with completely different purposes, one is backed by a billion$ corporation, and the other is developed by a group of volunteers. I cannot accept the assertion by some, that we 'should' look to C# for language advice.
Re: Project Elvis
On Friday, 10 November 2017 at 11:45:25 UTC, Satoshi wrote: Nobody is trying to silent you, you just started trolling there. Bullshit! I tried to inject some humour into the discussion. I thought that was pretty self-evident. The MSFT fanboys on these forums, which seem to completely lack any sense of humour, decided to take it personally.
Re: Project Elvis
On Friday, November 10, 2017 11:39:48 codephantom via Digitalmars-d wrote: > On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis > > wrote: > > Shooting down an idea just because it comes from Microsoft (or > > any other company) rather than judging it on its technical > > merits is just bad policy. Ideas should be judged based on > > their own merit, not simply on where they came from. > > > > > > - Jonathan M Davis > > Can I remind you, of one of your great contribtions to this > discussion: > > "So, I really don't think that there's any point in adding the > Elvis operator, but there are some folks here who seem to think > that it's a great loss that we don't have it, because they're > used to writing stuff like that in languages like C#, which do > way more with classes and null than D code typically does." > > Any then you have a go at me, for saying we shouldn't be looking > to C#? > > Wow! I "had a go at you," because it seemed like you were bashing on Adam for suggesting that we look at what C# had done and what research Microsoft had done simply because it was Microsoft that had done it. You have been bashing on Microsoft in so many posts that there's no way that I'm going to be able to tell when you're trying to make a joke and when you're simply making fun of Microsoft and putting down information or an idea because it came from Microsoft. I don't think that the elvis operator and its ilk should be added to D, because I don't think that D is in the same position as C# (and as such, it's not useful in D in the same way), and I think that code that's written to use null in a way that would make heavy use of such operators desirable is code that is going about things in a bad way. Sometimes, it makes a lot of sense for a reference or pointer to be null (especially when it's declared), but I'm very much against code where many references or pointers in the program would be null without it being a bug. I think that that's just begging for bugs related to null. However, I see no problem with someone presenting information from Microsoft about C# and why they did what they did with their operators. That doesn't mean that I think that we should do what they did, but it's perfectly valid information to be used in support of getting new operators in D if that's what the person posting wants. And even if we don't want to take the same path in D, it can still better inform our decisions. - Jonathan M Davis
Re: Project Elvis
On Friday, 10 November 2017 at 11:26:41 UTC, codephantom wrote: On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote: You are judging C# Umm... I have 17y in C# programming. Was one of the first to take it up. Have designed/developed apps for large corporates. Umm... My old colleague had 30 years of development skills, he had developing apps for military sector and still he had writing 2000 lines long functions in C with memcpy and str* crap... Yet, I switched from C# to D. I switched from D to C#. There aren't any positions for D. I don't think looking to MSFT for programming language advice is a good idea. D is not C#. If someone doesn't agree with me, ok, let them argue their case, not try to silence me. Nobody is trying to silent you, you just started trolling there. but looks where is D and where is C#. ok..and where exactly is C#? Still, to this day, trying to get itself out of the Windows only world. What a joke. The world moved beyond the Windows monopoly a decade ago. C# is still catching up.. How many corporations is using D right now? 10? Windows is still dominant OS and there are a lot of job opportunities for C#. D is unusable for startups or corporations where are junior programmers hired anyway because it's too complicated to use. And pay senior developers for job what can be done by juniors but in different language is not worth. (e.g. metaprogramming is great stuff but require high skilled programmers to use it correctly.)
Re: Project Elvis
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: Shooting down an idea just because it comes from Microsoft (or any other company) rather than judging it on its technical merits is just bad policy. Ideas should be judged based on their own merit, not simply on where they came from. - Jonathan M Davis Can I remind you, of one of your great contribtions to this discussion: "So, I really don't think that there's any point in adding the Elvis operator, but there are some folks here who seem to think that it's a great loss that we don't have it, because they're used to writing stuff like that in languages like C#, which do way more with classes and null than D code typically does." Any then you have a go at me, for saying we shouldn't be looking to C#? Wow!
Re: Project Elvis
On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote: You are judging C# Umm... I have 17y in C# programming. Was one of the first to take it up. Have designed/developed apps for large corporates. Yet, I switched from C# to D. I don't think looking to MSFT for programming language advice is a good idea. D is not C#. If someone doesn't agree with me, ok, let them argue their case, not try to silence me. but looks where is D and where is C#. ok..and where exactly is C#? Still, to this day, trying to get itself out of the Windows only world. What a joke. The world moved beyond the Windows monopoly a decade ago. C# is still catching up..
Re: Project Elvis
On Friday, 10 November 2017 at 11:12:38 UTC, codephantom wrote: On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: we're trying to have a technical discussion. - Jonathan M Davis And will someone please tell me, where is technical benefit of putting this crap (?: or ??) into a programming language? After 8 pages of people rambling on about it, nobody agrees on anything. And then you have a go at me for trying to bring in some humour? Wow! "Technical benefit" Where is the technical benefit in changing design of web pages or apps? Why windows, Unity, KDE, Gnome or OSX changes their design by ages? Not everything is about technical benefits. Sometimes it's about better look, better usability or just innovation and bringing something new. You are judging C#, but looks where is D and where is C#.
Re: Project Elvis
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: we're trying to have a technical discussion. - Jonathan M Davis And will someone please tell me, where is technical benefit of putting this crap (?: or ??) into a programming language? After 8 pages of people rambling on about it, nobody agrees on anything. And then you have a go at me for trying to bring in some humour? Wow!
Re: Project Elvis
On Friday, 10 November 2017 at 08:24:59 UTC, codephantom wrote: On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. Is that the same company that made Windows 10? Not just the company, it's the same person who written MSDOS, Win 95, Windows Vista, 7, 8, 8.1, 10 and everything else in M$ because M$ is just one person company with some random guy who can write a thousands lines of code per hour.
Re: Project Elvis
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: Shooting down an idea just because it comes from Microsoft (or any other company) rather than judging it on its technical merits is just bad policy. Ideas should be judged based on their own merit, not simply on where they came from. Based on other posts that you've made, you seem interested in bashing anything related to Windows or Microsoft, and that really isn't productive when we're trying to have a technical discussion. - Jonathan M Davis and btw. the suggestion that we look to MSFT for how to do things with the D language, deserves (in my opinion), to be treated with humour. You disagree? Too bad.
Re: Project Elvis
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis wrote: merit, not simply on where they came from. Based on other posts that you've made, you seem interested in bashing anything related to Windows or Microsoft, and that really isn't productive when we're trying to have a technical discussion. - Jonathan M Davis yeah..whatever... maybe try getting a sense of humour..then the discussion might be interesting for a change.
Re: Project Elvis
On Friday, November 10, 2017 10:36:01 codephantom via Digitalmars-d wrote: > On Friday, 10 November 2017 at 10:24:01 UTC, Adam Wilson wrote: > > And what? > > This Windows 10. > > https://www.youtube.com/watch?v=KHG6fXEba0A > > You want us to look the MSFT on how things should be done?? In general, I don't like Microsoft, and I certainly don't like what they've done with Windows post Windows 7, but that doesn't mean that everything they say or do is terrible. Even if some what they do is terrible, there are some really smart people working there, and some of what comes out of there is definitely good. I really don't think that judging the situation with ?: or ?? or any other operator in C# on what's happened with Windows 10 makes any sense. Sure, we're talking about the same company, but we're talking about completely different teams here. And Adam is talking about the research that they've done on the operators in C#, which is completely different from talking about what they've done with a product unrelated to that research. Shooting down an idea just because it comes from Microsoft (or any other company) rather than judging it on its technical merits is just bad policy. Ideas should be judged based on their own merit, not simply on where they came from. Based on other posts that you've made, you seem interested in bashing anything related to Windows or Microsoft, and that really isn't productive when we're trying to have a technical discussion. - Jonathan M Davis
Re: Project Elvis
On Friday, 10 November 2017 at 10:24:01 UTC, Adam Wilson wrote: And what? This Windows 10. https://www.youtube.com/watch?v=KHG6fXEba0A You want us to look the MSFT on how things should be done??
Re: Project Elvis
On 11/10/17 00:24, codephantom wrote: On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. Is that the same company that made Windows 10? And what? -- Adam Wilson IRC: LightBender import quiet.dlang.dev;
Re: Project Elvis
On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote: MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. Is that the same company that made Windows 10?
Re: Project Elvis
On 11/6/17 12:20, Michael wrote: I can't quite see why this proposal is such a big deal to people - as has been restated, it's just a quick change in the parser for a slight contraction in the code, and nothing language-breaking, it's not a big change to the language at all. On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: I am all for the Elvis operator, however I have two reservations about it. The first is that I don't see much use for it without a null-conditional. The second is that the current proposed syntax ?: is MUCH to easily confused with ?. This is not easy to read: obj1?.obj2?.prop3?:constant. When designing syntax sugar, ergonomics are very important, otherwise people won't use it. Microsoft spent a LOT of time and treasure to learn these lessons for us. I see no reason to ignore them just because "we don't like Microsoft" My proposal would be to copy what MSFT did, expect that I would I would introduce both operators at the same time. Syntax as follows: obj1?.obj2?.prop3 ?? constant In practice I don't see much use of the idiom outside of null's. The ONLY other thing that would work there is a boolean field and you might as well just return the boolean itself because the return values have to match types. I feel this is kind of embellished somewhat. When you write This is not easy to read: obj1?.obj2?.prop3?:constant. you're not separating it out as you do when you write your preferred version: Syntax as follows: obj1?.obj2?.prop3 ?? constant How is obj1?.obj2?.prop3 ?: constant not as easy to read as obj1?.obj2?.prop3 ?? constant You're right, I didn't, that was intentional, because sometimes people write things like that. And it took a while for anyone to say anything about it. That is my point. But that's the thing. The ?? is significantly more obvious in the condensed version. This is something that a UX designer would recognize instantly, but human factors are very definitely not our strong skill as engineers. FWIW, my human factors experience comes from the deep study of airline crashes that I do as a pilot. to me they are the same in terms of readability, only with ?? you have greater chances of mistyping and adding a second ? in there somewhere, whereas the ?: is just a contraction of the current syntax, I really don't think it's that difficult, so I'm not sure what people's hang-ups are, but I don't think the argument that ?? is easier to read than ?: holds any weight here, because one *is* a change to the language, and the other is a change to the parser and a contraction of a standard convention. Two things. ?: is ALSO a change a to language (lexer+parser). As to the whole "it's no more likely to typo the colon than the question" argument, sure, but that depends on the keyboard layout more than anything else, what works for you may not work elsewhere. And in either case, it's an easy compiler error. So you don't win anything with the ?:, but you win readability with the ??. MSFT spends a LOT of time studying these things. It would be wise to learn for free from the money they spent. -- Adam Wilson IRC: LightBender import quiet.dlang.dev;
Re: Project Elvis
On Wednesday, 8 November 2017 at 07:32:05 UTC, aberba wrote: I have gone through all the threads and none of the comment argues why we REALLY need Elvis in D. Seem to me like some kind of "language peer influence" or something. It can be done as a library and using ternary works (more expressive). The problems we need to be solving ...I'm gonna cry :( ...we aren't talking about. I'd say add canonical versions of the relevant functions to Phobos first and then if really popular add to language later.
Re: Project Elvis
On Wednesday, 8 November 2017 at 07:32:05 UTC, aberba wrote: I have gone through all the threads and none of the comment argues why we REALLY need Elvis in D. Seem to me like some kind of "language peer influence" or something. Presumably, it's just a more 'elegant' (less verbose) way of doing something that can already be done. -- taken from: https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator val l: Int = if (b != null) b.length else -1 Along with the complete if-expression, this can be expressed with the Elvis operator, written ?:: val l = b?.length ?: -1 -- But I can understand the first example really easily. The second example, with the elvis operator, I have to spend 'more time' making sure I've interepreted those little symbols correctly. I don't like this syntactic 'elegance' at all. The human brain has too much trouble with it, unless it comes into contact with it often. So as someone once said, "one has to be very suspicious of the elegant solution" - Butler Lampson 1992.
Re: Project Elvis
On Monday, 6 November 2017 at 10:12:11 UTC, Jonathan M Davis wrote: On Monday, November 06, 2017 09:26:24 Satoshi via Digitalmars-d wrote: [...] _Everything_ that is added to the language complicates it further. It's one more thing that everyone learning the language has to learn and know and potentially deal with in code. Obviously, some things are worth the extra complication, or we'd all be programming in C, but there is always a cost to adding something, and the feature needs to be worth that cost. [...] I have gone through all the threads and none of the comment argues why we REALLY need Elvis in D. Seem to me like some kind of "language peer influence" or something. It can be done as a library and using ternary works (more expressive). The problems we need to be solving ...I'm gonna cry :( ...we aren't talking about.
Re: Project Elvis
On Tuesday, 7 November 2017 at 13:43:20 UTC, user1234 wrote: On Monday, 6 November 2017 at 20:14:17 UTC, Meta wrote: [...] import std.stdio; writeln(safeDeref(tree).right.right.val.orElse(-1)); writeln(safeDeref(tree).left.right.left.right.orElse(null)); writeln(safeDeref(tree).left.right.left.right.val.orElse(-1)); vs. writeln(tree?. right?.right?.val ?: -1); writeln(tree?.left?.right?.left?.right); writeln(tree?.left?.right?.left?.right?.val ?: -1); The functionality is probably a good idea, but a library solution is doable today without any acrobatics. Show me a library solution that works fine with IDE completion (so for the safe navigation operator, not the Elvis one). Yes, this is unfortunately the one sticking point of a library solution, although if the front end becomes fully usable as a library it may be possible to an extent.
Re: Project Elvis
On Tuesday, 7 November 2017 at 17:37:42 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 7 November 2017 at 17:27:30 UTC, bauss wrote: Which this operator has already proven to be in other successful languages. Not exactly this variation, but I get your point. On the other hand, so has hundreds of other operators from other languages... So which one should one not implement? Anyway, I've already shared my viewpoints on the flaws of "?:" as proposed. Yes. My point wasn't entirely for the addition of this operator, but in general for every good idea around here. Honestly I don't care too much if it gets implemented or not. It'll be a great addition, but in my own opinion it's not life or death.
Re: Project Elvis
On Tuesday, 7 November 2017 at 17:27:30 UTC, bauss wrote: Which this operator has already proven to be in other successful languages. Not exactly this variation, but I get your point. On the other hand, so has hundreds of other operators from other languages... So which one should one not implement? Anyway, I've already shared my viewpoints on the flaws of "?:" as proposed.
Re: Project Elvis
On Tuesday, 7 November 2017 at 16:32:50 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 7 November 2017 at 14:08:07 UTC, bauss wrote: I think we have a problem in this community to always bash down things with "It can be solved as a library.", "I don't see the value of this being added.", "I'm not going to use this feature, so nobody else will." It is considered good practice in language design to first insist on a library solution and only implement it in the language iff 1. it turned out to be a useful feature 2. a library implementation was inadequate Ola. Which this operator has already proven to be in other successful languages.
Re: Project Elvis
On Tuesday, 7 November 2017 at 14:08:07 UTC, bauss wrote: I think we have a problem in this community to always bash down things with "It can be solved as a library.", "I don't see the value of this being added.", "I'm not going to use this feature, so nobody else will." It is considered good practice in language design to first insist on a library solution and only implement it in the language iff 1. it turned out to be a useful feature 2. a library implementation was inadequate Ola.
Re: Project Elvis
On Tuesday, 7 November 2017 at 14:08:07 UTC, bauss wrote: [snip] However there's another idiom to D, which is what I'll call the "high-level" idiom which is mostly people writing applications with libraries such as vibe.d, which heavily relies on classes and reference types passed around, rather then structs. Another example of what I'd call "high-level" idiom is libraries like "dlangui" which also heavily relies on classes, a common idiom for UI applications. A DIP could probably include examples of how vibe.d and dlangui handle nulls and how whatever solution is proposed would be simpler.
Re: Project Elvis
On Tuesday, 7 November 2017 at 13:36:19 UTC, Atila Neves wrote: On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: On 10/28/17 04:38, Andrei Alexandrescu wrote: [...] C# has extensive experience with this operator and I think it would be wise to study the history of what they did and why the did it. NOTE: I understand that other languages have it, and there are variations on the theme, but C# has many similarities to D and extensive "in practice" idioms. [...] My problem with a null coalescing operator is that it bakes in one particular monad into the syntax, and it's not even a monad that's that useful for most idiomatic D code I've seen or written. I'd rather have do notation or something like that. Atila There's a big problem in the discussion here. Everyone opposed to the operator keeps repeating that it's not that useful for most idiomatic D code. However I'd argue as far to say D has two idioms. The "low-level" idiom which is what most people would say is a typical D idiom. Passing structs around etc. This idiom is typically seen in the core of D such as Phobos, D Runtime etc. However there's another idiom to D, which is what I'll call the "high-level" idiom which is mostly people writing applications with libraries such as vibe.d, which heavily relies on classes and reference types passed around, rather then structs. Another example of what I'd call "high-level" idiom is libraries like "dlangui" which also heavily relies on classes, a common idiom for UI applications. Saying that using classes and types that can be null referenced ins't idiomatic D is wrong IMO. I agree the elvis operator wouldn't have much purpose without something like the null-conditional operator. If D truly wants to expand further than a hobby language, then we'd have to focus on enterprise development, which D will never reach with a mentality like this. C# is a good reference for an ideal language that's fit for enterprise development and D could learn a lot from the language. I think we have a problem in this community to always bash down things with "It can be solved as a library.", "I don't see the value of this being added.", "I'm not going to use this feature, so nobody else will." Instead we should be like: "This will make the language more clean, since we don't need to have unnecessary imports and ten different implementations for the same thing.", "Personally this has no value to my code, because of 'X', but I could see how it could help people writing code like 'Y'", "I'm not going to use this feature, but I can see how it might be useful to others." I understand the mentality of people who believe it has a cost to add something, because it's another idiom to learn, but ask yourself this? What's easier to learn? A couple operators (elvis, null-conditional ...) or 10 different module names for all your 3rd party libraries and their implementations doing the same thing as the operators that could be implemented. Even when something exist in Phobos, people forget about it and end up writing their own implementations that do the exact same, because we're humans and humans forget. Sometimes it can be hard to remember exact modules where some functionality is implemented and that's the down-side of library solutions. You have to remember which module something belongs to. A language solution however doesn't have that problem, because you don't have to memorize anything other than the syntax of the operators. You don't have to remember any names of modules or any names of functions, their parameters or return types. You just have to remember the operator and in which order it takes its arguments. Language implementations are usually much simpler and are better suited for optimizations too. Don't get me wrong though, I don't believe this operator is life or death, neither do I believe that it's one of the most important things to be implemented. Yes there are other things more important to implement, but it doesn't mean this operator shouldn't be implemented; maybe not now, but in the future. I believe we're too quick in this community to shut down good ideas, because we believe other problems have better priority. Instead of shutting good ideas down, we need to queue them, so they don't get shut down, but aren't prioritized. Yes there are more important things than implementing the so called elvis operator and we should definitely focus on that instead, but we shouldn't entirely shut down the idea of implementing such a feature, just because D has bigger and more prioritized issues.
Re: Project Elvis
On Monday, 6 November 2017 at 20:14:17 UTC, Meta wrote: [...] import std.stdio; writeln(safeDeref(tree).right.right.val.orElse(-1)); writeln(safeDeref(tree).left.right.left.right.orElse(null)); writeln(safeDeref(tree).left.right.left.right.val.orElse(-1)); vs. writeln(tree?. right?.right?.val ?: -1); writeln(tree?.left?.right?.left?.right); writeln(tree?.left?.right?.left?.right?.val ?: -1); The functionality is probably a good idea, but a library solution is doable today without any acrobatics. Show me a library solution that works fine with IDE completion (so for the safe navigation operator, not the Elvis one).
Re: Project Elvis
On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: On 10/28/17 04:38, Andrei Alexandrescu wrote: [...] C# has extensive experience with this operator and I think it would be wise to study the history of what they did and why the did it. NOTE: I understand that other languages have it, and there are variations on the theme, but C# has many similarities to D and extensive "in practice" idioms. [...] My problem with a null coalescing operator is that it bakes in one particular monad into the syntax, and it's not even a monad that's that useful for most idiomatic D code I've seen or written. I'd rather have do notation or something like that. Atila
Re: Project Elvis
On Tuesday, 7 November 2017 at 09:42:50 UTC, Satoshi wrote: I strongly agree with you. As I wrote earlier int this thread. Kotlin has the `?.` operator for the same reason. I honestly can't think of a more obvious operator for that purpose...
Re: Project Elvis
On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: On 10/28/17 04:38, Andrei Alexandrescu wrote: [...] C# has extensive experience with this operator and I think it would be wise to study the history of what they did and why the did it. NOTE: I understand that other languages have it, and there are variations on the theme, but C# has many similarities to D and extensive "in practice" idioms. [...] I strongly agree with you.
Re: Project Elvis
I can't quite see why this proposal is such a big deal to people - as has been restated, it's just a quick change in the parser for a slight contraction in the code, and nothing language-breaking, it's not a big change to the language at all. On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: I am all for the Elvis operator, however I have two reservations about it. The first is that I don't see much use for it without a null-conditional. The second is that the current proposed syntax ?: is MUCH to easily confused with ?. This is not easy to read: obj1?.obj2?.prop3?:constant. When designing syntax sugar, ergonomics are very important, otherwise people won't use it. Microsoft spent a LOT of time and treasure to learn these lessons for us. I see no reason to ignore them just because "we don't like Microsoft" My proposal would be to copy what MSFT did, expect that I would I would introduce both operators at the same time. Syntax as follows: obj1?.obj2?.prop3 ?? constant In practice I don't see much use of the idiom outside of null's. The ONLY other thing that would work there is a boolean field and you might as well just return the boolean itself because the return values have to match types. I feel this is kind of embellished somewhat. When you write This is not easy to read: obj1?.obj2?.prop3?:constant. you're not separating it out as you do when you write your preferred version: Syntax as follows: obj1?.obj2?.prop3 ?? constant How is obj1?.obj2?.prop3 ?: constant not as easy to read as obj1?.obj2?.prop3 ?? constant to me they are the same in terms of readability, only with ?? you have greater chances of mistyping and adding a second ? in there somewhere, whereas the ?: is just a contraction of the current syntax, I really don't think it's that difficult, so I'm not sure what people's hang-ups are, but I don't think the argument that ?? is easier to read than ?: holds any weight here, because one *is* a change to the language, and the other is a change to the parser and a contraction of a standard convention.
Re: Project Elvis
On Monday, 6 November 2017 at 19:55:13 UTC, Jacob Carlborg wrote: On 2017-11-06 20:40, Dmitry Olshansky wrote: I’d argue this NOT what we want. Nullability is best captured in the typesystem even if in the form of Nullable!T. Yeah, it would be better if the elvis operator good integrate with a nullable/option type as well in addition to null. What's the point when we can already do it easily in a library, and arguably with better ergonomics? (http://forum.dlang.org/post/fshlmahxfaeqtwjbj...@forum.dlang.org) auto tree = new Node(1, new Node(2), new Node(3, null, new Node(4) ) ); import std.stdio; writeln(safeDeref(tree).right.right.val.orElse(-1)); writeln(safeDeref(tree).left.right.left.right.orElse(null)); writeln(safeDeref(tree).left.right.left.right.val.orElse(-1)); vs. writeln(tree?. right?.right?.val ?: -1); writeln(tree?.left?.right?.left?.right); writeln(tree?.left?.right?.left?.right?.val ?: -1); The functionality is probably a good idea, but a library solution is doable today without any acrobatics.
Re: Project Elvis
On 2017-11-06 20:40, Dmitry Olshansky wrote: I’d argue this NOT what we want. Nullability is best captured in the typesystem even if in the form of Nullable!T. Yeah, it would be better if the elvis operator good integrate with a nullable/option type as well in addition to null. -- /Jacob Carlborg
Re: Project Elvis
On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote: On 10/28/17 04:38, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. Razvan Nitu has already done a good part of the work: https://github.com/dlang/dmd/pull/7242 https://github.com/dlang/dlang.org/pull/1917 https://github.com/dlang/dlang.org/pull/1918 Some years later the C# team introduces the Null-Conditional operator: ?. which allows you to write: obj1?.obj2?.prop3 ?? constant. NOW people start using Null Coalescing all over the place. So C# embraced the Null. Everything is nullable and you are expected to ?. proof it if you don’t know in advance. In contrast other languages (e.g. Scala) decided to discourage the use of null in favor of algebraic type Option!T and even remove the null all together. I am all for the Elvis operator, however I have two reservations about it. To me the biggest reservation is “embracing the null” that this entails. In other words since we dedicate a feature to support nulls that indicates null return is an endorsed aproach to e.g. model APIs and libraries that deal with optional values. I’d argue this NOT what we want. Nullability is best captured in the typesystem even if in the form of Nullable!T.
Re: Project Elvis
On 10/28/17 04:38, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. Razvan Nitu has already done a good part of the work: https://github.com/dlang/dmd/pull/7242 https://github.com/dlang/dlang.org/pull/1917 https://github.com/dlang/dlang.org/pull/1918 What's needed is a precise DIP that motivates the feature properly and provides a good proposal for it. I'm no fan of bureaucracy but we really need to be pedantic about introducing language features. Walter argued thusly in a PR, and I agree: "I'm concerned that the elvis operator is not well understood, and we shouldn't be designing it in the comments section here. A DIP needs to be written. Things like operator precedence, side effects, type resolution, comparison with the operator in other languages, grammar changes, lvalues, how it would appear in the generated .di file if it isn't its own operator, etc., should be addressed." A lowering looks like the straightforward approach, of the kind: expr1 ?: expr2 ==> (x => x ? x : expr2)(expr1) Who wants to join Razvan in Project Elvis? Thanks, Andrei C# has extensive experience with this operator and I think it would be wise to study the history of what they did and why the did it. NOTE: I understand that other languages have it, and there are variations on the theme, but C# has many similarities to D and extensive "in practice" idioms. C# got the Elvis operator before it got the Null Conditional operator. In C# it only covers the case: a == null. The reason is that in practice most devs only use it like so: a != null ? a : b. The funny thing is that it was almost never used. Some years later the C# team introduces the Null-Conditional operator: ?. which allows you to write: obj1?.obj2?.prop3 ?? constant. NOW people start using Null Coalescing all over the place. I am all for the Elvis operator, however I have two reservations about it. The first is that I don't see much use for it without a null-conditional. The second is that the current proposed syntax ?: is MUCH to easily confused with ?. This is not easy to read: obj1?.obj2?.prop3?:constant. When designing syntax sugar, ergonomics are very important, otherwise people won't use it. Microsoft spent a LOT of time and treasure to learn these lessons for us. I see no reason to ignore them just because "we don't like Microsoft" My proposal would be to copy what MSFT did, expect that I would I would introduce both operators at the same time. Syntax as follows: obj1?.obj2?.prop3 ?? constant In practice I don't see much use of the idiom outside of null's. The ONLY other thing that would work there is a boolean field and you might as well just return the boolean itself because the return values have to match types. For example: return obj1.bool ?? obj2 //Error: incorrect return type return obj1 ?? obj2 // Pass: if same type I cannot actually imagine a scenario outside of objects (including strings) where you could actually use it since the left-hand side MUST evaluate to a boolean. Also, I am going to start repeating this mantra: Just because something CAN be done in the library, does not mean it SHOULD be done in the library. Ergonomics matters. Yes, I understand that D is a powerful language, but Syntax Sugar has it's place in taking common idioms and standardizing them in the language itself (English is loaded with stuff like that) so that everyone can "speak the same language". -- Adam Wilson IRC: LightBender import quiet.dlang.dev;
Re: Project Elvis
On Monday, 6 November 2017 at 10:12:11 UTC, Jonathan M Davis wrote: All it does is take the expression x ? x : y and make it x ?: y Yes, that is an issue because it means that typos no longer are caught. E.g. if you accidentally comment out or delete the second expression. Which is why I think ?? or some other choice would offer better usability. The difference is that you think that the feature is worth the cost, not that the folks who don't want to use the feature don't have to pay the cost. Indeed.
Re: Project Elvis
On Monday, 6 November 2017 at 10:12:11 UTC, Jonathan M Davis wrote: x ? x : y and make it x ?: y It saves 2 characters plus the length of the variable name. That's it. I find I often use this in C# with a more complex expression on the left-hand side, like a function call. A quick search shows more than 2/3 of my uses are function calls or otherwise significantly more complex than a variable. Also, it works great in conjunction with the null conditional: foo.Select(a => bar(a, qux)).FirstOrDefault?.Name ?? "not found"; It seems to be targeted primarily at code that does a lot with classes and is written in such a way that it's not clear whether a class reference should be null or not, whereas most D code doesn't do much with classes. In my C# code, it's used with strings and Nullable more often than with classes. Given my own experience with the ?? operator, I'd argue it's probably not worth it without also including null conditional (?.). A quick search in a few projects indicate roughly half the uses of ?? also use ?.. -- Biotronic
Re: Project Elvis
On 11/05/2017 07:20 PM, Neia Neutuladh wrote: On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. It's easy to write in function form: auto orElse(T)(T a, lazy T b) { return a ? a : b; } writeln(args[1].length.orElse(fibonacci(50))); This version can also be specialized for things like Nullable, where you can't necessarily cast it safely to a boolean but have a check for validity. Is it that valuable to have an operator for it instead? As an aside, I believe feepingcreature had a custom infix operator for this sort of thing defined, so you could write: (a /or/ b /or/ c).doStuff(); The implementation (along with /and/) is left as an exercise to the reader. If a DIP emerges, it would need to present such alternatives and argue how it adds value over them. -- Andrei
Re: Project Elvis
On Monday, November 06, 2017 09:26:24 Satoshi via Digitalmars-d wrote: > Look, this operator does not break anything. If you don't want to > use it, just don't, but why do you force everyone else to not to > use it, just because it is not adding anything "more valuable" > than just better syntax? _Everything_ that is added to the language complicates it further. It's one more thing that everyone learning the language has to learn and know and potentially deal with in code. Obviously, some things are worth the extra complication, or we'd all be programming in C, but there is always a cost to adding something, and the feature needs to be worth that cost. Granted, the elvis operator as proposed is not all that complicated, but adding it does make the language that much more complex, and it really doesn't do much. All it does is take the expression x ? x : y and make it x ?: y It saves 2 characters plus the length of the variable name. That's it. And it's optimizing an idiom that isn't going to tend to show up much in idiomatic D code. It seems to be targeted primarily at code that does a lot with classes and is written in such a way that it's not clear whether a class reference should be null or not, whereas most D code doesn't do much with classes. Rather, it does a lot with ranges and structs on the stack. Obviously, some code uses classes, and I expect that some code would benefit from the elvis operator, but I dispute that it's a common enough idiom to merit being added the language. Personally, while I frequently use the ternary operator, I almost never end up with the left and middle branches being the same, which is the only place that the elvis operator would be useful. And I don't think that Phobos does it much either. So, unless a lot of D code out there is using a drastically different coding style that does a lot with null, the elvis operator will not help much D code. So, IMHO, the elvis operator adds very little value, and I'd just as soon not see the language complicated further without adding real value in the process. So, I'll argue against it, but ultimately, it's not my decision. Rather, it's up to Walter and Andrei, and they'll decide what they decide. But don't expect anyone not to be unhappy about a feature being added to the language when they don't think that the feature adds value, because there is always a cost to a new feature. The difference is that you think that the feature is worth the cost, not that the folks who don't want to use the feature don't have to pay the cost. - Jonathan M Davis
Re: Project Elvis
On Monday, 6 November 2017 at 08:06:54 UTC, Jonathan M Davis wrote: On Monday, November 06, 2017 07:10:43 bauss via Digitalmars-d wrote: On Monday, 6 November 2017 at 00:20:09 UTC, Neia Neutuladh wrote: > On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei > > Alexandrescu wrote: >> [...] > > It's easy to write in function form: > auto orElse(T)(T a, lazy T b) > { > > return a ? a : b; > > } > > writeln(args[1].length.orElse(fibonacci(50))); > > This version can also be specialized for things like > Nullable, where you can't necessarily cast it safely to a > boolean but have a check for validity. > > Is it that valuable to have an operator for it instead? > > > As an aside, I believe feepingcreature had a custom infix > > operator for this sort of thing defined, so you could write: > (a /or/ b /or/ c).doStuff(); > > The implementation (along with /and/) is left as an exercise > to > the reader. Sure you might be able to write it easily, but pretty much everyone writes a function like that in their projects and you don\t really know the implementation always and you have to remember the exact name or else you end up writing the function yourself in your project to make sure the implementation is exactly like that, which in fact turns out to be re-inventing the wheel. By having an official syntax for it, you don't end up with code duplication like that and the implementation details of the behavior is clear. Because in some implementation "orElse()" might only check if the value is null and not necessary if the value is true. Ex. one might implement it like: auto orElse(T)(T a, lazy T b) { return a !is null ? a : b; } Such implementation detail is not clear from the call-side. However with an official implementation you know exactly how it will behave and nothing is obscure like this. That might be an argument for having an official implementation, but it's not really an argument for why it should be built into the language; it could just as easily be in Phobos if that's all that matters. - Jonathan M Davis You need additional import for this verbose syntax https://en.wikipedia.org/wiki/Syntactic_sugar Why we have operators overloading when we could have Equals() and stuff like in java? Why we have arr ~= arr2 when we could have Array.mergeArrays(arr, arr2) instead? Look, this operator does not break anything. If you don't want to use it, just don't, but why do you force everyone else to not to use it, just because it is not adding anything "more valuable" than just better syntax?
Re: Project Elvis
On Monday, November 06, 2017 07:10:43 bauss via Digitalmars-d wrote: > On Monday, 6 November 2017 at 00:20:09 UTC, Neia Neutuladh wrote: > > On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei > > > > Alexandrescu wrote: > >> Walter and I decided to kick-off project Elvis for adding the > >> homonym operator to D. > > > > It's easy to write in function form: > > auto orElse(T)(T a, lazy T b) > > { > > > > return a ? a : b; > > > > } > > > > writeln(args[1].length.orElse(fibonacci(50))); > > > > This version can also be specialized for things like Nullable, > > where you can't necessarily cast it safely to a boolean but > > have a check for validity. > > > > Is it that valuable to have an operator for it instead? > > > > > > As an aside, I believe feepingcreature had a custom infix > > > > operator for this sort of thing defined, so you could write: > > (a /or/ b /or/ c).doStuff(); > > > > The implementation (along with /and/) is left as an exercise to > > the reader. > > Sure you might be able to write it easily, but pretty much > everyone writes a function like that in their projects and you > don\t really know the implementation always and you have to > remember the exact name or else you end up writing the function > yourself in your project to make sure the implementation is > exactly like that, which in fact turns out to be re-inventing the > wheel. > > By having an official syntax for it, you don't end up with code > duplication like that and the implementation details of the > behavior is clear. > > Because in some implementation "orElse()" might only check if the > value is null and not necessary if the value is true. > > Ex. one might implement it like: > > auto orElse(T)(T a, lazy T b) > { > return a !is null ? a : b; > } > > Such implementation detail is not clear from the call-side. > > However with an official implementation you know exactly how it > will behave and nothing is obscure like this. That might be an argument for having an official implementation, but it's not really an argument for why it should be built into the language; it could just as easily be in Phobos if that's all that matters. - Jonathan M Davis
Re: Project Elvis
On Monday, 6 November 2017 at 00:20:09 UTC, Neia Neutuladh wrote: On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. It's easy to write in function form: auto orElse(T)(T a, lazy T b) { return a ? a : b; } writeln(args[1].length.orElse(fibonacci(50))); This version can also be specialized for things like Nullable, where you can't necessarily cast it safely to a boolean but have a check for validity. Is it that valuable to have an operator for it instead? As an aside, I believe feepingcreature had a custom infix operator for this sort of thing defined, so you could write: (a /or/ b /or/ c).doStuff(); The implementation (along with /and/) is left as an exercise to the reader. Sure you might be able to write it easily, but pretty much everyone writes a function like that in their projects and you don\t really know the implementation always and you have to remember the exact name or else you end up writing the function yourself in your project to make sure the implementation is exactly like that, which in fact turns out to be re-inventing the wheel. By having an official syntax for it, you don't end up with code duplication like that and the implementation details of the behavior is clear. Because in some implementation "orElse()" might only check if the value is null and not necessary if the value is true. Ex. one might implement it like: auto orElse(T)(T a, lazy T b) { return a !is null ? a : b; } Such implementation detail is not clear from the call-side. However with an official implementation you know exactly how it will behave and nothing is obscure like this.
Re: Project Elvis
On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. It's easy to write in function form: auto orElse(T)(T a, lazy T b) { return a ? a : b; } writeln(args[1].length.orElse(fibonacci(50))); This version can also be specialized for things like Nullable, where you can't necessarily cast it safely to a boolean but have a check for validity. Is it that valuable to have an operator for it instead? As an aside, I believe feepingcreature had a custom infix operator for this sort of thing defined, so you could write: (a /or/ b /or/ c).doStuff(); The implementation (along with /and/) is left as an exercise to the reader.
Re: Project Elvis
On Monday, 30 October 2017 at 19:46:54 UTC, Andrei Alexandrescu wrote: I see from comments that different people think of it in a different way. I suggest them to read this section from Kotlin docs to understand the reasoning behind the elvis operator. The principle of least astonishment indicates we should do what the lowering does: expr1 ?: expr2 ==> (x => x ? x : expr2)(expr1) An approach that does things any differently would have a much more difficult time. It is understood (and expected) that other languages have subtly different takes on the operator. Andrei I may add that the same logic is used in .get(key, defaultValue) method of Associative Arrays
Re: Project Elvis
On Thursday, November 02, 2017 09:46:06 H. S. Teoh via Digitalmars-d wrote: > On Thu, Nov 02, 2017 at 12:50:47PM +, Nick Treleaven via Digitalmars-d > wrote: [..] > > > I'd like to mention null-coalescing assignment syntax. Perl has `$a > > //= $b`, and PHP has voted to support `$a ??= $b`, expanding to `$a = > > $a ?? $b`. > > [...] > > > I expect D could do the same with `a ?:= b` or use the `??` operator > > syntax. > Isn't the `??` syntax what the Elvis operator `?:` supposed to do? > > Given that the proposed Elvis operator would be `?:`, I'd expect the > corresponding assignment operator would be `?:=`, in following the > pattern of the other op-assign operators. In a previous thread, it was stated that in other languages (no idea which ones), ?? tests specifically for null, whereas ?: tests for true. Other, related operators were discussed as well - including ?. - which if I understood correctly, allows you to call a member function only if the object isn't null. But going into other operators like that starts taking this well beyond the basic idea of shortening the ternary operator for the x ? x : y case like the elvis operator does, and for better or worse, that takes the DIP in a whole new direction. However, if we do add ?:, I think that it's pretty clear that some folks will be asking for stuff like ?. or ?:=, since I think that it's largely the case that the folks who want the elvis operator are interested in the related operators. However, their usefulness seems to be mostly predicated on the idea that you're doing a lot with class references or pointers which might be null and where you would want to do an operation with them if they're non-null and just skip that code if they're null. And given how little idiomatic D code uses classes, I don't know how useful they'll be in practice in D. It's likely to depend a lot on your coding style. I'm quite sure that I would find them borderline useless, but some of the folks who are highly interested in them may find a lot of use for them. I don't know. - Jonathan M Davis
Re: Project Elvis
On Thu, Nov 02, 2017 at 12:50:47PM +, Nick Treleaven via Digitalmars-d wrote: [..] > I'd like to mention null-coalescing assignment syntax. Perl has `$a > //= $b`, and PHP has voted to support `$a ??= $b`, expanding to `$a = > $a ?? $b`. [...] > I expect D could do the same with `a ?:= b` or use the `??` operator syntax. Isn't the `??` syntax what the Elvis operator `?:` supposed to do? Given that the proposed Elvis operator would be `?:`, I'd expect the corresponding assignment operator would be `?:=`, in following the pattern of the other op-assign operators. > Just from memory, I think I would use null coalescing assignments more > than null coalescing comparisons. If we're going to have one of them, might as well have both. T -- I think the conspiracy theorists are out to get us...
Re: Project Elvis
On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. I'd like to mention null-coalescing assignment syntax. Perl has `$a //= $b`, and PHP has voted to support `$a ??= $b`, expanding to `$a = $a ?? $b`. Rationale: // The following lines are doing the same $this->request->data['comments']['user_id'] = $this->request->data['comments']['user_id'] ?? 'value'; // Instead of repeating variables with long names, the equal coalesce operator is used $this->request->data['comments']['user_id'] ??= 'value'; https://wiki.php.net/rfc/null_coalesce_equal_operator I expect D could do the same with `a ?:= b` or use the `??` operator syntax. Just from memory, I think I would use null coalescing assignments more than null coalescing comparisons.