- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Combining the comment to two comments on my original comment:
Boog said: I didn't know it either until a few weeks ago, but Java has five Boolean operators: &&, ||, &, | and ^.Then JB said:
& in Java is a Boolean operator when used with two Boolean expressions, and a bit-wise operator when used with integral types (byte, short, int, long). As I said, I didn't know either until a few weeks ago.The & and | Boolean operators always evaluate both parts of the expression, similar to the ^ (exclusive-or) operator.
There's a bit of a story about how this came along. We have an API to send SMS messages, but you don't want to send a message to a customer in the middle of the night, so there's a 'daytime only' flag.
Now, you would imagine that night time starts somewhere in the evening, and ends somewhere in the morning of the next day. Not so according to our support people: they insisted that we, developers, program in the option that begin and end times of 'night time' are during the same day. Obviously, this will muck up any code that incorrecty assumes that the start time of 'night time' on a 24 hour clock is later than end time.
So a piece of code was written, with nested if-statements, and when I was maintaining the code, I decided it could be made more efficient. So this is what came out of that:
(In this example, 'hour' is the current hour of the day; 'start' and 'end' are start and end times of night time.)
One could argue that this is far from readable, and one would be absolutely right. But is is an interesting use of operators that you would normally hardly ever use.
Despite some shortcomings, Java is a nifty little language.
Admin
Isn't it easier to check if it is daytime, where "start" and "end" time are in the same day etc, and then say isNightTime = !isDayTime? Or am I missing something?
Admin
Admin
It's best to write a truth table to figure out how it works; that's what I had to do.
Yep, works just as well.Admin
Don't answer that. Back away from the computer and never touch a keyboard again.
Admin
Admin
Admin
Or he can reply to comments by e-mail. "
I think you have constructed a strawman, you imagined my thought process as something incredibly stupid and then castigated me for it. It doesn't at all reflect on my competence, more so on your ability to evaluate it.
I hope you don't do interviews.
Admin
In European languages (except English obviously), "," is used as decimal separator. If you have such a locale, Excel uses ";" as argument separator.
Most of the time, this works transparent and if you switch between different versions of Excel, it does the right thing.
It gets annoying when you're working with CVS files: Excel expects either ',' or ';' as field separator and there is no easy way to switch.
Admin
I can't edit history, so here goes:
I didn't read the other post that you posted, but the fact that you posted both makes you look even dumber than you thought before. Lets see if I can make it MORE obvious your fail. What server am I using? The companies? Clearly no, or I wouldn't have access.
Also, where did I say you were wasting time?
Do you believe in aliens?
Admin
This is called "what happens when DBAs try to write VB," since SQL Server only has RTrim/LTrim and not Trim.
Admin
Yeah, I know.
Admin
Sure, and so does C++, but the problem is not the development platform/language, but the programmers. They apparently only thinks that their programs will ever be used in the US....
Yazeran
Plan: To go to Mars one day with a hammer
Addendum (2011-06-21 10:01): Slight error, it should have been: they apparently thinks that their programs will only be used in the US..
Admin
I didn't know you could sign up for that, but then again, why would you?
Admin
Admin
TRWTF is no one else figured out it out either. At least 2 other guys I read were wondering how he was posting. Amazing.
Admin
They're called trolls. They are usually bored, stupid children living at home with access to the internets. Like their own parents and loved ones have discovered, if you ignore them enough, eventually they stop bothering you.
Don't feed the tards.
Admin
Admin
FTFY
:)
Admin
Thanks!
Admin
This makes perfect sense when considering that java is built on a 'C' style background where false = zero and true = non-zero. Where this is the case, it would be a bitwise AND.
Admin
So you could define "isDayTime", but it wouldn't be any easier.
Admin
These comments were to read when this site came out. It's even funny when clicking on the Random Article button on this site and reading them. It's NOT funny when someone links to an image in a one-sentence post and thinks they're so fucking clever to have discovered the special olympics.
You probably still use lmgtfy and think you're so damn clever.
It means in real life, you're an unoriginal hipster doofus.
Fuck off. You're not clever.
Admin
You try that same troll every time someone posts a picture, it didn't work then it won't work now.
Admin
Um, it just worked... Dummy.
Admin
Admin
Ruby is a programming language that appeared in '95, RoR is a framework for ruby which reared it's ugly head in 2005... Google is your friend.
Admin
No quack.
Admin
Wait, you have to read the comments in order to spout off some silly nonsense in reply?
I'm sorry, I thought this was the internet. I'll move along.
--Joe
Admin
My comment was intended to be a joke. You see, it's funny because I calmly state as true something that is obviously false. Of course in real life no one is going to laugh at a joke that needs to be explained. This introduces irony, and irony is one form of humor.
So now that I've explained the joke, you're laughing. Right?
Admin
I'm laughing my arse off, but thats because I suffer from a condition.
Admin
I don't know if this has been mentioned (I haven't read all the comments), but SeiginoRaikou is completely wrong. Double.TryParse does not just use Parse with a try/catch. Just reading the documentation for Double.TryParse makes that pretty clear, but also if you open up the code in .NET Reflector, you can see how it actually works and notice that at no time is there any try/catch code or any code that throws an exception.
So, basically SeiginoRaikou, you've reinvented the wheel for no reason and completely misunderstood why Microsoft included TryParse in the first place.
Admin
Why do inane frist posts and banal trolling get deleted when something as offensive as this survive the censor?
Admin
I'd agree with all of the above: VB seems to have tied itself up in knots maintaining backwards compatibility whilst adding useful features from other languages.
Lazy evaluation can be very useful, not just for avoiding unnecessary expensive evaluations, but also for avoiding illegal evaluations, e.g.:
if (p == NULL || *p == '\0')
On the whole, I'm not sure that introducing lazy evaluation to VB was sensible. Most of the time, lazy evaluation is appropriate, and where it isn't, code is usually more readable if refactored anyway. The problem is that VB code then ends up littered with OrElse and AndAlso, which is hardly readable, especially when it starts getting mixed with Or and And as a result of different programmers, and you have to start deciding whether the non-lazy version was a deliberate choice, or just an accident.
I've not used VB for quite some time, finding C or Perl very well suited to my needs, and I've certainly not missed it!
Admin
Others have expressed doubt about that, but even if mathematically it's true, doesn't it matter what context it's run in? If it executes on 100000 "inputs" and only, say, 5 throw an error, are you still better off having done 2 parses 99995 times? (IOW, if you have reasonable expectation of clean input that's one thing. If it's part of an app to clean up data from a known often-dirty source, that's another thing, amirite?)
Admin
My brother-in-law's going to The New School. Python is very definitely not new school. While they don't have a computer school, per se, it's quite clear they have a definite policy against any computer stuff that works reliably. As such, both perl and python are clearly right out.