www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How Nested Functions Work, part 2

reply Walter Bright <newshound1 digitalmars.com> writes:
http://www.reddit.com/r/programming/comments/9lxy5/how_nested_functions_clos
Sep 18 2009
next sibling parent reply Max Samukha <spambox d-coding.com> writes:
Walter Bright wrote:

 
http://www.reddit.com/r/programming/comments/9lxy5/how_nested_functions_clos There is a typo in the example (if it is supposed to be compiled with current dmd): int bar(int i) { int abc(int x) { return i + x; } return foo(&abc); } should be int bar(int i) { int abc(int x) { return i + x; } return foo!abc; }
Sep 19 2009
parent Walter Bright <newshound1 digitalmars.com> writes:
Max Samukha wrote:
 Walter Bright wrote:
 
 http://www.reddit.com/r/programming/comments/9lxy5/how_nested_functions_clos
 
 
 There is a typo in the example
Thanks, fixed it.
Sep 19 2009
prev sibling parent reply Lutger <lutger.blijdestijn gmail.com> writes:
Cool article, I posted a comment. Reddit seems to be going downhill fast 
though, it's even worse than slashdot. 

Are locally instantiated templates used in phobos?
Sep 19 2009
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Lutger wrote:
 Cool article, I posted a comment. Reddit seems to be going downhill fast 
 though, it's even worse than slashdot. 
I know, the negative comments don't even make any sense.
 Are locally instantiated templates used in phobos?
Yes.
Sep 19 2009
parent reply language_fan <foo bar.com.invalid> writes:
Sat, 19 Sep 2009 11:44:33 -0700, Walter Bright thusly wrote:

 Lutger wrote:
 Cool article, I posted a comment. Reddit seems to be going downhill
 fast though, it's even worse than slashdot.
I know, the negative comments don't even make any sense.
 Are locally instantiated templates used in phobos?
Yes.
I read the comments and I think some of them are justified. You cannot really expect the way you built dmd to be the only alternative. Efficient closures can be implemented differently if you have a VM that supports precise generational gc, region inference, and the language is a bit more value oriented (= functional).
Sep 19 2009
next sibling parent reply language_fan <foo bar.com.invalid> writes:
Sun, 20 Sep 2009 01:09:56 +0000, language_fan thusly wrote:

 Sat, 19 Sep 2009 11:44:33 -0700, Walter Bright thusly wrote:
 
 Lutger wrote:
 Cool article, I posted a comment. Reddit seems to be going downhill
 fast though, it's even worse than slashdot.
I know, the negative comments don't even make any sense.
 Are locally instantiated templates used in phobos?
Yes.
I read the comments and I think some of them are justified. You cannot really expect the way you built dmd to be the only alternative. Efficient closures can be implemented differently if you have a VM that supports precise generational gc, region inference, and the language is a bit more value oriented (= functional).
Another thing is that often when an article about D is released, the only positive comments come from the members of the existing (smallish) community. There is no real interest in D outside the community (IMHO). Reddit's programming section is full of language fanatics, thus it is a bit hard to impress folks with tiny tricks as they daily work with various programming languages and concepts.
Sep 19 2009
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
language_fan:

There is no real interest in D outside the community (IMHO).<
There can be various causes: - At University here they teach mostly Java. So young people know and like VM-based languages. - Such people are "spoiled": they don't even want to touch a language that has no very good IDE and no good std lib and no good module ecosystem. D looks fitter for older people, grown with milk&C. - Currently D isn't very useful for the web/mobile, where lot of programmers are. - People today like a handy language, because often CPU efficiency isn't strictly critical (and when necessary Java is usually fast enough, and often faster than D code compiled with DMD). A language that already has just the one lib you need right now, is often what they prefer. - D allows to program in a low-level style too, but most people don't know how to program in that style, don't know asm, and usually don't need it. So by design D may be a nice language. I don't know. Bye, bearophile
Sep 19 2009
parent reply Justin Johansson <procode adam-dott-com.au> writes:
bearophile Wrote:

 - Currently D isn't very useful for the web/mobile, where lot of programmers
are.
I'd be interested to know how good D is for implementing scripting/dynamic languages .. maybe that could change the odds? I know about DMDScript (ECMAScript in D) supposedly being fast, though whatever I've read is no doubt out of date as Javascript engine (performance) wars between Google (webkit) and Mozilla (spidermonkey?) engines have been raging as of late.
Sep 21 2009
next sibling parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Justin Johansson wrote:
 bearophile Wrote:
 
 - Currently D isn't very useful for the web/mobile, where lot of programmers
are.
I'd be interested to know how good D is for implementing scripting/dynamic languages .. maybe that could change the odds? I know about DMDScript (ECMAScript in D) supposedly being fast, though whatever I've read is no doubt out of date as Javascript engine (performance) wars between Google (webkit) and Mozilla (spidermonkey?) engines have been raging as of late.
It is definitely easier to implement scripting languages in D than it is in other languages such as C/C++. However where I believe V8 (google's JS engine) is gaining in performance is at the direct translation of parse nodes to assembly without using intermediate representation in between and without the need of an interpreter, they even go as far as to modify code paths dynamically to gain more performance. I hear mozilla rewrote their JS engine lately too but didn't check what improvements they made.
Sep 21 2009
next sibling parent grauzone <none example.net> writes:
Jeremie Pelletier wrote:
 It is definitely easier to implement scripting languages in D than it is 
 in other languages such as C/C++. However where I believe V8 (google's 
Tools like SWIG are missing in D, and you could claim that D's GC gets into the way of memory managment (you need a mechanism to pin D references within the scripting language's heap), so you could claim it's actually harder.
Sep 21 2009
prev sibling parent reply language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 13:17:38 -0400, Jeremie Pelletier thusly wrote:

 Justin Johansson wrote:
 bearophile Wrote:
 
 - Currently D isn't very useful for the web/mobile, where lot of
 programmers are.
I'd be interested to know how good D is for implementing scripting/dynamic languages .. maybe that could change the odds? I know about DMDScript (ECMAScript in D) supposedly being fast, though whatever I've read is no doubt out of date as Javascript engine (performance) wars between Google (webkit) and Mozilla (spidermonkey?) engines have been raging as of late.
It is definitely easier to implement scripting languages in D than it is in other languages such as C/C++. However where I believe V8 (google's JS engine) is gaining in performance is at the direct translation of parse nodes to assembly without using intermediate representation in between and without the need of an interpreter, they even go as far as to modify code paths dynamically to gain more performance. I hear mozilla rewrote their JS engine lately too but didn't check what improvements they made.
When implementing a scripting language VM, it does not really matter if you use C, C++, D, Ada, Eiffel, Pascal, Obj-C, Haskell or OCaml (or any of the top15 languages in the great language shootout). They all are pretty fast. The fact is, if you have studied CS and know mechanisms like dynamic translation, generational garbage collection, or region inference, you can build a fast scripting language VM in any decent language. D is in no way special here. In fact it is not even hard to make the fastest Javascript VM in the world with D - the current ones are not very good.
Sep 21 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
language_fan wrote:
 Mon, 21 Sep 2009 13:17:38 -0400, Jeremie Pelletier thusly wrote:
 
 Justin Johansson wrote:
 bearophile Wrote:

 - Currently D isn't very useful for the web/mobile, where lot of
 programmers are.
I'd be interested to know how good D is for implementing scripting/dynamic languages .. maybe that could change the odds? I know about DMDScript (ECMAScript in D) supposedly being fast, though whatever I've read is no doubt out of date as Javascript engine (performance) wars between Google (webkit) and Mozilla (spidermonkey?) engines have been raging as of late.
It is definitely easier to implement scripting languages in D than it is in other languages such as C/C++. However where I believe V8 (google's JS engine) is gaining in performance is at the direct translation of parse nodes to assembly without using intermediate representation in between and without the need of an interpreter, they even go as far as to modify code paths dynamically to gain more performance. I hear mozilla rewrote their JS engine lately too but didn't check what improvements they made.
When implementing a scripting language VM, it does not really matter if you use C, C++, D, Ada, Eiffel, Pascal, Obj-C, Haskell or OCaml (or any of the top15 languages in the great language shootout). They all are pretty fast. The fact is, if you have studied CS and know mechanisms like dynamic translation, generational garbage collection, or region inference, you can build a fast scripting language VM in any decent language. D is in no way special here. In fact it is not even hard to make the fastest Javascript VM in the world with D - the current ones are not very good.
Studying CS has nothing to do with how competent you are, period. The number of languages and algorithms a guy can name has no relevance either. It can help to get you started, but anyone with enough interest in programming can learn much more on their own and in much less time. Sorry for the rant, I'm just tired of seeing CS thrown around as an argument. When it comes to writing scripting engines, with IR running in a VM or generated machine code, the language used is really just a matter of preference, it will affect productivity way more than performance, if the code is properly done. That's what I meant by easier to do in D, you'll have way less lines of code than in C/C++ or most other systems languages. Now its only obvious that things like garbage collection and whatnot are required to be familiar to the programmer implementing it, no need to go to CS to know that :)
Sep 21 2009
parent reply language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 15:07:47 -0400, Jeremie Pelletier thusly wrote:

 language_fan wrote:
 Mon, 21 Sep 2009 13:17:38 -0400, Jeremie Pelletier thusly wrote:
 
 Justin Johansson wrote:
 bearophile Wrote:

 - Currently D isn't very useful for the web/mobile, where lot of
 programmers are.
I'd be interested to know how good D is for implementing scripting/dynamic languages .. maybe that could change the odds? I know about DMDScript (ECMAScript in D) supposedly being fast, though whatever I've read is no doubt out of date as Javascript engine (performance) wars between Google (webkit) and Mozilla (spidermonkey?) engines have been raging as of late.
It is definitely easier to implement scripting languages in D than it is in other languages such as C/C++. However where I believe V8 (google's JS engine) is gaining in performance is at the direct translation of parse nodes to assembly without using intermediate representation in between and without the need of an interpreter, they even go as far as to modify code paths dynamically to gain more performance. I hear mozilla rewrote their JS engine lately too but didn't check what improvements they made.
When implementing a scripting language VM, it does not really matter if you use C, C++, D, Ada, Eiffel, Pascal, Obj-C, Haskell or OCaml (or any of the top15 languages in the great language shootout). They all are pretty fast. The fact is, if you have studied CS and know mechanisms like dynamic translation, generational garbage collection, or region inference, you can build a fast scripting language VM in any decent language. D is in no way special here. In fact it is not even hard to make the fastest Javascript VM in the world with D - the current ones are not very good.
Studying CS has nothing to do with how competent you are, period. The number of languages and algorithms a guy can name has no relevance either. It can help to get you started, but anyone with enough interest in programming can learn much more on their own and in much less time. Sorry for the rant, I'm just tired of seeing CS thrown around as an argument. When it comes to writing scripting engines, with IR running in a VM or generated machine code, the language used is really just a matter of preference, it will affect productivity way more than performance, if the code is properly done. That's what I meant by easier to do in D, you'll have way less lines of code than in C/C++ or most other systems languages.
If I write the same code in OCaml or SML, it will be even shorter without apparent performance penalties. Apparently the fact that you do not have enough skills to use them makes them academic toy languages despite their commercial quality implementations and compilation to native code, and not systems programming languages.
 
 Now its only obvious that things like garbage collection and whatnot are
 required to be familiar to the programmer implementing it, no need to go
 to CS to know that :)
"Computer science (or computing science) is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems." I am not talking about getting a degree from some university. I have already said that you can read it all yourself if you do not like the pace they use to teach the same stuff. But still, it *is* computer science. You cannot really invent it all by yourself without studying existing work.
Sep 21 2009
next sibling parent reply language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 20:42:47 +0000, language_fan thusly wrote:

 I am not talking about getting a degree from some university. I have
 already said that you can read it all yourself if you do not like the
 pace they use to teach the same stuff. But still, it *is* computer
 science. You cannot really invent it all by yourself without studying
 existing work.
On the other hand, if you think you have re-invented from scratch everything we know about computer science topics today, by all means, do not hesitate to contact me. I am sure I can hire you. I am also sure folks like Turing, Knuth, Hoare, Kleene, Milner, McCarthy etc. would be proud of you since you can come up in a split second with much more complex topics than they invented in their whole lifetime. In that case it also makes sense to not call it computer science, because of geniuses like you, it is not worth calling a true form of science anymore, just a mere child's play.
Sep 21 2009
parent Jeremie Pelletier <jeremiep gmail.com> writes:
language_fan wrote:
 Mon, 21 Sep 2009 20:42:47 +0000, language_fan thusly wrote:
 
 I am not talking about getting a degree from some university. I have
 already said that you can read it all yourself if you do not like the
 pace they use to teach the same stuff. But still, it *is* computer
 science. You cannot really invent it all by yourself without studying
 existing work.
On the other hand, if you think you have re-invented from scratch everything we know about computer science topics today, by all means, do not hesitate to contact me. I am sure I can hire you. I am also sure folks like Turing, Knuth, Hoare, Kleene, Milner, McCarthy etc. would be proud of you since you can come up in a split second with much more complex topics than they invented in their whole lifetime. In that case it also makes sense to not call it computer science, because of geniuses like you, it is not worth calling a true form of science anymore, just a mere child's play.
It never was a true form of science to begin with, its like music theory: knowing music theory does not make you a musician, it only gives you the tools to describe music. A lot of influential musicians had little to no training in music theory just like a lot of influential programmers have no training in programming theory. Mathematics, physics, acoustics, to name a few, are sciences since their theory is used to describe the real world. Computer science is closer to engineering than to science anyways. What I meant in my original rant is that its one thing to study what the people you named invented, its a completely different thing to understand how they invented it. You can understand the most complex algorithm in the world and not be able to write your own, yet you could know nothing about existing algorithms and come up with the smartest one. Coming back to music, the theory evolved from people breaking the rules, from those who were thinking outside the box. Once their compositions got popular new theory was invented to describe what they did. If everyone follows theory blindly nothing will ever progress, no matter what the domain is.
Sep 21 2009
prev sibling parent reply Lutger <lutger.blijdestijn gmail.com> writes:
language_fan wrote:
...
 "Computer science (or computing science) is the study of the theoretical
 foundations of information and computation, and of practical techniques
 for their implementation and application in computer systems."
 
 I am not talking about getting a degree from some university. I have
 already said that you can read it all yourself if you do not like the
 pace they use to teach the same stuff. But still, it *is* computer
 science. You cannot really invent it all by yourself without studying
 existing work.
I think you forget one thing: software engineering is not exactly a science. Being able to prove the complexity of a certain algorithm doesn't mean you can architect a good domain model. For example, I have two books here lying at my desk. One is Programming language pragmatics, because I wanted to have more background on language design (out of interest, trying to follow the discussions here...). The other is Patterns of Enterprise Application Architecture because my employer was kind enough to organize a course on design patterns. Now the Fowler one isn't exactly CS while PLP is. Which one do you think weights more in a professional context?
Sep 21 2009
parent language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 23:50:55 +0200, Lutger thusly wrote:

 One is Programming
 language pragmatics, because I wanted to have more background on
 language design (out of interest, trying to follow the discussions
 here...). The other is Patterns of Enterprise Application Architecture
 because my employer was kind enough to organize a course on design
 patterns. Now the Fowler one isn't exactly CS while PLP is. Which one do
 you think weights more in a professional context?
Both. Design patterns are useless if e.g. the best sorting algorithm you know is the bubble sort. It is not worth the effort to always come up with new algorithms from scratch. For instance sorting is one domain where optimal solutions to many common problems are already known. Another one is parsing. To be honest, your question was a bit unfair. The programming language pragmatics book is a introductory level book on its domain (far from the state of the art PL books), the second one is an advanced level book written by one of the most appreciated veterans on the industry.
Sep 21 2009
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Justin Johansson:

I'd be interested to know how good D is for implementing scripting/dynamic
languages .. maybe that could change the odds?<
You can surely implement Ruby or JS or other dynamic languages with D1. But I don't know how this can change the diffusion of D a lot. A possible way to use (and spread) D on the web is to compile D (with LDC) for NaCl: http://code.google.com/p/nativeclient/ Bye, bearophile
Sep 21 2009
parent reply language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 14:01:27 -0400, bearophile thusly wrote:

 Justin Johansson:
 
I'd be interested to know how good D is for implementing
scripting/dynamic languages .. maybe that could change the odds?<
You can surely implement Ruby or JS or other dynamic languages with D1. But I don't know how this can change the diffusion of D a lot. A possible way to use (and spread) D on the web is to compile D (with LDC) for NaCl: http://code.google.com/p/nativeclient/
The native client has a rather static policy model. I suppose the future of mobile code is in dynamic languages like JVM & .NET based ones, Actionscript and Javascript. Of course you all disagree, you are free to do so. It just makes sense to me to use e.g. Java since it is not only faster than D in many cases, but it has a nice security model and a nice class loader (both of which are not perfect, though)
Sep 21 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
language_fan wrote:
 Mon, 21 Sep 2009 14:01:27 -0400, bearophile thusly wrote:
 
 Justin Johansson:

 I'd be interested to know how good D is for implementing
 scripting/dynamic languages .. maybe that could change the odds?<
You can surely implement Ruby or JS or other dynamic languages with D1. But I don't know how this can change the diffusion of D a lot. A possible way to use (and spread) D on the web is to compile D (with LDC) for NaCl: http://code.google.com/p/nativeclient/
The native client has a rather static policy model. I suppose the future of mobile code is in dynamic languages like JVM & .NET based ones, Actionscript and Javascript. Of course you all disagree, you are free to do so. It just makes sense to me to use e.g. Java since it is not only faster than D in many cases, but it has a nice security model and a nice class loader (both of which are not perfect, though)
It really just comes down to what the language allows you to do. You can easily write portable code in any language given the right platform abstraction, some of them just have that abstraction in the language itself at the cost of losing most of your freedoms. Java is mostly popular in academic contexts, it may have nice features but I don't see it getting popular among systems programmers anytime what systems languages provide: liberty. Its no wonders why companies like amazon and ebay write their web applications in systems languages, they get so much load that using anything else would require them to spend way more on more servers than they would on more competent programmers. Google also wrote their own web server program to get every ounce of performance they can out of a machine, something no scripting or "safe" language can achieve. In the end, different languages have different target audiences, dynamic languages target mostly the people who don't want to learn the full semantics of how computer works and quickly develop small to medium scale applications. Systems languages target programmers who understand how the computer works at its lowest levels and write real time or large scale programs. That's what most people I met who praised CS around failed to grasp: there are no "wrong" languages, and no "better" languages. But when you spent 3+ years of your life studying something your ego can get the best of you when you're given something else :)
Sep 21 2009
next sibling parent language_fan <foo bar.com.invalid> writes:
Mon, 21 Sep 2009 15:29:13 -0400, Jeremie Pelletier thusly wrote:

 language_fan wrote:
 Mon, 21 Sep 2009 14:01:27 -0400, bearophile thusly wrote:
 
 Justin Johansson:

 I'd be interested to know how good D is for implementing
 scripting/dynamic languages .. maybe that could change the odds?<
You can surely implement Ruby or JS or other dynamic languages with D1. But I don't know how this can change the diffusion of D a lot. A possible way to use (and spread) D on the web is to compile D (with LDC) for NaCl: http://code.google.com/p/nativeclient/
The native client has a rather static policy model. I suppose the future of mobile code is in dynamic languages like JVM & .NET based ones, Actionscript and Javascript. Of course you all disagree, you are free to do so. It just makes sense to me to use e.g. Java since it is not only faster than D in many cases, but it has a nice security model and a nice class loader (both of which are not perfect, though)
It really just comes down to what the language allows you to do. You can easily write portable code in any language given the right platform abstraction, some of them just have that abstraction in the language itself at the cost of losing most of your freedoms. Java is mostly popular in academic contexts, it may have nice features but I don't see it getting popular among systems programmers anytime what systems languages provide: liberty.
If you look at the job markets in Europe, most jobs require knowledge of Java, since maybe 10% of programming is with systems programming languages (50% of that in the embedded market), 10% uses scripting like the commercial world is divided between systems programming languages and scripting languages. In reality the "academic toy
 That's what most people I met who praised CS around failed to grasp:
 there are no "wrong" languages, and no "better" languages. But when you
 spent 3+ years of your life studying something your ego can get the best
 of you when you're given something else :)
State of the art CS is not using Java anymore. Praising Java is not academic wistful dreaming.
Sep 21 2009
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Jeremie Pelletier:

 Java is mostly popular in academic contexts, it may have nice features 
 but I don't see it getting popular among systems programmers anytime 

 what systems languages provide: liberty.
 
 Its no wonders why companies like amazon and ebay write their web 
 applications in systems languages, they get so much load that using 
 anything else would require them to spend way more on more servers than 
 they would on more competent programmers. Google also wrote their own 
 web server program to get every ounce of performance they can out of a 
 machine, something no scripting or "safe" language can achieve.
 
 In the end, different languages have different target audiences, dynamic 
 languages target mostly the people who don't want to learn the full 
 semantics of how computer works and quickly develop small to medium 
 scale applications. Systems languages target programmers who understand 
 how the computer works at its lowest levels and write real time or large 
 scale programs.
 
 That's what most people I met who praised CS around failed to grasp: 
 there are no "wrong" languages, and no "better" languages. But when you 
 spent 3+ years of your life studying something your ego can get the best 
 of you when you're given something else :)
[Please allow me a bit of flamebait once in a while] I am sorry, but most things written in this post are wrong :-) Bye, bearophile
Sep 21 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
I know, I have to explain why...

Jeremie Pelletier:

Java is mostly popular in academic contexts,<
In my university they teach mostly Java the fist two years, but usually Java is not seen as a research language. For that they usually use parallel languages or functional ones, or logic ones, etc. Java is the most used on servers and for business-oriented situations.
 it may have nice features
 but I don't see it getting popular among systems programmers anytime
 soon.
This is true, but the percentage of system programmers isn't very large compared to all programmers.

 what systems languages provide: liberty.
and values, you can give a specific layout to such structs, you can even use enums. You can use pointers is unsafe sections of code. This is not full freedom yet, but it's quite more freedom than Java offers, and it's enough for lot of people. Regarding the "system language" purposes, that is to write an operating system kernel, take a look at the one Microsoft is writing using an extended language it's able to remove most of the overhead caused by being "safe". The result is something that may be efficient enough even for a kernel.
 Its no wonders why companies like amazon and ebay write their web
 applications in systems languages, they get so much load that using
 anything else would require them to spend way more on more servers than
 they would on more competent programmers. Google also wrote their own
 web server program to get every ounce of performance they can out of a
 machine, something no scripting or "safe" language can achieve.
Today Java is usually fast enough for such purposes. Google uses some C++ for some core components of its search engine (probably the ones that have to process brutal amounts of data), but it also uses a ton of Python (and Java) for many other purposes. I think C++ is almost a niche language at Google.
 In the end, different languages have different target audiences, dynamic
 languages target mostly the people who don't want to learn the full
 semantics of how computer works and quickly develop small to medium
 scale applications. Systems languages target programmers who understand
 how the computer works at its lowest levels and write real time or large
 scale programs.
Probably today Java allows to write programs bigger than C++ ones. higher abstractions. They are designed to avoid bugs, to write programs in less time, and allow programmers to focus more on the problems and less on the ways to write the programs.
 That's what most people I met who praised CS around failed to grasp:
 there are no "wrong" languages, and no "better" languages. But when you
 spent 3+ years of your life studying something your ego can get the best
 of you when you're given something else :)
CS teaches you lot of important things that are harder to learn elsewhere. For example if you want to write a new compiler for Haskell you have to know your good CS courses :-) Bye, bearophile
Sep 21 2009
parent reply Walter Bright <newshound1 digitalmars.com> writes:
bearophile wrote:
 I think C++ is almost a
 niche language at Google.
Every chance I get, I ask programmers what languages their companies use. In the last 5 years, I've seen a steady shrinking of the amount of I've also seen a drying up of excitement about C++ and what you can do with it. The major impediment I find to D adoption is the lack of an IDE that is as productive as VS.
Sep 23 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter Bright:

 bearophile wrote:
 I think C++ is almost a
 niche language at Google.
Every chance I get, I ask programmers what languages their companies use. In the last 5 years, I've seen a steady shrinking of the amount of
problems, but they are usually tolerable. Its main problem is to be a freedom than Java), while being "safe" and allowing for good IDEs. Programming to D. The ecological niche for D is shrinking, programmers like VMs with lot of libraries, good IDE and good amount of modules available. I like D, but I don't know if all the work spent on creating D is somewhat wasted effort. My friends don't seem interested in a "better C++"... Bye, bearophile
Sep 23 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
bearophile wrote:
 Walter Bright:
 
 bearophile wrote:
 I think C++ is almost a niche language at Google.
Every chance I get, I ask programmers what languages their companies use. In the last 5 years, I've seen a steady shrinking of
some problems, but they are usually tolerable. Its main problem is to lot of more freedom than Java), while being "safe" and allowing for corner cases present in C++ and the language is designed to be not niche for D is shrinking, programmers like VMs with lot of libraries, good IDE and good amount of modules available. I like D, but I don't know if all the work spent on creating D is somewhat wasted effort. My friends don't seem interested in a "better C++"...
An opposing trend is that single processor speed is plateau-ing, at least for the time being. This means two things. One, parallelism is becoming increasingly important. Second, efficient languages will be sought after because new applications will always put more demands on processing speed. Until recently, it was the case that processing speed increased together with new software releases (leading to the bloatware we know), but that needs to change now. So I see the niche for D growing for the time being. Andrei
Sep 23 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Andrei Alexandrescu wrote:
 bearophile wrote:
 Walter Bright:

 bearophile wrote:
 I think C++ is almost a niche language at Google.
Every chance I get, I ask programmers what languages their companies use. In the last 5 years, I've seen a steady shrinking of
some problems, but they are usually tolerable. Its main problem is to lot of more freedom than Java), while being "safe" and allowing for corner cases present in C++ and the language is designed to be not niche for D is shrinking, programmers like VMs with lot of libraries, good IDE and good amount of modules available. I like D, but I don't know if all the work spent on creating D is somewhat wasted effort. My friends don't seem interested in a "better C++"...
An opposing trend is that single processor speed is plateau-ing, at least for the time being. This means two things. One, parallelism is becoming increasingly important. Second, efficient languages will be sought after because new applications will always put more demands on processing speed. Until recently, it was the case that processing speed increased together with new software releases (leading to the bloatware we know), but that needs to change now. So I see the niche for D growing for the time being. Andrei
I agree with Andrei, D is still in its infancy. C++ might be getting less popular in certain domains, companies nowadays don't want to spend much in development anymore and wrongly focus their resources on marketing instead. However I do believe D has the potential to tap into this market; it gives much more freedom in the hands of the programmer than Java and is than C/C++ provides. Once the shared qualifier gets an usable specification, and a few different concurrent models are implemented in the runtime and completely abstracted from any underlying libraries or mechanisms, D will definitely have an edge over other languages. Most languages I've seen implement either one concurrent model, or none. I would love to see the D runtime implement at least four concurrent models: vector processing (OpenCL), message passing, software transactional memory and shared memory. I will definitely try and implement them in my runtime when I get to it. I believe in giving a complete set of tools to the programmer and letting them decide which is best suited for what they're doing. And having all four of these models in D would really put it at the front of concurrent programming languages. I also agree with Walter about the lack of an IDE for D as powerful as Visual Studio, I myself use poseidon only because of its overly simple build process and simple project manager and debug in windbg. But that isn't the case with most programmers who like or dislike a language based on the IDE they use. Jeremie
Sep 23 2009
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeremie Pelletier wrote:
 I also agree with Walter about the lack of an IDE for D as powerful as 
 Visual Studio, I myself use poseidon only because of its overly simple 
 build process and simple project manager and debug in windbg. But that 
 isn't the case with most programmers who like or dislike a language 
 based on the IDE they use.
I do hear over and over that without a VS workalike IDE, programmers just aren't interested in a language. They argue, probably with a lot of merit, that the productivity increase of using VS is more than the productivity increase of using a better language. It's clear Microsoft has hit a home run with VS. I was talking to some serious hardcore C++ programmers yesterday. One was a die-hard emacs user, and he admitted that he'd switched to VS and wasn't looking back, it was that much better. I asked him what the killer feature of VS was, and he said it was being able to instantly see every use and definition of a symbol. (With emacs he'd have to run ctags first, and even then ctags was inaccurate and clumsy.)
Sep 23 2009
next sibling parent Jeremie Pelletier <jeremiep gmail.com> writes:
Walter Bright wrote:
 Jeremie Pelletier wrote:
 I also agree with Walter about the lack of an IDE for D as powerful as 
 Visual Studio, I myself use poseidon only because of its overly simple 
 build process and simple project manager and debug in windbg. But that 
 isn't the case with most programmers who like or dislike a language 
 based on the IDE they use.
I do hear over and over that without a VS workalike IDE, programmers just aren't interested in a language. They argue, probably with a lot of merit, that the productivity increase of using VS is more than the productivity increase of using a better language. It's clear Microsoft has hit a home run with VS. I was talking to some serious hardcore C++ programmers yesterday. One was a die-hard emacs user, and he admitted that he'd switched to VS and wasn't looking back, it was that much better. I asked him what the killer feature of VS was, and he said it was being able to instantly see every use and definition of a symbol. (With emacs he'd have to run ctags first, and even then ctags was inaccurate and clumsy.)
Yeah I'm also a die hard fan of VS when coding C/C++, while I don't require many features when I write code other than a project manager, syntax highlighter and a convenient build tool, I do use way more of its features when I study code I didn't write myself. The ability to grep for every reference to a given symbol from a simple click is simply amazing for that, jumping to the declaration of a symbol is also as useful, so is the call browser. An IDE doesn't require a large set of features to be useful, but it definitely needs to implement the features it has in such a convenient way that you don't notice their presence. I myself often disable the annoying suggestion popups in an IDE and a few other features, but thats just me :)
Sep 23 2009
prev sibling parent Bill Baxter <wbaxter gmail.com> writes:
On Wed, Sep 23, 2009 at 11:21 AM, Walter Bright
<newshound1 digitalmars.com> wrote:
 Jeremie Pelletier wrote:
 I also agree with Walter about the lack of an IDE for D as powerful as
 Visual Studio, I myself use poseidon only because of its overly simple build
 process and simple project manager and debug in windbg. But that isn't the
 case with most programmers who like or dislike a language based on the IDE
 they use.
I do hear over and over that without a VS workalike IDE, programmers just aren't interested in a language. They argue, probably with a lot of merit, that the productivity increase of using VS is more than the productivity increase of using a better language. It's clear Microsoft has hit a home run with VS. I was talking to some serious hardcore C++ programmers yesterday. One was a die-hard emacs user, and he admitted that he'd switched to VS and wasn't looking back, it was that much better. I asked him what the killer feature of VS was, and he said it was being able to instantly see every use and definition of a symbol. (With emacs he'd have to run ctags first, and even then ctags was inaccurate and clumsy.)
Yep, and being able to jump to the definitions of things instantly without rooting around through a bunch of source files where you think you remembered seeing it. Or which sound promising based on the name of the file. But I think Descent can now do this kind of thing to some extent. It seems to be getting better and better all the time. --bb
Sep 23 2009
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeremie Pelletier wrote:
 That's what most people I met who praised CS around failed to grasp: 
 there are no "wrong" languages, and no "better" languages.
I can't agree with that. I've used many different languages. There are definitely languages that are better than others. If that weren't true, it would be pointless to even try to improve languages. It's like airplane design. There are better designs and worse designs, and some designs so bad the airplane won't even get off the ground.
Sep 23 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Walter Bright wrote:
 Jeremie Pelletier wrote:
 That's what most people I met who praised CS around failed to grasp: 
 there are no "wrong" languages, and no "better" languages.
I can't agree with that. I've used many different languages. There are definitely languages that are better than others. If that weren't true, it would be pointless to even try to improve languages. It's like airplane design. There are better designs and worse designs, and some designs so bad the airplane won't even get off the ground.
Hmm, you do make a good point. What I was trying to say is that different languages will serve different purposes, if there was a better language it would be the only one used until another one arises to take its place, no matter what its used to develop. I use PHP and JavaScript on web development, shell scripts for automated tasks, and C/C++/D for almost everything else, maybe with a LUA/Python frontend to allow easy customizations and assembly for low level optimizations. Of all the languages I just named its impossible to pick the best one since they all have their purposes, therefore making it impossible to also pick a worst one.
Sep 23 2009
parent reply BCS <none anon.com> writes:
Hello Jeremie,

 making it impossible to also pick a worst one.
 
"worst" no. But it's easy to find "worse" languages, just start listing languages no one uses.
Sep 23 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
BCS wrote:
 Hello Jeremie,
 
 making it impossible to also pick a worst one.
"worst" no. But it's easy to find "worse" languages, just start listing languages no one uses.
Yeah, but its like calling for a failed experiment, there is no such thing, only experiments. Think of these "worse" languages as experiments on how not to design languages :) Besides I was talking about better or worse in the scope of languages which are actually used.
Sep 23 2009
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeremie Pelletier wrote:
 Yeah, but its like calling for a failed experiment, there is no such 
 thing, only experiments. Think of these "worse" languages as experiments 
 on how not to design languages :)
 
 Besides I was talking about better or worse in the scope of languages 
 which are actually used.
Many languages are "worse" because they solve problems that no longer exist, use techniques that have been obsoleted by newer ideas, were constrained by issues that have since gone away, etc. This often doesn't stop zealots from using them, but their numbers shrink steadily as they die off and are not replenished :-) It's sort of like when quantum mechanics theory rose in the physics world. Acceptance of it was with the new physicists, not the old guard, and QM didn't become dogma until the old guard died off.
Sep 23 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Walter Bright wrote:
 Jeremie Pelletier wrote:
 Yeah, but its like calling for a failed experiment, there is no such 
 thing, only experiments. Think of these "worse" languages as 
 experiments on how not to design languages :)

 Besides I was talking about better or worse in the scope of languages 
 which are actually used.
Many languages are "worse" because they solve problems that no longer exist, use techniques that have been obsoleted by newer ideas, were constrained by issues that have since gone away, etc. This often doesn't stop zealots from using them, but their numbers shrink steadily as they die off and are not replenished :-) It's sort of like when quantum mechanics theory rose in the physics world. Acceptance of it was with the new physicists, not the old guard, and QM didn't become dogma until the old guard died off.
True, which is why we have a thing called progress, and I'm glad I found about D for that reason, since it's quite a refreshing feel to the world of systems languages. That does not make every code using C/C++ wrong. Quantum theory is far from being complete, and so is general relativity, we're still searching for that "god particle" and a way to unify those two theories. It does not make these two theories "wrong" but rather required stepping stones to attain a better one. Just like Newton's theory was a stepping stone for Einstein, among others. And I would like to mention that even if Newton's theories have been outdated for almost a hundreds years now, they're still widely used as being *much* cheaper to compute for no noticeable difference, so long as we stay in our scale of things. You don't need to learn differential algebra to understand Newton either. Those new and better ways of doing things in programming languages might imply semantics some programmers are not willing to use, and would rather keep their older language and implement their own version of that feature themselves, pure C will always dominate in that in my opinion since I can't think of anything in the language itself that generate calls to runtime methods, which fortunately can also be done in D. A lot of D features require runtime calls, not everyone is willing to dig into the runtime to learn what such calls imply in terms of performance. For example, I myself stay off scope() for real time code because I'm aware it needs to call into _d_framehandler. Maybe I'm just too optimistic, but I have a hard time labeling things as "wrong", I prefer to use the term "different" :)
Sep 23 2009
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Jeremie Pelletier wrote:
 Those new and better ways of doing things in programming languages might 
 imply semantics some programmers are not willing to use, and would 
 rather keep their older language and implement their own version of that 
 feature themselves, pure C will always dominate in that in my opinion 
 since I can't think of anything in the language itself that generate 
 calls to runtime methods,
There are several things that do - things like floating point conversions, long division, etc.
 which fortunately can also be done in D. A lot 
 of D features require runtime calls, not everyone is willing to dig into 
 the runtime to learn what such calls imply in terms of performance. For 
 example, I myself stay off scope() for real time code because I'm aware 
 it needs to call into _d_framehandler.
That's only called when handling an exception, not for just setting up the frame and normally executing it. Also, if you annotate your functions as "nothrow", and your guarded statements do not throw, the compiler will elide the exception handling code.
Sep 23 2009
parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Walter Bright wrote:
 Jeremie Pelletier wrote:
 Those new and better ways of doing things in programming languages 
 might imply semantics some programmers are not willing to use, and 
 would rather keep their older language and implement their own version 
 of that feature themselves, pure C will always dominate in that in my 
 opinion since I can't think of anything in the language itself that 
 generate calls to runtime methods,
There are several things that do - things like floating point conversions, long division, etc.
Aren't those just part of the generated machine code? I mean the compiler does not add calls to symbols which need to be resolved in the runtime library.
 which fortunately can also be done in D. A lot of D features require 
 runtime calls, not everyone is willing to dig into the runtime to 
 learn what such calls imply in terms of performance. For example, I 
 myself stay off scope() for real time code because I'm aware it needs 
 to call into _d_framehandler.
That's only called when handling an exception, not for just setting up the frame and normally executing it. Also, if you annotate your functions as "nothrow", and your guarded statements do not throw, the compiler will elide the exception handling code.
Oh, I haven't thought of that, I was sure nothrow was still just a reserved keyword. Thanks for that information, I will make sure to get the best of it now :)
Sep 23 2009
parent Walter Bright <newshound1 digitalmars.com> writes:
Jeremie Pelletier wrote:
 Walter Bright wrote:
 Jeremie Pelletier wrote:
 Those new and better ways of doing things in programming languages 
 might imply semantics some programmers are not willing to use, and 
 would rather keep their older language and implement their own 
 version of that feature themselves, pure C will always dominate in 
 that in my opinion since I can't think of anything in the language 
 itself that generate calls to runtime methods,
There are several things that do - things like floating point conversions, long division, etc.
Aren't those just part of the generated machine code? I mean the compiler does not add calls to symbols which need to be resolved in the runtime library.
No, they are calls to functions in the runtime library. All C compilers I know of do this.
Sep 23 2009
prev sibling parent Lutger <lutger.blijdestijn gmail.com> writes:
language_fan wrote:

 Sun, 20 Sep 2009 01:09:56 +0000, language_fan thusly wrote:
 
 Sat, 19 Sep 2009 11:44:33 -0700, Walter Bright thusly wrote:
 
 Lutger wrote:
 Cool article, I posted a comment. Reddit seems to be going downhill
 fast though, it's even worse than slashdot.
I know, the negative comments don't even make any sense.
 Are locally instantiated templates used in phobos?
Yes.
I read the comments and I think some of them are justified. You cannot really expect the way you built dmd to be the only alternative. Efficient closures can be implemented differently if you have a VM that supports precise generational gc, region inference, and the language is a bit more value oriented (= functional).
Where does it say that the article describes the one true method?
 Another thing is that often when an article about D is released, the only
 positive comments come from the members of the existing (smallish)
 community. There is no real interest in D outside the community (IMHO).
 Reddit's programming section is full of language fanatics, thus it is a
 bit hard to impress folks with tiny tricks as they daily work with
 various programming languages and concepts.
The majority of the negative comments on this post follow one of two lines of attacks: 1) D sucks or 2) Glaringly obvious straw man. From most of these, it's quite clear they haven't even read the article but responded anyway.
Sep 20 2009
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
language_fan wrote:
 I read the comments and I think some of them are justified. You cannot 
 really expect the way you built dmd to be the only alternative. Efficient 
 closures can be implemented differently if you have a VM that supports 
 precise generational gc, region inference, and the language is a bit more 
 value oriented (= functional).
I don't understand how the article implies that it describes the only way to do it. It only describes *a* way.
Sep 23 2009