Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
Compare cell phone plans using Wirefly's innovative plan comparison tool ×

Comment Re: Why in the heck should a file server need 2M l (Score 1) 222

Yeah, no disagreement there - I was addressing just the LOC aspect.

FWIW Python's threading model does have concurrent execution of threads, but only for a part of the time - it does support true OS-level threads, but a single, process-wide interpreter lock gets held when running Python bytecode or in a Python API function, so /some/ applications see benefits to using multiple threads (typically cases when you can either do lots of work in a C API or when you are waiting on I/O and just want concurrency but aren't necessarily CPU bound), but often that is not the case and/or the app has trouble using all available CPU. On the upside, it's really great in that you can't corrupt Python's internal state and crash with threads, but that's a pretty minor upside. :)

The multiprocessing library is pretty nifty - at my current job we run a Python request handler process on each CPU core and use pipes to talk to a "controller" process (ends up being message inter-thread communication, so a lot like if you use ZMQ), but it's still a far cry from normal threads. And if you just need concurrency and aren't CPU bound, then gevent is pretty spectacular.

But despite all of this, I think Python's threading model is still one of the big design decisions that can make it a difficult choice in some environments - for our current system, we settled on Python despite this and decided that the cost of dealing with it is offset by the other benefits of Python, but it'd sure be notice to avoid that.

Long term, I'm keeping an eye on pypy+STM (http://doc.pypy.org/en/latest/stm.html) - it's nowhere near ready and may not ever be, but it's cool in that it's taking a radically different approach to the problem.

Comment Re: Why in the heck should a file server need 2M (Score 2) 222

Yeah, that's a good point. I think an even better example might be low level bit twiddling of a byte stream and conversion back and forth between a struct in memory and a packed binary file format - C rules there and in Python you end up jumping through weird hoops a lot of times. The struct module helps a lot (though to your point it's more verbose than the same task in C), but only to a point.

Comment Re:I hate Python (Score 1) 222

I'll bite, though I wish you hadn't posted anonymously. :)

1) I don't think Twisted is that relevant because it's judging a language based on a library that some third party wrote. And Twisted was insane in part because of the callback-oriented approach to asynchronous programming it took (these days you can use e.g. gevent, which is awesome).

2) The whole whitespace issue is pretty simple, actually. In all the languages you cited (C, C++, Java, etc.) there's a problem in that in reality there are *two* systems for denoting blocks, and the programmer (and IDE, if used) keeps them in sync. The first is the *actual* system, which are things like the { } tokens in C. The second is the whitespace - you'd be rightfully skewered if you tried to write code without "proper" formatting because it'd be an unreadable mess. The problem is that the language parser cares only about the first one, while the human - intentionally or not - generally leans more heavily on the second one, most of the time.

Instead of removing the redundancy and having both the machine and the human rely on a single means of denoting blocks, we instead went with the bandaid solution of making the tools help point out errors like this:

while (x < 100);
    doSomething();

Python took a different approach and made the language use the same code block delimiter that humans use for both pseudocode and real code: the whitespace. Some people simply don't like that, and that's fine, but for me it makes great sense and I'm pretty skeptical of people who are rabidly against it, since they undoubtedly rely on whitespace all the time, even if it's subconscious.

3) I use Python a ton, and it's because it's concise while readable, in part due to the language design and in part due to the rich set of built in data types and standard libraries. For any non-trivial task, an equivalent C program (and I love C, BTW) is often 5x or more LOC. That's totally fine because C is great at what it's for, but it's also really great to write 20% of the code to do stuff in Python. A core part of Python's philosophy is to keep in mind that code is read far more times than it is written, so readability is hugely important (for example, the colon at the end of e.g. an 'if' statement wouldn't really be necessary, but Guido et al actually did some code readability tests and found that it improved readability, so he put it in).

Obviously you can write ugly code in any language, and Python is no exception, but I've found that Python makes it easy to write readable code.

4) Performance is often a bit of a red herring. Yes, Python itself is quite slow, but in day-to-day work there's often very little code that actually needs high performance. I've worked at several companies with large Python systems and for most parts of the system, if something takes 1ms vs 0.05ms, it just doesn't matter, but the cost of building, testing, and maintaining that component does matter. A lot. Further, huge parts of most Python programs are actually running C code because so much happens in libraries. Doing file I/O? Networking? All of that is really in C. Number crunching, image manipulation, crypto, etc. etc. - it's all C routines in a pretty Python interface.

Beyond that, in cases where you really do have some chunk of code that has to be blazingly fast, you can easily write it in C and call it from Python (see ctypes, libffi, cython, and so on). Python is by no means a perfect fit for every problem, and it does have its warts, but it's a really terrific fit for a huge set of problems, and a good fit for many more. (and on the performance front I didn't even touch on pypy, which is a drop-in replacement for a large and growing set of Python programs - basically a no-effort perf boost)

5) The kicker for me actually has to do with your question of "What the heck is the attraction". Developing in Python is just more fun. It's kind of silly, on some level, but you might be surprised by how much that matters. I've programmed extensively in many languages, and every 6 months or so I do a hunt to find a replacement for Python, but to date I always come back to it. And when I find myself programming in another language I often get annoyed at all of the useless stuff that language makes me do - stuff I know isn't really necessary because in Python I don't have to do it. I get annoyed at how much the other languages get in the way. I get annoyed at how much work it is to refactor something, even with a spiffy uber-powered IDE. I get annoyed at how much time I spend not working on what I'm trying to accomplish, but working on other things because the language and/or stdlib won't do it for me. I get annoyed at how many hoops I have to jump through just to get up and running. I get annoyed waiting for stuff to compile and link, even when it's nearly instantaneous.

The short of it is that Python is just really fun. It totally encourages a highly iterative approach to development, which in turn encourages you to test everything. I find large Python apps to be far more maintainable (and far less buggy to begin with) than apps written in other languages. You could argue that that's just me, and I'm totally ok with that, haha. :)

Comment Re: Why in the heck should a file server need 2M l (Score 3, Insightful) 222

The Kernel is written in C - a language designed for brevity, while python is much more verbose. ... So the exact same algorithm is likely to use more lines in python than in C

I dunno, YMMV, but to me the opposite seems to pretty much always be the case - for any non-trivial chunk of code, the Python version tends to require far fewer lines than the C equivalent. At several different companies we've ported various C modules to Python and it's common for the Python version to have only 20% (or fewer) LOC vs the C original. The reason is just the usual stuff: Python, being a much higher level language, introduces a lot of overhead but in exchange you get powerful built-in data types and have to do basically zero manual memory management.

This tends to show up in not just large libraries or apps, but even in small chunks of code. For example, below is a function from one of our network monitoring agents; as background, basically there are a bunch of different server clusters and a job monitor spits out an hourly file that lists on each line the IP address of each server and the number of errors it encountered (this is part of some legacy thing we're hoping to replace, it's kind of goofy). Anyway, those files get aggregated to a central monitor, that in turn looks for various conditions and alarms if e.g. the error rates are too high.

Anyway, here's a function that reads those files and tells you which servers are seeing the most errors (it returns a list of server IP address and number of errors encountered, in descending order of number of errors):

def ServerErrorRates(reportFiles):
    counts = {} # ip addr --> total errors
    for filename in reportFiles:
        for line in open(filename):
            ip, errors = line.strip().split()
            counts[ip] = counts.get(ip, 0) + int(errors)
    return sorted(counts.items(), key=lambda x:x[1], reverse=True)

Nothing fancy, but doing that in straight C is likely going to take far more than 7 code statements. There's just no way to perform the same work in C in anything close to 7 statements. It's not a knock on C, the two tools are just optimized for different things.

As another example, I just took a peek at our HTTP server library. The whole thing is a single file of less than 800 LOC, and that handles all HTTP request/response handling including header reading/writing, file uploads, cookies, websocket support, request routing, etc., etc. without using any of the HTTP stuff from the Python standard library. The C equivalent would certainly be several times as many lines of code.

I think you could maybe argue that individual statements in Python are more verbose than C, but it's common for each Python statement to be the equivalent of several C statements (and/or many statements in C are simply not required in Python), so on the whole Python programs end up being way more concise. Occasionally I'll see an exception, but it's just that - an exception.

Comment Re:Odd choice of tools (Score 2) 93

The summary, especially the title, omitted a really important detail: it's not that they are porting it to VC++, it's that they are making it work with VC++ *2015*.

IOW they apparently already had the build working with an earlier version of VC++, and this is all about them changing things to work with this newer version of VC++.

Comment Re:This was the one. (Score 2) 467

Are movie theaters in most cities really that terrible, or has it just been a long time since you've been to a movie theater? So many people gripe about having to put up with a theater experience and I just don't get it.

Within 20 miles of my home there are 4-5 "megaplex" theaters where, for a $5 matinee ticket, you can go see the very latest movies on incredibly good screens with terrific audio systems, you stand in no waiting lines, you sit in large, plush semi-reclining chairs with stadium (sloped) seating. The room is clean, the floors are clean. Heck, even the bathrooms are clean. Even if you pay a few bucks more to go at night, you still don't really wait in line and there's never any jostling for seats because you can buy your tickets online and choose your exact seat ahead of time.

At home we have a pretty nice setup for watching movies, but we still occasionally go to the theater not to "put up" with a movie theater, but because of it - it's a fun experience.

FWIW I'm not trying to rip on you, I'm just genuinely curious. :)

Comment Re:Rollercoaster (Score 2) 467

Haha, so true. If it had been any more different from the original trilogy then people would be complaining that it departed from the heart and soul of SW, that it was Star Trek rebranded, etc. I took my kids to it, we had a great time too - it was fun and it felt nice and Star Wars-y.

If I was to sit back and pick the movie apart then, sure, I could find problems with it. But what's the point of doing that? I exchanged some amount of money for some amount of entertainment, and in the end I felt it was a good trade. Me looking for flaws in the movie will just decrease the enjoyment I got out of it and will in no way improve the subsequent movies, so why bother?

We like the Star Wars universe, we got to see more of it, and now I'm cautiously optimistic about future installments. WIN!

Comment Re:Still sucks (Score 1) 467

But she makes more progress in half a movie (and years less time in the story) than Luke AND Anakin did with training by masters, field experience, and a lot of time.

It's not incredible... it's simply not credible.

Hmm... aren't you making an assumption that there is no alternative explanation for this that fits in the story? Yes, given "she makes an incredible amount of progress in a short amount of time", then one conclusion *could* be "therefore, the story is broken", but why assume that's the only possible explanation?

I wondered if her rapid pace at discovering the force wasn't discovering at all, but remembering. i.e. I won't be surprised if in Ep8/9 we find out that she had been a Padawan in training at Luke's school and when things went crazy there, they took some of the promising kids and hid them away on various planets, wiping their memories as a way to protect them. Her vision after finding the lightsaber would seem to suggest this is at least possible.

Anyway, yeah, /maybe/ that part of the story is screwed up. Or maybe, since this act one of a new multi-act story, you're supposed to wonder about some things that eventually get explained. :)

Comment Re:Still reacting too slowly (Score 1) 242

In generally I think you'd be right, but the specific channel they're considering is truTV - a channel that has very little scripted (in the traditional sense) content. Their big focus is on "reality" TV (https://en.wikipedia.org/wiki/TruTV), and next to sports programming, reality shows would be the easiest to lengthen - much of the editing process is whittling down hours and hours of footage into the 22 or 44 minutes of available time.

In other words, Turner is going to just barely dip their toes into the water, a year from now, and they'll do it with some of the easiest content they could try. So... slow... :)

Comment Still reacting too slowly (Score 1) 242

"Time Warner's truTV will cut its ad load in half for prime-time original shows starting late next year"

Wait, so you're gonna react to a problem a year from now?!

I know this is probably driven in part by existing contracts, and while the current state of advertising is definitely a mess, I think it's more a symptom of an underlying problem. And that problem is that in almost every respect, traditional TV broadcasters have been way too slow to keep up. Almost without exception they had to be dragged into the 21st century. They had to be coaxed into alternate viewing devices, allowing time-shifting was a huge battle, etc.

The way they alienate their users via current ad models is bad, but it's just an example from a larger set of ways they alienate their users.

Comment Re:Here's an idea (Score 2) 103

Yes! Also, stop remembering the hashes of my past N passwords.

Forcing you to routinely change passwords, forcing the inclusion of mixed case or numbers or symbols, forcing you to not reuse a past password... net result is less security because most people will just end up writing their weird passwords down somewhere.

All of these restrictions aren't fixing the problem, just shifting elsewhere to be not the site's problem.

Slashdot Top Deals

"Stupidity, like virtue, is its own reward" -- William E. Davidsen

Working...