Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Python vs. C#

Reply
Thread Tools

RE: Python vs. C#

 
 
Aahz
Guest
Posts: n/a
 
      08-12-2003
In article <Jq%Za.8237$(E-Mail Removed) .net>,
Joe Cheng <(E-Mail Removed)> wrote:
>
>Python is "strongly" typed in the sense that every object has a type.
>It is not "statically" typed in that references do not have types.
>Statically typed languages generally require you to declare variable
>types (some languages infer them) and in return you get compile-time
>warnings when you try to call methods that do not exist or perform
>casts that are semantically impossible.
>
>I may be wrong but I believe C is an example of a language with static
>weak typing... you have to declare variable types and some types of
>errors can be caught at compile time, but you can perform unsafe casts
>and not only will the compiler not stop you but at runtime you won't
>get an exception--just a possibly corrupted value in memory.


http://www.artima.com/weblogs/viewpost.jsp?thread=7590
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
 
Reply With Quote
 
 
 
 
Heiko Wundram
Guest
Posts: n/a
 
      08-12-2003
On Tue, 2003-08-12 at 06:45, Brandon J. Van Every wrote:
> Yes your rendering code is nice looking. Is it fast? Were you working on a
> problem where it needed to be fast? I haven't been using C++ out of love.
> I've been using it for performance. And I don't think "what I can do in 72
> hours" is a valid test for big industrial system architectures. Is your
> code going to hold up in the face of dozens of programmers banging on it,
> and hundreds or thousands of programmers using it? And still be fast?


Yes, I was working on problems where the rendering code needed to be
fast. Doing an import psyco solved all my earlier fears about lagging
behind in performance terms against the people I had to compete with.
And, is having an interpreted language really such a major concern in
the age of computers operating at 2000+ Mhz? The final goal of the
project was designing a 3D-ego shooter with the engine we had written.
And it didn't run overly fast, but fast enough on the machine I tested
it on.

If I had had the time, I'd have worked most of the rendering code down
to C, which I would've wrapped with SWIG or the like, but I was
surprised how fast it even ran using plain Python with psyco. And I
don't really want to express game logic, such as computer player AI, or
the like, in C++. Do you?

(genetic algorithms are plain cool here...)

Just btw., my code help up to other programmers banging on it, and also
held up to larger usage. Just because you have static typing doesn't
mean that the code works together with an "evil programmer" (casting is
lots of fun...). And because my code was understandable, other
programmers who used it could read the code before using my library.
This is impossible to do with an overly complex C++ library, in my eyes.

> It is? Then I'm confused, because around here people keep talking about the
> beauty of avoiding types.


static typing = needing to declare types for all slots
(slots==variables).
dynamic typing = a slot can take up an object of any type (python's
slots only take up references, everything is a reference).

strong typing = types are checked on usage. If you don't use a correct
type (like with an expression (float*)&"1234" in C, which makes no sense
at all), you get an exception.
weak typing = types aren't checked on conversion, so things like
(float*)&"1234" work.

Python is certainly strongly typed, but unlike C, it is dynamically
typed. People also speak of static weak typing in C, as you can cast
anything into anything else (without checks), what you can't do in
Python. C++ is (was) the same, at least when I learnt it.

> What you are saying is Python excels at prototyping, where speed and
> flexibility are paramount. You are not saying that Python excels as a big
> system architecture language, where stability and safety are paramount.


Isn't a renderer and a game engine a big system architecture? I didn't
just prototype it in Python, I could offer a complete system, which was
very extensible. I could've never managed this in any other langauge
without the usual headaches.

> That "except" is, like, 1/2 to 2/3 of industry. I think you Python guys
> need to wake up that there's a much bigger, scarier, and more threatening
> world out there than the UNIX world of "engineering done right." That world
> is also not sitting still, it's on the move. For interoperability of
> langauges, UNIX has nothing to offer like the .NET Framework. DirectX is
> now ahead of OpenGL on vertex/pixel shader API capability and stability.
> The black hole, if not taken seriously, will swallow you. Either that or
> you're forced into "clone and conquer" in reverse.


I don't really know why you compare OpenGL to DirectX, they are just
plain API specifications. Maybe on your Windows Box DirectX is faster
than OpenGL (and offers support for more tasks), but this is a driver
vendor problem. Most graphics drivers on Windows are developed with
DirectX in mind, not with OpenGL. NVidia is IMHO an honorable exception,
as their OpenGL code (sometimes) works faster than DirectX.

And to a sidenote: Unix has always had a .NET Framework. The libraries
..NET tries to standardize have been available on Unix since a long time.
And I don't especially like the thought that I have to choose a single
Framework to do all I need, as this only makes me dependant on the
original implementor (Microsoft in this case). And if you need a
"portable" virtual machine, Python, Java, and Perl (just to name a few)
have offered this since ages. .NET isn't such a big innovation as it
claims to be...

Heiko.


 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      08-12-2003
> > Python advocates tend to pooh-pooh strong typing,
>
> Disinformation nonsense. Python objects are more strongly typed than
> C variables.


Agreed!

> Does C# have casts?


Yes! Explicit! About the same level as Java.
 
Reply With Quote
 
Brandon J. Van Every
Guest
Posts: n/a
 
      08-12-2003
Heiko Wundram wrote:
> And, is having an interpreted language really such a major concern in
> the age of computers operating at 2000+ Mhz?


For those of us who are going to continue to increase our triangle counts,
yes it is a concern. But if we can find a way to do those parts of the code
in C++, and gracefully integrate them, the concern goes away.

> And I
> don't really want to express game logic, such as computer player AI,
> or the like, in C++. Do you?


C++ is appropriate for low-level AI, such as pathfinding and terrain
analysis. I would not want to do high level AI in C++, and probably game
logic would be better done in something else. The question is, what price
do you pay for integration?

> Isn't a renderer and a game engine a big system architecture? I didn't
> just prototype it in Python, I could offer a complete system, which
> was
> very extensible. I could've never managed this in any other langauge
> without the usual headaches.


Yes it is, but you didn't write a big system architecture in 72 hours.

> And to a sidenote: Unix has always had a .NET Framework. The libraries
> .NET tries to standardize have been available on Unix since a long
> time.


I"m talking about language interoperability because of the Intermediate
Language.

--
Cheers, www.3DProgrammer.com
Brandon Van Every Seattle, WA

20% of the world is real.
80% is gobbledygook we make up inside our own heads.

 
Reply With Quote
 
Christopher Barber
Guest
Posts: n/a
 
      08-13-2003
Andrew Bennetts <(E-Mail Removed)> writes:
> On Tue, Aug 12, 2003 at 02:03:58AM -0700, Brandon J. Van Every wrote:
> > Joe Cheng wrote:
> > And how, in a large scale industrial systems context, are you supposed to
> > ensure that Joe Programmer doesn't in fact screw it up?

>
> By writing tests.
>
> Just because C++, C# or Java code compiles cleanly doesn't mean it's
> correct.
> Just because Python code parses correctly and gives clean PyChecker output
> doesn't mean it's correct, either.
>
> In both cases, you need tests, preferably comprehensive, automated tests, to
> verify that your code actually works correctly.


I like the sentiment, but in practice there is no such thing as comprehensive
tests.


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      08-14-2003
Christopher Barber wrote:
>
> Andrew Bennetts <(E-Mail Removed)> writes:
> > In both cases, you need tests, preferably comprehensive, automated tests, to
> > verify that your code actually works correctly.

>
> I like the sentiment, but in practice there is no such thing as comprehensive
> tests.


Without an agreed-upon definition of "comprehensive", this is arguable.

"1. Including much; comprising many things; having a wide
scope or a full view."

Surely you'd agree that comprehensive tests are possible in this case.

"2: including all or everything"

In this case, although I'm unclear on the distinction between "all" and
"everything", you're certainly correct, but it's an uninteresting point
as it's too obvious. Certainly Andrew doesn't think anyone has tests
which cover *everything*...

And is your objection based on personal experience only, or do you
consider others' situations. I would say that at my workplace we
certainly have *comprehensive* and fully automated tests for some of
our code. And those tests do verify quite well that the code works.

-Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments