The Artima Developer Community
Sponsored Link

Java Community News
Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs

31 replies on 3 pages. Most recent reply: Apr 28, 2008 1:43 PM by dark mx

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 31 replies on 3 pages [ 1 2 3 | » ]
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 14, 2008 6:13 PM
Reply to this message Reply
Summary
In a wide-ranging interview with MSDN's Howard Dierking, Bjarne Stroustrup, designer of the C++ programming language, shares his views on domain-specific languages, loosely-typed systems, languages that support multiple dispatch, and on code readability and programming style.
Advertisement

Bjarne Stroustrup, designer of the C++ programming language, was interviewed recently on Microsoft Developer Network, Bjarne Stroustrup on the Evolution of Languages. The interview focused on a range of topics, including domain languages and code readability, and even on Stroustrup personal development style preferences. The most interesting parts of the interview focused on code readability, especially in the context of a general-purpose programming language versus domain-specific languages:

I think that a DSL should be a last resort, not a first. If at all possible, the DSL should be firmly rooted in a general-purpose language and standard tool chains. A DSL needs a general-purpose language (or at least a systems programming language) for its implementation and the implementation of its run-time primitives...

I think it would be best if a DSL is consciously and firmly paired with at least one general-purpose language so that it is easy to add new facilities through the use of libraries written in that general-purpose language...

Obviously, a professional should master several languages, but I do wonder if the sum of complexity of a variety of DSLs couldn't become so high that it became a problem. Also, many (if not most) DSLs seem to "want to" become general-purpose languages.

Stroustrup also shared his views on what makes a general-purpose language successful:

A general-purpose language is constrained not only by the need to support a wide variety of uses, but also by the need to be teachable to large groups of people with a variety of assumptions and educational backgrounds (the basics have to be usable by a high-school student with a poor teacher)...

So I think a general-purpose language can encourage elegance as long as elegant code can be expressed in it. In the case of C++, very elegant code can be written. By being part of a general-purpose language and widely available, such examples can get into the hands of millions and into articles and textbooks that can be read by millions. No specialized language—however elegant—has those options.

Stroustrup was asked about the relationship between readability and the overall productivity of a language, especially in the context of C++:

A simpler syntax would be nice, but I suspect that what most people grumble about when they talk about readability is not so much the actual text as the complexity of what is being expressed...

Too many people expect to walk up to any program written in any language and—with only a bit of help from an online support facility—understand all the constructs used to express the program and all the logic of the program itself.

Compare that to the way we look at natural languages and use them. Would you expect to understand a Shakespearean sonnet without background information? How about Beowulf in the original Old English? Maybe we expect too much from our programming languages.

Any language that can express all that is needed for a wide range of application areas could be considered unnecessarily complex for any given application, but it must cope with an essentially unbounded set of applications. Domain-specific languages can help in specific cases, but now we have to deal with the complexities of many languages and their interactions.

In the context of readability, Stroustrup spoke about static and dynamic languages:

I don't think we have a choice between static and dynamic languages in general and furthermore I don't think languages cleanly fit into those two categories: most if not all dynamic languages have aspects that are statically determined, and all the major static languages can do things that require run-time determination of the meaning of values. There are fashions, of course, and I can't guess about those, but I think that many real-world language choices are rationally made based on the requirements of an application, an application area, and/or the skills of the available developers.

In the rest of the interview, Stroustrup discusses his views on languages that support multiple dispatch, on the importance of knowing more than one programming language well, and on his views on buzzwords, such as "agile" development.

What do you think of Stroustrup's views on language evolution?


Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 6:36 AM
Reply to this message Reply
I think that we can talk about C++ as a serious contender for big projects after it has garbage collection. The rest of the issues are not of that importance.

Frank Wilhoit

Posts: 21
Nickname: wilhoit
Registered: Oct, 2003

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 10:10 AM
Reply to this message Reply
I think we can talk about a programmer as a serious candidate after they don't need garbage collection any longer.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 10:32 AM
Reply to this message Reply
> I think that we can talk about C++ as a serious contender
> for big projects after it has garbage collection. The rest
> of the issues are not of that importance.

Serious contender? It's used for embedded devices, operating systems and large scale applications. How much of windows is written in C++.

From what I can find the majority of windows in written in C++. MySQL is mostly C++. Are those not big enough? How many lines of code are in the windows source?

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 1:53 PM
Reply to this message Reply
This sentence intrigued me:

"I published a research paper on how to cleanly add multiple dispatch to C++. The resulting code for multiple dispatch use-cases is shorter, simpler, uses less memory, and runs faster than all workarounds we have seen (see Figure 2). That work came too late for C++0x, though."

Does it mean that we may get multimethods in the post C++0x standard?

Alex Stojan

Posts: 95
Nickname: alexstojan
Registered: Jun, 2005

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 2:06 PM
Reply to this message Reply
> This sentence intrigued me:
>
> "I published a research paper on how to cleanly add
> multiple dispatch to C++. The resulting code for multiple
> dispatch use-cases is shorter, simpler, uses less memory,
> and runs faster than all workarounds we have seen (see
> Figure 2). That work came too late for C++0x, though."
>
> Does it mean that we may get multimethods in the post
> C++0x standard?

That was my understanding too; at least it sounded like there was or will be an attempt to push this into a (future) C++ standard.

Howard Lovatt

Posts: 321
Nickname: hlovatt
Registered: Mar, 2003

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 15, 2008 5:06 PM
Reply to this message Reply
@Nemanja & Alex,

If you are interested in multiple dispatch my pet project:

https://pec.dev.java.net/nonav/compile/index.html

adds it to Java along with other design patterns

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 16, 2008 9:45 AM
Reply to this message Reply
If you are interested in multiple dispatch... And option types, and anonymous functions, and ... compiling to JVM bytecode

"The Nice programming language"
http://nice.sourceforge.net/

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 16, 2008 9:55 AM
Reply to this message Reply
> Serious contender? It's used for embedded devices,

Very few embedded devices.

> operating systems

Nope. Unless you are talking experimental kernels.

> and large scale applications.

No, it's not used by any large scale application. Commercial large scale applications use Cobol, Java, and a set of other languages.

How much
> of windows is written in C++.

Not much of it. Windows is written in C, mostly, and in .NET, recently.

>
> From what I can find the majority of windows in written in
> C++. MySQL is mostly C++. Are those not big enough? How
> many lines of code are in the windows source?

So that's why Explorer, Internet Explorer, Outlook, Word, Excel, Powerpoint, Firefox, Thunderbird, M-Torrent, Deluge, Visual Studio and every other C++ app has occasionally crashed...it's written in C++...that explains it.

(yes, I am trolling, but if you don't understand the importance of GC for big projects, you, my dear reader, are trolling as well...)

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 16, 2008 10:39 AM
Reply to this message Reply
I would like to ask the Artima editors to introduce some minimal amount of moderation on their forums. It is hard to find a discussion on C++ that does not get ruined by constant trolling by the same people.

Thank you.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 16, 2008 11:12 AM
Reply to this message Reply
> > Serious contender? It's used for embedded devices,
>
> Very few embedded devices.
>
> > operating systems
>
> Nope. Unless you are talking experimental kernels.
>

Symbian OS? You can even find some recent articles on this site talking about this. e.g. http://www.artima.com/weblogs/viewpost.jsp?thread=225544
Hardly experimental.

> > and large scale applications.
>
> No, it's not used by any large scale application.
> Commercial large scale applications use Cobol, Java, and a
> set of other languages.
>
> How much
> > of windows is written in C++.
>
> Not much of it. Windows is written in C, mostly, and in
> .NET, recently.
>

Strangely, I found this quote from bill gates regarding the windows code base

Here's the official word straight from the horse's mouth:
"It was written primarily in C++, with some machine language mixed in.
Most of the new code is written in C++." --Bill Gates

> >
> > From what I can find the majority of windows in written
> in
> > C++. MySQL is mostly C++. Are those not big enough? How
> > many lines of code are in the windows source?
>
> So that's why Explorer, Internet Explorer, Outlook, Word,
> Excel, Powerpoint, Firefox, Thunderbird, M-Torrent,
> Deluge, Visual Studio and every other C++ app has
> occasionally crashed...it's written in C++...that explains
> it.
>

Java apps do a fine job of crashing as well. I think I only need point at the Oracle administrative tools to show an exhibit of how bad java code can be. NullPointerException being my favorite Java error message. Yaaaay null pointers.

> (yes, I am trolling, but if you don't understand the
> importance of GC for big projects, you, my dear reader,
> are trolling as well...)

Understanding the importance of GC is a far cry from saying a language is not "a serious contender for big projects" because it doesn't have garbage collection.

Here's a list. I guess you can play the 'consider the source' card, but I know people that work at Amazon and Microsoft and can say those two are accurate.

http://www.research.att.com/~bs/applications.html

I see at least a few things on there I would consider big projects.

I'm not trolling. I'm simply stating that your statement about C++ not being a serious contender for big projects because it lacks garbage collection is false. There is so much evidence to the contrary I can't understand what would prompt that statement.

Alex Stojan

Posts: 95
Nickname: alexstojan
Registered: Jun, 2005

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 16, 2008 6:53 PM
Reply to this message Reply
> I would like to ask the Artima editors to introduce some
> minimal amount of moderation on their forums. It is hard
> to find a discussion on C++ that does not get ruined by
> constant trolling by the same people.
>
> Thank you.

I agree. It seems to me that some statements we see here come from frustration rather than rational thinking and as such don't make much sense. Why would someone blame C++ if they have to fix code written by someone else that has lots of memory leaks (referring to some previous statements)? Blame the people who wrote the code! I use C++ every day and we have a huge framework written in it and there are rarely bugs related to memory leaks, and where there were such bugs they were always localized and easy to fix.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 17, 2008 12:28 AM
Reply to this message Reply
> > Not much of it. Windows is written in C, mostly, and in
> > .NET, recently.
> >
>
> Strangely, I found this quote from bill gates regarding
> the windows code base
>
> Here's the official word straight from the horse's mouth:
> "It was written primarily in C++, with some machine
> language mixed in.
> Most of the new code is written in C++." --Bill Gates

It's probably worth mentioning that he said this in 1995 and was talking in the past tense, so the reference would be to Windows 3.1 and earlier rather than Windows 95 and later.

Germán Diago

Posts: 7
Nickname: germandiag
Registered: Apr, 2008

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 17, 2008 4:40 AM
Reply to this message Reply
I think that C++ and Java, although similar syntax, require different idioms to be exploited.
C++ is a value-based language and Java is reference-based. If you combine well shared_ptr and rely mainly on automatic memory management (I mean stack-allocated objects with scope), you rarely need GC.
But people think that C++ should be used exactly as Java, and that's because many people have a background in Java. C++ is more powerful in many ways, but it lacks the big standard framework that Java has.
I've been using C++ for more or less 4-5 years, and value-semantics are a little more complicated than reference semantics, but you get code that can be very well optimized and you can rely on RAII to delete dynamic memory inside objects. And you also have very deterministic code, unlike with a GC.
A GC for C++ is good for OOP programming, but you can rely on shared_ptr and with almost no care (with no cycles) you can get very good results even without GC.
Anyway, I think the future C++0x and the runtime-concept library (poly-library from adobe) represent a far superior solution than traditional OOP design, because it will let us combine truly generic code with OOP.

Alex Fabijanic

Posts: 71
Nickname: aleksf
Registered: Aug, 2006

Re: Bjarne Stroustrup on Language Evolution, Multiple Dispatch, and DSLs Posted: Apr 17, 2008 4:46 AM
Reply to this message Reply
> No, it's not used by any large scale application.

Except for Amazon, Google, and most of the world's phone systems, to name a few.

Flat View: This topic has 31 replies on 3 pages [ 1  2  3 | » ]
Topic: ZeroTurnaround Releases JavaRebel 1.1 Previous Topic   Next Topic Topic: Scala and XML

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use