Using D is a win

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Sun Jun 10 10:15:41 PDT 2007


Jarrett Billingsley wrote:
> Just compare the code to ask the user for their name and print it back
> out, in Java:
> 
> import java.util.*;
> 
> public class Program
> {
>     public static void main(String[] args)
>     {
>         System.out.print("Enter your name: ");
>         Scanner input = new Scanner(System.in);
>         String name = input.nextLine();
>         System.out.println("Hi, " + name);
>     }
> }
> 
> And in a simpler language, say MiniD (though it'd look similar in
> JavaScript or so):
> 
> write("Enter your name: ");
> local name = readln();
> writefln("Hi, ", name);
> 
> No types, no protection attributes, no obscure syntax, no knowledge of OOP
> necessary -- just pure, simple logic.

I'd say Ruby is even better (simpler) than Python or MiniD as an educational
language. The syntax is very forgiving and user friendly and "scales" well
when the user learns new stuff. It's also much more powerful
(syntactically) than Java. Previous example converted to Ruby:

print "Enter your name: "
name = gets
print "Hi, ", name


Or some "advanced" stuff:

a = []
3.times { a << gets.to_i }
a.map { |i| 42 - 2 * i }



More information about the Digitalmars-d mailing list