PDA

View Full Version : What do you like best in a programming language?


Banana
2007-12-14, 02:28
Surfing the Wikipedia for fun, I decided to run through various languages just to see how they all looked and felt. It was cool to see how diverse one can get with programming languages and I would like to hear from others about what *you* like about the language you usually use (this also begs the question- did you learn the language by choice or by necessity?)

Few general questions:

How do you feel about dynamic/static/duck typing?
Should a language allow for unsafe typing?
Would you prefer to use punctuation symbols instead of English words?

chucker
2007-12-14, 03:28
It depends on what level of code you're writing: low-level stuff (performance-critical, for the kernel, for drivers/file system implementations/etc.) or high-level stuff.

With high-level code, it's simple: a good language and a good API work in tandem to make me write as little code as possible. The less code, the less potential errors. Thus, I'm okay with unsafe duck typing – but I frequently avoid it, such as with database access – wouldn't want an exception because the row's value happens to be NULL for whatever reason). Of course, there are frequently screw-ups: did you know "0" is considered an empty string in PHP 4 and newer? Are you cringing right now? If not, you should be.

Low-level doesn't interest me much (I could never get myself motivated to work on such things), so I don't have much experience with it. That said, the above does not apply here. You statically, safely type. Period. Always. End of story. In those critical moments, you just cannot rely on the language to get it right.

Both cases have one thing in common: while AppleScript is appealing to a general user (it was deliberately designed not to be like a typical development language), it isn't to me. The verbosity makes for more readability, which is nice in some cases (say, ObjC's message signatures, which always tell you "which argument was this again?"), but can seriously eat up your productivity. There's a reason maths uses "+" and not "plus" or "add to", and it isn't to be obscure.

Banana
2007-12-14, 13:36
...to make me write as little code as possible. The less code, the less potential errors.

Totally understood. This also seems to be popular, as well.

Thus, I'm okay with unsafe duck typing – but I frequently avoid it,

You already gave reasons why it shouldn't be used, and while I agree with you, I wonder what are the benefit of unsafe typing. I can get dynamic typing although I personally disagree with the flexibility (why bother to define it as a string only to do integer arithmetic on it?

Of course, there are frequently screw-ups: did you know "0" is considered an empty string in PHP 4 and newer? Are you cringing right now? If not, you should be.

:eek: :err: WTF what they were thinking?

Low-level doesn't interest me much (I could never get myself motivated to work on such things), so I don't have much experience with it. That said, the above does not apply here. You statically, safely type. Period. Always. End of story. In those critical moments, you just cannot rely on the language to get it right.

Just so I'm following you- you feel that unsafe typing, if it is ever to be allowed, should be confined to high level languages only? To be honest, I'm having trouble with coming up with a good reason to allow for unsafe typing. Dynamic typing is understanding, and seems to be more of a personal preference of whether you want to explicitly cast the type yourself or let it do it for you. I kind of assumed that unsafe typing would make more sense in low-level language but that's only because I don't do any low level programming myself.

The verbosity makes for more readability, which is nice in some cases (say, ObjC's message signatures, which always tell you "which argument was this again?"), but can seriously eat up your productivity. There's a reason maths uses "+" and not "plus" or "add to", and it isn't to be obscure.

Now, I don't know of any programming language (unless AppleScript actually fits this, as I've never read it before) that *doesn't* use mathematical notation at all and would be annoyed myself if it forced me to type "plus" when I very well know what "+" is for. That said, I personally would favor a verbose language (e.g. Ada and Python seems more appealing to me than C++ or Java).

First, with curly brackets, it's not as bad when you have one function by itself. It's only when you nest multiple functions with several statement each where it get a bit hard. I feel that if I have to count the curly brackets and keep track of where it is in, then I'm spending too much of my time reading the code and that hurts my productivity.

Second, curly brackets can mean several things- was that to separate a conditional in a if/then or was that to separate a case in switch construct? This of course get worse when it's nested. With english word, even contractions using 'elif' for "else if" and 'case', there's no need to guess where you are in a nest.

Third, I personally think readability is much more important and agree with the idea that it's much more easier to write code than it is to read code and therefore, language should allow for maximum readability. It also comes with additional benefit that it's self-documenting, so I see myself spending less time making comments than if I were using a terse language.

Disclaimer: This is a friendly note reminding that the statement above is my personal opinion and preferences and nothing more. :)

ast3r3x
2007-12-14, 17:31
Of course, there are frequently screw-ups: did you know "0" is considered an empty string in PHP 4 and newer? Are you cringing right now? If not, you should be.

:eek: :err: WTF what they were thinking?
For some clarification, "0" is technically equal to 0 in php since strings and numbers are not differentiated. So while empty() returns true for 0 and "0", 0 === "0" would not return true because they are not identical. Just a tip for comparison if people don't know. (not you chucker, you and brad know everything)

hflomberg
2007-12-14, 17:54
You know I'm going to say it --- COBOL!

Brad
2007-12-14, 18:05
:eek: :err: WTF what they were thinking?
My colleagues and I could easily write whole volumes on "WTF what they were thinking?" with regards to the PHP language. We have a "board of hate" that actually contains a reference to this exact issue. :)

Banana
2007-12-14, 18:34
For some clarification, "0" is technically equal to 0 in php since strings and numbers are not differentiated. So while empty() returns true for 0 and "0", 0 === "0" would not return true because they are not identical. Just a tip for comparison if people don't know. (not you chucker, you and brad know everything)

I'm not following on empty("0"); shouldn't that return false because it's not a empty string? And how does PHP not differentiate between numbers and strings? Does that mean I can just enter the ASCII representations of characters and get a string?

You know I'm going to say it --- COBOL!

Mind listing what you like about COBOL. I won't bite. :)

My colleagues and I could easily write whole volumes on "WTF what they were thinking?" with regards to the PHP language. We have a "board of hate" that actually contains a reference to this exact issue. :)

Would have liked to see that board. :)

rollercoaster375
2007-12-14, 20:35
Basically, I look for a language that allows me to write elegant code. That is, something that gives me power and flexibility, but still looks decent (Aka. not perl.)

I primarily use PHP, simply because it's the most practical. It has a lot of quirks, and I hate it for that, but it's so freaking practical >_>. Everybody has it installed, and the whole stupid planet uses it. Further, it's nice to be able to write large scale and small scale apps in the same language.

If you're looking into languages, here are a few lesser know ones to check out:
Io (http://www.iolanguage.com/about/)—The most extreme form of semantic minimalism I've ever seen.
Dylan (http://www.opendylan.org/)—/I/ like it because I've never been a big fan of Lisp syntax, however, I do like some of the ideas.

colivigan
2007-12-14, 21:50
Basically, I look for a language that allows me to write elegant code. That is, something that gives me power and flexibility, but still looks decent (Aka. not perl.)

Hey, man, don't be dissing Perl. Looks decent? That's entirely up to the programmer. Language should not enforce looks. Perl is the epitome of power and flexibility, but power can be abused (and, as we know, so often is).

When judging by the "fewest lines of code to accomplish the task" criteria, Perl will come out on top more often than not. Sure, it can be ugly (in the wrong hands), but it can just as easily be elegant. Corporate IT types often don't like it (it scares them), but the real geeks appreciate it.

I happen to love Perl, and somehow manage to make a large part of my living at it. :)

rollercoaster375
2007-12-14, 22:28
I'll stop dissing Perl when Perl 6 is released =D






(That's supposed to be a joke about how Perl 6 is vaporware, in the event that it wasn't clear)

As for real arguments... I mean that the code should be readable, as well as elegant in design.

Kickaha
2007-12-14, 22:38
Hey, man, don't be dissing Perl.

Indeed, Perl should be respected as the direct successor to APL.

They're both write-only languages. :p

colivigan
2007-12-14, 22:55
Indeed, Perl should be respected as the direct successor to APL.

They're both write-only languages. :p

Well, you lost me there. But, Google and Wikipedia to the rescue:

APL is usually interpretive and interactive, and features a read-edit-print loop (REPL)

Hmm, REPL. All you have to do is rearrange the letters, I guess.

But I still don't know wtf you're talking about. :)

Perl is old, sure. But so are C++, C, and most other languages we're discussing. PHP? Give me a break - it's web programming for folks who don't really want to program. ASP for the open source generation.

Not that there's anything wrong with that. :)

Kickaha
2007-12-14, 23:15
But I still don't know wtf you're talking about. :)

APL was an amazingly powerful language that required a special keyboard for its symbolic constructs. Arrays? Pfft. It handled multi-dimensional matrices in a few keystrokes. Lists? Puleeze. Lisp wished it had such lists. String manipulation? Cakewalk.

You could fire off a single line in a few seconds that would take a C programmer a few hundred lines of loops to replicate.

Unfortunately, there were a bazillion ways to do any particular task, which meant that every programmer selected a specific subset of the features that they were comfortable manipulating, and used them in very dense, very convoluted ways.

Meaning that NO ONE ELSE COULD READ THEIR DAMNED CODE.

Sound familiar?

hflomberg
2007-12-14, 23:19
COBOL -
1. Clean simple readable syntax.
2. magnificently elegant and simple multidimensional table handling routines.
3. Magnificent file and database handling and manipulation
4.When written correctly COBOL is extremely maintainable.
5. Contrary to most opions, COBOL can do bit level manipulation
6. Quite adaptable to object Orientation
7. Quite adaptable to Event processing
8. Lots of it out there - and a good COBOL programmer is going to be a scarce resource in a few years.
9. If you need to handle huge amounts of data - a COBOL environment is the best way to go - proven historically


And - oh yes - supported my family nicely for 30+ years.


In his earth-shaking article to the ACM,"Goto's considered harmful" Dyjkstra established the fact that software is a corporate asset and must be treated as such

colivigan
2007-12-14, 23:24
Unfortunately, there were a bazillion ways to do any particular task, which meant that every programmer selected a specific subset of the features that they were comfortable manipulating, and used them in very dense, very convoluted ways.

Meaning that NO ONE ELSE COULD READ THEIR DAMNED CODE.

Sound familiar?

:lol:

Point to Kickaha.

Kickaha
2007-12-14, 23:28
:lol:

Point to Kickaha.

:D I actually took a course in the history of computer architecture from Fred Brooks, and he used APL to model *every single blasted architecture*. It was an amazing fit, letting him set up a runtime model for any legacy machine he wanted, and then we'd have to program it. Also, we had to design our own systems, and model them in APL.

It's a *wonderful* language... and I can see why it died out. :p