[Tutor] Const on Python
katcipis at inf.ufsc.br
Thu Mar 6 16:51:56 CET 2008
so far im starting to feel all what you have said. Im using python to
implement some works on university and im felling that everything is high
level, easy to use, and far easier than c++ and even java. java is less
complicated than c++ but cant be compared with the simplicity of python
code. And the code gets pleasant to read...thanks to indentation and no
braces...i just lerned to hate the damn braces :P. Saddly the lab where i
work only develops on c++ for now... but everything that i can choose i will
develop with python, im still green on developing but so far it is the more
pleasant language to program...is actually fun to develop on python..all the
time....in c++...sometimes is fun....the most part of the time is debugging
suffering =/, and mistic compile errors that sometimes gets a lot of time to
understand what REALLY is the problem. Its amazing how the compiler can
trick you in c++, almost all the times it only points in the wrong
direction..the only thing that can help you is experience or someone with
experience at your side :P. Python runtime errors always helped me to debug
fast and easy, really a joy :D.
thanks everyone for helping me
On Thu, Mar 6, 2008 at 11:18 AM, Andreas Kostyrka <andreas at kostyrka.org>
> Am Donnerstag, den 06.03.2008, 08:35 -0500 schrieb Kent Johnson:
> > C++ is extremely complex. The good side of this is it gives you
> > tremendous control - final, const, pass by reference or value, memory
> > allocation, etc, etc. The bad side is that it is a lot to think about -
> > should this parameter be const? who is going to deallocate this object?
> > and there is a lot of room for error, whole books have been written on
> > the topic (e.g. Effective C++ which even has a sequel).
> Concur. What is worse, it's to complicated for the average "commercial"
> developer. And the claim that you can program C++ effectively without
> knowing the whole language does not work in practice. (Hint: Yes, you
> can program without understanding the whole language. And no, you have
> no chance of debugging your program if you don't understand what that
> complicated library is doing. So in practice you end with senior
> developers doing the debugging, while the newbies try to understand what
> you are doing.)
> As a saving grace to C++ I must note that there are a number of
> "features" in Python that can produce something comparativly
> newbie-unfriendly as C++. But you will notice that most Python
> developers shrink away from using these features, so in effect this is
> not a burning issue. Somehow these "advanced" topics don't deter newbies
> from writing and debugging Python programs. (E.g. you can program for
> years Python without learning the fact that it's not the class that does
> the self bounding, instead it's function.__get__ that does it ;) )
> > Java is less complex and flexible than C++. At first I missed the
> > control of C++, then I realized that it wasn't really buying me much and
> > that the cost was too high - coding Java is much less work than coding
> Java has automatic memory management, is safe (meaning that typically
> the worst thing that happens is traceback), and has an object model that
> nearer to a dynamic language like Python or Smalltalk than to C++.
> Basically, while it looks much like C++ on a first glance, the
> underpinnings come from more dynamic/runtime oriented languages.
> And because it does all these irrelevant details for the developer
> automatically, the IT industry can get enough souls to program it. ;)
> > Then Python. Python takes away even more low-level control. And I don't
> > miss it at all. My Python programs work just fine without static typing,
> > constants, etc.
> Worse, something that one likes to forget. Practically in any software
> system the amount of code that is heavily exercised, the "inner loop" is
> tiny. Meaning that after having written your Python code (usually in a
> fraction of the time planned for the C++ implementation), you can
> improve the algorithms and speed up these critical sections. (By redoing
> them in Python, Pyrex, C/C++.)
> That's the underlying truth to "Python faster than C++" message. Not
> because Python is faster than C++ (in execution speed). Of the primitive
> operations around 98-98% are slower in Python than in C/C++. But it
> allows you to implement your application faster than in C++. The initial
> implementation will be slower than a C++ implementation. But it might be
> already "fast enough". But the point is, that in most cases, your
> friendly C++ coder in the next room is still implementing his initial
> implementation while the Python coder is already benchmarking/tuning his
> app. Or spends time thinking about the algorithms.
> So the following stands, usually, and you can usually even replace the
> languages with Perl, Ruby, PHP, Smalltalk, Lisp, Java, ...:
> C++ is faster than Python (if the resources in money and time are
> unlimited: that's why many C++ gurus in academy have a strong different
> Python is faster than C++ (in time to market, if resources are limited)
> Python is faster than C++ (in execution time, if resources are limited
> enough so that the C++ version is an unoptimized first try, while the
> Python version is usually a 2nd or 3rd generation implementation).
> In commercial practice sometimes "political" considerations make for
> crazy decisions, e.g. witnessed by me:
> 1.) a new web service needs to be developed.
> 2.) the policy of the company is that all developers need to know C
> 3.) the project lead calls in the next free developer to his office, and
> as it happens it's one of the local C++ gurus.
> 4.) The C++ guru, being slightly bored, tells the project lead that in
> his own estimation, it would be faster to do the service in Python, even
> with him learning Python first. It would make even more sense
> technically to do the webservice in Erlang, as it has to interface with
> an Erlang server. He'd be happy to learn more Erlang too ;)
> 5.) The project lead makes him to do it in C++ anyway. Would make the
> scheduling of the group way to complicated if you could not assign any
> developer to every ticket coming in.
> That's the moment where you start scratching your head.
> > Python is simple and flexible and just does what I want with no fuss.
> > Java is a heavy straightjacket. C++ is inconceivably complex.
> Concur. It's just that most people in the IT industry don't grasp it. Or
> the fact that especially C++ comes like an iceberg with the worst under
> the waterline: Debugging that stuff. (Even with the nicest coolest
> debugging tools, debugging C++ still takes an experienced developer with
> > So relax and enjoy it, the only risk is that you will never want to
> > touch Java and C++ again.
> Well, at least not without getting an premium for all the pain ;)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor