Jump to content

php style computer coding


MadnessRed

Recommended Posts

Hi, I am sorry if this is in the wrong place but I was wondering, are there any programming languages that are similar to php with the interchangeable data types and and amazing arrays, however are fro standard desktop programming rather than web programming. If there are I would be very interested, I have tried C and C++ but the arrays are nowhere near as god a phps.

Link to comment
Share on other sites

Perl is a good one ;)

 

Google, "loosely typed languages", and try some out, I don't know what you mean by:

 

but the arrays are nowhere near as god a phps.

 

I mean with php you can have strange assortments of arrays

array(
  array(
    int a,
    array(
      char b,
      boolean c
  ),
  string d
);

 

and you can call and edit an array value like a normal variable ( array[rel]; )

 

 

Also the way you can switch between data types.

 

 

$var = pow(12,7);

$var = "Your anser is: ".$var;

 

where the variable is never defined and can be switched between strings and numbers ect. I will try perl though

Link to comment
Share on other sites

For an associative array in C++, you can just use a hash map.  For an array that is dynamically sized, you can use a vector.  for type casting, that's often not even needed.

 

 

As for an array like you stated as an example....  I can't think of a time when I was coding in C++ that I've ever needed to do that.  And, if that was ever required, a1[key] could just point to a2[a1[key]].

 

Vector example (a hash map example would be almost as easy):

 

(Windows)

 

#include <vector>
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int main(int argc, char* argv[]) {
    vector<int> v;
    srand((unsigned int) time(NULL));
    int rn = rand() % 100 + 1;
    //1-100 random numbers
    int r = 0;
    for(int i = 0; i < rn; ++i) {
        r = rand();
        v.push_back(r);
        cout << "The number was: " << r << endl;
    }
    //Now v is a [content-holding] dynamically sized array of ints.
}

 

 

 

 

There is a reason that C/C++ are strictly typed by the way.  Since they are compiled straight to computer code (for lack of a better term without going into detail), the compiler has to know exactly how much memory each thing will take up, where it will be and so on.  As someone else once said (I think it was Daniel0), "It doesn't have the PHP interpreter sitting there holding its hand."  (I doubt that's how it was exactly worded.)

 

 

 

 

 

 

By the way, I would be willing to argue that Perl is no more a "desktop language" than PHP is.  Note that I'm not saying that Perl is strictly a web language.

Link to comment
Share on other sites

Hi, I am sorry if this is in the wrong place but I was wondering, are there any programming languages that are similar to php with the interchangeable data types and and amazing arrays, however are fro standard desktop programming rather than web programming. If there are I would be very interested, I have tried C and C++ but the arrays are nowhere near as god a phps.

You could take a look at PHP-GTK, and there's a couple of PHP compiles for Win32 that I've seen around
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.