7 ms·
Safety is one of Python's greatest advantages over C or C++. Why would anyone use unsafe Python when P0ython doesn't have other features such as type safety and
by idkdotcom 2y ago
Safety is one of Python's greatest advantages over C or C++. Why would anyone use unsafe Python when P0ython doesn't have other features such as type safety and all the debugging tools that have been built for C and C++ over time is beyond me.
Python is a great language, but just as the generation of kids who got out of computer science programs in the 2000s were clueless about anything that wasn't Java, it seems this generation is clueless about anything that isn't Python.
There was life before Python and there will be life after Python!
- jandrese 2y agoSeems to me if you could do most of the work in Python and then just make the critical loop unsafe and 100x faster then that would certainly have some appeal.
- gibolt 2y agoPlenty of people would gladly not have to learn another language (especially C). You could also benefit from testing blocks of code with safety enabled to have more confidence when safety is removed.
- KeplerBoy 2y agoIt was explained pretty well in the blog: Installing the OpenCV python package is easy, fast and painless as long as you're happy with the default binary. Building OpenCV from source to get it into a C/C++ program can quickly turn into a multi-hour adventure, if you're not familiar with building sizeable C++ projects.
- idkdotcom 2y ago[dead]
- TylerE 2y agoOr if you’re going to learn another language might as well learn nim. Keep most of the python syntax, ditch the performance and the packaging insanity.
- idkdotcom 2y ago[dead]
- eru 2y ago> Why would anyone use unsafe Python when Python doesn't have other features such as type safety and all the debugging tools that have been built for C and C++ over time is beyond me. C and C++ 'type safety' is barely there (compared to more sane languages like OCaml or Rust or even Java etc). As to why would anyone do that? The question is 'why not?' It's fun.
- idkdotcom 2y ago[dead]
- gibolt 2y ago"Why would anyone use" -> "when" usage generally means lots of use cases are being ignored / swept under the rug. >1 billion people exist. Each has a unique opinion / viewpoint.
- bongodongobob 2y agoI don't use Python because of type safety, I use it because it's easy to write. I couldn't give a single fuck about some missed pointers that weren't cleaned up in the 2.5 seconds my program ran. I'm not deploying public code. I tend to prototype in Python and then just rewrite the whole thing in C with classes if I need the 10000x speedup.
- SunlitCat 2y agoThat easy to write part is something, I am not so sure about. It took me ages to understand why my first try at writing a blender plugin didn't work. It was because of white spaces not lining up. I was like, really? Using white spaces as a way to denote the body of a function? Really?
- nottorp 2y agoI'm curious... what rock have you been living under in the past 33 years since python was launched?
- SunlitCat 2y agoLet's see, I was living under the: - Amiga E - Assembler (on Amiga) - perl - tcl/tk - javascript - vbscript - java - vba - c - c++ - python rock. Granted at some of those rocks, I just took a quick peek (more like a glance), but a rock with whitespaces being important was, at that moment, new to me!
- nottorp 2y agoOh cmon, I can still write some z80 assembly from memory and remember the zx spectrum memory layout somewhat, but I check new programming languages now and then :)
- SunlitCat 2y ago:) I just meant that for someone coming from a language(s) where different kinds of delimiters are used to denote function bodies, a language that puts such a huge emphasis on whitespace was kinda throwing me off to get an error message slapped at me even though I was replicating the example letter by letter (although, obviously, I missed the importance of whitespace).
- omoikane 2y agoThe "unsafe" in the title appears to be used in the sense of "exposing memory layout details", but not in the sense of "direct unbounded access to memory". It's probably not the memory safety issue you are thinking of.
- yosefk 2y agoYou can absolutely get direct unbounded access to memory with ctypes, with all the bugs that come from this. I just think/hope the code I show in TFA happens to have no such bugs.
- SunlitCat 2y agoThing about academia (like computer science and the like) is, you need a programming language you can get across easily, quickly and can get people to produce satisfying results in no time. Back then it might have been java, then python, till the next language comes around. The java thing was so apparent, that when you looked at c++ code, you were able to spot the former java user pretty easily. :) About python, sometime ago, I was looking into arudino programming in c and found someone offering a library (I think) in c (or c++, can't remember). What i remember is, that this person stopped working on it, because they got many requests and questions regarding to be able to use their library in python.
- pjmlp 2y ago> The java thing was so apparent, that when you looked at c++ code, you were able to spot the former java user pretty easily. :) Well, Java was designed based on C++ GUI development patterns typical in the 10 years of C++ GUI frameworks that predated Java. Yet, people keep using these kind of remarks.
- kragen 2y agowhile python is eminently criticable, yosef kreinin has designed his own cpu instruction set and gotten it fabbed in a shipping hardware product, and is the author of the c++fqa, which is by far the best-informed criticism of c++; criticizing him with 'this generation is clueless about anything that isn't Python' seems off the mark