Programming Language Comparison

Dear Friends,

I'm working on some resources for teaching Ruby.

As part of this, I'm studying what already exists, and whether or not it is conducive to learning to program.

I have put together a list of several programming languages and tried to do a comparison.

http://www.oriontransfer.co.nz/education/learn-ruby/why/language-comparison/index

The purpose of this comparison is to help people make a decision about what language they would like to use for teaching people how to program.

Another part of this is evaluating existing resources. I've put this list together here:

http://www.oriontransfer.co.nz/education/learn-ruby/why/existing-resources/index

The purpose of this list is to try and review the "best" resources for learning how to program for each particular language. I'm really not sure if what I've selected is actually representative of this - so if anyone has any ideas or recommendations for additions or removals please let me know.

... I know this is all highly subjective, but if anyone felt like giving me some feedback on these two pages, I'd appreciate that.

P.S. I don't want to cause any grief :slight_smile:

Kind regards,
Samuel

Is the general syntax simple and concise?
I wouldn't consider C's syntax to be simple and concise. It's type system
leads to weird contortions and obnoxious typecasting that just add confusing
lines to code. To do anything polymorphic you have to use void pointers and
function pointers. You have to use esoteric naming conventions because it
doesn't support namespaces. Compiling multiple source files requires
knowledge of makefiles (I've switched to rake) which have their own esoteric
syntax (and god help you if you use spaces instead of tab on some line
somewhere). If there is a single comprehensive source of documentation (like
ruby-doc.org), I don't know what it is, and I've looked and asked and been
using C off and on for about 2 years. Prototypes duplicate your functions'
signatures across files that you then have to remember to change if you
alter your code, you have to include them to make your code visible to other
files, and because code in your own file can't see code that comes after it,
so you either deal with dependencies depending on where you wrote the code
in the file in relation to other code, or you use a header. But even headers
can have dependency issues when included in some other file in the wrong
order. You can't just include the file your header is dependent on within
your header, because C can only include files a couple files deep. Their
type equality forces you to use typedefs because structures use some weird
equality measurement that the type system won't realize is the same.

Is it generally easy to write new code?
I also disagree with C for this category. C does not support many
abstractions like interfaces, namespaces, OO, closures, etc. So you end up
with a lot of code duplicated, and bound to eachother. I'm not saying this
is inevitable, just that it's really easy to for that to happen. This means
that if you want to write new code, you end up being concerned you're going
to break something you've already done. It also has very poor support for
testing, because it is so static and brittle, which makes it dangerous to
refactor existing code. You also have to always be aware of where things
came from, and really let people know where they are going, because you have
to manage all of your own memory, so if you don't free that 'object' or the
user you return your result to doesn't free it, it's going to turn into a
memory leak.

Does the language have a type system conducive education?
I think Java should be green here. It's static typing only gets in the way
when you use things like containers. Otherwise, I think it is helpful for
education to be able to look at the signature of the method, and see it
takes a String and an int, or just a String, and it returns an array of
strings. I always found that helpful when learning OO. And explicitly
declaring that your variable is of type whatever is helpful when you are not
very strong with understanding types. It also allows the compiler to find
incompatibilities, and (ideally, at least) give you more useful errors.

In this regard, I think Ruby should be yellow here. Ruby relies much more on
naming conventions, because you can't display types in signatures. You can
have code that will break because you passed the wrong type of variable, and
it won't break, because you don't execute that particular piece of code.
Then much later when you do, you get an unexpected error! That is fine if
you understand how types work, you don't need all that extra code declaring
this type or that type or casting between types. But if you are just
learning, then having the compiler hold your hand would probably be
conducive.

Is it easy to reuse existing code?
I think C should be red. If you want to do anything non trivial, reusable
code pretty much means function pointers and void pointers, which means
obnoxious typecasting and code/namespace pollution. You also have the risk
that the library you are including has some function named the same as some
function you are using, or in some other library you want to use, because
there is only the global namespace. To get around that, you have to have
really obnoxious names, usually preceeded by several characters to
artificially namespace it, but it all just makes the code more cryptic.
Also, I don't know where you would go to get existing code other people have
written, is there any standard documentation like rdoc or javadoc? I assume
not since I've read several books on C without any such mention. You also
have to know how to build the code you are using, and know how to link
against it.

Does the language provide a useful and consistent set of object oriented
constructs?
Maybe I'm misunderstanding the question, but C is not OO. To get OO like
behaviour, you have to declare a struct with all types in it, go write your
own create and destroy functions to malloc and free the code. Write all your
functions with prefixes appended to their names to make it clear that they
are related to eachother, accept the object itself as your first parameter
(something oo does explicitly for you), and then pass everything in
functionally, instead of calling methods. Ie let the prefix pr_ indicate we
are defining a "method" for a person (which is just a typedefed struct).
Then ruby's person.has_birthday; would look like pr_has_birthday(person,1);
Now imagine if you wanted to chain methods.

Are people in education already familiar with the language and environment?
At my school (Wichita State), C would be green, C++ would be yellow, and
Java would be green. Everything else on that list would be red.

Are there good learning resources available for use in education?
I think Java should be green, it's api is very very helpful. I don't know
why C is green, for me it was just google and books (and now stack overflow
^^).

Anyway, thats my opinion. Anyone is welcome to disagree, but as a
pre-emptive rebuttal, if there is a resource that resolves the issue, but is
not widely accepted or adopted, then I don't think it is relevant, because
it is not the kind of thing a new programmer will know about or is likely to
understand well enough to use.

···

On Mon, Mar 29, 2010 at 9:23 AM, Space Ship Traveller < space.ship.traveller@gmail.com> wrote:

Dear Friends,

I'm working on some resources for teaching Ruby.

As part of this, I'm studying what already exists, and whether or not it is
conducive to learning to program.

I have put together a list of several programming languages and tried to do
a comparison.

http://www.oriontransfer.co.nz/education/learn-ruby/why/language-comparison/index

The purpose of this comparison is to help people make a decision about what
language they would like to use for teaching people how to program.

Another part of this is evaluating existing resources. I've put this list
together here:

http://www.oriontransfer.co.nz/education/learn-ruby/why/existing-resources/index

The purpose of this list is to try and review the "best" resources for
learning how to program for each particular language. I'm really not sure if
what I've selected is actually representative of this - so if anyone has any
ideas or recommendations for additions or removals please let me know.

... I know this is all highly subjective, but if anyone felt like giving me
some feedback on these two pages, I'd appreciate that.

P.S. I don't want to cause any grief :slight_smile:

Kind regards,
Samuel

Are you aware of pleac? That's certainly a candidate for your
existing resources section.

Kind regards

robert

···

2010/3/29 Space Ship Traveller <space.ship.traveller@gmail.com>:

I'm working on some resources for teaching Ruby.

As part of this, I'm studying what already exists, and whether or not it is conducive to learning to program.

I have put together a list of several programming languages and tried to do a comparison.

http://www.oriontransfer.co.nz/education/learn-ruby/why/language-comparison/index

The purpose of this comparison is to help people make a decision about what language they would like to use for teaching people how to program.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Should C# also be included in your comparison? I know that it is very
popular, and different enough from C++ to be considered a separate
language. I know that it is used a lot in the computer science
department at my university. I'm not advocating its use, but think it
should be included.

--Alex

···

--
Posted via http://www.ruby-forum.com/.

Dear Robert,

Thanks, yes I am aware of that but haven't added it.

Kind regards,
Samuel

···

On 30/03/2010, at 7:21 AM, Robert Klemme wrote:

2010/3/29 Space Ship Traveller <space.ship.traveller@gmail.com>:

I'm working on some resources for teaching Ruby.

As part of this, I'm studying what already exists, and whether or not it is conducive to learning to program.

I have put together a list of several programming languages and tried to do a comparison.

http://www.oriontransfer.co.nz/education/learn-ruby/why/language-comparison/index

The purpose of this comparison is to help people make a decision about what language they would like to use for teaching people how to program.

Are you aware of pleac? That's certainly a candidate for your
existing resources section.

http://pleac.sourceforge.net/

Kind regards

robert

Dear Josh,

Thanks for your feedback. I've incorporated many of the ideas into the comparison. Thanks for pointing out that C is not object orientated - that was a bug in my data :slight_smile:

Unfortunately I don't know many teachers who are proficient with C. It might be popular in some places, but here in NZ it is not very well known.

I personally don't know if even Visual Basic should be green, but a recent study showed that about 50% of teachers know about it. I couldn't say the same for any other language on that chart.

Kind regards,
Samuel

If you're looking to see some specific problems with solutions in many
different languages, see rosettacode.org

···

At 2010-03-29 02:21PM, "Robert Klemme" wrote:

2010/3/29 Space Ship Traveller <space.ship.traveller@gmail.com>:
> I'm working on some resources for teaching Ruby.
>
> As part of this, I'm studying what already exists, and whether or not it is conducive to learning to program.
>
> I have put together a list of several programming languages and tried to do a comparison.
>
> http://www.oriontransfer.co.nz/education/learn-ruby/why/language-comparison/index
>
> The purpose of this comparison is to help people make a decision about what language they would like to use for teaching people how to program.

Are you aware of pleac? That's certainly a candidate for your
existing resources section.

http://pleac.sourceforge.net/

--
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous

Another thing to consider is that Perl is being demerited for TIMTOWTDI, but
Ruby is not. Yet how many ways are there to loop from 0 to 2 in Ruby?

results = Array.new

3.times { |i| results << i }

(0..2).each { |i| results << i }

0.upto(2) { |i| results << i }

0.step(2) { |i| results << i }

(0..2).to_a.each { |i| results << i }

for i in 0..2 do results << i end

i = 0
while i <= 2
  results << i
  i+=1
end

i = 0
until i > 2
  results << i
  i+=1
end

i = 0
loop do
  results << i
  break if 2 < i+=1
end

puts RUBY_VERSION
results.join.scan /.../ do |result|
  puts result
end

There are also a few additional ways in Enumerable that aren't shown here
b/c they don't work on 1.8.6

And I left out array based solutions, because while they will work in this
small range, that is not what they are there for, and so will quickly become
unmanageable. ie [0,1,2].each {} might work but is not scalable if you want
to iterate the first hundred numbers, and is not dynamic if you want to be
able to determine your range from variables.

···

-----

And I don't know enough about Perl to answer this, but I'd be interested to
know from anyone who does, whether Perl is actually difficult to read, or
whether that is just a consequence of certain styles of coding that get the
most attention or have become idiomatic within the Perl community.

Dear Josh,

Those are all really good points.

Ruby does have many ways to do things. So does Perl. I wonder if this is really a disadvantage?

I guess it potentially makes the language tricky if different ways of doing things have subtly different implications.

Kind regards,
Samuel

···

On 31/03/2010, at 1:59 AM, Josh Cheek wrote:

Another thing to consider is that Perl is being demerited for TIMTOWTDI, but
Ruby is not. Yet how many ways are there to loop from 0 to 2 in Ruby?

results = Array.new

3.times { |i| results << i }

(0..2).each { |i| results << i }

0.upto(2) { |i| results << i }

0.step(2) { |i| results << i }

(0..2).to_a.each { |i| results << i }

for i in 0..2 do results << i end

i = 0
while i <= 2
results << i
i+=1
end

i = 0
until i > 2
results << i
i+=1
end

i = 0
loop do
results << i
break if 2 < i+=1
end

puts RUBY_VERSION
results.join.scan /.../ do |result|
puts result
end

There are also a few additional ways in Enumerable that aren't shown here
b/c they don't work on 1.8.6

And I left out array based solutions, because while they will work in this
small range, that is not what they are there for, and so will quickly become
unmanageable. ie [0,1,2].each {} might work but is not scalable if you want
to iterate the first hundred numbers, and is not dynamic if you want to be
able to determine your range from variables.

-----

And I don't know enough about Perl to answer this, but I'd be interested to
know from anyone who does, whether Perl is actually difficult to read, or
whether that is just a consequence of certain styles of coding that get the
most attention or have become idiomatic within the Perl community.

Ruby does have many ways to do things. So does Perl. I wonder if this is really a disadvantage?

I'd say this depends on the user. Some like choices, others are
swamped by choices and can't find /any/ way to do something.

I guess it potentially makes the language tricky if different ways of doing things have subtly different implications.

Yes, I guess that's true. Still, often certain idioms emerge and
people use those most of the time so that risk might not be as big in
practice as in theory.

Kind regards

robert

···

2010/3/30 Samuel Williams <space.ship.traveller@gmail.com>:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/