Programming Languages Side By Side


I’ve been thinking about a parallel programming language textbook for a while now. Not for parallel programming but I’m not sure how to phrase it. What? OK let me explain. One of the popular Bible study tools is a parallel Bible where several translations are printed side by side with each other. That way someone can easily compare how different interpretation teams have looked at the same Bible verses. What I have been thinking about for some time is a textbook of sorts that covers multiple programming languages in a similar parallel fashion. Each concept would show side by side examples in multiple languages. This way students would see different implementations – different syntax – for the same concepts. In theory (completely untested so far) this would build both a greater understanding of the concepts and make it easier for students to transition from one programming language to another.

From there is gets complicated. What languages and how many languages? Handling C++, C# and Visual Basic seems like a logical easy combination since all three languages are built into the Visual Studio IDE. Is there enough of a difference in early stages between C++ and C# though? Certainly in some areas like class creation and OOP concepts. Should Java be included realizing that a second IDE would be required? How about something like Small Basic which is largely a subset of Visual Basic?

How about completely different paradigms? F# will be in the next version of Visual Studio so would permit the easy (ok relatively speaking) inclusion of a functional programming language. That might over complicate the book though. I need input on that one. Is it worth trying? Similarly how about a graphic beginners language like Scratch or Alice? Some concepts would not translate at all but some of the early ones would fit in nicely.

How about some historic languages like FORTRAN (still often used in scientific programming) or COBOL (still used for many legacy applications with believe it or not some new development still taking place)? Not sure about the development environments for those though.

Help me brainstorm on this a bit please. Are you interested in seeing something like this? What would it include to make it useful?

Comments (13)

  1. Garth says:

    How about writing the book with no specific languages but based around pseudocode?  Threaded through the chapters would be samples from various languages.  For example start with a simple programming problem such as constructing a simple pong game.  The beginning of the chapter would define the problem as though talking to a customer.  Then step into the necessary procedures required for the game, i.e. three wall bounces, a paddle bounce and a miss. Once the program is outlined in pseudocode have the chapter break out in to the required coding for several languages.  Each chapter could target a fundamental programming concept and be cumulative.  Since I teach introductory programming I am thinking of an introductory level book designed for first and second semester high school kids.  Basing each chapter around a project would give the learners a goal.  As the level of complexity of the projects increases the kids will get the idea why use different languages for different projects.

  2. Brons says:

    For my money, looking for languages all supported in a single IDE is a bit counter to the thrust of the idea. One of the things that makes side by side Bible translations so helpful is the range of viewpoints. Using multiple Catholic translations can be a bit illuminating, but when translations favored by very different denominations always helped me more.

    Similarly, I’d like to sse not a cluster around Visual Studio, but say C# vs Objective C vs Ruby vs Java vs Javascript vs Python vs ANSI C vs Smalltalk vs FLEX. You can’t run all of them parallel through all examples, but if you pick the ones that best serve to illuminate a particular issue, it would really help in teaching.

    Of course if the book is going to be published by Microsoft, say, or Apple, then a structure that much more resembles a Bible study tool for Catholics or LDS members would be more appropriate. But recall that I was an agnostic who hosted the Bible study and discussions notesfile at DEC all those years ago and worked on PATHWORKS a product targeted at Vaxen, Macs and PCs and making them talk. I have a natural bias towards ecumenism in various realms.

  3. AlfredTh says:

    I’d probably look for a third party publisher. I have written and published though Cengage in the past for example.

    Initially I assumed that people might want to create/compile/rn all examples but that may not be the case. So including examples from several languages and letting people select which ones to build might be a way to go.

  4. Rob Miles says:

    Comparative languages are a great idea. I used to teach a course like this in our second year. The idea was to get students thinking about other paradigms, and how languages are influenced by the aims and priorities of their designers.

    At the end I got everyone write a pitch for a particular requirement as a representative of a given language, I remember some really good submissions from companies like "Eiffel Experts" and "Smalltalk Systems". Great fun.

    If it was me I’d look at Smalltalk (objects with everything), C/C++ (speed and danger), Prolog (just the facts and rules ma’am), Forth (polish Reverse?), F# (functional fun) and JavaScript(because it’s there, OK).

    I wouldn’t make that much distinction between C# and VB.NET really, because they have so much in common.

    I would not make this an introductory text. It is best to teach one programming language well (my preference is C#) and then move into the craft of programming later. I would see it as something you read once you thought you knew what programming was about…..

  5. David Klappholz says:

    Older parallel-text Bibles, like the Complutensian Polyglot Bible of the early 16th century, don’t have parallel translations, but, rather, have the text in different languages: Hebrew, Greek, Latin, etc.

  6. Steve Hiner says:

    As far as an IDE for Fortran, how about the .Net IDE.  I haven’t been keeping up with the development but I was a beta tester for Lahey years ago while they were working on Fortran.net and it integrated right into the VS IDE.

    Fortran has some very interesting features so it could be a useful language to contrast.  It’s not as radically different as something like F# but for mathematical work, especially working with arrays, it has some very handy syntax.

    By the way, I think around the Fortran 95 or Fortran 2000 days they quit using all caps.  I suppose if you refer to FORTRAN 77 you should still use all caps.

    I, for one, think your idea is quite interesting.  As far as language inclusion, you could just switch the languages used based on the chapter subject.  You could even include DOS Batch, BASH, VBScript and PowerShell in a chapter about command line scripting.

  7. Joe Enos says:

    It would appeal to me if it was a side-by-side of a mainstream language vs. a newer less-well-known language.  The perfect scenario for me would be C# vs. F#, and the book would basically be a "learn F#" book for people who already know C#.

    Depending on how you implement it, you may have to stick with different languages in the same world (.NET for example), so that the code really does the exact same thing, from two different languages’ points of view.

    If you tried to compare something like C# and Java, for example, you’d find issues on any non-trivial code when C# uses the .NET BCL since it’s not in the Java world, and anything that uses the Java base classes since they’re not in the .NET world.  You’d be showing how to accomplish tasks in both languages, as opposed to how to accomplish specific lines of code in another language.  Then it’s just more of a "how to accomplish task X in language Y" book, except with two languages.  For example, reading text from a textfile – there are a dozen ways of accomplishing this in .NET, and probably as many ways of doing it in Java – but do each of the strategies map one-to-one between the two languages, when talking about side effects, file locking, how the text is stored in memory, etc.?

    For my money, I’d say C# vs. F# would be an amazing tool for C# developers to learn F#.  (Same on a lesser scale for C# vs. VB.NET, or C# vs. MC++, or even C# vs. J#).  The idea of comparing unrelated languages would be interesting, but in my opinion, not as special as C# vs. F#.

  8. Andrew Nutter-Upham says:

    I’ve actually encountered a similar idea at the RosettaCode wiki ( http://www.rosettacode.org/wiki/Main_Page ). I think the notion is great. I often refer to code examples when moving into a new language. And I think that illustrating the differences between a low level language (C/C++) and a higher one, or, as you said, between oo and functional would be interesting, especially for people who already know one. I’m not sure how it would play out for someone who knew neither since I think the ability to understand problems across different syntaxes often comes from an understanding  of the abstract components of the possible solutions. For someone new to programming it might be overwhelming.

  9. Mike Mol says:

    Rosetta Code is my site.  I’ve been meaning to programmatically export PDFs on a quarterly basis, and sell hardcopies via a POD service as a kind of fundraiser for it.  Haven’t gotten around to it for a combination of technical, temporal and financial reasons.

    The content is GFDL, of course, and I would honor the license right down to listing contributors.  I’d be happy for advice or assistance; As it was, it was going to be little more than an arrangement of the best task pages, for some heuristically-determined value of "best". (Perhaps based on popularity determined from analytics data, or by example count.  Not sure.  Plenty of ideas and options.)

  10. Tom says:

    You must be a VB programmer if you think that C++ and C# are similar enough to be able to omit one or the other. :o)

    Needless to say, I would keep both.  In addition to the language differences, these two languages also differ in terms of the libraries that are used.  Specifically C++ developers typically use the standard C and C++ libraries, whereas in C# of course you’re using .NET.  Big difference there, even for getting started.

    I think Java is also important, due mainly to its popularity.  If you cover C/C++, C#, VB, and Java, you’ve covered probably 3/4 of the market.  I think it is a mistake to try to go into the "long tail" after that.

    Maybe some other commenters already mentioned this, but IMO the majority of the learning curve in learning a new language is learning the APIs of the supporting environment.  For example, I’ve been using C++ for about 20 years, and I consider myself an expert in that language.  Many of those years have been programming against the Win32 APIs, and I have to admit, I still need to refer to MSDN quite a lot when calling Win32 APIs.  Same for C# and .NET.

  11. Tom says:

    You must be a VB programmer if you think that C++ and C# are similar enough to be able to omit one or the other. :o)

    Needless to say, I would keep both.  In addition to the language differences, these two languages also differ in terms of the libraries that are used.  Specifically C++ developers typically use the standard C and C++ libraries, whereas in C# of course you’re using .NET.  Big difference there, even for getting started.

    I think Java is also important, due mainly to its popularity.  If you cover C/C++, C#, VB, and Java, you’ve covered probably 3/4 of the market.  I think it is a mistake to try to go into the "long tail" after that.

    Maybe some other commenters already mentioned this, but IMO the majority of the learning curve in learning a new language is learning the APIs of the supporting environment.  For example, I’ve been using C++ for about 20 years, and I consider myself an expert in that language.  Many of those years have been programming against the Win32 APIs, and I have to admit, I still need to refer to MSDN quite a lot when calling Win32 APIs.  Same for C# and .NET.

  12. Michael Mol says:

    Mr. Thompson, the term you’re looking for is "<a href="http://en.wikipedia.org/wiki/Program_Chrestomathy"program chrestomathy</a>."

    If you’re wondering which languages you should include, it depends on what you’re trying to accomplish.  Are you trying to teach your reader how to learn to adapt quickly between languages of similar paradigm and idiom, or are you trying to teach your reader to consider multiple paradigms while coding and potentially recognize when a different paradigm might be more suited to a given task?

    I can think of a book structure that might accomplish both.  Take three <a href="http://www.rosettacode.org/wiki/Language_Comparison_Table">paradigms</a&gt;, and find two (perhaps three) languages for each paradigm.  Then create a series of 48 tasks, and solve them in each language for the paradigm you’ve chosen.  When laid out in the textbook, each of these tasks would be missing one or more of the examples you prepared; The exercise for the reader/student is to find an appropriate solution for the missing language(s) for each task.  The Instructor’s Edition would contain all of the missing code, but with the caveat that the student’s submissions needn’t be statement-per-statement identical with the solution code.

    Personally, I think having more than one language per paradigm is important, at least in the training phase, to help the student identify and distinguish where a program written in a functional programming language is different from a program written in an object-oriented language because of the paradigm, and not just because of differences in the language syntax.

    And don’t worry too much about the development environment.  Yes, it would be nice if you could package Visual Studio Express with the book.  But that doesn’t preclude you from including ActiveState Python, MinGW (It’s not just a C/C++ compiler) or GHC.  Throw in JEdit to provide a more comfortable editing environment in the languages that VS doesn’t support.

    As far as language and syntax comparisons within a paradigm set, beware the dangers of strict translation; Yes, you can get code that works in both languages, but it’s not likely to take advantages of the features that each language provides to make the programmer’s job easier and his code more elegant.  In fact, this is why so many languages (C++, Python, Perl, etc) have support for multiple paradigms baked into the language; They know There’s More Than One Way To Do It, and allow the programmer to find and use the best one for the problem at hand.

    For a set of paradigms, I would suggest considering declarative/logic programming, functional programming and procedural programming.  Object-oriented programming <em>might</em> be a useful thing to compare against, but I’m not sure how many common procedural languages <em>don’t</em> have OO coding as part and parcel to them; The only common case I’m aware of is the use of C for kernel-level and embedded programming.

    If you’re interest isn’t in academic training of thought process flexibility, but rather in the ability to switch back and forth between languages of similar paradigm (Which is likely to be a much more marketable book), then I would probably go with C++, Java, C# and either Ruby or Python. Likely Python; While there is certainly a lot of buzz around Ruby, and there are certainly plenty of job opportunities out there for Ruby programmers, I tend to see more useful code written in Python.

  13. AlfredTh says:

    Tom, I do think of myself as a VB programmer as I have written a couple of VB textbooks. I’ve also written a C# book and programmed professionally in C and taught C++. So I am aware of some of the important differences. I was looking for comments though and figured a crack like the one I made might get someone going. 🙂

Skip to main content