Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


I have to say I have a great disdain for higher level languages.

I'm converting a noise tutorial I wrote in ASP.NET to PHP or some scripting language that runs on a typical linux system. I used C# in the ASP version, and though I don't like ASP, C# is quite nice so I was happy with it. I'm moving my site over to a linux server, though, so the tutorial needs to be rewritten (that and I hated some things about ASP). Needless to say, I thought it would be easy.

I could rephrase: I hate languages that aren't strongly typed. Maybe I'm just not used to them? I hate having a function and having no idea what types are really being passed in. I guess that's the point- you shouldn't have to worry. But 2/3 of the time my operations on the parameters assume it is a certain type, like a string!

The implementation was easy, but I could not get it to work for the life of me. When it did work, it was extremely slow. I know I probably shouldn't be doing noise, a rather computational operation, in PHP but I liked the interactivity of my tutorial.

The problem was the PHP would internally convert between types, especially integer and long (I think). There were random places in the math where wrong numbers would result from an expression. I had to lay out each step of the expression per-line and cast it to the type I wanted it to be. Maybe I just don't know how to use PHP but that was the only way it worked! So. freaking. annoying.

This was so much freaking hassle on top of being so freaking slow that I gave up on it. Suddenly I had the bright idea of creating a c++ executable that would output the image data and I could use php for all the image creation and spitting out as an actual image. Got it running in an hour (whereas I spent 4-5 hours last night debugging php).

It's a pretty cool trick in my opinion. PHP calls the executable and fills in an array with the output, and in the exe I just printf() each float. Then in PHP I loop through the whole area and setpixel() in an image and output the image.

This made it sooo easy as well as met my speed requirement. (Seriously, it's about 500% faster).

Anyway, a sample php page can be seen here: Noise

This is the tutorial I wrote years ago. I need to fix a lot of stuff on it.. it's too wordy, isn't even really Perlin Noise, etc..
Sign in to follow this  


Recommended Comments

That's a good solution. I hate PHP too. But I love it just as much. Cool noise generation. I'll have a look at your tutorial soon.

Share this comment

Link to comment
Given that you're looking at an interpreted language that is parsed on-the-fly versus direct machine code, it doesn't surprise me that it's faster [smile]

Share this comment

Link to comment
true, that should be obvious, but for some reason it just makes me like c++ more, though you can't really compare c++ and php because they are built for different purposes!

PHP is good, it's just a little too high-level for me. I'd rather use Perl if I was going to use a scripting language.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!