
-----------------------------------
wtd
Sun Oct 30, 2005 1:41 pm

Programming Languages Suck
-----------------------------------
Consider this an even-handed companion to my Why Java sucks thread.

Loops

One of the most common uses of a loop is to do something a certain number of times.  Often, we don't especially care which reptition we're on.  We just want something done.

So, why can't more languages support this?  Instead we often have to introduce a useless counter variable.

for (int i = 0; i < 10; i++) 
{
   ...

That is so horrifically ugly.

5.times do
   ...

And that is beautiful.

-----------------------------------
goomba
Sun Oct 30, 2005 8:38 pm


-----------------------------------
Probably because Java wants to remain syntactically similar to C. The foreach loop in 1.5 helps a bit when you want to iterate over a list, but I agree that it doesn't compare to the syntax and flexibility of iterations in Python/Ruby.

Which raises the question, why is Java used so much more than Ruby/Python in the "Real World" if it is so inferior?

-----------------------------------
rizzix
Sun Oct 30, 2005 8:43 pm


-----------------------------------
cuz TIMTOWTDI is real bad in the real world...  :wink:

-----------------------------------
beard0
Sun Oct 30, 2005 8:45 pm

Re: Programming Languages Suck
-----------------------------------
Consider this an even-handed companion to my Why Java sucks thread.

wtd is talking about all languages in this post.

-----------------------------------
Cervantes
Sun Oct 30, 2005 8:59 pm

Re: Programming Languages Suck
-----------------------------------
wtd is talking about all languages in this post.
Maybe, but Ruby wins this round. :D

Which raises the question, why is Java used so much more than Ruby/Python in the "Real World" if it is so inferior?

Traditions are hard to change...

-----------------------------------
wtd
Sun Oct 30, 2005 9:11 pm

Re: Programming Languages Suck
-----------------------------------
Consider this an even-handed companion to my Why Java sucks thread.

wtd is talking about all languages in this post.

Well, for any given problem there are likely at least a few languages that get it right.  The "all" part comes from the fact that none of them get everything right.

-----------------------------------
wtd
Sun Oct 30, 2005 9:13 pm


-----------------------------------
Which raises the question, why is Java used so much more than Ruby/Python in the "Real World" if it is so inferior?

Sun spent a lot of money hyping the heck out of Java, and still does.  Several other companies do as well.

I'd say the biggest (though not necessarily the only) reason is that so many people simply haven't either heard of Python or Ruby, or haven't given them a chance.

-----------------------------------
Dan
Sun Oct 30, 2005 11:14 pm


-----------------------------------
Well the for loop counter var dose make it alot more apreate where the index var is and how to call apone it. I mean in the 2nd case you posted the index var is still there some where you just can not see it (tho it maybe accesable throw other methods). The for aporch makes it so some one viewing or making the code cleary knows how to deal with the index var with out having to know the API or libbrays of the langue.

This may not mean this the for aporch is better but it dose give a reason for using it.

-----------------------------------
Martin
Mon Oct 31, 2005 12:01 am


-----------------------------------
wtd, what do you think the perfect language (syntactically) would look like?

-----------------------------------
rizzix
Mon Oct 31, 2005 12:02 am

Re: Programming Languages Suck
-----------------------------------
Instead we often have to introduce a useless counter variable.

for (int i = 0; i < 10; i++) 
{
   ... I've created many algorithms that make good use of the for ( ; ; ) syntax... there's not need to eliminate it all together.. but sure.. a for (int i : n,m .. p) kind of syntax would be cool.

-----------------------------------
wtd
Mon Oct 31, 2005 12:32 am


-----------------------------------
wtd, what do you think the perfect language (syntactically) would look like?

Haskell is really nice syntactically.  The ML languages also have a nice syntax.

-----------------------------------
Martin
Mon Oct 31, 2005 12:36 am


-----------------------------------
Yeah, Haskell is pretty nifty.

-----------------------------------
rizzix
Mon Oct 31, 2005 12:37 am


-----------------------------------
Haskell pwnz.

-----------------------------------
Cervantes
Mon Oct 31, 2005 6:33 pm


-----------------------------------
Well the for loop counter var dose make it alot more apreate where the index var is and how to call apone it. I mean in the 2nd case you posted the index var is still there some where you just can not see it (tho it maybe accesable throw other methods). The for aporch makes it so some one viewing or making the code cleary knows how to deal with the index var with out having to know the API or libbrays of the langue.

This may not mean this the for aporch is better but it dose give a reason for using it.
Yes, but the Ruby example can be extended as well.  You can optionally add the block parameter:

5.times do |index|

If you don't want to start at zero:

5.upto( 10 ) do |index|

or

5.downto( 0 ) do |index|

And if you want a different incriment other than 1 or -1,

5.step( 11, 2 ) do |index|


So it becomes a question of somewhat ugly looking syntax that can do everything from the basic configuration, or beautiful syntax that requires more knowledge of the language / more approaches to getting the task done.

-----------------------------------
MysticVegeta
Mon Nov 07, 2005 3:08 pm


-----------------------------------
If I made a programming language (which is just a thought) I would have the following syntax for it

var 