|
Janin posted:Or you could just use exceptions. Obviously you've learned, or been taught, that exceptional circumstances are inherently errors. In Python, this is not the case; an exception just means that the code was unable to finish executing, for any reason. It does look an awful lot like Guido shoehorned what would be an event anywhere else into the exception model because, in the context of every other language I have used, this is strange behavior. Conditions already look like a better idea just because they don't try to call a shoe a sock. Munkeymon fucked around with this message at 22:21 on Nov 7, 2008 |
# ? Nov 7, 2008 22:19 |
|
|
# ? May 14, 2024 16:55 |
|
Misogynist posted:Scientists do not know Perl This cannot be stressed enough.
|
# ? Nov 7, 2008 22:42 |
|
Munkeymon posted:It does look an awful lot like Guido shoehorned what would be an event anywhere else into the exception model because, in the context of every other language I have used, this is strange behavior. Conditions already look like a better idea just because they don't try to call a shoe a sock. What languages have you used? If you've only used the C family (C++/C#/Java) then the idea of a non-error exception will seem strange, but to understand Python you need to realize that they are different concepts.
|
# ? Nov 7, 2008 22:59 |
|
Janin posted:What languages have you used? If you've only used the C family (C++/C#/Java) then the idea of a non-error exception will seem strange, but to understand Python you need to realize that they are different concepts. It's often a good idea to give different concepts different names - and possibly even different structure - to avoid confusion. When you borrow the name and structure for a construct like exceptions from the popular language crowd and then subtly change what it's generally used for, you create a situation where problems are more likely for most programmers who use your language. I could also see a Python-taught programmer bringing this concept to a different language and making a huge mess. Anyway, it's silly to argue over this now since it's not going to go back in time and affect Guido's decision, but I think he screwed up there. Not a huge deal, but still not the best idea he's had.
|
# ? Nov 8, 2008 00:12 |
|
People seem to be arguing over fundamentally different definitions of "exception". If there was ever an overloaded term in the realm of coding, it's "exception". It means everything to everybody. Janin almost hit it: if you come into Python thinking "'exception' means non-Python definition x", it won't look right. Part of making your own language is deciding what "exception" means to you. Wikipedia's definition of exception handling is something that is "designed to handle the occurrence of a condition that changes the normal flow of execution". That definition seems general enough to include the case where a generator/iterator/etc. can't continue executing normally because there's nothing left to generate/iterate/etceterate. Beyond that, it's up to the language.
|
# ? Nov 8, 2008 07:32 |
|
Seriously, what is attempting to iterate past the end of a sequence, if not an exceptional circumstance?
|
# ? Nov 8, 2008 18:06 |
|
A logic error that deserves to be punished with undefined behaviour~
|
# ? Nov 8, 2008 18:20 |
|
BigRedDot posted:Seriously, what is attempting to iterate past the end of a sequence, if not an exceptional circumstance? The language shouldn't even let you
|
# ? Nov 8, 2008 18:54 |
|
BigRedDot posted:Seriously, what is attempting to iterate past the end of a sequence, if not an exceptional circumstance? Victor fucked around with this message at 22:03 on Nov 8, 2008 |
# ? Nov 8, 2008 20:28 |
|
Janin posted:If generators do their work in has_next(), then what should happen when they raise an exception? Does it appear from the has_next() call? That's awfully awkward. Calling sys.exit() from the middle of a generator is making a mess. Depending on order of evaluation of generators is to rely on spooky action at a distance. If you want side effect but no results, why are you using a generator? The clue is in the name, it generates output. quote:The issue with using a has_next()/get_next() style is that it's not as general as the current system. Any loop implemented with has/get_next() can be wrapped in a generator, but the converse is not true because the behavior of a generator allows unpredictable results. code:
|
# ? Nov 9, 2008 00:13 |
|
Zombywuf posted:Calling sys.exit() from the middle of a generator is making a mess. Depending on order of evaluation of generators is to rely on spooky action at a distance. If you want side effect but no results, why are you using a generator? The clue is in the name, it generates output. If you want a language with carefully-managed side effect handling, use Haskell. The imperative nature of Python precludes stateless generators. You are also ignoring that sys.exit() is just an example of a side effect; it could be anything else. Here's a simple coroutine example; how would you implement this using has/get_next()? has_next() wouldn't be able to advance beyond the current point, because the generator requires a value from the yield statement to work. code:
Zombywuf posted:
Shouldn't that code just use for..in? Zombywuf posted:The only thing I can think of this construct being good for is that it makes it slightly easier to implement your own generator class. However python doesn't seem to accept any old class with a next() method as a generator :-(. I don't understand what you mean, here. If you mean custom iterables, that's easy to do. If you mean actual custom generator classes, why on earth would you want to?
|
# ? Nov 9, 2008 01:39 |
|
Janin posted:If you want a language with carefully-managed side effect handling, use Haskell. The imperative nature of Python precludes stateless generators. quote:You are also ignoring that sys.exit() is just an example of a side effect; it could be anything else. Here's a simple coroutine example; quote:how would you implement this using has/get_next()? has_next() wouldn't be able to advance beyond the current point, because the generator requires a value from the yield statement to work. PEP 342 effectively redefined next to mean send(None). Handling this case is just matter of having a "has next when sent a" function. This is easily handled with an optional argument on the has_next(). quote:Shouldn't that code just use for..in? quote:I don't understand what you mean, here. If you mean custom iterables, that's easy to do. If you mean actual custom generator classes, why on earth would you want to? You probably wouldn't, yet the design seems to be geared around making it easier.
|
# ? Nov 9, 2008 11:55 |
|
Zombywuf posted:I never said the language should manage side effects. I said that if you're using generators for their side effects you're doing it wrong. Unless the language prevents all side effects within a generator, it's not possible to reliably implement has_next(). Zombywuf posted:PEP 342 effectively redefined next to mean send(None). Handling this case is just matter of having a "has next when sent a" function. This is easily handled with an optional argument on the has_next(). So you would prefer the code to be expanded to this: code:
Zombywuf posted:Yes, my point is that you'll only ever see the behavior of using an exception to stop iteration if you do something badly wrong. This is an argument for exception-based iteration Zombywuf posted:You probably wouldn't, yet the design seems to be geared around making it easier. Not really; the use of iterators with next() makes implementing custom iterables easier, but that's got nothing to do with custom generators. --------------------- Also, here's a word from the original developer: quote:<<Fix for memory leak>>> every dev read
|
# ? Nov 9, 2008 21:36 |
|
I found out this week why certain bits of code are slow at work. We have a cache of ticket prices - I thought this was a simple as the ticket details (people, date) being the key, and the price being the value in a hash. It turns out that he constructs the key from the ticket details and the price, just to be sure. Unfortunately this means he can't then do a simple lookup, so he iterates through the hash values to find it. "iterating over the keys of a hash is like clubbing someone to death with a loaded Uzi." - larry wall.
|
# ? Nov 16, 2008 16:19 |
|
So I'm a PHP developer at an internet marketing (spam) company. We have two developers, and the other one is leaving soon. We're set to interview a guy on Friday, so about 15 minutes before the interview I actually look at his resume and Google his name. He's got a blog, a video blog, and a Twitter. He's got a BS in "Legal Studies" and master's in "Information Technology" from an unaccredited (fake) online university. I managed to look at his video blog and find out that he won't accept less than 85k salary. For reference, I graduated with my BS in CS in May and am making 38k at this company. Still looking at his video blog, I notice another video with a screenshot of something other than his face. Unfortunately, I decided to click on it. "Oh wow, this must be some sort of scuba diving video." NOPE! Turns out it's a camera inside his ureter recording several minutes of a surgeon removing some cysts. Thanks for posting that on the internet! I'd love to work alongside you since you have a fake degree, no real education that would help you as a developer, an ego that makes you think people want to read your Twitter and watch your video blog, and weird diseases. Surely he will redeem himself in the interview! Of course, this is SA so you already know what happens. To make a long story short, he failed to answer these questions: Write a recursive function to do factorial (he didn't know what recursion meant) Name a way that Linux differs from real UNIX (no idea, but not a big deal) How do you prevent SQL injections? (he had never heard of prepared statements/parameter queries) I'm sure there's more to say, but I wager this post is getting boring at this point. Maybe I'll post a link tomorrow if y'all really want it. Hopefully we'll have some more hilarious interviews coming up before my coworker quits and leaves me in charge of software that I can barely maintain, let alone extend! spiritual bypass fucked around with this message at 20:17 on Nov 16, 2008 |
# ? Nov 16, 2008 20:12 |
|
Today I had to do some maintenance on the administration part on one of our websites. You can link some stuff to one of 15 different locations. Here's how they did it: php:<?php switch($selected){ case 1: $q .= "location1='selected', "; $q .= "location2='', "; $q .= "location3='', "; $q .= "location4='', "; $q .= "location5='', "; $q .= "location6='', "; $q .= "location7='', "; $q .= "location8='', "; $q .= "location9='', "; $q .= "location10='', "; $q .= "location11='', "; $q .= "location12='', "; $q .= "location13='', "; $q .= "location14='', "; $q .= "location15=''"; break; case 2: $q .= "location1='', "; $q .= "location2='selected', "; $q .= "location3='', "; $q .= "location4='', "; $q .= "location5='', "; $q .= "location6='', "; $q .= "location7='', "; $q .= "location8='', "; $q .= "location9='', "; $q .= "location10='', "; $q .= "location11='', "; $q .= "location12='', "; $q .= "location13='', "; $q .= "location14='', "; $q .= "location15=''"; break; //ommitted default: $q .= "location1='', "; $q .= "location2='', "; $q .= "location3='', "; $q .= "location4='', "; $q .= "location5='', "; $q .= "location6='', "; $q .= "location7='', "; $q .= "location8='', "; $q .= "location9='', "; $q .= "location10='', "; $q .= "location11='', "; $q .= "location12='', "; $q .= "location13='', "; $q .= "location14='', "; $q .= "location15=''"; } ?>
|
# ? Nov 17, 2008 21:10 |
|
willemw posted:Today I had to do some maintenance on the administration part on one of our websites. You can link some stuff to one of 15 different locations.
|
# ? Nov 17, 2008 21:22 |
|
Jethro posted:So is this the mystical unrolled for-case? Duff's Enigma.
|
# ? Nov 17, 2008 21:30 |
|
They go against the C# NamingConventions but that doesn't bug me too much. Except for when they don't. I couldn't decide if I should name the file namespaces.png or NameSpaces.PNG, so I just uploaded them both
|
# ? Nov 17, 2008 22:24 |
|
royallthefourth posted:Thanks for posting that on the internet! I'd love to work alongside you since you have a fake degree, no real education that would help you as a developer, an ego that makes you think people want to read your Twitter and watch your video blog, and weird diseases. The fake qualifications aren't good, and I guess saying online that you won't work for under $85k could turn off some employers, but really who gives a poo poo if a prospective employee:
|
# ? Nov 17, 2008 23:03 |
|
amanvell posted:Yes because having cysts==bad programmer. Those two points served as evidence that he was utterly socially inept. I work very closely with my co-developer and I need to be able to replace him with somebody that is easy to work with. Someone who thinks he is so important that I need to be updated on his life every hour or thinks that posting surgery videos online is a good idea is probably not someone that I want reading code over my shoulder. Most importantly, I thought it had good comedy value.
|
# ? Nov 18, 2008 00:21 |
|
willemw posted:Today I had to do some maintenance on the administration part on one of our websites. You can link some stuff to one of 15 different locations. There's plenty of code like that in the codebase I work with. We also have this: code:
But we can't be bothered to use this in the proper way. Instead we get this monstrosity: code:
|
# ? Nov 18, 2008 02:00 |
|
royallthefourth posted:Those two points served as evidence that he was utterly socially inept. I work very closely with my co-developer and I need to be able to replace him with somebody that is easy to work with. Someone who thinks he is so important that I need to be updated on his life every hour or thinks that posting surgery videos online is a good idea is probably not someone that I want reading code over my shoulder. While I mostly agree with you... royallthefourth posted:Someone who thinks he is so important that I need to be updated on his life every hour ...that's not necessarily what twitter is about. I didn't see anything in your story that said it was like that, just that he had one, and I'm just wondering if you just jumped to that conclusion. Twitter (and its relatives) can be fine and not just for attention whores.
|
# ? Nov 18, 2008 02:13 |
|
Mercator posted:Duff's Enigma. You just made a long terrible day melt away into laughter. I decree this to be its official name.
|
# ? Nov 18, 2008 02:35 |
|
No Safe Word posted:...that's not necessarily what twitter is about. I didn't see anything in your story that said it was like that, just that he had one, and I'm just wondering if you just jumped to that conclusion. Twitter (and its relatives) can be fine and not just for attention whores. I understand that Twitter is simply a tool. I read a couple days of his feed and it was pretty douchebaggy, but I guess my first post didn't reflect this. His awkward online presence would only be considered a real factor if he was very skilled yet socially inept and there was someone else equally skilled but more personable. The main reason he didn't get hired is because he's incompetent. Anyway, it all struck me as very funny in a sad kind of way, which is the sort of thing goons enjoy. The interview made me feel like I had walked into the Weekend Web, but I guess I'm not good enough at writing comedy to make the experience make sense in a forum. Next time, I'll post hilarious code and let that speak for itself.
|
# ? Nov 18, 2008 03:22 |
|
This is psuedocode. I was having trouble figuring out why the test could never fail... code:
|
# ? Nov 18, 2008 23:52 |
|
royallthefourth posted:So I'm a PHP developer at an internet marketing (spam) company. How the gently caress can you take the high ground here? Sure, he went to fake schools and posted gross videos online, but you're part of the loving spamming business! Go die. ymgve fucked around with this message at 11:28 on Nov 19, 2008 |
# ? Nov 19, 2008 11:24 |
|
ymgve posted:How the gently caress can you take the high ground here? Sure, he went to fake schools and posted gross videos online, but you're part of the loving spamming business! Sometimes it's just a job man, chill out.
|
# ? Nov 19, 2008 12:24 |
|
TheSleeper posted:Sometimes it's just a job man, chill out. You are in fact responsible for what you do at work.
|
# ? Nov 19, 2008 16:42 |
|
TheSleeper posted:Sometimes it's just a job man, chill out. Yeah, well, you know who else were JUST FOLLOWING ORDERS?!?!
|
# ? Nov 19, 2008 16:51 |
|
ymgve posted:How the gently caress can you take the high ground here? Sure, he went to fake schools and posted gross videos online, but you're part of the loving spamming business! Everyone who gets spam from my company opts-in. I designed the database that keeps track of our e-mail addresses and the service that receives them from our partners. It honors unsubscribe requests! Nobody can get spam from my company without explicitly asking for it. I never claimed any moral high ground here anyway; I claim a professional high ground based on the fact that I can actually write computer programs. Of course, you've got some mighty strong moral values if you think people who work for relatively honorable spam businesses should be killed. In case you're wondering, I'd rather not be developing crappy web marketing apps. I'd really like to work on something interesting, like writing software at NASA or programming robots. I had to take a job somewhere, and this place has actually treated me pretty well. I don't have any problems sending spam to people who explicitly ask for it and then don't bother to click the opt-out link at the bottom of every email.
|
# ? Nov 19, 2008 17:56 |
|
royallthefourth posted:Everyone who gets spam from my company opts-in. I designed the database that keeps track of our e-mail addresses and the service that receives them from our partners. It honors unsubscribe requests! Nobody can get spam from my company without explicitly asking for it. Then it's not spam.
|
# ? Nov 19, 2008 17:58 |
|
JoeNotCharles posted:Then it's not spam. He's not the one that made a big todo about it. Back to the thread: php:<? $LIVE_PRODUCTION_FLAG='TEST'; //Change above only to 'ON' or 'TEST'. ?> php:<? if (isset($LIVE_PRODUCTION_FLAG) && ...) { ?>
|
# ? Nov 19, 2008 18:40 |
|
geetee posted:
What, you don't think they should test the live production flag
|
# ? Nov 19, 2008 18:49 |
|
geetee posted:He's not the one that made a big todo about it. I'm just saying that posting, "I work for a spammer" is a good way to get people to hate you, and if what you're doing is not actually spam calling it that is pretty stupid.
|
# ? Nov 19, 2008 19:20 |
|
I just got done debugging a custom javascript image rotator that was spawned in hell. There was a basic javascript error, which wasn't a big deal. What was the big deal was that the rotator was a custom control project that existed only on that ex-employee's machine. And all the javascript was done server-side and fed line by line into a StringBuilder which looked like this: sb.Append("function buttes() "); sb.Append("\r"); sb.Append("{"); sb.Append("\r"); sb.Append("if (this==that) "); sb.Append("\r"); sb.Append("{"); gently caress I JUST NEED TO CORRECT YOUR INSANE JAVASCRIPT SO THE setTimeout() IS APPLIED TO A VARIABLE AND CAN BE CLEARED. BUT FINDING THE ACTUAL TIMEOUT IS A NEEDLE IN YOUR STRINGBUILDER HAYSTACK!
|
# ? Nov 19, 2008 19:56 |
|
The real WTF is in several online tutorials that teach you to use a StringBuilder for instances such as the above, instead of letting the compiler automatically combine all the string constants into one. It's pretty sad.
|
# ? Nov 19, 2008 20:12 |
|
Victor posted:The real WTF is in several online tutorials that teach you to use a StringBuilder for instances such as the above, instead of letting the compiler automatically combine all the string constants into one. It's pretty sad. Not only that, but even in the case of appending a bunch of string constants and string variables together, the Java compiler is smart enough (that's a phrase you don't hear too often!) to compile that into a StringBuilder construction and sequence of append() calls. I never knew this until I had to decompile a class for something and saw that. I wonder under what conditions this transformation occurs -- without compiling an example, I bet it only applies to a single statement at a time. Still, it really cuts down on the number of times that you actually need to use StringBuilder explicitly. vvv Fair enough, I suppose my beef with Java is with the design of the core language and not the compiler. It's just hard to be nice when Java's the topic of conversation Flobbster fucked around with this message at 22:11 on Nov 19, 2008 |
# ? Nov 19, 2008 21:17 |
|
Flobbster posted:the Java compiler is smart enough (that's a phrase you don't hear too often!)
|
# ? Nov 19, 2008 21:44 |
|
|
# ? May 14, 2024 16:55 |
|
In my case, I was actually working with a c# project. However, I imagine that the javascript would be equally unreadable regardless of what was used on the serverside
|
# ? Nov 19, 2008 23:09 |