New To Programming: What Language Is Right For Me?

Started by
65 comments, last by demonkoryu 15 years, 12 months ago
Quote:
You're right, of course. I misspoke. What I meant is that (almost) everything the programmer works with is an object; with the exception of static methods (which are still classified within classes, which aids in the mental mapping of functional groups to specific classes), your code is always modeled as an interaction between objects.


Again,no. Programmers work with types(or classes) all the time, yet types are not objects in Java. You can't keep a list of types, for instance. How is then your code modelled as an interaction between objects, since one of the most basic building blocks(types) are not objects to begin with?

Quote:
you have a situation similar to (though of course much cleaner than) C++: you can write in an OOP paradigm, but the language lends itself more naturally to a procedural approach (at first, that is--you can do OOP just fine in Python, but from a pedagogical point of view you aren't hammered over the head with it--and I believe that you very much should be hammered over the head with it at first). With a proper instructor who's strict about enforcing the use of OOP where intelligent, Python is surely fine. But learning on your own--not so much, because the structure and framework isn't really there.


Putting a function inside the namespace of a class so you can say 'there, I used the class keyword' doesn't make your code more 'OO'. I don't understand how Python 'lends itself more naturally to a procedural approach'. It simply doesn't force you to use the 'class' keyword when it isn't needed and allows the definition of functions outsite classes. Well, many times this just makes more sense. Those free functions are objects themselves, which exist in the namespace of the module they were defined in, which in turn is also an object than can be passed around.

Say you have a function that takes a list of entities and returns the number of collisions between them. How is that implemented best in Java? You will probably have a Physics class and a Physics::FindCollisions(list) static method. What does that teach a beginner about classes? That classes are not only types, there are also namespaces we can dump functions in since we have to put them 'somewhere' and, well, classes is the only place code can exists since the language says so.

Take the similar situation in Python. You'd simply have a Physics modules that defines a FindCollisions(list) free function. That module can be passed around as a value, so you could have,say, 2 modules, one with impementation A and one with implementation B that implement FindCollisions(). You can even choose between those 2 modules at runtime, and the corresponding function will be called. Not tell me that this isn't more 'OO' than the static method technique, or that it doesn't teach better the notions of 'class' and 'module'.


Quote:
I am the wrong person of whom to ask this question, because I consider Python itself to be inelegant in general usage. I dislike the language from a stylistic standpoint, and I simply don't see any "elegance" in it whatsoever despite attempts to do otherwise. I can recognize its pluses, but the best answer to your question, for me, would be "I can't think of an algorithm that is more natural in Python, ever," because I...well...can't.


I didn't ask you to think an algorithm that is more natural in Python. I asked you the exactly opposite. An algorithm that is more natural in Java than in Python(that is, the syntax obscures the implementation of the algorithm as little as possible). Since you consider Python to be inelegant, you surely can provide such an example.
Advertisement
Quote:Original post by eedok
huh? I don't understand any of this part of the post, especially having worked for a company that solely used python for near everything. How does python force you to think in terms of python rather than the problem(as IIRC it's one of the few languages that doesn't puke when a new programmer tries to calculate something like 19! to learn recursion)?
As I said above--like C++, it allows (and, from my own experience, encourages) you to work procedurally rather than in an object-oriented fashion. The common learning ma

Quote:Glorified shell scripts? Is that what you think that is all a programmer programming python is capable of?
Yes, because I really said that. Don't put words in my mouth. Of course Python can do anything any other Turing-complete language can.

Quote:Whitespace in python a bad thing(You're saying the whitespace in your C/C++/C#/Java code is different than what python would enforce)?
I take a dim view of any language that tries to enforce how I can structure my program for easy reading. End of story. (And yes, it does occasionally differ from how I would do it. Not often, but when I do differ from my standard indentation I have a reason for it.

Quote:Again,no. Programmers work with types(or classes) all the time, yet types are not objects in Java. You can't keep a list of types, for instance. How is then your code modelled as an interaction between objects, since one of the most basic building blocks(types) are not objects to begin with?
Being able to manipulate a list of types isn't necessary when teaching programming; that's relatively advanced stuff. The types themselves are irrelevant to the modeling, except as a sort of mold from which objects are created. (And by the way, they are objects in C#, which is what I recommended to begin with...I consider C# to be far superior to Java in pretty much all respects.)

Quote:I don't understand how Python 'lends itself more naturally to a procedural approach'. It simply doesn't force you to use the 'class' keyword when it isn't needed and allows the definition of functions outsite classes. Well, many times this just makes more sense.
I disagree on the sensibility of it. We aren't going to get very far on this one--it's a question of style and preference.

Quote:I didn't ask you to think an algorithm that is more natural in Python. I asked you the exactly opposite. An algorithm that is more natural in Java than in Python(that is, the syntax obscures the implementation of the algorithm as little as possible). Since you consider Python to be inelegant, you surely can provide such an example.
Then I'll answer all of them, because Python's syntax always gets in the way for me. It's hideous (whitespace meaning something, newlines delimiting the end of a statement, abbreviated keywords), and it, in my opinion, needlessly differs from most of the languages in common use. Don't bother arguing on this point, because I fully acknowledge that it's personal taste, and it's why I didn't mention these problems I have with the language with regards to pedagogy.
http://edropple.com
Quote:Original post by Edward Ropple
Quote:Original post by eedok
huh? I don't understand any of this part of the post, especially having worked for a company that solely used python for near everything. How does python force you to think in terms of python rather than the problem(as IIRC it's one of the few languages that doesn't puke when a new programmer tries to calculate something like 19! to learn recursion)?
As I said above--like C++, it allows (and, from my own experience, encourages) you to work procedurally rather than in an object-oriented fashion. The common learning ma

Quote:Glorified shell scripts? Is that what you think that is all a programmer programming python is capable of?
Yes, because I really said that. Don't put words in my mouth. Of course Python can do anything any other Turing-complete language can.

What would compel you to say this?
Quote:Original post by Edward Ropple
It might be a not-entirely-terrible language first if all you want to do are glorified shell script

I'd also reply to the first bit but it seems your post got cut off, so I'll wait for the edit
Fair enough. I'm not going to continue, just closing with this because it is a pet-peeve of mine:

Quote:
Being able to manipulate a list of types isn't necessary when teaching programming; that's relatively advanced stuff.


No it is not. It definately, certainly isn't. It's only 'advanced' when we talk about languages like C# and Java, where the types are mysterious entities hidden in the depths of the compiler, and the programmer has to jump through various hoops(mainly use Reflection libraries) to inspect and manipulate them. Of course that's 'advanced stuff' in Java. But in Python(or Ruby,or Smalltalk) it's as simple as it gets. If you teach the beginner that types are regular objects like anything else, that is what he's going to learn.

Since you insist that the beginner must be tought from the beginning the basics of OOP, how about this example: Write a program that defines three classes 'Dwarf','Elf','Human', take input from the user at runtime and create the appropriate object('D' for Dwarf,'E' for 'Elf' and so on). Basically, a tiny class factory. If we forget about the language used, is that idea so advanced? I don't think so. But how we teach this in,say,Java or C#? Probably with a switch statement, because diving into Reflection would indeed be premature for a beginner. And since teaching this using switches wouldn't really offer anything to the student, we just don't teach it at all. Now, how we teach this in Python? Simple. We put these types in a dictionary:


registered_classes={'D':Dwarf,'E':Elf,'H':Human}


and we create the instance:


the_class=registered_classes[char_that_user_gave]
entity=the_class()
entity.SaySomething()


Which of the 2 approaches is more elegant,scalable, and teaches better the beginner about the basics of OO? Which implements what we have in mind more straightforward, without having to wrestle with the syntax?

I'll let the reader decide.
Quote:Original post by Edward Ropple
It's hideous (... abbreviated keywords)....

A brief selection of C# keywords: bool, char, const, enum, extern, int, ref, sbyte, stackalloc, struct, uint, ulong, and ushort. Hypocrisy much?
Quote:Original post by SiCrane
Quote:Original post by Edward Ropple
It's hideous (... abbreviated keywords)....

A brief selection of C# keywords: bool, char, const, enum, extern, int, ref, sbyte, stackalloc, struct, uint, ulong, and ushort. Hypocrisy much?

lol I find it funny as the only abbreviated keyword in python are def del elif exec
C# is definitely a top pick language. However, since you are a beginner, I recommend C++, solely because going from C++ to C# is easy, the other way around can be challenging for some. Ultimately you will have to be able to pick up any language to be a good programmer. Although Python is a fine language I recommend against it because the syntax isn't quite the same as other popular languages's (C++, C#, Java).
One more thing, definitely go Object Oriented.
Quote:
Quote:Original post by SiCrane
Quote:Original post by Edward Ropple
It's hideous (... abbreviated keywords)....

A brief selection of C# keywords: bool, char, const, enum, extern, int, ref, sbyte, stackalloc, struct, uint, ulong, and ushort. Hypocrisy much?



To be fair, that's a small portion of C# keywords and python does have many fewer. The standard library class names rather than keywords should probably also be included there.

Anyways:

I must admit, I find the obsessive conciseness of Python and Ruby to be revolting.

F# and similar style syntaxes don't bother me while still being elegantly brief. I'm not quite sure what causes such a visceral response... perhaps the similarities to perl?

But whatever. As long as beginners aren't learning C++, I'll be happy. [grin]
Quote:Original post by Telastyn
But whatever. As long as beginners aren't learning C++, I'll be happy. [grin]


The less people I have to tell not to blindly cast function pointers (or any kind of pointer, for that matter), the better. [smile]
Quote:Original post by Edward Ropple
C++ is halfassedly object-oriented

C++ is not, never was and never will be an object oriented language.

This topic is closed to new replies.

Advertisement