Been doing a lot of coding in python lately. While some of the hackability of the language is nice for doing some cool things, overall, I cant say im a fan. Its a little too obscured for writing algorithms where effiency is important. Its hard to tell what data types are truly backing various variables and thus makes it tricky to pick the right implementation. I think im working with raw arrays and they turn out to be linked lists or worse. Even then things like a "Dict" isnt always clear if its a Tree implementation or a hashmap implementation or something else entirely.

Granted this isnt an impossible task, I have managed to figure it out by pulling open the source code of the libraries I call and using profiling tools. But python seems to not care or obscures a lot of that.

@freemo I think that python is optimised for reducing *development* time. It's good for when you need to do something quick-and-dirty, the sort of thing where you need to only ever run it once or twice and you're really not going to be stretching the processing or memory bounds of the computer. The sort of thing where it's important that the code be readable, because there's a good chance that if you ever want to run it again, you'll need to tweak it a bit, first.

And in that narrow domain, it's really very good. But outside of that domain, it's probably not the best choice...

@ccc

While I might agree that it is geared towards shorter development time it seems odd to me it finds so much use in scientific circles considering its not well suited for it.

Also I think readability can be interpreted in different ways here. I'd say due to the ability to hack code it really isnt very readable in a meaningful way. You can look at code and have no idea what it is **really** doing and can be rather difficult to find out. thats the opposite of readability in my mind.

The only way I sorta see the readability thing is just with the tabs and the syntax it might be easier to scan lines of code, but thats a small part of readability in my eyes.

But I do agree that it does a fine job at minimizing single-developer start time on small projects where performance doesnt matter.

@freemo Python is used in a lot of places that it is not really all that well suited for. This seems to be largely because someone discovers how great it is with short, quickly coded, demonstration problems - which is where it is at its best - and then starts trying to use it for everything.

Now, it can *do* just about everything; and having a shorter development time is a solid advantage in a large slice of 'everything'. It's just that, once you get away from simple demonstration problems and into large, serious projects, then there are usually other languages that work out better; but even there, there's a very large category of problems where the difference might be fairly marginal.

So it gets used in a lot of places where it's not the best choice - because in some of those places, it's still a *decent* choice, just not the *best* choice.

@ccc @freemo

I mean every Turing-complete language can “do just about everything”…

I got turned off from python a while ago. It was the lack of static typing, the overcomplicated bizarrely behaved parallel processing, and the fact that if my text editor is incapable of understanding a program’s structure, then how the hell am I supposed to understand it?

Oh and the fact that it’s slow.

Every time I wrote a python extension to go with my old awful python code, and it segfaults from a double free again with no way to tell how or why it happened, I just started asking myself, “Why don’t I just write EVERYTHING in C?” At least C has a debugger that isn’t pants-on-head retarded.

Follow

@cy

While I do agree with your sentiments on python I also wouldnt go so far as writing everything in C. C is not well suited for many things and certainly isnt a good drop in for high level scripted languages. But otherwise your point by point on python seems accurate to me.

@ccc

@freemo @ccc C is a little verbose, but if you just go with certain standard extensions (POSIX, basically), you can do a lot of “high level” stuff with it pretty cleanly. It’s when you try to be “cross platform” that C starts getting pretty nightmareish, mostly thanks to Microsoft and Apple.

Or rather, I can do a lot of high-level stuff. It’s a good language if you are the sort of person who forgets what module you imported the “foo” function from like 2 minutes ago. It’s not a good language if you don’t want to sit there typing “very_important_module_foo()” every time. You definitely shouldn’t use it if a different language works better for you.

@cy

I am using high-level here to include certain ideas such as:

* platform independence

* minimal resource management (memory management)

* implied performance improvements (memory slating, cacheing of certain operations that are repeated, etc)

* automatic handling of by-reference and by-value in a safe way obscured from the coder

and many more other things. while you can wrangle C into doing any of those things, as well as many of the things I didnt mention, it is not intrinsic to the language.

@ccc

@freemo @cy @ccc python is good for prototyping.
Also somehow it's nice for buildsystems as I use waf and meson in my C/C++ projects.

But writing something complicated in it? Uhhh... no.

@a1batross

Agreed. The thing about prototying is, while python is fine at doing that, it also means if it isnt suited to the full system you are prototying to demonstrate (as in it isnt suited to a more complex application) then your prototype is essentially a throw-away prototype.

In that sense I'd argue it isnt really well suited to prototying at all as one would hope that when you go past the prototype stage you would not need to start completely from scratch. So as a prototype it has less value than a prototype written in another language.

@cy @ccc

@freemo @cy @ccc Yeah, it highly depends on the complexity of the idea. Something simple is fine.

I would rather say that if time to fix bugs that usually appear in the language you prefer is bigger than writing throw-away prototype in Python, then it's fine. Ship prototype first, then rewrite it to something better.

Otherwise... nah.

@a1batross

Well I've coded in python before, and I'm doing it again. So clearly I do think it is workable and has a place. Though after this project I might use it a little less.

@cy @ccc

@a1batross

My projects can be big, but not interdependent. Like a huge API layer is fine since each component tends to be pass through and very isolated.

@cy @ccc

@freemo @cy @ccc sounds fair.

It's always fun to write something that is going to be used as part of something else. Well, it was in my case. :)

@freemo @cy I'll admit, I probably use C++ in rather more places than it is strictly best in - simply because I tend to default to it. C++ isn't always the best language, mainly because it takes more development time than certain other languages (like, say, Python) - and more developer *care*, as well. This is because it gives you a lot of control over things that are abstracted away by high-level scripting languages; which is both a strength and a weakness (strength: you can handle the situation correctly even in odd circumstances weaknes: you *need* to handle the situation correctly in *all* circumstances).

So it takes a bit longer to write; but if you do it correctly, and do some very thorough testing-and-debugging, you end up with very solid, reliable code.

@ccc

I am proficient enough with almost any language (aside from a few obscure ones) that the language itself, in terms of syntax, isnt a huge limiting factor for me.Most of the time I never even get far enough into my considerations to think of the language quality itself. The very fact that C++/C is compiled will often cause me to reject or select it as an option there alone. For example I love haskell conceptionally but almost never use it because it is compiled (there is an interpreted version but that has its own limitations as it is less popular).

Compiled to system-level binaries (and therefore platform dependent even if the code itself isnt platform dependent) will often rule out half the languages i want to use right off the bat. If I'm using a scripted language the fact that the code can be run directly and in its current form can be run on any system is often the very first requirement.

@cy

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.