- 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
Brevity was obviously the second-last item on the requirements list. Why else use a generic JSON with name / value keys.
Admin
Is it just me, or is that really a JSON array in a string in JSON? :wtf:
Admin
it's not just you.... i see it too....
Admin
The first snippet is a
var_dump
ed PHP array; it looks like it contains the deserialized JSON data and the original JSON string in itsdata
attribute (alongside with other stuff), for some reason.Speaking of redundancy, there’s some in the JSON itself:
which could be simplified to
Admin
*cough*
Admin
i knew that seemed familliar....
Admin
I must have missed that first time round; back in November, I was only just starting to up my activity levels, and I wasn't a regular in Programmers' Testing at the time either. It wasn't until I started contributing to @sockbot that I was active in that category.
Admin
Just now realized how long I've been telling myself "damn, I need to get back to that when I have some time". Ah well...
Admin
There izmeni things wrong with that code!
Admin
Join the club :laughing:
Admin
to be honest i'm still shocked that i'm still actively developing SockBot....
i really thought that would die a quick death after i burned through the "see i can too write a bot nyeh nyeh neyh!" phase.... i didn't expect the "hey this is actually fun let's keep doing this" phase that was waiting right around the corner to ambush me.
not that i'm complaining mind you.... :-D
Admin
It's addictive, isn't it? You've even roped in a
haplesshappy little hedgy to help you out ;)Admin
While I see what you did there, that means "change" btw.
I also wonder how much fun they are having JS-side (if there is a JS side) with those phone numbers and "JMBG" fields which can also begin with a
0
. Been there, done that, duck typing is a PITA in those cases if you're trying to make your interface generic....Filed under: Oh, it's an integer! Let me get that for you! Who needs those leading 0s anyway...
Admin
Just like working with US postal codes through New England. :D
(The problem with JS is not the duck typing, it's that it overloads
+
to do two — or maybe more — totally different things. If it always did addition, nobody would get nearly so excited…)Admin
And then there's C++-style operator overloading, where "+" can do anything imaginable that may or may not have anything to do with addition.
Admin
I'm pretty sure just calling
JSON.parse()
was enough to screw it up, because I know I wasn't doing any concatenation. Maybe the templating library I use does. In any case, I had to hack around it many a time usingvar = var + ""
.Admin
HOWEVER: in C++, you can predict exactly which
BINGO! For contrast:operator+
is called simply by inspecting the types of the operands, which are available to you before the program runs.Admin
I wonder whether the name/value thing was because someone didn't know how to iterate over an object in JavaScript. Might be one (dumb) reason for that (horrible) (anti)pattern.
Admin
Is that the fault of C++ though? It's no different than writing a function add(a, b) that has nothing to do with addition. Would you blame that on the language, or on the programmer?
Admin
Good point. All common words should be banned as function names to prevent this kind of abuse
Admin
Also, camelCase, because you can use it to trick the compiler otherwise. And case-sensitivity in general, really, because you just know some asshole will make both
add()
andAdd()
with the same signature but doing wildly different things.Admin
That's reasonable to do in C++03 code, but if you're working with C++11 code which makes heavy use of the
auto
keyword, manually deciphering all of the inferred types very quickly turns into a rat's nest.Admin
Just hover over the variable and have your IDE tell you!!!!! Nobody ever looks at code outside an IDE.
Admin
Filed under: Now going to solve world hunger next.
Admin
auto cflpszname
? Am I doing it right?Admin
What's the correct Hungarian notation for a variable of type
std::unordered_map<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>, std::vector<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>, std::allocator<wchar_t>>>
? And that's just the tip of the iceberg.Admin
Admin
Alternatively,
witide
Huh, interesting interaction between <abbr> and backticked words there...
Admin
..... that woulc be called.... RUN!
Admin
Oh please, you've clearly never soon any error messages from messing up a Boost template parameter. Those have been known to break some compilers' error message printers.
Admin
Admin
Excuse my language, but this is one thing PHP gets right.
+
is addition..
is concatenation.Admin
Not that there's ambiguity of course; just curious.
Admin
That's actually
->
in PHP. Though indeed there would be no ambiguity, as the right-hand operator would be a completely different token type.Admin
TIL :smile:
It's been a long time since I did any PHP, and I've never used its OO features.
Admin
I'm not sure I'd have picked
.
but at least it's not ambiguous. There. (It's PHP after all…)Admin
orand.Admin
So VB and PHP do it right and everything else is TRWTF?
When did I enter Bizarro world again?
Admin
Admin
That would probably explain why I'm talking to a female hedgehog called Dave...
Admin
ML uses
^
, Perl uses.
, SQL and REXX use||
, Haskell uses++
. D uses~
. Tcl and Shell don't use an operator (or arguably it's the empty string).Admin
Obviously, when I say Everything Else I mean C#, the One True Language.
Also, T-SQL uses
+
. I don't think I've ever used a SQL engine that uses||
Admin
Oracle.
Admin
Also Postgres and SQLite. It's what the SQL92 standard actually specifies. (So it's naturally ignored by about half of all vendors…)
Admin
That's SQL for you.
Admin
Lua uses
..
Admin
And this should give you a hint of why PHP is such a WTF language. You would think that a C-like language born to be embedded into HTML code would have used something different than the single most used character in HTML: ">"
Also, it's a C-like language and it borrows basically everything else from C but not for member operators, because it's so much better to type . than - + Shift + >
I just hate reading/writing PHP code because of this, specially if it's embedded in HTML where it's almost impossible without syntax highlight.
Admin
Admin
There, there. The loss of memory incidents only get more frequent as you get older…
Admin
At least I avoided a fourth whoosh badger :relieved:
I would also say I avoided Blakey calling me an idiot, but he would call me that anyway :smile: