Raiding the RAID

« Return to Article
  • mitschke 2008-11-03 09:03
    But exec is so temting easy sometimes....
  • KittyKat 2008-11-03 09:07
    Wouldn;t it been safer and better to add a custom php addin?
  • Tim 2008-11-03 09:11
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).
  • Hivemind 2008-11-03 09:13
    I'm an IT geek whose primary language is PHP *ducks*
    Though I've never done anything like this, I at least know when to NOT use PHP. For shell scripting - yes, anything browser-based - ok. but that? hell no.

    *sigh*
  • g0ats3 2008-11-03 09:19
    5th!!!!!!1111!!555%%555five
  • snoofle 2008-11-03 09:20
    This comment on php-driven raid controllers *beep* is being written because *Beep* it is important to note that *BEEP* php may not be the best choice for this purpo... *Plug yanked*
  • Mii 2008-11-03 09:24
    I'm a PHp programmer.. and I actually didn't recognize that as PHP...

    And yes.. I agree.. kill PHP please.. now that decided to use the \ as namespace separator I really wanne quit it :S
  • Bob 2008-11-03 09:26
    It always scares me when I meet engineers who program. Think of all the firmware code out there. And what it does.
  • Jason Felice 2008-11-03 09:29

    My favorite part is definitely:

    $new_str .= sprintf("%s", $str);

  • Ken 2008-11-03 09:33
    oh... my... god.

    that's worse than the LSI Logic RAID util code I had to work on last summer as an intern. Here I was thinking that was the worst code I would ever see...
  • Bobble 2008-11-03 09:34
    I think there is a CTO that deserves a beating somewhere.
  • SlyEcho 2008-11-03 09:36
    Jason Felice:

    My favorite part is definitely:

    $new_str .= sprintf("%s", $str);



    Well, it's better than:

    $new_str .= sprintf($str);
  • Richard 2008-11-03 09:37
    Actually, PHP-CLI is quite a decent scripting language for general purpose use. In many cases, it's interchangeable with perl. Given that the LCD control probably requires just a bit of simple "glue", and some re-formatting, and most likely has a serial port interface, I can't see anything wrong with using PHP here. If the performance is bad, it's probably not PHP that's really to blame, but one of the underlying programs.

    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.
  • Anonymous 2008-11-03 09:52
    RAID controller firmware is definitely not a personal home page. And even if it was, I'd still question the use of PHP.
  • mauhiz 2008-11-03 09:59
    exec('echo "This is a comment"' > mycomment && wget --post-data mycomment "http://thedailywtf.com/Comments/AddComment.aspx?ArticleID=6348"');
  • Alex 2008-11-03 10:00
    Richard:
    Actually, PHP-CLI is quite a decent scripting language for general purpose use. In many cases, it's interchangeable with perl. Given that the LCD control probably requires just a bit of simple "glue", and some re-formatting, and most likely has a serial port interface, I can't see anything wrong with using PHP here. If the performance is bad, it's probably not PHP that's really to blame, but one of the underlying programs.

    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.


    Isn't that like using paper glue to try and tie two pieces of PVC pipe together ?

  • relaxing 2008-11-03 10:17
    please, please tell me what company this is so i can not buy their products...
  • PHP Programmer 2008-11-03 10:20
    http://www.php.net/manual/en/function.str-pad.php
  • kennytm 2008-11-03 10:20
    SlyEcho:
    Jason Felice:

    My favorite part is definitely:

    $new_str .= sprintf("%s", $str);



    Well, it's better than:

    $new_str .= sprintf($str);

    Don't worry, at least PHP's sprintf is safe from format string attack.
  • kennytm 2008-11-03 10:21
    exec("killall php");
  • tdb 2008-11-03 10:42
    WTF for does an LCD controller module write events to log? Shouldn't it, like, control the LCD and let other parts of the system do the logging and whatnot?
  • operagost 2008-11-03 10:44
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.
  • Ted 2008-11-03 10:48
    "... not quite what PHP was designed for."

    PHP was designed?
  • Matt 2008-11-03 10:50
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    Wow. Who made you king jack-ass?
  • Evo 2008-11-03 10:52
    Ted:
    "... not quite what PHP was designed for."

    PHP was designed?


    Absolutely. By about 5000 different people with completely different ideas.
  • bla 2008-11-03 11:05
    Ted:
    "... not quite what PHP was designed for."

    PHP was designed?


    You made my day :-)
  • idan 2008-11-03 11:13
    sprintf("I agree.");
  • EatenByAGrue 2008-11-03 11:17
    Ted:
    "... not quite what PHP was designed for."

    PHP was designed?


    No, it was congealed.

    And this whole article can be filed under "use the right tool for the job". Having been subjected to PHP in previous jobs, it's semi-tolerable for web apps, but worse than useless in most other contexts.
  • Chiper 2008-11-03 11:18
    Evo:

    PHP was designed?

    Absolutely. By about 5000 different people with completely different ideas.

    Each of them coming and going over the course of, what, ten years? PHP has more depreciated function calls and features then any other language I've ever used.

    But I still love it, because it's easier to work with then JSP, and cheaper to deploy then ASP.
  • jspenguin 2008-11-03 11:22
    tdb:
    WTF for does an LCD controller module write events to log? Shouldn't it, like, control the LCD and let other parts of the system do the logging and whatnot?


    No, it doesn't handle logging. The log daemon is written in C -- but running 'strings' on it reveals that it abuses 'exec' just as much:


    $ strings qlogd
    ...
    /bin/umount -f %s >/dev/null 2>&1
    /sbin/e2fsck -p %s >/dev/null 2>&1
    /bin/mount -t ext3 %s %s >/dev/null 2>&1
    /sbin/mke2fs -j -b 4096 %s >/dev/null 2>&1
    ...
    ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F: '{print $2}'
    ...
    /usr/bin/snmptrap -v 1 -c %s %s %s %s 6 %d "" %s s "%s"
    ...
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1

  • gabba 2008-11-03 11:28
    Not clear what he means by "due in no small part to the kernel module, exec() is slow", but if he's loading and unloading the module on demand, try not doing that.
  • Matthew 2008-11-03 11:29
    Richard:
    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.


    In this case PHP is the hammer, and the problem is a screw. Yeah if you bang hard enough it will work, but a Screwdriver (C) or even a powerdrill (Python) would work much better :)
  • SomeCoder 2008-11-03 11:48
    I've seen this sort of thing a lot. In fact, I know people who actively do it, though not to this degree, certainly.

    Because PHP has the CLI interface, everyone thinks that it's great for writing applications.

    PHP may not stand for Personal Home Page anymore, but that doesn't mean it's a good language to use to interface with hardware.

    I like PHP for web stuff but this kind of abuse is just... gah.
  • Yep 2008-11-03 11:48
    Matthew:
    Richard:
    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.


    In this case PHP is the hammer, and the problem is a screw. Yeah if you bang hard enough it will work, but a Screwdriver (C) or even a powerdrill (Python) would work much better :)


    Haha.. Python.. a power drill. That's a good one. You almost had me believing that you were serious.
  • Robert Englewood 2008-11-03 12:14
    Chiper:

    PHP has more depreciated function calls and features then any other language I've ever used.

    Oh sure, these other function calls might be worth half of what they used to, but you can't really expect to get retail price after they're standardized anyway.
  • rycamor 2008-11-03 12:19
    Well now, it could have been worse. They could have hosted Windows inside a virtual machine and then run an instance of ASP.NET, with the backend calls being implemented as emails to the host (Linux?) OS.

    Or Ruby on Rails (ducks flamewar).

    Seriously, I have perpetrated a few PHP atrocities (although I at least coded them better), but never in my wildest most desperate imaginings would I use PHP on firmware. The only scripting language I see as being appropriate for firmware might possibly be Lua, but honestly, if you're going to the trouble, why not just code it in C? It's FIRMWARE. The whole concept of firmware runs completely counter to the idea of scripting languages.
  • Anon Ymous 2008-11-03 12:24
    Yep:
    Matthew:
    Richard:
    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.


    In this case PHP is the hammer, and the problem is a screw. Yeah if you bang hard enough it will work, but a Screwdriver (C) or even a powerdrill (Python) would work much better :)


    Haha.. Python.. a power drill. That's a good one. You almost had me believing that you were serious.


    Python is a football bat.
  • James 2008-11-03 12:27
    OK, I have one question about the very last code snippet: if exec'ing was wrong to get the IP of eth0 (specifically eth0, not just "any old network"), what's the right way to do it? I've been looking for just that kind of information lately...
  • jspenguin 2008-11-03 12:29
    rycamor:
    The only scripting language I see as being appropriate for firmware might possibly be Lua,


    YES. Thank you. If I had actually designed the blasted thing, I would use Lighttpd and Lua. Lua is faster than PHP or even Python (which is still much better than PHP). A scripting language is fine for things like the web UI.

    Bad programmers can write PHP in any language, though.
  • rycamor 2008-11-03 12:39
    jspenguin:
    A scripting language is fine for things like the web UI.


    Except for the part about it being a custom kernel module. Again, if you are going to go to the trouble of building a kernel module... in C...?

    jspenguin:

    Bad programmers can write PHP in any language, though.


    I like that one, and I'm going to use it.
  • JamesQMurphy 2008-11-03 12:40
    Well, at least all of the exec's appear to be abstracted into centralized functions. Think how much worse it would be if the code was peppered with exec('ipconfig ...') all over the place.
  • jspenguin 2008-11-03 12:41
    James:
    OK, I have one question about the very last code snippet: if exec'ing was wrong to get the IP of eth0 (specifically eth0, not just "any old network"), what's the right way to do it? I've been looking for just that kind of information lately...



    struct ifreq req;
    int fd = socket(AF_INET, SOCK_STREAM);

    strcpy(req.ifr_ifrn.ifrn_name, "eth0");
    ioctl(fd, SIOCGIFADDR, &req)
    return inet_ntoa(((struct sockaddr_in*)req.ifr_ifru.ifru_addr).in_addr);


    It would be easy to code a wrapper function for PHP that does that. They already have several custom native functions that allow the PHP web UI to manage the RAID.

    Even still, the command is a pipeline that starts three processes, when it could just start one ("ifconfig eth0") and parse the output text itself instead of using awk and grep. That's what my replacement function does.

    And calling "grep" just to find out if a file contains a certain line -- well that's just pure laziness and stupidity.
  • Zach Bora 2008-11-03 12:43
    http://ca.php.net/manual/en/preface.php:
    http://ca.php.net/manual/en/preface.php PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Its syntax draws upon C, Java, and Perl, and is easy to learn. The main goal of the language is to allow web developers to write dynamically generated web pages quickly, but you can do much more with PHP.


    the sky is the limit!
  • jspenguin 2008-11-03 12:45
    rycamor:
    jspenguin:
    A scripting language is fine for things like the web UI.


    Except for the part about it being a custom kernel module. Again, if you are going to go to the trouble of building a kernel module... in C...?


    I think you misunderstand. The kernel module is not written in PHP. My brain would explode if it was.

    The RAID module (sansoft.o) is written in C, but it's so poorly written that it slows down the entire system. It creates a kernel thread called "SCHED" that constantly uses 97% of the CPU.

    If I boot with a stripped down firmware that doesn't load the module, everything runs snappy.
  • Bored Bystander 2008-11-03 12:46
    Chiper:

    ...snip...
    PHP has more depreciated function calls and features then any other language I've ever used.
    ...snip...


    Give it a while, Python will definitely have more.
  • rycamor 2008-11-03 12:55
    jspenguin:
    rycamor:
    jspenguin:
    A scripting language is fine for things like the web UI.


    Except for the part about it being a custom kernel module. Again, if you are going to go to the trouble of building a kernel module... in C...?


    I think you misunderstand. The kernel module is not written in PHP. My brain would explode if it was.


    No, I understood that, but I was under the impression that the PHP/Apache runtime was a custom kernel module. In other words, someone still had to go to the trouble of mucking around with C and compiling, just to get the scripting environment.

    Or am I wrong about that also?
  • jspenguin 2008-11-03 13:16
    rycamor:
    jspenguin:

    I think you misunderstand. The kernel module is not written in PHP. My brain would explode if it was.


    No, I understood that, but I was under the impression that the PHP/Apache runtime was a custom kernel module. In other words, someone still had to go to the trouble of mucking around with C and compiling, just to get the scripting environment.

    Or am I wrong about that also?


    The kernel module is just for the RAID. The http daemon (I think it's called mini_httpd) runs in userspace, and uses plain old CGI to interface with PHP. The PHP binary is definitely customized, as I said before, since they have functions that interface with the RAID module (probably through ioctls on some device -- I haven't disassembled anything). Apparently, they don't know how to use standard IOCTLs, though.

    Also, because each PHP CGI request involves forking and execing, the web UI is slow as crap. And perhaps the biggest WTF is that using the web UI can actually slow down transfer speeds - over Ultra320 SCSI. And, since the web UI automatically refreshes every 10 seconds or so, even having the config UI open can slow down transfers.
  • Charles400 2008-11-03 13:17
    Matthew:
    Richard:
    For what it's worth, I do use PHP extensively, and (at the risk of thinking that, if all you have is a hammer, everything looks like a nail), I've used it for simple hardware interfacing myself.


    In this case PHP is the hammer, and the problem is a screw. Yeah if you bang hard enough it will work, but a Screwdriver (C) or even a powerdrill (Python) would work much better :)



    Ha, heh, heh... you said "screw",... heh, heh, ha... and "bang".
  • snoofle 2008-11-03 13:26
    jspenguin:
    James:
    OK, I have one question about the very last code snippet: if exec'ing was wrong to get the IP of eth0 (specifically eth0, not just "any old network"), what's the right way to do it? I've been looking for just that kind of information lately...



    struct ifreq req;
    int fd = socket(AF_INET, SOCK_STREAM);

    strcpy(req.ifr_ifrn.ifrn_name, "eth0");
    ioctl(fd, SIOCGIFADDR, &req)
    return inet_ntoa(((struct sockaddr_in*)req.ifr_ifru.ifru_addr).in_addr);


    It would be easy to code a wrapper function for PHP that does that. They already have several custom native functions that allow the PHP web UI to manage the RAID.

    Even still, the command is a pipeline that starts three processes, when it could just start one ("ifconfig eth0") and parse the output text itself instead of using awk and grep. That's what my replacement function does.

    And calling "grep" just to find out if a file contains a certain line -- well that's just pure laziness and stupidity.

    It's been a VERY long time since I've used "C", but I am quite certain it doesn't garbage collect connections; shouldn't you also close the socket?

    If you're going to show someone how to do something, please go all the way!

  • rycamor 2008-11-03 13:33
    jspenguin:


    The kernel module is just for the RAID. The http daemon (I think it's called mini_httpd) runs in userspace, and uses plain old CGI to interface with PHP. The PHP binary is definitely customized, as I said before, since they have functions that interface with the RAID module (probably through ioctls on some device -- I haven't disassembled anything). Apparently, they don't know how to use standard IOCTLs, though.

    Also, because each PHP CGI request involves forking and execing, the web UI is slow as crap. And perhaps the biggest WTF is that using the web UI can actually slow down transfer speeds - over Ultra320 SCSI. And, since the web UI automatically refreshes every 10 seconds or so, even having the config UI open can slow down transfers.


    So my argument still stands. They had to install an httpd daemon, and customize and compile their own PHP binary, which still pretty much begs the question of using a scripting language. Not to mention, they used CGI?? And auto-refreshes... gahh!! The more I hear, the more WTF I see. Really, the simple fact that PHP was used is the least of the WTFs here.
  • elbekko 2008-11-03 13:46
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.
  • convicted felon 2008-11-03 14:02
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.


    Wide support is a non-issue for this WTF. They were running a customized PHP with a customized HTTP server on the local machine.

    Because of that, I would suggest Perl, Ruby, Python, or Lua. Hell, even C++ if the object oriented speed is absolutely essential.
  • rycamor 2008-11-03 14:03
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.


    Actually, I'm not a PHP-basher, and I would even take some exception to your restrictions above, having found PHP to be quite robust at doing simple systems programming... for example, running a socket daemon for an IPC protocol (not meant for scalability, only for a handful of processes to interact), and other such fun stuff.

    Yes, I hear the gasps but the fact is it worked, and worked quite well, so stuff it. Basically, I just treated PHP like a scripting-language version of C and it worked.

    PHP isn't bad as long as you A) don't program Java in PHP, B) keep it simple (see A), and don't try to be clever or cute with your programs (see A and B).
  • Kl4m 2008-11-03 14:04
    double post
  • Yazeran 2008-11-03 14:05
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.


    Well Perl does that job just fine. I don't know the speed of Perl versus PHP (no PHP experience), but on all the other counts it does fit the bill.

    Yours Yazeran

    Plan: To go to Mars one day with a hammer
  • Kl4m 2008-11-03 14:06
    snoofle:
    This comment on php-driven raid controllers *beep* is being written because *Beep* it is important to note that *BEEP* php may not be the best choice for this purpo... *Plug yanked*


    Let me guess, Promise SX**** ?
  • Franz_Kafka 2008-11-03 14:09
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    I like it - slag on someone for hating php. Seriously, it's you who has the problem; php is godawful, has little consistency, and is generally useful only because it's easy to use. It's the VB of the web world. But I guess you can't deal with someone pointing out the flaws of your baby.
  • skin256 2008-11-03 14:19
    But I use VB in the web world too, I like PHP also and C# and Perl and Python and C and C++ and Java etc...I like programming..why bash at all??
  • rycamor 2008-11-03 14:22
    convicted felon:

    Wide support is a non-issue for this WTF. They were running a customized PHP with a customized HTTP server on the local machine.

    Because of that, I would suggest Perl, Ruby, Python, or Lua. Hell, even C++ if the object oriented speed is absolutely essential.


    Perl, Ruby, and Python are well within the same performance range as PHP, and would require pretty much the same sort of solution (ignoring the specific idiocy of the PHP code quoted above). Actually, Ruby is considerably slower than PHP.

    The question of running an HTTP server with then CGI, thus re-starting the scripting environment for each refresh (THUS re-invoking every system call you just made) makes the whole thing a joke, no matter what scripting language you use. Lua alone might be a winner here just because of its small start-up footprint.

    More to the point, as I was saying, the overall architecture is the problem. Lua would solve this nicely if you just installed Kepler, thus having an HTTP daemon running continuously, with no need for external server or CGI. But even lighttpd with PHP running as a module would be much preferable to HTTP/CGI/Python, for example.
  • Franz_Kafka 2008-11-03 14:23
    convicted felon:
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.


    Wide support is a non-issue for this WTF. They were running a customized PHP with a customized HTTP server on the local machine.

    Because of that, I would suggest Perl, Ruby, Python, or Lua. Hell, even C++ if the object oriented speed is absolutely essential.


    I'd say use java, ruby, or python. I don't really see the appeal of straight perl if php is out.
  • uzytkownik 2008-11-03 14:26
    operagost:

    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    While I agree that VB and PHP are different languages they have 2 things in common:
    1) They are used by not-the-most-proficient-programmers
    2) They are hard to use and encourage bad code and bad/no design.

    PS. VB is kind of cross-platform. There is gambas and mono-basic.
  • SomeCoder 2008-11-03 14:28
    Franz_Kafka:
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    I like it - slag on someone for hating php. Seriously, it's you who has the problem; php is godawful, has little consistency, and is generally useful only because it's easy to use. It's the VB of the web world. But I guess you can't deal with someone pointing out the flaws of your baby.


    I like it - slag on someone for liking php. Seriously....


    That argument can go both ways, you know.

    You can write bad code in any language. PHP has some flaws that make it easier to write bad code in it but it's still possible to write perfectly functioning, fast, code in PHP. You are free to insert your favorite language in place of PHP in this comment.
  • Montoya 2008-11-03 14:30
    I love love LOVE the part where they unset() a global variable ($new_str), then start building a string with the same variable (now in the function's scope) and then return it. Or maybe it was never global. It just shows a lack of basic programming comprehension :(
  • Franz_Kafka 2008-11-03 14:31
    skin256:
    But I use VB in the web world too, I like PHP also and C# and Perl and Python and C and C++ and Java etc...I like programming..why bash at all??


    You use VB6? I guess that would make VB the VB of the web world, along with PHP. VB.Net is a bit different, enough so that VB programmers were fairly unhappy with the switch.

    As an addendum to my last comment, I'd write the raid i/f as a persistent process that accepted tcp connections from localhost or updated a text file as the situation required; all depends on the actual use case, but I bet it'd get rid of some of the slowness and overall braindamage.
  • Franz_Kafka 2008-11-03 14:33
    SomeCoder:
    Franz_Kafka:
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    I like it - slag on someone for hating php. Seriously, it's you who has the problem; php is godawful, has little consistency, and is generally useful only because it's easy to use. It's the VB of the web world. But I guess you can't deal with someone pointing out the flaws of your baby.


    I like it - slag on someone for liking php. Seriously....


    That argument can go both ways, you know.

    You can write bad code in any language. PHP has some flaws that make it easier to write bad code in it but it's still possible to write perfectly functioning, fast, code in PHP. You are free to insert your favorite language in place of PHP in this comment.


    I'm slagging on OG for his kneejerk reaction - I don't care if he likes php or not. if he does, he should be familiar with the warts.

    anyone can write bad code in any language, but PHP makes it really easy.
  • Montoya 2008-11-03 14:38
    PHP installed as an Apache module is really fast, and that's what you'll get with any stock server nowadays. Add one module, APC, which caches your compiled scripts, and you have an insanely fast site environment.

    We all know that PHP shouldn't be used for devices, or desktops, or (insert-non-server enviroment here).

    It started out as "Personal HomePage." It's obvious. It's for websites. And if you use it right, it's REALLY GOOD for them. It's a lot faster than any RoR or Java or .NET setup you can get, and it's a heck of a lot easier to setup than Python or Perl, where the speed is comparable.

    But those of us who use it professionally don't need to defend it; we don't code to be trendy. We also don't mind that script kiddies make the language look bad. We just keep doing what we do.
  • uzytkownik 2008-11-03 14:44
    elbekko:

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)


    What do you mean by 'slow'? For example GC in theory slows down programs. But since programers don't have to worry to track leaks (except logicall leaks) they have more time to optimalisation.
    In many cases caching can speed up the whole process and/or speed little matters (compared to transfers).

    elbekko:

    * Is widely supported


    What do you mean 'widely'? Nearly all of languages (python, ruby, perl...) has it's own active community grouped around newsgroup or irc channel.

    elbekko:

    * Isn't expensive to deploy


    In short of long run?

    elbekko:

    * Doesn't add ages to development time


    Nearly all (except initial treining).

    elbekko:
    * Isn't platform-specific


    Nearly all
  • rycamor 2008-11-03 14:47
    Montoya:
    I love love LOVE the part where they unset() a global variable ($new_str), then start building a string with the same variable (now in the function's scope) and then return it. Or maybe it was never global. It just shows a lack of basic programming comprehension :(


    No, it is not a global. In PHP you need to define globals inside the function or the variable is local. Ergo, what they are doing is just plain idiotic: unsetting a variable that does not yet exist.

    Maybe they thought it had something to do with concurrency, but that betrays an abysmal ignorance of PHP.
  • danixdefcon5 2008-11-03 14:51
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.
    Java?

    I for one, like PHP for small projects and budget-strapped web applications; if you're good enough you can even do MVC on PHP. But for beefier stuff, I will tend to jump into Java with its EE framework; it does a good job on managing DB transactions without much hassle.
  • henke37 2008-11-03 14:52
    Is it only me or does this feel like a re-run?
    I could have sworn that i have read about a raid controller that abuses exec and uses php a lot already.
  • Brompot 2008-11-03 14:52
    skin256:
    But I use VB in the web world too, I like PHP also and C# and Perl and Python and C and C++ and Java etc...I like programming..why bash at all??


    Because bash is a much nicer scripting language than all the other ones.
  • Saturday League Devver 2008-11-03 14:54
    If I dad wrote this piece of code, I would have written it in PHP too since C is too difficult to spell out for me.

    Serious. PHP is able to do things like this, but still. I would prefer a more low-level language for critical applications.
  • jonnyq 2008-11-03 15:21
    Chiper:
    Evo:

    PHP was designed?

    Absolutely. By about 5000 different people with completely different ideas.
    PHP has more depreciated function calls and features then any other language I've ever used


    This is a good thing. That gives it the potential to not suck someday.
  • Benanov 2008-11-03 15:23
    jspenguin:
    tdb:
    WTF for does an LCD controller module write events to log? Shouldn't it, like, control the LCD and let other parts of the system do the logging and whatnot?


    No, it doesn't handle logging. The log daemon is written in C -- but running 'strings' on it reveals that it abuses 'exec' just as much:


    $ strings qlogd
    ...
    /bin/umount -f %s >/dev/null 2>&1
    /sbin/e2fsck -p %s >/dev/null 2>&1
    /bin/mount -t ext3 %s %s >/dev/null 2>&1
    /sbin/mke2fs -j -b 4096 %s >/dev/null 2>&1
    ...
    ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F: '{print $2}'
    ...
    /usr/bin/snmptrap -v 1 -c %s %s %s %s 6 %d "" %s s "%s"
    ...
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1



    So it unmounts and fscks for you...that's what they mean by software RAID. :P
  • Franz_Kafka 2008-11-03 16:32
    jonnyq:
    Chiper:
    Evo:

    PHP was designed?

    Absolutely. By about 5000 different people with completely different ideas.
    PHP has more depreciated function calls and features then any other language I've ever used


    This is a good thing. That gives it the potential to not suck someday.


    No, it's a bad thing - it points to a lack of coherent design and that means it's probably simpler to toss it and go with something else.
  • Franz_Kafka 2008-11-03 16:33
    jspenguin:


    $ strings qlogd
    ...
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1



    hehehe...
  • operagost 2008-11-03 16:33
    Matt:
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    Wow. Who made you king jack-ass?

    Who asked you, Captain I'm-Not-Registered-But-I'm-Still-Entitled-To-Pontificate?
  • operagost 2008-11-03 16:47
    Franz_Kafka:
    operagost:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    I like it - slag on someone for hating php. Seriously, it's you who has the problem; php is godawful, has little consistency, and is generally useful only because it's easy to use. It's the VB of the web world. But I guess you can't deal with someone pointing out the flaws of your baby.

    I don't slag on people for hating something; I slag on them for summarily dismissing various technologies and affixing labels to those who use them.

    It's not my baby, and that's where your rant falls flat. Maybe if you'd use more descriptive terms than "godawful" and "VB of the web world," you'd have some credibility.

    If it's easy to use, it can't be too inconsistent, can it?
  • Franz_Kafka 2008-11-03 17:06
    operagost:

    I don't slag on people for hating something; I slag on them for summarily dismissing various technologies and affixing labels to those who use them.

    It's not my baby, and that's where your rant falls flat. Maybe if you'd use more descriptive terms than "godawful" and "VB of the web world," you'd have some credibility.

    If it's easy to use, it can't be too inconsistent, can it?


    Who said i dismiss people for using PHP? I hate PHP, but it works for some stuff - so what? It is the VB of the web world - simple to use and responsible for a lot of nasty code riddled with security holes and slow sites.

    And yes, it can be easy to use and inconsistent - anyone can make it do something, but there are three ways to do lots of different thing, and you have to go looking for the way that does what you want. There may be something in the api for your specific needs, but it's named funny, so you don't find it and use an exec hack. Woops, security hole.
  • pink_fairy 2008-11-03 17:16
    SomeCoder:
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).
    I like it - slag on someone for liking php. Seriously....


    That argument can go both ways, you know.

    You can write bad code in any language. PHP has some flaws that make it easier to write bad code in it but it's still possible to write perfectly functioning, fast, code in PHP. You are free to insert your favorite language in place of PHP in this comment.
    (Puts on Carl Sagan voice)"Since time immemorial, people who take pride in their coding ability have pointed out that 'You can write bad code in any language.' Billyuns and Billyuns of scripting languages are out there..."

    Well, it's simply not true. I'd defy anybody to write bad code in Brainf*ck. Or indeed any code.

    More to the point, it's a pretty bloody stupid statement. Yes, it's possible. It's possible to write Alexandrine verse in anything other than French -- but it's bloody difficult. I imagine that Hawaiian might work well, but not much else will. (Mr Pope might care to disagree, but I'll bet it caused him severe gout.)

    Who cares about bad code? (Other than this site, obviously.) The objective is to write ... well, actually, good code is a fairly minimal step, but we'll leave it at that. Why don't we turn this perenially stupid argument on its head?

    "Language X encourages you to write good code because ..."

    Language X is clearly not PHP. That doesn't mean you don't use PHP where appropriate. It does mean that you don't use PHP where it's a synonym for tranquillising a horse.

    My personal bread-basket of non-X includes, in no particular order: Java, Visual Basic (in any form), ASP, JSP, Ada, Fortran, and Ruby (although the internal jury's still out on that one).

    80% of coding is maintenance. I've used and maintained PHP, but I wouldn't recommend it; needs must. It's a fine little language if you've got a small web-site and you don't mind castrating the MVC model.

    Perl also fails on this basis, although it's more than fine for a quick hack.

    For the job in the OP, I myself would probably pick Forth. I mean, jeez, it's a hardware controller. Who the fuck needs all the rest of this scripting/execing rubbish?

    I did, however, enjoy the following:

    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1

    For some reason, this makes me want to sing 'Spam Spam: "Spam" "Spam" Spam" "Spam" "Beans" "Spam "Spam" "Spam" ...

    ... but I doubt that /dev/null is listening.
  • Chris 2008-11-03 17:21
    jspenguin:
    tdb:
    WTF for does an LCD controller module write events to log? Shouldn't it, like, control the LCD and let other parts of the system do the logging and whatnot?


    No, it doesn't handle logging. The log daemon is written in C -- but running 'strings' on it reveals that it abuses 'exec' just as much:


    $ strings qlogd
    ...
    /bin/umount -f %s >/dev/null 2>&1
    /sbin/e2fsck -p %s >/dev/null 2>&1
    /bin/mount -t ext3 %s %s >/dev/null 2>&1
    /sbin/mke2fs -j -b 4096 %s >/dev/null 2>&1
    ...
    ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F: '{print $2}'
    ...
    /usr/bin/snmptrap -v 1 -c %s %s %s %s 6 %d "" %s s "%s"
    ...
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1

    So what happens when you don't use ext[2|3]?
  • Carnildo 2008-11-03 18:01
    henke37:
    Is it only me or does this feel like a re-run?
    I could have sworn that i have read about a raid controller that abuses exec and uses php a lot already.


    It's from the forums: http://forums.thedailywtf.com/forums/p/8748/165703.aspx
  • elbekko 2008-11-03 18:08
    danixdefcon5:
    elbekko:
    Looks like it's cool again to bash PHP.

    First of all, PHP should be used for webpages, and cronjobs related to webpages. That's about it.

    Now then, please do suggest a good alternative to PHP that:
    * Doesn't suck balls
    * Isn't slow as hell (in the sense of slower than PHP)
    * Is widely supported
    * Isn't expensive to deploy
    * Doesn't add ages to development time
    * Isn't platform-specific

    So now that we've ruled out the fanboy languages and ASP(.NET), what's left?

    For the love of programming, I'd expect people on here to have a brain once in a while and not jump on the first bandwagon they see.
    Java?

    I for one, like PHP for small projects and budget-strapped web applications; if you're good enough you can even do MVC on PHP. But for beefier stuff, I will tend to jump into Java with its EE framework; it does a good job on managing DB transactions without much hassle.


    I meant for web development. I probably should've made that clearer. If you use Java for that, I WILL come over there and kill you.

    And to those suggesting Perl: seriously? I'd much rather stick to using PHP, which atleast has a decent interface for Apache.
  • blunder 2008-11-03 18:39
    Bored Bystander:
    Chiper:

    ...snip...
    PHP has more depreciated function calls and features then any other language I've ever used.
    ...snip...


    Give it a while, Python will definitely have more.


    How many does PHP have? I've never used it so I'm curious.

    IMO Python's not bad (yet): http://www.python.org/dev/peps/pep-0004/

    But it seems like they do a decent job of pulling out them out after a while. Which makes me sort of wish they'd "deprecate" Tkinter.
  • tgape 2008-11-03 19:03
    elbekko:
    And to those suggesting Perl: seriously? I'd much rather stick to using PHP, which atleast has a decent interface for Apache.


    My biggest issue with PHP is that part of its grammar is simple enough that even someone with no real understanding of programming, such as my father, could actually write significant amounts of code without too much difficulty.

    Many people would tell you that's a good thing. However, I believe it allows people who are only able to code WTFs to extend them much farther. In a language like Perl, if you can't think like a computer, you will have a very difficult time making a royal WTF. You're much more likely to give up in frustration.

    Also, while mod_perl may not be the greatest Apache interface, EmbPerlObject (written on top of mod_perl) seems to work fairly well to me.

    Now, I wouldn't recommend Perl for all programmers. It works well for me because my mind works that way. There are many perfectly competent programmers whose minds do not work in the way of perl, and I'd recommend they don't try too hard - not only will they hurt themselves, but, when I look at their code, they'll hurt me, too.

    Addendum (2008-11-03 19:27):
    elbekko:
    And to those suggesting Perl: seriously? I'd much rather stick to using PHP, which atleast has a decent interface for Apache.


    My biggest issue with PHP is that part of its grammar is simple enough that even someone with no real understanding of programming, such as my father, could actually write significant amounts of code without too much difficulty.

    Many people would tell you that's a good thing. However, I believe it allows people who are only able to code WTFs to extend them much farther. In a language like Perl, if you can't think like a computer, you will have a very difficult time making a royal WTF. You're much more likely to give up in frustration.

    Also, while mod_perl may not be the greatest Apache interface, EmbPerlObject (written on top of mod_perl) seems to work fairly well to me.

    Now, I wouldn't recommend Perl for all programmers. It works well for me because my mind works that way. There are many perfectly competent programmers whose minds do not work in the way of perl, and I'd recommend they don't try too hard - not only will they hurt themselves, but, when I look at their code, they'll hurt me, too.

    Addendum: All that having been said, the brief overview of what the PHP code was supposed to do sounds like something that PHP is very suited for. However, it also sounds like there's far too much code there. Furthermore, using Apache + PHP without using the Apache PHP module is a tremendous WTF. I do not see any benefit for this configuration.

    I'm still confused why a logging daemon would need to mount, fsck, or mkfs. I'm suspecting it's a fundamental confusion regarding what a logging daemon is supposed to do.
  • SomeCoder 2008-11-03 19:07
    tgape:

    My biggest issue with PHP is that part of its grammar is simple enough that even someone with no real understanding of programming, such as my father, could actually write significant amounts of code without too much difficulty.


    I often hear this argument used in the opposite way. "We need GC languages" or "We need languages that are easier" because "developer cycles are more expensive than CPU cycles!"

    Therefore, the argument goes, we need EASIER languages.

    To me, it just sounds like an excuse for programmers to be lazy. "They've got 1 GB of RAM so who cares if I'm frugal with memory?"
  • katastrofa 2008-11-03 19:23
    SomeCoder:

    I often hear this argument used in the opposite way. "We need GC languages" or "We need languages that are easier" because "developer cycles are more expensive than CPU cycles!"

    Therefore, the argument goes, we need EASIER languages.

    To me, it just sounds like an excuse for programmers to be lazy. "They've got 1 GB of RAM so who cares if I'm frugal with memory?"


    No, it sounds like people do programming for money, not for bragging rights. Buying more RAM will often be cheaper than spending two weeks rewriting the damn thing from Java to C++. It is different with shrinkwrap software, but they're a different league from your typical in-house systems.
  • Franz_Kafka 2008-11-03 19:24
    uzytkownik:
    operagost:

    Ha ha, I get it. You're an elitist programmer. You probably only know C on BSD or Linux, spell "Windows" with a Z, and laugh at "User Friendly." You do a little web programming in Perl, but dismiss its inferiorities as being part of a "more powerful" scripting language "not for MC$E idiots." Your fatal slip was attacking VB and PHP in the same sentence, whereas they are two totally different languages and, for one, PHP is actually cross-platform. Ha ha, I and every other quasi-programmer who even knows how to spell PHP should kill ourselves. That's hilarious. I can't wait to hear your splendid C-pound material.


    While I agree that VB and PHP are different languages they have 2 things in common:
    1) They are used by not-the-most-proficient-programmers
    2) They are hard to use and encourage bad code and bad/no design.

    PS. VB is kind of cross-platform. There is gambas and mono-basic.


    No it isn't - Mono can't run VB, only VB.Net. Gambas doesn't count either, because VB requires its legion of VB components in order to be what it is.
  • Franz_Kafka 2008-11-03 19:25
    katastrofa:
    SomeCoder:

    I often hear this argument used in the opposite way. "We need GC languages" or "We need languages that are easier" because "developer cycles are more expensive than CPU cycles!"

    Therefore, the argument goes, we need EASIER languages.

    To me, it just sounds like an excuse for programmers to be lazy. "They've got 1 GB of RAM so who cares if I'm frugal with memory?"


    No, it sounds like people do programming for money, not for bragging rights. Buying more RAM will often be cheaper than spending two weeks rewriting the damn thing from Java to C++. It is different with shrinkwrap software, but they're a different league from your typical in-house systems.


    You could just spend a couple hours removing and redoing the worst of your code - java isn't that small, but there's no reason a decent java programmer can't make things play nicely in limited memory environments.
  • jspenguin 2008-11-03 19:34
    Chris:
    jspenguin:
    tdb:
    WTF for does an LCD controller module write events to log? Shouldn't it, like, control the LCD and let other parts of the system do the logging and whatnot?


    No, it doesn't handle logging. The log daemon is written in C -- but running 'strings' on it reveals that it abuses 'exec' just as much:


    $ strings qlogd
    ...
    /bin/umount -f %s >/dev/null 2>&1
    /sbin/e2fsck -p %s >/dev/null 2>&1
    /bin/mount -t ext3 %s %s >/dev/null 2>&1
    /sbin/mke2fs -j -b 4096 %s >/dev/null 2>&1
    ...
    ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F: '{print $2}'
    ...
    /usr/bin/snmptrap -v 1 -c %s %s %s %s 6 %d "" %s s "%s"
    ...
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1

    So what happens when you don't use ext[2|3]?


    This isn't for the actual volume. It reserves 256MB from each drive, which it places into a hidden RAID-1, which it formats as ext3 and stores the event log. Until I figured out that the event log follows the drives and not the controller, I was very confused as to why a brand-new controller had logged errors when I used test drives.
  • tgape 2008-11-03 19:51
    SomeCoder:
    tgape:

    My biggest issue with PHP is that part of its grammar is simple enough that even someone with no real understanding of programming, such as my father, could actually write significant amounts of code without too much difficulty.


    I often hear this argument used in the opposite way. "We need GC languages" or "We need languages that are easier" because "developer cycles are more expensive than CPU cycles!"

    Therefore, the argument goes, we need EASIER languages.


    Perl has automatic garbage collection. Unlike some languages, it actually does it as variables go out of scope, so you're not hit with big pauses when a GC cycle is run.

    To me, Perl is about as easy as these newer 'easier' languages. It's harder to learn, but once you know the language, it's just as quick to code in it. Quicker, in many cases, thanks to the sheer quantity of stuff in CPAN.

    The biggest difficulties with perl seem to be:

    1. Regexes. Perl considers regexes to be a first-class programming technique, as part of its rubbish listing focus. Many people therefore use them, sometimes extensively. Simple regexes make code difficult to read for the uninitiated. Complex regexes (such as the heart of Email::Valid) make code difficult to read even for the likes of me.

    2. Shell escapes are either a first or second class programming technique. As a result, people use them. This is rarely a good idea. (Hint: if you're ever tempted to do 'system("rm $file");', don't.)

    3. Some people have problems understanding simple variable references such as ${$hashrefs->[$i]}{$hashkey1}[$elem]{$1}. Other people don't. (Personally, I try to not write code like the above - but I can read it just fine.) There are also some people who go for complex variable references.

    4. Perl includes some easy array handling options, which should only be used under certain circumstances. It is left to the programmer to determine what those circumstances are.
  • tgape 2008-11-03 19:56
    jspenguin:
    This isn't for the actual volume. It reserves 256MB from each drive, which it places into a hidden RAID-1, which it formats as ext3 and stores the event log. Until I figured out that the event log follows the drives and not the controller, I was very confused as to why a brand-new controller had logged errors when I used test drives.


    When you say 'logging', are you saying 'something similar to what syslog does', or are you saying 'journaling'? 256MB seems to me to be a lot to reserve to 'something similar to what syslog does', at least for low-end systems. I can't^Wdon't want to imagine something like what you are describing being used for something which is not low-end...
  • Andrew Eddie 2008-11-03 19:56
    jspenguin:
    Bad programmers can write PHP in any language, though.
    Bad programmers write code. Good programmers write code. The only difference between good and bad code is the programmer, not the language *sighs*
  • Santa Claus 2008-11-03 20:06
    Jeez, I really HATE this language. It's killing cells in my brain every time I see code written in PHP!

    Why would somebody decide to use PHP in firmware unless he is brainless?
  • OldSchoolGeek 2008-11-03 20:17
    FIRST!


    But my exec() abuse might have delayed the post a little bit.
  • Duke of New York 2008-11-03 20:18
    Any language lets you write bad code. Some languages even encourage you.

    But there are a few languages, very few, that go so far as to punish you for not writing bad code.
  • tin 2008-11-03 21:52
    Andrew Eddie:
    jspenguin:
    Bad programmers can write PHP in any language, though.
    Bad programmers write code. Good programmers write code. The only difference between good and bad code is the programmer, not the language *sighs*


    Damn straight. Choice of language is usually a follow-on problem caused by the first (as it certainly was in this case).
  • Peter 2008-11-03 21:55
    I'm sure I'm not the first person to say this, but do you think we could have syntax highlighting on the code snippets?

    From a teaching perspective, it makes it a lot easier to see what the coder was thinking, and therefore where he went wrong.
  • jspenguin 2008-11-03 22:11
    tgape:
    jspenguin:
    This isn't for the actual volume. It reserves 256MB from each drive, which it places into a hidden RAID-1, which it formats as ext3 and stores the event log. Until I figured out that the event log follows the drives and not the controller, I was very confused as to why a brand-new controller had logged errors when I used test drives.


    When you say 'logging', are you saying 'something similar to what syslog does', or are you saying 'journaling'? 256MB seems to me to be a lot to reserve to 'something similar to what syslog does', at least for low-end systems. I can't^Wdon't want to imagine something like what you are describing being used for something which is not low-end...


    Yes. It is just like syslog. In fact, it has an option to send log events to a remote syslog server. The log is stored as a plain text file with a binary index file.
  • Kagome Higurashi 2008-11-03 22:36
    When all you have is a pineapple, and you're stupid enough, every problem looks like a nail.
  • cfreak 2008-11-03 23:30
    Tim:
    Dear God,

    Please kill PHP.

    Sincerely,

    Everyone except PHP programmers (and VB programmers).


    I'm a PHP programmer and I wish it would die. (Fortunately I know a few other languages as well)
  • Matt Burgess 2008-11-03 23:53
    Despite all the TRWTF=PHPLOL attitudes the issue here is not the language but this implementation of it. I've been a PHP programmer for many years and I like it. But there's no way in hell I'd use it to write firmware, any more than I'd use a salad fork to cut a watermelon.

    I do think PHP is in need of an enema. I was hoping PHP 6 would take the opportunity to spring clean, but sadly not. I'd love to see some redundant functions removed, and some inconsistencies cleaned up. It's clearly been built by 1000 different people, all of whom used different naming conventions, etc. strtotime, nl2br, isset, is_array, empty... what a mess.
  • wocky 2008-11-04 00:15
    Normally I'm a bit-twiddling C and C++ person, but I just rendered a movie in PHP. Seriously.

    I needed to make a video that showed off a large set of images. Imagine a field of constantly changing images, spaced on a grid, and together forming a pattern given by an input bitmap. The video starts centered on one of the images and does a series of movements including a nonlinear pullout zoom, panning with acceleration, and changing the properties of individual images on the fly.

    Solution: use the PHP imaging libraries to create the frames, output them as pngs, and use VirtualDubMod to make a video out of the frames. Total code to render an awesome looking 60 second video, 186 lines. I don't know any other language with such simple but powerful image manipulation so easily at hand.

    Any decent programmer needs multiple languages. You need a near the hardware language like C or C++ for applications and game programming, as well as for scientific programming. You need a powerful symbolic language like Matlab for prototyping complex algorithms. You need a managed code language with good network support like Java or C# for building client/server systems. You need a scripting language like Python, PHP, or Perl to generate web pages or to script simple tasks that would be too painful to write out in shell. You need a client side scripting language, for which Javascript is the only real contender.

    Any of these languages can do the work of any of the others, but a competent programmer will use the right tool for the job. There are precious few languages that aren't well suited for some project or other. So yes, it's funny that someone wrote a driver in a scripting language, but that doesn't make the language a joke.
  • Michael 2008-11-04 00:16
    These are all turing-complete languages we're discussing here, right? Why are we quibbling about mere things like running times that only differ by a polynomial?
  • argh 2008-11-04 00:55
    I like the naming convention for the functions. If I didn't know better, I would think it's part of the PHP standard library.
  • Ben 2008-11-04 02:33
    PHP is not an appropriate language for a RAID controller. It's not an appropriate language for firmware. You shouldn't write an interpretive language interpreter in PHP.

    But what PHP *does* do, it does quite well. It's a stable, powerful scripting language that minimize development time. It's like a cross between a RAD prototyping language and a production environment - take meaningful business logic and complex website concepts from concept to implementation in a matter of hours, with good enough performance to become a production system!

    It's a decent CLI environment, too.

    You don't do brain surgery with a 4-lb sledgehammer, you don't write firmware in PHP. But for rapid prototyping of highlevel business logic rules and "weblication" development, it's really hard to beat PHP's awesome combination of power and simplicity. Other languages come close, (perl and python jump to mind) but PHP is just really good at what it does.

    No, it's not the "purest" language around - for that, look to Pascal. But for raw "get it done" power, it really is hard to beat PHP.
  • a 2008-11-04 03:23
    bad coder + your favourite language => bad code.

    kill bad coders?
    nah, educate them.
  • Barf 4Eva 2008-11-04 03:31
    skin256:
    But I use VB in the web world too, I like PHP also and C# and Perl and Python and C and C++ and Java etc...I like programming..why bash at all??


    So true. This is what I say to those who continue to chuck their tasteless diatribes at developers slightly different from themselves....

    Let him who is without spaghetti cast the first meatball.
  • Dave G. 2008-11-04 03:39
    a:
    bad coder + your favourite language => bad code.

    kill bad coders?
    nah, educate them.


    The problem is that most managers have difficulty distinguishing between bad coders and good coders.

    To wit: a reduction in the number of bad coders caused by, for example, their untimely demise, causes the supply curve for coders in general to shift left (bearing in mind that for most managers, a bad coder and a good coder are perfect substitutes)

    The reduction in supply of bad coders will result in increased salaries for the remaining good coders, because the equilibrium price for coders is now at a higher point on the demand curve.

    You were right the first time. Kill the bad coders.
  • v.dog 2008-11-04 04:49
    So, if there was a problem that affected all eight hard drives -- say, a power issue...
    ...I doubt anyone actually makes it until the last step, though. It's much easier to just yank the power plug in frustration.
    Power Issues.

    The cause of and solution to all of life's problems.
  • Kiss me I'm Polish 2008-11-04 06:12
    When you keep hitting your fingers, is it the hammer or the nail to blame?
    Or maybe the shoe you're using instead?
  • Dark 2008-11-04 06:19
    jspenguin:
    %s %s: "%s" "%s" "%s" "%s" "%d" "%s" "%s" "%s" >/dev/null 2>&1

    Buffalo buffalo: buffalo Buffalo buffalo 5 Buffalo buffalo buffalo
  • Arkh 2008-11-04 08:47
    rycamor:
    don't try to be clever or cute with your programs (see A and B).

    Too bad closures are coming in php. I sense a lot of WTF coming.
  • DaveK 2008-11-04 10:11
    rycamor:

    (ducks flamewar).
    Your favourite ducks aren't as good as my favourite ducks! Mallards are rubbish! All real programmers use Mandarin ducks!
  • savar 2008-11-04 13:47
    Matt Burgess:
    Despite all the TRWTF=PHPLOL attitudes the issue here is not the language but this implementation of it. I've been a PHP programmer for many years and I like it. But there's no way in hell I'd use it to write firmware, any more than I'd use a salad fork to cut a watermelon.

    I do think PHP is in need of an enema. I was hoping PHP 6 would take the opportunity to spring clean, but sadly not. I'd love to see some redundant functions removed, and some inconsistencies cleaned up. It's clearly been built by 1000 different people, all of whom used different naming conventions, etc. strtotime, nl2br, isset, is_array, empty... what a mess.


    Agreed totally...

    I always wonder to myself, "Why did Oracle name a function NVL2()?" What a stupid, stupid name for a very common function in one of the most powerful, well-known, and oldest applications on the planet.

    But just because it's a stupid name doesn't mean I wouldn't use it, nor does it mean I think all of Oracle sucks.\

    PHP is the same. It has some idiotic stuff -- extract(), for example -- but if you use the language primitives and build up a platform (like Cake, Zend Framework, etc.) you can get away from that mess and create a clean foundation.
  • rycamor 2008-11-04 14:10
    Arkh:
    rycamor:
    don't try to be clever or cute with your programs (see A and B).

    Too bad closures are coming in php. I sense a lot of WTF coming.


    Ahem... I think the sort of PHP programmers that produce most WTFs don't even have the slightest idea what a closure is.

    Of course, closures are one of those "a little knowledge is a dangerous thing" problems. They are great solutions to certain types of problems, especially for event-driven programming, but are a rich source of Failidity when used gratuitously.
  • Sigivald 2008-11-04 15:59
    rycamore:
    The whole concept of firmware runs completely counter to the idea of scripting languages.


    I believe "firmware" here is being used loosely to mean "embedded software".

    I suspect the "RAID controller" here is not a RAID controller card, but a NAS box. (After all, cards don't typically have an LCD; detached server boxes are pretty likely to.)

    In that case, the "firmware" is doubtless the whole OS; probably linux + apache (possibly + DAV) + samba.

    Which means they probably already have php for their webpage/admin stuff, so why not have one of their PHP guys write the driver for the LCD?

    (Turns out the reason is "because he won't do performance testing", but...)
  • Eternal Density 2008-11-04 17:06
    When all you have is a swamp, every problem looks like it can be solved through desktop search.
  • Matthew 2008-11-04 18:05
    Hivemind:
    I'm an IT geek whose primary language is PHP *ducks*
    Though I've never done anything like this, I at least know when to NOT use PHP. For shell scripting - yes, anything browser-based - ok. but that? hell no.

    *sigh*


    For shell scripting?? You need to be shot.
  • iToad 2008-11-06 12:15
    Zach Bora:
    http://ca.php.net/manual/en/preface.php:
    http://ca.php.net/manual/en/preface.php PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Its syntax draws upon C, Java, and Perl, and is easy to learn. The main goal of the language is to allow web developers to write dynamically generated web pages quickly, but you can do much more with PHP.


    the sky is the limit!


    Suggested additional areas for PHP use:
    - Avionics
    - Medical devices
    - Weapons control systems
    - Nuclear power plant emergency shutdown systems
    - Pharmaceutical plant control
    - Chemical plant or refinery operations
  • MiffTheFox 2008-11-07 19:57

    #!/usr/bin/php -q

    <?php

    $langs = Array("C", "C++", "PHP", "Perl", "Python", "Ruby", "Java", "VB", "C#", "Lua", "Delphi");
    $lang1num = rand(0, count($langs) - 1);
    $lang2num = rand(0, count($langs) - 1);
    while ($lang2num == $lang1num) $lang2num = rand(0, count($langs) - 1);

    $lang1 = $langs[$lang1num];
    $lang2 = $langs[$lang2num];

    print "Dear God,\n\n".
    "Please kill $lang1.\n\n".
    "Sincerely,\n\n".
    "Everyone except $lang1 programmers (and $lang2 programmers).\n\n";

    ?>
  • Egon_Freeman 2008-11-07 21:19
    I'm a "PHP programmer", and that is to say I write Win32 apps in PHP. I know, double-kill: PHP + Win32. But it works.

    When I need to do something that stupid, though - I build an extension. PHP wasn't designed to do this, I agree completely. PHP wasn't designed to do a LOT of things, it's just that the language and a lot of its constructs/extensions are written in a way that does not implicitly disallow it (not that I'm complaining, do mind). And it is a helluva lot easier than C...

    But then, there's a reason why C exists in the first place, and this program is it. :D

    I've also dropped exec() in favor of the more native StartProcess() from w32kernel (had to write my own ext. to do it, though).
  • huojia 2009-03-02 01:03
    &nbsp;&nbsp;
    货架racking.&nbsp;&nbsp; 仓储货架
    南京货架设备要产品包括:重型货架
    ,阁楼货架,超市Shelf,重量型货架,横梁式货架,驶入式货架... 仓储笼
    货架的形式与材料 · 立体仓库 · 货架厂
    物流规划设计的步骤与程序(货架的设计... 中国物流行业呈现三足鼎立抢市场 · 亚洲第三方物流的现状和发展 ... 托盘
    抽出式货架系列 · 重力式 货架/推入式货架钢托盘
    移动式货架 · 阁楼式货架 · 悬臂式货架
    系列 长件物料储存货架&nbsp;货架公司
  • cheap nike shoes 2009-05-18 18:44
    ����cheap nike shoes���ű�������������cheap nike shoes������Ϣ��·��Cheap nike shoes��ƣ�·��Cheap nike shoesͼƬ���Ϻ�·��Cheap nike shoes��˾��·��Cheap nike shoes��ƣ�·��Cheap nike shoes����.���Cheap nike shoes ��˾������Cheap nike shoes ��˾���Ϻ�Cheap nike shoes ��˾������Cheap nike shoes ��˾��,���Cheap nike shoes ��˾������Cheap nike shoes��е����,Cheap nike shoes��ʮ�����,��Cheap nike shoes��Ϣ,Cheap nike shoes��������,���ǻ����˷ḻ��Cheap nike shoes�����ṩ����Cheap nike shoes ��·,����Cheap nike shoes ����,����Cheap nike shoes ����,��������Cheap nike shoes ,����̽��Cheap nike shoes ,�����չ����,����Cheap nike shoes ,����cheap nike shox,����cheap nike shox��Ѷ,���ϾƵ�,����cheap nike shox��ͨ,����cheap nike shox�������������,����cheap nike shox�Ϻ�cheap power levelingΪרҵcheap power leveling��˾��cheap power leveling������Ϊרҵ��cheap power leveling��˾֮һ��cheap shoes��Ʒ�⡢cheap shoes���š�cheap shoes�������¡�cheap shoes��ҵ������cheap shoes��Ϊ���ṩcheap shoes��Ϣ
  • prada shoes 2009-07-24 13:31
  • oksupra.com 2010-06-13 23:57

    Supra shoes are so popular all over the world. Whatever you take on Supra being in the Supra Skytop Shoes market. Now Supra Strapped Shoes also very popular attention. It is nice that they actually took the time to make Supra Skate Shoes that work well. Supra shoes is a brand that has been inspired, designed and marketed by passionate individuals. We have brought to you the fullest selection of Supra footwear at cheapest price. Overload Skateshop carries a wide range of Supra Shoes to fit your 9-stair kickflips.
  • Lisa 2010-07-15 20:59
    It was my pleasure to visit your Website. I am also very Website you
    enjoy the article.And I also have http://www.emubootsmall.com emu boots he feeling that it was really a pity that we did not meet each other earlier. Because the kindness and warmth in your Website can make me completely relaxed and happy. I hope that you will visit my blog if you can have the same feeling.
  • Seahen 2011-01-29 15:33
    If all eight disk drives had lost power at once, wouldn't the controller probably have lost power too?