So stumbled upon a comment on PHP.net
-
Ok so I had to look up the name of the string replacement function in PHP. Sometimes my filters are off and I start reading, I'm TRWTF. This was the first comment
A faster way to replace the strings in multidimensional array is to json_encode() it, do the str_replace() and then json_decode() it, like this:
<?php function str_replace_json($search, $replace, $subject){ return json_decode(str_replace($search, $replace, json_encode($subject))); } ?>
Maybe the poster will mention the limitations and dangers? It's a horrible 'optimization' after all.
This method is almost 3x faster (in 10000 runs.) than using recursive calling and looping method, and 10x simpler in coding.
Well, no.
-
I can't decide if that's brilliant or pants-on-head retarded.
-
I propose we name this style of coding SanicStyle1
1After Sonic the Hedgehog -- gotta go fast! And might as well throw a speedrunning meme in there while we're at it...
-
I don't know what it is with these PHP freaks. The comment section is filled with optimization tricks and performance comparisons. Not once has this been of any use to me.
It's like when you gave up on doing it right, at least do it faster.
-
It's like when you gave up on doing it right, at least do it faster.
I don't do PHP, haven't seen it around me in 11 years, but God, that comment hurts.
-
TRWTF is if his method truly IS faster. Think about all the steps these 3 functions have to go through to get this done. And yet, multidimensional iteration is still slower, according to him. Very strange.
-
Very strange.
The JSON converter stuff might be written in C and so able to iterate more efficiently? But it's still a nasty way to do it, even if possibly OK (depending on a bunch of factors).
-
If only he'd thought to use XML instead of JSON, his code would have been enterprise grade.
-
If only he'd thought to use XML instead of JSON, his code would have been enterprise grade.
No, he would have just punted it out onto the enterprise service bus, where a string transform service would have done it for him. After dynamically negotiating a contract with SLA for doing it.
-
It would work for lojban texts because something like
ko cusku lu lo mlatu cu pu zutse lo matci li'u
contains no JSON special characters.
-
Much of PHP, like Pearl consists of Modules. Where a User has contributed with something that was /is not available in the Core. (PHP, unlike Perl, periodically includes some of the better of theses in the Core with each new update).
Now, in the same way that the saying "All it takes for evil to thrive, is for good to do nothing". Those modules persist - we are talking about the non-core ones: Because they are used; because nothing better exists; because, unlike entropy, you can't uncode code.
PHP had / has a suite of Modules that "do stuff" to XML Files. All I wanted (once) was to parse an XML file into a multidimensional array. The "only" module available to do that or even get close to to, (according to the "blurb") produced a billion zillion collection of cross referenced, indexed, triple verified arrays for which, as far as I could determine, was only really good at testing memory allocation. So I was "forced" to roll my own - which I achieved with a few lines of code (or a recursive for each). But that was back in the days when rolling your own was acceptable (NB: Every single Module, command or whatever you use was created [rolled] by somebody. Oh. Yeah. Before I forget - If you don't have the capability of rolling your own then you are just using the language - not developing it).
INB4E: The difference between those who think they can roll their own and those that can roll their own, is the difference between 0 and 1
INB4EBE: In retrospect, I had "reinvented" JSON, but that was before I discovered JSON, and before JSON was widely known.
I could go on (especially about Perl), but I'll save it for another day
-
It would work for lojban texts because something like
ko cusku lu lo mlatu cu pu zutse lo matci li'u
contains no JSON special characters.I wanted to pendant you that
'
is actually syntax in JS, and then I remembered we're talking about JSON where it isn't. Now all that's left is the control character for newline. Newline is useful even when writing Lojban I suppose, even though the language has a boundary word for paragraphs. And let's not forget ASCII0x7 BEL
, wouldn't want to write text without it.
-
To be fair,
,
is a semi-vowel in lojban used to change the joining of vowel sounds, soma,iu
is mah-ew whereasmaiu
ormai,u
would be my-you.
-
Ah, like a diæresis, but lojban was created by people without knowledge of linguistic or typographic history?
-
One of the big selling points of lojban is that you can spell any word using ASCII printable characters.
Also, lojban sounds are 1:1 with lojban letters. Having ä and a make the same sound would break that rule.
-
Also, lojban sounds are 1:1 with lojban letters.
Kedo, sore wa sonna ni mezurashikunai.
-
Kedo, sore wa sonna ni mezurashikunai.
I'm going to guess silent letters were also undesired. Matsushita couldn't be reached for comment.
-
One of the big selling points of lojban is that you can spell any word using ASCII printable characters.
I've often felt the same way about English.
-
The weird thing about Japanese is that the sounds you could call 'silent' sort of run together with the next sound rather than actually being silent. They're only partially vocalized, but the sound they make is important to the structure of the word.
-
They're only partially vocalized, but the sound they make is important to the structure of the word.
Yeah, I know, but and all.
-
Considering "any" word includes proper names of people, you, Ben L. and Lojban are all wrong.
Or assholes who change people's names.
-
One of the big selling points of lojban is that you can spell any word using ASCII printable characters.
Ah yes, solving the last millennium's problems… today!
-
TRWTF is trying to optimize PHP. If you want something fast, don't use PHP. A function call in PHP has a crazy amount of overhead. I found this out when implementing function calls in PHP-CPP, an extension for PHP extension development.
-
-
Having ä and a make the same sound would break that rule.
But it would be much more Mëtäl.
-
There are rules on how to lojbanize names, so indeed the names are changed to use them in the flow of the language. It comes naturally though, humans are assholes that way. Lojban has an escaping grammar that allows unlojbanic syllables, if you feel the need of quoting a name in its original form and make people stumble.
-
Lojban has an escaping grammar that allows unlojbanic syllables, if you feel the need of quoting a name in its original form and make people stumble.
zoi
, followed by any word not in the text, then a pause, then the text, then another pause, then the same word. For English texts, the wordgy.
is often used, meaning "g", the first letter ofglico
, meaning "English".
-
Considering "any" word includes proper names of people
Even Chinese has rules (more than one even) to turn their cray drawing language into normal letters. Any bullshit with funny marks might as well be written without them in English because they don't really mean anything. Your objection is like saying that some other language uses non-ASCII glyphs, which is to say that you're wrong.
-
Or assholes who change people's names.
Well, the CJK orthographies have changed enough that some proper names in those languages are not representable in Unicode.
-
Well, the CJK orthographies have changed enough that some proper names in those languages are not representable in Unicode.
Is that not representable in the Unicode BMP, or not representable at all?
-
Not representable at all -- the characters needed never made it into Unicode...
-
the characters needed never made it into Unicode
Don't worry; they'll probably get there eventually. Non-BMP Unicode is a bit of a wild west…
-
And they expect common people to get this right? The same people that keep confusing your and you're?
-
-
looks familliar that does:
-
Not representable at all -- the characters needed never made it into Unicode...
But on the upside, people named have no problem writing their names.
-
And they expect common people to get this right? The same people that keep confusing your and you're?
The problem with
you're
andyour
is that they are pronounced the same way. Transforming between spoken and written English requires knowing context.Lojban is specified to map cleanly between spoken and written language without depending on context, so it does not have that problem. (It is questionable whether this provision would hold for long if Lojban were actually used though.)
-
Well, it's literally the exact same thing ...
-
Yes, but that was just an example.
What Ben L described is a system like MIME boundaries (an arbitrary string that does not appear in the escaped text, used as separator). For a language that's supposed to be usable for casual conversation, that seems like overkill, and I doubt the average person would immediately understand the concept. OTOH there are languages specifically designed to be easy to learn.
(Yes, I get that the point is to make a completely unambiguous language, I just question the importance of that).
-
-
For a language that's supposed to be usable for casual conversation, that seems like overkill, and I doubt the average person would immediately understand the concept.
Yeah, the concept is probably not widely understood. But it's used only when quoting unlojbanic syllables, normal quoting is straightforward. I don't see it as a very high barrier, we're talking about learning a language here.
-
If what you're quoting is grammatical, open quote is
lu
and closing quote isli'u
.Ungrammatical word soup can be surrounded by
lo'u
...le'u
-
What about nesting? I guess
lu
would allow embedding another quotation which could have embedded quotations...
-
What about embedding a term from a language that uses
li'u
orle'u
as a word in its own right? (I don't know if any of the polynesian languages do this, but this is where I'd look first…)
-
Other languages do not follow the Lojban syllable rules, so they cannot be quoted with
lu
orlo'u
. It would be ungrammaticYou need the elaborate style, which uses the marker
zoi, followed by any word not in the text, then a pause, then the text, then another pause, then the same word. For English texts, the word gy. is often used, meaning "g", the first letter of glico, meaning "English".
-
-
I did read an introduction to Lojban years ago. Then I decided to learn Türkçe instead. It shares quite a few grammaticalities with Lojban, yet there are actual humans to talk to.
If I'm ever bored like that again, I might just learn Lojban.
-
I did read an introduction to Lojban years ago.
So maybe this is just something kids experiment with ( ) in their college years and Ben will grow out of it?
-
Lojban does have the appeal of a virgin language. It's very pure and untarnished by use you might say. And it is designed to be the most powerful language of all! It's the Athene of languages!
I still think that its stated goal (to show that the language shapes thinking) is a worthy one and that we'd all be better off speaking Lojban.
-
And it is designed to be the most powerful language of all!
As opposed to all the other synthetic languages…