PDA

View Full Version : What's your language of choice?


Anaconda
05-22-2003, 12:04 AM
Just trying to get a feel for what everyone here prefers to develop in. Personally I use C primarily, but am curious to see what the split out there really is.

Zero Tolerance
05-22-2003, 01:27 AM
i am just learning C++....but from what i can see so far....both have good and bad points.....short and longcuts.....but at least if its still in the header file ill use a C shortcut if i can

RacinRN
05-22-2003, 03:56 AM
I prefer English...but I do know a bit of Spanish. ;)

Bond
05-22-2003, 11:01 AM
What about those of us who use C++ to write C programs? (I voted for C).

Anaconda
05-22-2003, 11:18 AM
I'm referring to the language you program in only, not the compiler tools you use. Many, if not most C compilers now also do C++.

Bond
05-22-2003, 03:17 PM
I understand.

But many C compilers are picky about the structure of a C program. For example, variables must be declared at the top of the scope in which they are to be used.

I couldn't do this in C:

int main()
{
int i;
i = 5;

int j;

return 0;
}

without getting an error for declaring j after I've already started "coding." But, with the C++ compiler this works fine. So, that's why I say I use C++ to write C programs. I don't use OOP or any of the C++ stream classes -- I just appreciate its forgivefulness.

Greg
05-22-2003, 03:27 PM
All that "forgiveness" IMHO just creates bad programming habits.

Anaconda
05-22-2003, 03:52 PM
Ah, Ok I see what you're referring to. Yes that ability to create instant vars is nice, but after years of ANSI C I find I'm always declaring my vars at the top, no matter what. :)

I also find that instant vars can make the debugging task more difficult, as you may find yourself inadvertantly out of scope on the one you are intending to use, especially if you reuse the name. Though from a readability standpoint, seeing the vars type the first time it's used is nice.

I guess there's no real winner here ;) Both methods are equally valid, and neither is programatically incorrect, or less efficient when compiled. In fact in terms of efficiency, an instant var may be more efficient memory wise, as it's life can be very limited, especially when used in loops. Though a good optimizing compiler should even this out.

eg for(int i=0;i<COUNT;i++) {...}

Though it's not valid in ANSI C it is a handy construct if i is not needed beyond the loop counter. And in terms of memory, i will only exist during the loop.

Nice point Bond.

Bond
05-22-2003, 05:05 PM
Originally posted by noppid
All that "forgiveness" IMHO just creates bad programming habits. I don't think so, personally. At least not in the case I was descibing. Every other popular programming language has no problems with declaring variables throughout your code. I often find it inconvenient to scroll all the way to the top of my functions to add/modify/delete a variable that I'm using 100+ lines down. Plus, when cleaning up your code, It can be cumbersome to look at your big block of variables and try to figure out which ones you're using and which ones you're not.

I dunno. Different strokes. But I certainly don't think it's a bad programming habit. I write clean code! :) (Some of you may have even seen some of it...)

Greg
05-22-2003, 05:45 PM
Didn't mean to sound judgemental, but the K&R book I learned from, if I remember correctly, pointed that out to me and it's stuck.

I'm guily of some bad habits, like not using option explicite in VB, just make vars as ya go.

Zero Tolerance
05-22-2003, 08:35 PM
yup.....i seen it....lol

id rather declare vars as i go too.....

zesti
05-08-2004, 12:08 PM
Wish I could vote on 1, I know my friend loves C++.