What language should I learn so I can understand programming logic better?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Lets see here....I started of with C/C++ in high school. We also touched on some Pascal, Basic, Assembly, Haskel, and Java.

I would consider myself very good at programming in c/c++ and Java. I have a very strong base in OOP. Next semester I am taking an Assembly class, I cant wait!!!

I started off my first programming with VI and GCC.

If I were you I would start off using Borland Turbo c++ 3.0 and find a simple trivial program to write. Write first the dumbest way you can think of, just make sure it works. Then spend some time and try to optimize it, make it cleaner.


Whoever made the comment about Java not being applicable in the real world is an idiot. How many modern, high-level, and powerfull languages can you write ONE piece of code and have it work on ALL different OS's AND platforms that support the Java VM?
 

BigPoppa

Golden Member
Oct 9, 1999
1,930
0
0
Scheme is horrible. Teaching tool my ass. Unstructured jibberish. We use it at Georgia Tech for one class, intro to comp sci. I know MIT uses it.
 

glugglug

Diamond Member
Jun 9, 2002
5,340
1
81
Originally posted by: MCrusty

Whoever made the comment about Java not being applicable in the real world is an idiot. How many modern, high-level, and powerfull languages can you write ONE piece of code and have it work on ALL different OS's AND platforms that support the Java VM?

Hmmm.... C, C++, Perl, Python to name a few.
 

yoda291

Diamond Member
Aug 11, 2001
5,079
0
0
Originally posted by: glugglug
Originally posted by: MCrusty

Whoever made the comment about Java not being applicable in the real world is an idiot. How many modern, high-level, and powerfull languages can you write ONE piece of code and have it work on ALL different OS's AND platforms that support the Java VM?

Hmmm.... C, C++, Perl, Python to name a few.

C code is not platform independent, even if you have the same compiler on both systems.
C++ -- ditto

Perl and Python and interpreted languages and get hit by all that entails.

However, arguing that Java is powerful because it spans across all different OSes is possibly the WORST argument in favor of Java ever. In other words, Java is good because you have developers writing code for hardware that doesn't actually exist.

I think the best argument pro - Java is a little piece of software called Resin...and I leave it at that.
 

FeathersMcGraw

Diamond Member
Oct 17, 2001
4,041
1
0
Originally posted by: Entity
I've learned / am still learning PHP, which has been relatively easy for me. I've got the basic principles of OO code down (though I know PHP isn't strong in OO support), and can do most of what I need to do for web applications in PHP. For some reason, though, I just feel like I'm missing something; it could be all the comments I hear from perl/C++ guys about how badly PHP sucks, etc., but I just want to understand how to code better -- write tighter, more efficient, code, etc. What would be a good starting point for learning stuff like this?

For example, trying to understand when it is better to use the ternary operator, switch, or lines of if statements. That kind of stuff. :p

The answer to "what is more efficient" isn't really an easy one, since most modern languages are going to pass your code through an interpreter or compiler, and it's that intermediate layer of software which is going to do a lot of that optimization for you. What is efficient in one language may not necessary translate to another language or platform.

That's not to say that there aren't some basic principles which are mostly common across languages: remove invariant code from loops, reduce unnecessary memory allocations (and clean up the necessary ones when you're done with them!), try to avoid recopying data, etc. but even these are not hard and fast rules.

I'm probably going to get flamed for promoting code bloat, but I think I've worked on enough large-scale projects to say that the best programming practices to learn are those which make your code decoupled, isolatable, "bite-sized", and above all, readable. The sacrifice of some additional memory for an additional class hierarchy, for example, or the additional CPU time needed to adapt a general-purpose utility class is far outweighed by the ability for you to make timely changes to your code and have good assurance that you won't be impacting the other pieces of code which connect to it.
 

blackdogdeek

Lifer
Mar 14, 2003
14,453
10
81
c++

a lot of developers i know recommend this book. it comes with a free version of vc++.

after that move to java and you'll be able to see the strengths and weaknesses of both.

after that scripting will be much easier :)
 

lukatmyshu

Senior member
Aug 22, 2001
483
1
0
Hmmm ... MIT starts out with Scheme, Berkeley starts out with scheme ... SICP is considered to be one of the greatest books in 'understanding' programming. Sure maybe you wont be an 31337 h4X0r with scheme but you absolutely will be a better programmer. Sometimes in java I REALLY wish I had a map function.

To the original poster ... one of the things REALY computer scientists will tell you is that programming languages != programming logic. A language is like a tool. You don't learn carpentry by learning how to use a screwdriver. In your original post you wanted to know what is more efficient ... a switch or nested ifs ... well the important thing to know there is WHAT your compiler does when you it sees such a statement (in this case, most languages will generate VERY similar code ... but the lesson is still applicable). If you are interested in being a computer scientist, and not someone who read the latest O'Reilly book read SICP. Learn scheme and you'll have a great foundation for the rest of your life. If you're interested in OOP then grab a STRONG OO language (read java ... ideally smalltalk but lets be SOMEWHAT practical) and a book of design patterns. One of the things I've realized is that in school, your programming classes usually don't foster good OO design. Makes sense .... as you're frantically building the last stages of your compiler or whatever you're working on ... you're not going to say "Hmm .. should this be an AbstractFactory or a Singleton ..."
 

lukatmyshu

Senior member
Aug 22, 2001
483
1
0
Well said ... remember that in the REAL world you spend WAY more time maintaining your code than writing it. And while the little tricks efficiencies that you can extrapolate will gain a minor reduction in runtime, and perhaps development, you'll always pay for it later. It is ALWAYS cheaper to do it right the first time.
 

Rickten

Golden Member
Apr 17, 2001
1,607
0
0
from my experience....

I learned C then C++. I became very strong in C. When I went to learn java it was not as hard to pick up at all. I think the initial language you learn is the hardest. Now I know C, C++, java, pearl, lisp, fortran, php, assembly using registers and things like that, prolog, and a few others. However for me the one that was the most difficult to pick up in my opinion was C. I think it was simply because I had never seen any kind of programming before in my entire life. Learn C, learn it well giving yourself a good basis to build on.

edit: the book blackdogdeek recommended is the book I have and use as a reference, although I think there is a newer edition.

for java I use this java
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Choose something people actually still use and get jobs in; ie not Fortran. I've never met a Fortran programmer. Sure they exist, but then so do cobol programmers, and you don't need to learn that.

I'd recommend VB or Java probably. VB is not 100% OO, but it is going to give you a great start and unlike Java it's very easy to use (yet more powerful than the average vb-hater will admit) and you can churn out applications quickly. VB is the most popular programming language at the moment.

I think you may find that C++ when compared to java is too difficult and slow, whereas Java is just much easier to use and if you could master that you'll have a real command over concepts.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
C (not C++) or Pascal are your best bets. Pascal is a great learning/teaching language, as that's what it was designed for. C is as raw as you're going to get without doing assembler.
 

glugglug

Diamond Member
Jun 9, 2002
5,340
1
81
Originally posted by: Skoorb
Choose something people actually still use and get jobs in; ie not Fortran. I've never met a Fortran programmer. Sure they exist, but then so do cobol programmers, and you don't need to learn that.

I'd recommend VB or Java probably. VB is not 100% OO, but it is going to give you a great start

A great start on the road to hell that is....
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Originally posted by: glugglug
Originally posted by: Skoorb
Choose something people actually still use and get jobs in; ie not Fortran. I've never met a Fortran programmer. Sure they exist, but then so do cobol programmers, and you don't need to learn that.

I'd recommend VB or Java probably. VB is not 100% OO, but it is going to give you a great start

A great start on the road to hell that is....
How so? Even if you don't care for the level of abstraction that VB allows, I see no reason to start with C/C++ over Java.
 

z0mb13

Lifer
May 19, 2002
18,106
1
76
Originally posted by: Aharami
Originally posted by: manly
Scheme.

SICP

what? scheme is the worst language ever!!!

then use lisp..

lisp is basically scheme on steroids.. its very good to teach beginner programmers the concepts of programming using scheme (recursion, loops, etc) because they will not be bogged down by the syntax.
 

DT4K

Diamond Member
Jan 21, 2002
6,944
3
81
Originally posted by: kevinthenerd
Yeah, VB sucks hard. You'll never write tight code with anything Microsoft. Sure, it's not a bad way to get into learning GUI's and stuff, but it's a terrible way to "hone" your skills. It's all clicking. That's not code. You're better off perfecting your PHP.
While I agree that VB6 is not a good choice if you want to learn good OO fundamentals, you are a little off base.
It is not just "clicking". If it was, why would my VB6 app need 15,000 lines of code? There is nothing inherently wrong with event based programming and vb6 was a great tool for building user-friendly business apps. It actually allows you to concentrate more on the logic of your app because it takes care of the mundane, time-consuming stuff like builiding forms and buttons and textboxes for you. But I agree that it is not a good tool for OO programming.

But your claim about Microsoft is way off base. Are you familiar with .Net at all?
VB.Net and C# are both complete OO languages that would be great choices for learning good programming fundamentals. The only reason I suggested Java over the .Net languages is because it's free and has been around longer.
First of all, writing "tight code" is overrated for most applications. Sure it's important when speed of execution is the goal. But then you are better off writing in C and skipping the whole OO concept. For many types of programming, clean logical structure and readability are more important than execution speed. This is because the rate-limiting step is accessing data across a network or from a database. In most cases, the extra 1/1000th of a second it takes to process some data is not going to be noticeable to the user. Especially compared to the second or two it takes to get the data from the db.

 

SP33Demon

Lifer
Jun 22, 2001
27,928
143
106
Originally posted by: kevinthenerd
Originally posted by: EyeMWing
Java ... despite having virtually no real world capability anymore.

The Florida Institute of Technology uses Java as a freshman programming class, and that's quite a good schol.

I'm not making my own judgement on the issue, but that's a good indicator that Java is alive and well.
Funny you should mention that. I'm taking the course next semester :) You go to FIT kevin?
FIT is switching their intro course from C++ to Java now, so I'd recommend Java as well.

 

DT4K

Diamond Member
Jan 21, 2002
6,944
3
81
Originally posted by: Skoorb
Originally posted by: glugglug
Originally posted by: Skoorb
Choose something people actually still use and get jobs in; ie not Fortran. I've never met a Fortran programmer. Sure they exist, but then so do cobol programmers, and you don't need to learn that.

I'd recommend VB or Java probably. VB is not 100% OO, but it is going to give you a great start

A great start on the road to hell that is....
How so? Even if you don't care for the level of abstraction that VB allows, I see no reason to start with C/C++ over Java.

Are you referring to VB.Net or VB6 ?
VB.Net is 100% OO and would be a great choice.
Although I'd recommend C# instead. I prefer C-style syntax and although VB.Net and C# have the same capabilities, the negative opinions about previous versions of VB will continue to haunt VB.Net programmers even though it is a completely different language.
VB6 is good for many things, but teaches you some really bad habits and is a poor way to try to implement any OO concepts.

EDIT: and by the way, anyone who lists HTML in a list of programming languages gets their "real programmer" pass revoked. VBScript and Javascript I would let slide. They have limited functionality, but they are still programming languages.