18 ms·
What Python Fixes
- jayruy 16y agoSciPy+NumPy+MatplotLib == Matlab ($2k+) returns true for most applications That's good enough for me to not bother with any other scripting language.
- wwortiz 16y agoSadly matlab still is much easier to use and understand for engineers, which is one of its, if not the, primary market(s).
- levesque 16y agoI agree that numpy python programming is nowhere near matlab for ease of use. I prefer using python for machine learning tho. I dislike the libraries written in matlab. Is numpy+python faster than matlab?
- wwortiz 16y agoTo be honest I have no reason to conclude that one is faster than the other but I would hope that given its age and girth matlab is more optimized. The main reason I say matlab is better for engineers is that its documentation is beyond amazing, if you think of something you need you search in the help browser and there is a good chance it is there with substantial information (something that is much harder with the math/science python libraries) also if you know a functions name you just type: help function and get plenty of information which helps when you forget how to use something and need a quick lookup. I have done some things with scipy but nothing more than solving some odes and I must say even with all the pains of matlab with writing separate files to solve odes and other such things plus some syntax grievances it is still the easiest solution for me.
- masterj 16y agoSince both (I assume) are calling the same BLAS and LAPACK libraries underneath the scripting niceness, it's likely they're very similar in speed.
- hugh3 16y agoOf course it depends what you're trying to do. I'm pretty sure that numpy/scipy have a lot more overhead than Matlab for everything that _isn't_ just a blas/lapack call, but I don't have the numbers to back it up. I do know that I tried rewriting one of my C++ codes using scipy/numpy and it was about a hundred times slower for that particular task (which did happen to involve very large matrices, approaching the limits of memory).
- infinite8s 16y agoFrom experience that kind of slowdown for pure numeric algorithms happens when your numpy/scipy code is structured in a way that it makes extra unnecessary copies.
- eru 16y agoMatlab also recently has gotten much better in its support for function approaches. You need those for e.g. numerical integration and solving differential equations. The earlier solvers took strings with the name of a function whenever they needed a functional argument. Nowadays Matlab provides `function handles' to refer to a function without calling it. The syntax is @function_name, they need this special syntax, because just mentioning function_name itself in your code, calls your function without arguments. Matlab even support proper closures with lexical scoping, now.
- jayruy 16y agoShow me proper Matlab data structures, I/O libraries, and string manipulation and I might actually care about language features... I do agree with all of these advantages of using Matlab in an environment where my data is already cleaned and normalized; I just rarely find myself in that position.
- hugh3 16y agoAs someone who spent a significant fraction of today trying to get scipy and numpy installed on one of his machines (and failed) I can totally see your point here.
- stefanvdwalt 16y agoWe would love to improve your experience in installing SciPy and NumPy. I'd like to invite you to join the mailing list and raise these issues so we may address them. The easiest way to install the suite of scientific computing Python packages on Windows may be PythonXY or Enthought EPD. Under Linux and OSX, users seem to have few problems.
- tumult 16y agoPython is a Lisp where the interface to everything is a domain-specific language that visually resembles simple imperative programming. If Python has fixed anything, it has been because of its roots as a teaching language, with a culture for treating the structure of the language as a tool. Blur the lines between syntax and semantics, and your only option is to create things that can be expressed in both realms at the same time.
- Xurinos 16y agoPython is a Lisp - I do not understand this. Howso?
- jpr 16y agoIt isn't, and people who say so probably don't know Lisp very well.
- tumult 16y agoIt's not Common Lisp, or Scheme, but it's a "Lisp" in the sense that it is a dynamic language with properties in the spirit of the original LISPs, with the notable exception of not writing directly in the abstract syntax tree. I wouldn't actually call it a Lisp on its own. It is a derivative, a less directly powerful form. "It's a Lisp where..." in the same way that a unicycle is "a bicycle where..." or something.
- catch23 16y agoI think there are dozens of languages that would be considered lispy before python would.
- wildjim 16y ago> I wouldn't actually call it a Lisp on its own. It is a derivative, a less directly powerful form. But you could argue every language is a derivative of another, or another's functionality, or style, or... To fairly call a language "a type of X" there honestly has to be a lot more in common with it. > "It's a Lisp where..." in the same way that a unicycle is "a bicycle where..." ... it has wheels??!! I'm sorry, it's not Lisp. It has several of Lisp's useful features, but it's likewise missing a large number of them; to the point that it's a real disservice to glibly compare it and conveniently ignores a lot of the power of Scheme, Common Lisp, and their true ancestors/siblings.
- j_baker 16y agoI think that Python "fixes" reliance on language features. Sure, Python has a lot of neat features compared to say C# or Java, but as a dynamic language it really isn't anything that great. But Python is probably the best example in recent history of a language that made it big not because it was anything radically new or innovative, but because it has a great standard library and a solid, mature implementation.
- samps 16y agoAgreed. In many ways, Python is the most "boring" of the modern dynamic languages, in the sense that it trades exciting features and hip syntax for predictability and elegance. So it gets a lot of the productivity, conciseness, and power of other dynamic languages without nearly as much cognitive dissonance for people familiar with C or Java.
- etal 16y agoI was going to say that Python fixes in programming languages whatever Markdown fixes in other plain-text markup syntaxes. But thinking about it, you're right -- it fixes the tendency of other languages to invent special syntax to represent standard, frequently used concepts. Python follows the conventions you might use when sketching out an idea on a napkin, and takes each convention to its logical, parser-friendly conclusion. There are few language features that would be hard to succinctly express in a line of pseudocode. ("If the implementation is hard to explain, it's a bad idea.") Result: straightforward, algorithmic code looks like pseudocode, and any code that uses special language features really pops out -- if you see an at-sign or double-underscores, you know something Python-specific is happening.
- samratjp 16y agoObligatory: http://norvig.com/python-lisp.html http://norvig.com/python-lisp.html Python to me is the new world where any immigrant has a niche for whatever he seeks.
- hackermom 16y agoWholeheartedly without trolling, but admittedly with some bitterness, and with much experience in Python, Perl, PHP, Java, C/++ and more, another thing that Python will fix for you is the problem of having a too fast processor on your deployment platform: Python effectively eliminates this problem in most cases, way better than most other languages will. There's always another side of every coin, and it shouldn't ever be ignored.
- pedoh 16y agoCan you expand on this, please?
- acqq 16y agosee for example: http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=python3&lang2=java http://shootout.alioth.debian.org/u64q/benchmark.php?test=al...
- jnoller 16y agoPython has never; and probably never will claim to be the fastest language in the stable. The tradeoff made is processor time, versus developer time - one is cheap, one is not. Should, and can Python be faster without sacrificing the speed of the programmer (including extension authors)? Yes, it can and will be, but never at the cost of productivity.
- stcredzero 16y agoShould, and can Python be faster without sacrificing the speed of the programmer (including extension authors)? Yes, it can and will be, but never at the cost of productivity. That this is a trade-off at all is a woefully outdated idea.
- jnoller 16y agoIronic, because I'm only 30. It's not outdated at all - take for example, the GIL - sure, get rid of it, and put in granular locking. You've now actively harmed the lives of every C extension author and maintainer out there, and slowed down single threaded performance. Sure; it's "easy" - but the cure can be worse than the disease for most of the python-using population. It's all a series of tradeoffs and compromises - in time, things like pypy and unladen swallow will change this (for python) but given both of those are pretty bleeding edge, I'd argue my initial point still stands.
- parfe 16y agoPython is not static Python is not monkey-patched Python is not multiple coding styles Python is not enterprise Python is not overly verbose Python is not overly concise Python is not lacking in libraries Python is not a dialect Python is not manual memory management Python is not hard to learn Python is not a roadblock to writing code quickly And really the only important issue: Python is not a pain to use.
- stcredzero 16y agoNot all of these things are 100% true, but those that aren't are true enough to make Python less painful to use than a lot of the alternatives. Python is not multiple coding styles - not entirely true, but probably true enough. Python is not monkey-patched - again not entirely true, but maybe true enough. Python is not overly concise - mostly true, though I've seen abuses of array slicing and passing/storing/calling functions. Python is not overly verbose - pretty much at the mercy of whoever is writing code, but again, seems to be true enough. Python seems to be pretty good or good enough in a lot of ways, and deserves credit for this. The far-sighted view will recognize it as a local maxima, however. (A "perfect" language is like a perfect predator. A tireless, scentless, invisible, silent, indestructible, ultra-fast killing machine would probably wreck its environment. Considered in the context of evolutionary change, it's practically impossible for such a thing to come about.)
- parfe 16y agoI agree completely. Python isn't perfect but, for me, it solves the issues I listed. I don't like Java and Perl can be the Pit of Despair. I don't have to worry about 4.days working depending on if I loaded a library that loaded another library that properly patched the integer class and the Scheme/Lisp (perceived by me) clusterfuck of libraries, reader macros, slight incompatibilities etc is just non-existent. I would drop python in an instant of a better language came along. For me, the question isn't what it fixes, but what it succeeds at. It makes my professional life less painful and that's really the only reason I need. edit: Also would like to not that the original article seemed fairly pointless. It's not really saying anything of substance.
- 16y ago
- RyanMcGreal 16y agoPython is like a piano: anyone can sit down and tap out Three Blind Mice within a few minutes, but a virtuoso can play Rachmaninoff's Symphony No. 2. The language is well designed; the barrier to entry is low; the language allows for progressive discovery of its advanced features; it is powerful and flexible enough to allow an arbitrary combination of imperative, object oriented and functional programming; and the large, mature ecosystem of third party libraries means it can already do about 80% of just about any problem you can think to throw at it.
- tumult 16y agoPiano is actually somewhat notorious for being excessively baroque and difficult to play at the higher skill levels, the keyboard having been originally designed to play only in a single key with a different tuning system.
- armandososa 16y agoI didn't know that and that sounds interesting to me. Can you elaborate? (I know this is an article about Python, but I love pianos)
- tumult 16y agoSure. It's actually pretty interesting, and involves math. http://en.wikipedia.org/wiki/Just_intonation http://en.wikipedia.org/wiki/Just_intonation http://en.wikipedia.org/wiki/Equal_temperament http://en.wikipedia.org/wiki/Equal_temperament http://en.wikipedia.org/wiki/Well_temperament http://en.wikipedia.org/wiki/Well_temperament Basically, when you play music aloud naturally with your voice or acoustic instruments where you have complete control of the pitch, people tend towards using whole numbers for representing harmony, like 3:2, since it sounds the best. Unfortunately there are 12 notes in an octave in the Western music system so you end up with bad ratios if you want to use instruments which are tuned to play anything more than a single key. If you are in complete control of your pitch, like with voice or violin or other stringed instruments, the all of the players can adjust their intonation on the fly when the keys change, and still keep the nice whole number ratios. Enter church organs, which are huge, expensive, and can't be tuned while they're being played. But they're very nice and impressive. So they were tuned to play in only one key -- C. That's why the keys representing the scale of C major on a keyboard are all white, and the other (less important) notes are smaller black keys. You won't be pressing these very often, better to get them out of the way. Then along came some math people who calculated tables of compromises that ended up giving a pretty decent sound to harmonies, but was laid out in a way so that you could play different keys without having to adjust your tuning or intonation. There were different systems, but they were referred to as having temperament. Hence the name "Well-Tempered Clavier" in the famous composition for keyboard instruments, which made ample use of the newfound ability to change keys whenever one pleases. So now there are a bunch of keyboard players who can suddenly play in any key they want with the new tuning systems. But the keyboard layout is still same one used for playing only in C. That all happened hundreds of years ago, but we're still stuck with the original layout for keyboards.
- mkramlich 16y agoSimple things are simple. Hard things are doable and still easy to read and maintain. Concise but not so much that it looks like line noise later. An application often has about as many characters as the pseudo-code used when designing it. The language syntax is so minimal and flexible that, unlike Ruby, you do not want to create a true DSL but rather plain old modules, functions and classes in order that you keep the readability & extensibility high by having a common language syntax.
- zephyrfalcon 16y agoHmm. Python isn't a really big language, but it isn't as small as it used to be, not by far, and it never was as small or minimalistic as e.g. Scheme or Io.
- iainduncan 16y agoFor me, Python is the only language that addresses the human side of programming well. You just plain make fewer mistakes with Python, and it's way easier to reload code into your brain after not looking at it for a while. The readability and obvious syntax has vastly more far reaching effects than one thinks it will when first learning it. It's amazing how much more productive one is in a language that is easy to read, easy to type, and easy to figure out what the most likely way to do something is. I reach for pdb more than a manual because most of the time I can guess what an api will be, and if not, 5 seconds of introspection reveals it. Ruby is well designed for computers, but Python is better designed for us fallible humans who have to type into computers. ;-)
- iainduncan 16y agoFurther to this, as fallible humans, we usually get the design wrong on the first try. The truly multi-paradigm nature of python has for me made it a really great language for refactoring and iteratively arriving on a good design. You can write proto-types really fast, and turn them into more formal architectures very smoothly.
- jacobian 16y agoPython fixes maintenance. You know that sinking feeling when you crack open 3-year-old code written by your predecessor's predecessor and realize it's a load of garbage and that you'll never be able to fix the bug? Yeah, well, with Python that doesn't happen. At least, not at all frequently. Python forces you to spend a bit more time up-front and then saves you time each and every time you need to read, edit, or improve your code. People choose Python for the same reasons they choose good testing practices. Python's a mature language for mature developers who want to produce mature software.
- j_baker 16y agoI'm willing to bet you haven't seen a lot of Zope 2 code. :-)
- blasdel 16y agoGiven that he developed Django, the framework that thankfully euthanized Zope, he's probably seen things us people wouldn't believe.
- eru 16y agoYou might want to have a look at Haskell, if you like this trade-off of making writing somewhat more complicated but reading much simpler. Also if you browse some PEPS (and other sources) you will find that Python and Haskell's history are more intertwined that one would guess at first.
- joe24pack 16y agoCan you go into more detail about how Python fixes maintenance? I'm really curious what language features of Python are conducive to good or easy maintenance, and how those features are unique to Python. Color me skeptical, but I can be convinced.
- stcredzero 16y agoI'm really curious what language features of Python are conducive to good or easy maintenance My guess is that "Less is More" in this situation. Python often does tend to read like pseudocode. The problem with this, though, is that idiocy has seemingly infinite resources on its side. Occasionally, you will have an outlier who has vast holes in their understanding of programming and writes large amounts of jaw-dropping bad code and can do this even in simple elegant languages. In fact, there's one on the team I'm working with right now. (He was maneuvered onto the testing team to mitigate the damage.)
- deleted 16y ago[deleted]
- jpr 16y agoTo me as a Lisp user, Python breaks more than it fixes. Lexical scoping? Nope, can't have it. Code as data, data as code? Not really. Literals for data? Compilation to native code? Compiler/interpreter warnings? Warnings for name collisions when importing? Standard for the language? Nope. And I don't really buy the argument that Python is simple and clean. It has multiple inheritance, metaclasses, operator overloading, decorators and whatnot. Also the type system is broken, a deriving class can define an overriding method that has incompatible signature, rendering isinstance powerless (yes, I know you probably shouldn't use isinstance much anyway, but dammit, it should at least mean something).
- jrp 16y agoI agree. I first learned to program in Python and then started learning about other languages with more options enabled. Coming from a Lisp to Python would have felt strange. Maybe worth it to use a nice library or program?
- stcredzero 16y agoAnd I don't really buy the argument that Python is simple and clean. Yes, but consider the competition. Python is a significant margin above average, but this says as much about the sorry state of computer languages in general as it says about Python. Heck, English is considered an "easy to learn" language among human languages, and it's a mess! Really the problem is with human beings.
- queensnake 16y ago(More specifically, English is said to be "easy to learn, hard to master" (because as you say, it's a mess).)
- zephyrfalcon 16y agoPython does have lexical scoping though. The only difference with languages like e.g. Scheme is that you cannot rebind variables in the enclosing scope.
- 16y ago
- Kilimanjaro 16y agoPython could be improved a bit, just remove the damn underscore from it. Everything else is love.