Sucky programming languages vs. good ones

By on February 21, 2010 8:54:27 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

Agent of Kh...

Join Date 02/2008
+31

The biggest "industry standard" programming languages of today by far are languages like C++ and Java.  And let me tell you - THEY SUCK.  You couldn't pay me enough money to program in either of them (and I've been offered quite a bit).  Either language will rot your brain to use it.

VERBOSITY

Consider a program which writes "Hello World" to the screen.  Here it is in Java:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World");
    }

}


plublic class HellowWorld?  public static void main?  system.out.println?  Are you kidding me?  The verbosity level of these languages is through the roof!  Nevermind the fact that they are monstrously huge, flabby, underpowered languages to boot.  These languages are just ugly, too.  Periods between words used to send messages?  Yuk.

Now, the same program in two of my favorite programming languages, APL or J (it's the same program in either language):

'Hello World'


Which would you rather write?

LOOPS

Often you need to do something to each element of an array.  For instance, add 1, or divide by 7, or whatever.  In a traditional programming language, you have to write a "loop" to do this.  But you don't need loops in APL or J.  To illustrate this, assume we have an array of numbers in a variable x.  Here is the code in APL or J to add 1 to each element of the array:

x+1


I just completed an electronic exchange (i.e. NYSE, AMEX, NASDAQ, etc).  I used J.  Not only did I complete it in 1% of the time it would have taken me in C++ or Java, and with literally 1% of the code size (the entire program is just a few pages long). But I didn't have to use a single loop.

Expressiveness and power

Using APL or J, it is possible to do many programs in just a single line of code.  I have a recent post on writing code to automatically pug matches for these online pug games (http://forums.sinsofasolarempire.com/376301).  But at any rate, here is my program in J to do it:

(#y) {. 1 (((#y) {. 1 0 1 0 0 1 1 0 0 1) # (+:?2)(|.@{.,}.)\: y) } 10#2

Yes, that's the entire program, and it works.  Sure, it's not documented, and it's terse and cryptic-looking, but I could document it and make it far less cryptic and far more readable.  But the point is simply to show you what you can do in one line of code with languages like this.  In fact, most of the space in the above program is actually taken up by static data in an array (1 0 1 0 0 1 1 0 0 1).  Remove that and look at actual code, and you are literally talking about a couple of keystrokes that do a hell of a lot in a hell of tiny amount of space.  If you are familiar with the classic "8 queens" (or "n queens") problem, you can do that in a single line of code using this language.  How many lines would it take in a "normal" language like Java?

Oh, also notice no "if then else" statements, no "case" or "switch" statements, etc.  It is often possible to write in these languages without using such constructs.

16 Replies
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
January 20, 2014 7:17:52 PM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

 

Its a lot more complex than what you make of it. I hope people who find this dont actually think of Java or C/C++ any less since these are the languages that make up many software applications you use today and Java even makes up all the Android applications you use (if you have Android, otherwise Apple uses Objective-C).

 

APL and J can be exceptionally cryptic. You use 2 isolated cases where it is simple: x[⍋x←6?40] <-- I have no idea what this is doing. Its supposedly picking 6 pseudorandom numbers from 1-40 but how could I tell if I wasnt an APL programmer? This would drive me away immediately. An equivalent occurrence in Java would be:

 

import java.util.Random;

public class WhyAPL {
    public static void main(String[] args){
        Random r = new Random();
        int[] lottery = new int[6];
        for(int l: lottery) {
            l = r.nextInt(40) + 1; //[0, 39] + 1 = [1, 40]
        }
    }
}

 

Which is much easier to understand or atleast to explain. You are importing the Random class, creating a new Random object and a new lottery int array holding 6 elements. Then you are using a for loop to get an element of type int from the lottery way to assign the nextInt between 1 and 40, generated by the Random object, to that element until you go through every element in the array. Its readable and comprehensive. C++ is as easy to understand:

 

#include <iostream>
#include <ctime>


int main()
{
    int arr[6], checker = 0;
    srand(time(NULL));
    for (int &i : arr){
        i = rand() % 40 + 1;
        std::cout << i << "   ";
    }
    getchar();
    return 0;
}

 

Which is just as explainable. Not to mention that incredible usefulness of pointers, operator overloading and combination of imperative and OOP paradigms (for C++). I am mostly a Java programmer but I have my fair share of C/C++ programming.

 

I would love to see you develop applications on the scale of those created in Java and C/C++ with APL or J.

Reason for Karma (Optional)
Successfully updated karma reason!
January 21, 2014 12:32:19 AM from WinCustomize Forums WinCustomize Forums

DR_HouseMD.... hopefully you can save some of your cognitive skills from programming languages and take note of dates and times.

I expect 4 years could just see the OP either gone, dead, or both...

 

This thread is the last [most recent] interaction with these Forums....so 'gone' is very much the case...

Reason for Karma (Optional)
Successfully updated karma reason!
January 21, 2014 1:08:32 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

35 years coding and I still have not found the ultimate language.  I do like brevity though.  And of course we can all comment our work to the point of ridiculousness.    

And have you ever come in behind people who were better coders but incapable of writing a single comment to explain "their awesomeness."  When you're part of a team you rise or fall together; that includes the people who have to maintain your work 15 years from now.

C++ and Java are bloated because they are trying to be general purpose languages; but they could be a little less wordy.

I like C++ because I can always read it and get the gist of it.

You both make valid propositions.   (you too Jafo)

There is only one way to finish this.

 

Listen all! This is the truth of it. Fighting leads to killing, and killing gets to warring. And that was damn near the death of us all. Look at us now! Busted up, and everyone talking about hard rain! But we've learned, by the dust of them all... Bartertown learned. Now, when men get to fighting, it happens here! And it finishes here! Two men enter; one man leaves.

http://www.hark.com/clips/szgncpwvwr-this-is-thunderdome

 

backs out of the room slowly...  

 

 

 

Reason for Karma (Optional)
Successfully updated karma reason!
Sign Up or Login and this ad disappears!
There are many great features available to you once you register. Sign Up for a free account and browse the forums without ads.
January 21, 2014 1:52:43 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

Oh this was a necroed topic. Sorry.

Reason for Karma (Optional)
Successfully updated karma reason!
January 23, 2014 12:15:09 PM from Elemental Forums Elemental Forums

At least it was something interesting to read.  Other necro threads often are not

Reason for Karma (Optional)
Successfully updated karma reason!
January 27, 2014 10:34:54 PM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

I don't like languages like Regular Expressions. They're compact, true, but they're not readable.

Programming is all about taking a big serving of spaghetti, and divide it up in easily edible portions.

Then comes along Regular Expressions - and your portions are mixed into spaghetti again.

Of course I like spaghetti, but I don't like Regular Expressions.

E-mail validation made... easy?

\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b

I think it's spaghetti.

 

I'm not certain yet if I like JQuery (javascript). On the one hand I like it, but on the other hand it can also be too short.

$('[name^=checkboxes]').each(function(){ do something here });

I dunno what's wrong with writing a normal loop, can anyone see that this produces an array of results, and a function is evaluated for each of them?

I would've preferred if javascript added a statement like "for each [...] in [...]" like in VB, that would've been more readable.

 

Reason for Karma (Optional)
Successfully updated karma reason!
January 27, 2014 10:47:36 PM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

Quoting GeomanNL,
I would've preferred if javascript added a statement like "for each [...] in [...]" like in VB, that would've been more readable.

 

Maybe the new guys writing these languages want to make their mark and strike off in a new direction.  That usually gets you killed.  I like well worn paths with no surprises.  

I say you write that compact code when you are launching a satellite to the outer reaches of the solar system and every byte counts.  Now if you are here on Earth and you need more hard drive space for your programs we can but it pretty cheaply.  There are also cases to be made for optimization but most compilers optimize for you because the guys who write those really are smarter than most of the other people on the planet.  

Does anybody remember how exciting it was to open Byte magazine and find out Borland released a new language.  You would jump in the car and head out to your nearest CompUSA (or your local version) and buy it for $99.  I loved those days and those languages.  It was a fun time.  

Now I am dodging Borg cubes for fun.  These are fun times too.  

 

backs out of the room slowly... 

 

 

 

 

Reason for Karma (Optional)
Successfully updated karma reason!
January 28, 2014 2:22:35 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

You know thats funny, I didnt note the time

 

Sorry bout that. Shouldn't revive a long dead forum post like that. Lets forget this ever happened.

Nonetheless, good discussion even for a dead thread

 

 

Officially ignoring this thread.... now.

Reason for Karma (Optional)
Successfully updated karma reason!
January 28, 2014 2:43:19 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

Quoting RedDwarf999,
I say you write that compact code when you are launching a satellite to the outer reaches of the solar system and every byte counts.

I'm not sure, but I think that's not the case for modern satellites and space probes.

 

Reason for Karma (Optional)
Successfully updated karma reason!
January 28, 2014 10:16:58 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

GeomanNL

Then comes along Regular Expressions - and your portions are mixed into spaghetti again.

Of course I like spaghetti, but I don't like Regular Expressions.

E-mail validation made... easy?

\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b

I think it's spaghetti.

Yes they're messy, but really, what can you expect when trying to match patterns of text? Anything more readable would likely be rather long, and odds are not very clear regardless. 

And in that specific example, unless I'm missing something it would pass something like "............@TEST.COM". Room for improvement (The dots are literal dots, not placeholders, and doesn't seem to be case insensitive)


GeomanNL

$('[name^=checkboxes]').each(function(){ do something here });

I dunno what's wrong with writing a normal loop, can anyone see that this produces an array of results, and a function is evaluated for each of them?

Of course, it reads pretty clearly.. "Select these things -> for each of these things -> execute function" 

Even if it didn't read clearly, executing functions over iterations of objects is the nature of jQuery, so it should generally be what you expect if you choose to use the library, and it'd be weird for them to implement something else.

 

If you wanted a normal for loop, you would use normal javascript. Hell, you could even use a standard for loop to iterate over your array of jQuery objects and use it just as you're suggesting. 

 

Reason for Karma (Optional)
Successfully updated karma reason!
January 28, 2014 10:29:11 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

I know, jQuery is useful and it's not that bad, but imho it still looks and behaves like a hack.

Imho it would've been better if they changed javascript so that writing a simple loop wouldn't be as bloated...

var list = document.getElementsByName('myname');

for (var i = 0; i < list.length; i++ ) {

   alert(list[i].id);
}

It's nicer to write it like this:

for each (element in document.getElementsByName('myname')) {

     alert(element.id);

}

And imho such a thing is also nicer than a jquery equivalent:

$('[name=myname]').each(function(){

     alert(this.id);

});

 

Reason for Karma (Optional)
Successfully updated karma reason!
May 13, 2014 7:28:40 AM from Elemental Forums Elemental Forums

I see you have forgotten the three best programming languages ever - Malbolge, LOLCODE and Brainfuck. 

 

Seek them out, they are fun!

 

Ad regular expressions - you can use multiline switch and structure them as much as you like. 

Reason for Karma (Optional)
Successfully updated karma reason!
May 13, 2014 9:31:04 AM from Elemental Forums Elemental Forums

Neophyte here, but I agree w/ the OP (2010).

Note sure why people need so many words to communicate w/ a machine or their own brain (Though RedDwarf999 has a point about maintenance)

Is there a future for someone like me? 

 

Quoting Dr_HouseMD,
x[⍋x←6?40]

I would have wondered about the range (0-40 or 1-40) but otherwise seems fairly clear to me.

 

Quoting GeomanNL,
\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b

Not sure about the "\b", I suppose it's some sort of reference to validation, and "%+-" might have a special meaning indicating how characters should be entered but rest seems very readable:

character range plus arobase plus something that is comprised of character range ending w/ "." plus character range character minmax


Quoting Kamamura_CZ,
LOLCODE

That's an amazingly intuitive language!



What is the programming language of tomorrow?

Reason for Karma (Optional)
Successfully updated karma reason!
May 13, 2014 6:45:42 PM from Stardock Forums Stardock Forums

Quoting Primal_Savage,
What is the programming language of tomorrow?

C++, just like yesterday.

Functional languages are good for some things, procedural languages are good for others.

APL and C are different because they were designed with different goals. APL has been around since the 60s and it hasn't been adopted widely simply because it isn't the appropriate solution for most problems.

That said, the whole argument that it's superior purely due to terseness is a bit silly. Sacrificing readability for terseness alone (assuming equivalent performance) in mid and high level languages is pretty much never worth it if you need to actually maintain the code (and often not even when you don't). Time spent typing is rarely the biggest part of software development.

 

Reason for Karma (Optional)
Successfully updated karma reason!
May 16, 2014 10:02:04 AM from Elemental Forums Elemental Forums

^^^this^^^

Reason for Karma (Optional)
Successfully updated karma reason!
May 16, 2014 3:00:20 PM from WinCustomize Forums WinCustomize Forums

APL has been calld a "write-onl;y" language as reading andn modifying someone else's code can be a nightmare.  Of course, any poorly written code would also qualify but APL begins that way!  

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #108433  walnut3   Server Load Time: 00:00:00.0000765   Page Render Time:

Home | About | Privacy | Upload Guidelines | Terms of Service | Help
WinCustomize © 2014 Stardock Corporation. All Rights Reserved.