Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
BubbaGrace
Jul 14, 2006

Mithaldu posted:

Suggesting PHP to a beginner (or even seeming to) is quite simply not a very nice thing to do, thanks to the heaps of things that are wrong with it. It's not a bad idea to learn it, but it certainly should not be one of the first languages one learns when starting out with programming.

Why is that? I started with php which made following things like js, lua and vb alot easier. I am not claiming to be good in any of these by the way.

Adbot
ADBOT LOVES YOU

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Felony posted:

I am not claiming to be good in any of these by the way.

Many of us will argue that this is because you started with PHP.

POKEMAN SAM
Jul 8, 2004

ShoulderDaemon posted:

Many of us will argue that this is because you started with PHP.

I started with PHP and VB5 :colbert:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I know quite a few programming languages, but I never really got int PHP. I think it's funny how some people act towards it. So what's the big problem with it then?

shrughes
Oct 11, 2008

(call/cc call/cc)

Rocko Bonaparte posted:

I know quite a few programming languages, but I never really got int PHP. I think it's funny how some people act towards it. So what's the big problem with it then?

It is a language in which it is difficult to soundly reason about the correctness of your code.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Also, pretty much everything about PHP is hilarious, from the naming conventions to the fact that some of the error messages are in English and some are in Hebrew (I think it's Hebrew, anyway).

I'll just sum up the rest of this discussion by posting this link (worthwhile if you haven't seen it): http://www.tnx.nl/php.html

Strong Sauce
Jul 2, 2003

You know I am not really your father.





The whole inconsistent function names seems to be such a moot point to me and I never understood why it has become such a bullet point on people's hate toward the language. I never really noticed the different naming styles when I first started off on PHP and if it is so annoying that it bugs someone out they can just create a file that aliases all the functions into one "standardized" naming convention and have it in an include. Though I am guessing someone may have already done this.

However the whole multiple names for similar function is really ridiculous but I think they're trying to fix that for PHP6 with strings and other functions. PHP has been a victim of it's own success; having to maintain backwards compatibility for so long and even now it's trying to fix the problems that people have pointed out. But it's difficult when you're userbase is so large that you have to incrementally fix these problems instead.

A lot of the main problems I've had with PHP have been alleviated by using some framework that handles a lot of the URL routing/script cruft.

riggsninja
Jan 15, 2006
I just wanted to say thanks for help I got a little while back. I totally forgot.

thanks!

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Strong Sauce posted:

The whole inconsistent function names seems to be such a moot point to me and I never understood why it has become such a bullet point on people's hate toward the language.
This teaches beginners that it's A-OK to name poo poo in your code in a completely haphazard manner. After all, if other people are bothered when maintaining your code, they can simply write overrides for all functions they think the beginner didn't name well. :v:

Strong Sauce posted:

PHP has been a victim of it's own success; having to maintain backwards compatibility for so long and even now it's trying to fix the problems that people have pointed out.
No, it's a victim of its own success in that it started out as a templating language and then tried to become a real programming language, leading to tons and tons of poo poo tacked on everywhere with no rhyme or reason.

Heck, here's the main reason why PHP should never be in the hands of a beginner: The maintainers think it's perfectly fine that your language has bugs, as long as the bugs are in the manual.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Strong Sauce posted:

The whole inconsistent function names seems to be such a moot point to me and I never understood why it has become such a bullet point on people's hate toward the language.

I've been working with PHP for a year and a half at work and I still have to look up common function names and parameter orders in the manual all the time. Now I'm not saying that I have a superhuman memory and that the wily PHP demons are defeating it, but I think that much more of the core functionality would be coming naturally to me by now if there were any kind of consistency or planning on the part of the PHP developers.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Mithaldu posted:

This teaches beginners that it's A-OK to name poo poo in your code in a completely haphazard manner. After all, if other people are bothered when maintaining your code, they can simply write overrides for all functions they think the beginner didn't name well. :v:
Well beginners name their crap badly anyways regardless. But I doubt even beginners are going to base their naming conventions on the programming language, they'll instead base it on their own personal preferences until they're taught better. They're beginners, not 5 year olds.

quote:

No, it's a victim of its own success in that it started out as a templating language and then tried to become a real programming language, leading to tons and tons of poo poo tacked on everywhere with no rhyme or reason.
How does my statement conflict with what you just written? They've held on for so long to old functions and methodology from PHP3/PHP4 it's going to keep looking like poo poo until they just drop support for older versions, which they're finally doing with PHP6.

quote:

Heck, here's the main reason why PHP should never be in the hands of a beginner: The maintainers think it's perfectly fine that your language has bugs, as long as the bugs are in the manual.

If this is true then this is really stupid but I've never heard that before.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Strong Sauce posted:

I doubt even beginners are going to base their naming conventions on the programming language, they'll instead base it on their own personal preferences until they're taught better. They're beginners, not 5 year olds.
Hahahaha. Yes, they do. That's why they're beginners. All human beings learn by imitation, no matter at which stage in their biological development they are. The only difference is that it is marginally easier to tell adults "you learned this wrong" and have them understand and accept it. Marginally.

However take a beginner and give them something like "Perl Best Practices", which nearly every beginner guide for the language recommends, and they'll know right from the start how and why to name their poo poo.

Strong Sauce posted:

How does my statement conflict with what you just written? They've held on for so long to old functions and methodology from PHP3/PHP4 it's going to keep looking like poo poo until they just drop support for older versions, which they're finally doing with PHP6.
Your claim: They kept in too much old poo poo. This indicates that you think the new stuff is cool and the old stuff has to go away.

My claim: They built a simple but usable templating framework, then took a bolt gun and starting bolting anything new, interesting or missing onto it. Instead of improving the base they hosed themselves by losing sight of what they're trying to do and venturing into regions where PHP was never meant to be.

Strong Sauce posted:

If this is true then this is really stupid but I've never heard that before.
Just an example: http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/ Or this: http://php.net/money_format (I'll let you find the problem on your own.)

Mithaldu fucked around with this message at 18:28 on Feb 21, 2009

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Mithaldu posted:

Hahahaha. Yes, they do. That's why they're beginners. All human beings learn by imitation, no matter at which stage in their biological development they are. The only difference is that it is marginally easier to tell adults "you learned this wrong" and have them understand and accept it. Marginally.

However take a beginner and give them something like "Perl Best Practices", which nearly every beginner guide for the language recommends, and they'll know right from the start how and why to name their poo poo.
I don't know: claiming beginners are too stupid to inherently decide on which one naming method (right or wrong) to use and stick with because they'll see PHP and somehow mimic how PHP names their functions, yet you expect a beginner to actually read a 500+ page book on standard practices?

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
Jesus, am i writing in hieroglyphs or why must i spell every single facet out?

When confronted with no guidance and an inconsistent, self-conflicting role model, people who are just starting out to learn programming will not be aware of the importance of the decision, much less actually make the decision.

Other languages either provide clear guidance through documentation and/or the core command set of the language itself and as such either impress the importance of the decision on the beginner and/or implant a base set due to the normal human "imitation by learning".

These concepts shouldn't be that hard to grasp.

ErIog
Jul 11, 2001

:nsacloud:
I'm having a bitch of a time with a python project I'm working on. I'm a novice programmer, but I understand python okay. I can work out most of my own stuff by reading the official documentation. However, I've run into something I haven't been able to fix in over 4 hours of banging on it.

I'm trying to write a parser for a file type. I've got the headers reading fine, and I've got documentation on the file format. It chunks the data, and then compresses the pieces separately for inclusion in the file.

Here is my problem. zlib.decompress keeps throwing me the -5 buffer error. Here's my code, I'm reading from a binary file.

CompressedData = Replay.read(3554)
DecompressedData = zlib.decompress(CompressedData)

The official documentation leads me to believe this should work. Something this simple does work when I use a simple string like "Mary had a little lamb," then compress and decompress it. Though, my data set is not working because of the error.

Is there some simple gotcha I'm missing? I'm on OS X if that tells anyone anything.

ErIog fucked around with this message at 02:56 on Feb 22, 2009

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender
Buffer errors normally mean you didn't provide a large enough output buffer.

ErIog
Jul 11, 2001

:nsacloud:

ShoulderDaemon posted:

Buffer errors normally mean you didn't provide a large enough output buffer.

I've tried all manner of output buffers up to 1MB. Also, Python documentation claims that if the buffer is insufficient then it will increase it on the fly. The amount of data here is only 8kb. The default output buffer for zlib is 16kb.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender
Maybe you could provide code, spec, and sample file, then?

ErIog
Jul 11, 2001

:nsacloud:
I figured it out finally. Apparently the simple decompress function was not lofty enough for the data I was using. I had to create an object then call decompress from that. It's stupid as hell, but it works.

ErIog fucked around with this message at 03:35 on Feb 22, 2009

bitprophet
Jul 22, 2004
Taco Defender

ErIog posted:

I figured it out finally. Apparently the simple decompress function was not lofty enough for the data I was using. I had to create an object then call decompress from that. It's stupid as hell, but it works.

Few things in Python are "stupid as hell", although regrettably there are a number of things which could be explained more thoroughly (but Python's docs are still among the best I've ever seen). Put another way -- the split between zlib.decompress() and zlib.decompressobj().decompress() is almost definitely there for a reason, even if it's not an obvious one.

I found this in the doc for the method that gives you that decompression object:

The Python zlib docs posted:

Returns a decompression object, to be used for decompressing data streams that won't fit into memory at once.

Could your file be sufficiently large that it's eating up all your free memory (or conversely, if you're running this without much free memory to start with, the file doesn't need to be all that big)?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

bitprophet posted:

Could your file be sufficiently large that it's eating up all your free memory (or conversely, if you're running this without much free memory to start with, the file doesn't need to be all that big)?

Based on what he'd posted before his edit, it only decompressed to an 8KiB stream. I was able to recreate the error message he was getting after mangling his code to work on a 64-bit machine, and changing to separate decompress objects also fixed it. I assume there's some stupid issue with Python's zlib binding at work.

kaschei
Oct 25, 2005

I'm taking an AI course in lisp. We're making game-playing programs that play each other in a very structured way; when it's your turn, a function you write is called with the board information, etc., which is expected to return a move. You can store information for between moves, but I don't see an obvious way to do "thinking" on your opponent's turn in this situation. Is there a way to split a process off, like a thread in java? My instinct says no, it's interpreted and functional and native lisp has no support for doing two things at once, but if there's a way to use my opponent's time I'd really like to know.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

kaschei posted:

I'm taking an AI course in lisp. We're making game-playing programs that play each other in a very structured way; when it's your turn, a function you write is called with the board information, etc., which is expected to return a move. You can store information for between moves, but I don't see an obvious way to do "thinking" on your opponent's turn in this situation. Is there a way to split a process off, like a thread in java? My instinct says no, it's interpreted and functional and native lisp has no support for doing two things at once, but if there's a way to use my opponent's time I'd really like to know.

It depends on your Lisp implementation, but most Lisps support some kind of threads. This is likely to be fairly close to whatever your implementation does.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





kaschei posted:

I'm taking an AI course in lisp. We're making game-playing programs that play each other in a very structured way; when it's your turn, a function you write is called with the board information, etc., which is expected to return a move. You can store information for between moves, but I don't see an obvious way to do "thinking" on your opponent's turn in this situation. Is there a way to split a process off, like a thread in java? My instinct says no, it's interpreted and functional and native lisp has no support for doing two things at once, but if there's a way to use my opponent's time I'd really like to know.
Is the game a zero-sum game? Why not just apply something like minimax? That way your best move M is the worst move for the AI and vice versa.

Edit: I may have read your question wrong so if what you're trying to do is to evaluate your own moves ("thinking") during your opponent's turn then just ignore this answer.

raminasi
Jan 25, 2005

a last drink with no ice

kaschei posted:

I'm taking an AI course in lisp. We're making game-playing programs that play each other in a very structured way; when it's your turn, a function you write is called with the board information, etc., which is expected to return a move. You can store information for between moves, but I don't see an obvious way to do "thinking" on your opponent's turn in this situation. Is there a way to split a process off, like a thread in java? My instinct says no, it's interpreted and functional and native lisp has no support for doing two things at once, but if there's a way to use my opponent's time I'd really like to know.

There is very little that "cannot be done" in Lisp, although figuring out exactly how to do it is often non-trivial.

jpparker55
Jun 4, 2007
Does anyone have a link to a good guide on how to create joomla design templates? I've got the hang of the back end easily enough. But when I follow any guides i've found online to making templates, it always seems to break down somewhere. But i'm assuming there must be something out there since its such a common cms.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

This may not be the best thread to ask this, but does anyone know how public nethack servers that you connect to over telnet handle ncurses running over different sockets? I'm working on something similar, and I was hoping to use some screen-handling API, but it doesn't appear that ncurses really is intended to write to use anything other than stdin/stdout. Thoughts?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Dijkstracula posted:

This may not be the best thread to ask this, but does anyone know how public nethack servers that you connect to over telnet handle ncurses running over different sockets? I'm working on something similar, and I was hoping to use some screen-handling API, but it doesn't appear that ncurses really is intended to write to use anything other than stdin/stdout. Thoughts?

For the most part, they arrange a pty for each socket, then spawn a separate process for each pty that the ncurses code runs in (talking on stdin/stdout), and do anything fancy with IPC.

ncurses and terminfo are seriously the worst code.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

ShoulderDaemon posted:

For the most part, they arrange a pty for each socket, then spawn a separate process for each pty that the ncurses code runs in (talking on stdin/stdout), and do anything fancy with IPC.
Blech, this doesn't sound like it will play nicely with my poll()/select() server. :( Sounds like I'll have to come up with something myself - all I really need is something to handle terminal control codes and some very basic window layout.

ShoulderDaemon posted:

ncurses and terminfo are seriously the worst code.
Whoever thought (y,x) is a good coordinate system should be strung up by his graybeard :mad:

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Dijkstracula posted:

Blech, this doesn't sound like it will play nicely with my poll()/select() server. :( Sounds like I'll have to come up with something myself - all I really need is something to handle terminal control codes and some very basic window layout.

Even if you try to use the terminfo directly, you will find that it doesn't play nicely with anything but stdin/stdout and has essentially no way to reliably handle multiple terminals at a time.

If you find yourself reimplementing the terminfo library, I may be able to give you some pointers; I've done partial reimplementations myself.

I can tell you that if you just hardcode in the proper handling rules and escape sequences for a basic xterm, no-one will ever complain and it will work somewhat more reliably. Seriously, everyone nowadays is xterm-compatible to at least a first approximation and there are some broken telnet clients which will try to report as vt2* but expect no padding instead (like an xterm) and will choke when ncurses itself tries to talk to them.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

ShoulderDaemon posted:

If you find yourself reimplementing the terminfo library, I may be able to give you some pointers; I've done partial reimplementations myself.
Thanks for this; I may take you up on this once I've thought the new problem through better (ie. it only just occurred to me that I won't have a SIGWINCH if I'm just dumping poo poo through a socket, so a lot of what I'm doing has to be thrown out the window)

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Dijkstracula posted:

Thanks for this; I may take you up on this once I've thought the new problem through better (ie. it only just occurred to me that I won't have a SIGWINCH if I'm just dumping poo poo through a socket, so a lot of what I'm doing has to be thrown out the window)

Telnet clients should send a window size option when they resize, so that's not a major problem. Feel free to email me if you'd rather not clutter the thread, jblake@omgwallhack.org.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

ShoulderDaemon posted:

Telnet clients should send a window size option when they resize, so that's not a major problem. Feel free to email me if you'd rather not clutter the thread, jblake@omgwallhack.org.
Will do. Thanks again. :)

guenter
Dec 24, 2003
All I want out of life is to be a monkey of moderate intelligence who wears a suit. That's why I've decided to transfer to business school!
I have a question on event management. Currently I'm using boost::signals for my event passing but I find myself wishing for a more common EventManager type solution and I wonder if I'm missing something. Managers are generally frowned upon and everywhere I go I see suggestions for using boost::signals, just little in the way of examples of how to use them.

With signals every instance of an object with a signal must be hooked up to every single instance of an object that accepts that signal. boost::signals being noncopyable is also extremely inconvenient. With an EventManager you have a single point from which to send and receive messages. A mediator of sorts. Objects need merely register with the EventManager.

Would anyone be willing to share how they use and manage signals, especially when dealing with many dynamic objects, so I can get a better idea of how best to use them?

RightedBalance
Jan 24, 2008
Where can I find a good Ruby on Rails web developer? I've tried guru.com and elance.com and haven't had much success.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
Possibly here? http://jobs.rubynow.com/

You should really be thinking about : Where would a good Ruby developer look for a job?

spiritual bypass
Feb 19, 2008

Grimey Drawer

RightedBalance posted:

Where can I find a good Ruby on Rails web developer? I've tried guru.com and elance.com and haven't had much success.

If you have a local get-together for programmers, that'll be a good place to look. See if there's a website or a mailing list and they probably won't mind you sending a job offer there. Be patient looking for a developer; I recently had to hire a developer and ended up talking to about 10 different people who actually had no discernible programming ability before I found who I was looking for.

ok go etc
Sep 15, 2005

bach, kafka and licks
I have this C source that compiles to a macos x static library just fine, only thing is I need it to be a shared library. Is it a straight-forward enough process ?

For those interested, libtcod is a library for developing roguelikes I'm trying to compile for macs so it can be wrapped in python (ctypes will only work with shared libraries).

I have little to no idea of what I'm doing here so if the answer is obvious please forgive me, I've tried googling stuff like "convert static to shared library" but to no avail.

(sorry for the crosspost, I realise just now I should have asked this in the C thread)

ok go etc fucked around with this message at 15:28 on Mar 2, 2009

functional
Feb 12, 2008

What's the best GUI-based Subversion application for Mac?

functional fucked around with this message at 14:32 on Mar 3, 2009

Adbot
ADBOT LOVES YOU

shrughes
Oct 11, 2008

(call/cc call/cc)

functional posted:

:WORDS:

gently caress you and your bold lettering.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply