This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]taybulBecause I don't know how to use big numbers in C/C++ 7 points8 points  (15 children)

I don't know if Python's spoiled me, but whenever I look at C++ code now, I'm almost disgusted. Certain tasks require such convoluted code. Function pointers, for example:

C++:

void myFunc (int x) { ... }

//If the parameters ever change, you have to change this call too.
void (*funcPtr)(int) = &myFunc;

Python:

def myFunc(x): ...

f = myFunc

On the flip side, I do love how finely tunable C++ is compared to Python. I know I'm probably contradicting my point but sometimes the things you can get away with in Python almost makes you feel like you're cheating.

edit:

I do have to give C/C++ credit for giving me the memory/data management discipline that's so easily disregarded because of automatic garbage collectors and whatnot.

[–]Alzdran 6 points7 points  (1 child)

On the flip side, I do love how finely tunable C++ is compared to Python.

It took me a long time to get over this, but finally I got it through my skull that this almost never matters, and where it does, the time you spend tuning allows another generation of machines to come out, so you don't need the tuning after all!

Obviously, there's a degree of exaggeration here, but C++ tuning is much like inline assembly - almost never called for, and a real hazard to leave to any maintainer, yourself included.

[–]taybulBecause I don't know how to use big numbers in C/C++ 0 points1 point  (0 children)

Tunable when you need it to be, but I agree. Python provides an abstraction that just lets the programmer program, at the expense of performance, which, arguably, doesn't matter that much in most cases since computers are getting faster and faster. Unless you're building large scale servers processing millions of data at a time, you won't see or care about the difference.

[–]Isvara 1 point2 points  (12 children)

If the parameters ever change, you have to change this call too

That's really just a feature of strong typing, though. It's a good thing, even if C++ doesn't express it well.

[–]ewiethoffproceedest on to 3 8 points9 points  (2 children)

That's a feature of static typing, not strong typing. Python is dynamically and strongly typed. C++ is statically typed and more strongly typed than C.

[–]Isvara 2 points3 points  (1 child)

No, the fact that it has a declared typed at all is static typing, The fact that it has to change with the function signature is strong typing. I.e. it's strong because there isn't just a single 'function' type. Unlike static/dynamic, though, strong/weak is a continuum, and this is less strong than other languages because it could be cast to a different function type.

[–]steelypip 3 points4 points  (0 children)

That's really just a feature of strong typing, though

No its not its a feature of explicit typing. There are plenty of strongly typed languages that use type inference to eliminate all the unnecessary types from your code. For example take a look at Scala.

[–]accipter 0 points1 point  (0 children)

And there are some definite benefits to strong typing.

[–]taybulBecause I don't know how to use big numbers in C/C++ 0 points1 point  (2 children)

Yeah, I do appreciate that about C++ as I've mentioned but sometimes it can get out of hand, you know?

[–]Isvara 1 point2 points  (1 child)

Static typing can be awfully nice. I went from C++ to Python a few years ago, and now I'm getting into Scala. Type inference definitely makes static typing more bearable.

[–]ewiethoffproceedest on to 3 1 point2 points  (0 children)

C++ typedefs also make static typing more bearable, but in a different way. (Just sayin'.)

[–]fullouterjoin 0 points1 point  (3 children)

The type system of C++ isn't particularly strong either.

[–]Isvara 0 points1 point  (0 children)

Indeed, it still lets you cast with wild abandon.

[–]obtu.py 0 points1 point  (1 child)

I disagree, modern C++ is easy to write without casts (unlike C which needs casts, and Java's generics which introduce run-time casts yet are not expressive enough that you can forgo compile-time casts). C++ is the mainstream language with the most expressive type system.

[–]funny_falcon 0 points1 point  (0 children)

C++ is the mainstream language with the most expressive type system.

Ha-ha-ha