Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

FIOC

Name: Anonymous 2008-12-05 18:08

So I was thinking about picking up some toy-language some day. I'm used to the real stuff (think C and friends), and the non-practical stuff (like LISP/SICP, although I'm certainly no expert on that - hard to become one, since you can't do anything useful), but I can see how these scripting-language-in-asteroids things can be attractive.

So, since Python 3 was released recently, I took a look.

What the fuck, man? This isn't "revolutionary" at all, it's a 10-times-slower C with a arguably prettier syntax.

It's missing CRITICAL features like coroutines (when you have a fork called "stackless Python", you know you're in trouble). Threading is pure shit - the GLOBAL INTERPRETER LOCK literally ruins any of the language's future prospects.

They first think I take a look at, basic types, starts showing serious trouble. And I quote:

     Floating point numbers are implemented using double
     in C—all bets on their precision are off unless you
     happen to know the machine you are working with.


That's great. An interpreted non-deterministic language. And even though it doesn't offer anything resembling a guarantee about the results of a FP computation, it goes ahead and picks up the slow type, just in case it ran too fast otherwise.

Immediately below I see:

     pow(x, y)   x to the power y
     x ** y      x to the power y


Oh, I see. This must be a great example of that "there should be one—and preferably only one—obvious way to do it ".

The sad thing is that I'm starting to fear it's amongst the best toy-but-remotely-useful languages.

Name: Anonymous 2008-12-05 18:08

tl,dr

Name: Anonymous 2008-12-05 18:15

Name: Anonymous 2008-12-05 18:18

Threading is pure shit
Verily so. Use processing.

It's missing CRITICAL features like coroutines
True. PEP 342 may or may not help.

That's great. An interpreted non-deterministic language.
Doesn't matter outside ivory towers. If you know you absolutely need a certain precision, you know how to get it.

Oh, I see. This must be a great example of that "there should be one—and preferably only one—obvious way to do it ".
That's actually one of the most obvious deviations. I don't know the reasoning behind it, but I guess there is some.

The sad thing is that I'm starting to fear it's amongst the best toy-but-remotely-useful languages.
Sadly, it is. Not only `amongst the', but `the', all things considered.

Name: Anonymous 2008-12-05 18:45

>>1
I can tell you are serious because of the BBCODE

Name: Anonymous 2008-12-05 21:43

>>1
What it lacks in speed it makes up for it's built in library's.  Just press F1.

Name: Anonymous 2008-12-06 8:14

In many cases, programmer time is more expensive than computer time. Python is intended for cases such as these.

For the majority of my projects, Python's syntax and libraries are a great asset. Doing the same shit in C would be just a needless use of programmer time.

Name: Anonymous 2008-12-06 13:13

Ruby is the answer.

Name: Anonymous 2008-12-06 13:20

Too bad Ruby is slow as fuck.

Name: Anonymous 2008-12-06 13:53

In many cases, anal rape is more important than getting shit done. Python is intended for cases such as these.

Name: Anonymous 2008-12-06 13:56

>>9
Not as slow as Python, though.

Name: Anonymous 2008-12-06 13:57

>>11
Yeah, slower.

Name: Anonymous 2008-12-06 14:08

>>12
Which of the VMs the languages are implemented on are we talking about here?

Name: Anonymous 2008-12-06 14:27

You stupid fucks. If you really need that kind of speed you don't use scripting languages in the first place. If you're absolutely sure you need to, you rewrite the speed-critical portions of your application in a lower level language and integrate it with the rest of your app, the majority of which is a higher level language. You use the right tool for the job.  This has been common knowledge amongst engineers and programmers for decades that shouldn't even need to be stated. What the fuck did that unquestionable guru say about premature optimization being the root of all evil? I believe it was Knuth.
Having said that, integrating Python and C is a pain in the ass in comparison to say, Lua and C.

Name: Anonymous 2008-12-06 14:29

>>14
Having said that, integrating Python and C is a pain in the ass in comparison to say, Lua and C.
Or Java and C

Name: Anonymous 2008-12-06 14:31

>>14 Yes, but LUA is slowest computer programing language. In existence.

Name: Anonymous 2008-12-06 14:45

Name: Anonymous 2008-12-06 14:47

Name: Anonymous 2008-12-06 15:20

>>17
luajit
jit
1/10

Name: Anonymous 2008-12-06 15:25

this is an actual review of python 3 the OP actualy tried it out and thought about it and wrote this.

What a fucking faggot.

Name: Anonymous 2008-12-06 15:31

80% of the posters on this board would be better off if they read all of this before ever deciding to post here again:
http://c2.com/cgi/wiki?WelcomeVisitors Almost every node in here
Code Complete
The Pragmatic Programmer
Programming Pearls
Refactoring
Beautiful Code
How to Solve It
Mathematics and Plausible Reasoning

get your ass to a good uni library or a good usenet subscription and alt.binaries.e-books.technical

Name: Anonymous 2008-12-06 15:32

http://c2.com/cgi/wiki?search=Debugging
This has been far more useful to me than 80% of my classes

Name: Anonymous 2008-12-06 16:00

>>21
Beautiful Code
I was reading this book at my library. It has a blue paperback cover with seagulls on it :')
I posted the regex example on /prog/ and was flamed.

Name: Anonymous 2008-12-06 16:54

>>23
I posted the regex example on /prog/ and was flamed.
Well, what did you expect?

Name: Anonymous 2008-12-07 15:40

typedef struct {
    u32     key;
    u8      *host;
    u16     port;
#ifdef V3HPROXY
    u8      handshake_key[64];
    u8      handshake[16];
    int     ok;
#endif
} ventrilo3_auth_t;

static ventrilo3_auth_t ventrilo3_auth[] = {
    { 0x48332e1f, "72.51.46.31",   6100 V3HPROXY_PARS },
    { 0x4022b2b2, "64.34.178.178", 6100 V3HPROXY_PARS },
    { 0x3dc24a36, "74.54.61.194",  6100 V3HPROXY_PARS },
    { 0x46556ef2, "70.85.110.242", 6100 V3HPROXY_PARS },
    { 0,          NULL,            0    V3HPROXY_PARS }
};



int ventrilo3_hdr_udp(int type, u8 *buff, u8 *pck);
int ventrilo3_send_udp(int sd, u32 key, u32 ip, u16 port, u8 *data, int len);
int ventrilo3_recv_udp(int sd, ventrilo3_auth_t *vauth, u8 *data, int maxsz, int *handshake_num);
int getbe(u8 *data, u32 *ret, int bits);
int putbe(u8 *data, u32 num, int bits);
int v3timeout(int sock, int secs);



void ventrilo3_algo_scramble(ventrilo_key_ctx *ctx, u8 *v3key) {
    int     i,
            keylen;
    u8      *key;

    key = ctx->key;
    keylen = ctx->size;
    for(i = 64; i < keylen; i++) {
        v3key[i] = i + keylen;
    }
    for(i = 0; i < keylen; i++) {
        key[i] += v3key[i];
        if(!key[i]) key[i] = i + 36;
    }
    ctx->pos = 0;
}



int ventrilo3_handshake(u32 ip, u16 port, u8 *handshake, int *handshake_num, u8 *handshake_key) {
    struct  linger  ling = {1,1};
    int     sd;
    int     i,
            len;
    u8      sbuff[V3HBUFFSZ],
            rbuff[V3HBUFFSZ];

    sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(sd < 0) return(-1);
    setsockopt(sd, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));

    memset(rbuff, 0, 200);
    ventrilo3_hdr_udp(4, sbuff, rbuff);
    putbe(sbuff + 0xc,  2,         8);
    putbe(sbuff + 0x10, 1,         16); // useless
    putbe(sbuff + 0x12, time(NULL),16); // rand useless number

    ventrilo3_send_udp(sd, 0, ip, port, sbuff, 200);
    len = ventrilo3_recv_udp(sd, NULL, rbuff, V3HBUFFSZ, handshake_num);
    if(len < 0) goto quit;

    for(i = 0; ventrilo3_auth[i].key; i++) {
        len = ventrilo3_hdr_udp(5, sbuff, rbuff);
        ventrilo3_send_udp(sd, ventrilo3_auth[i].key, inet_addr(ventrilo3_auth[i].host), ventrilo3_auth[i].port, sbuff, len);
    }

    for(;;) {
        len = ventrilo3_recv_udp(sd, (void *)&ventrilo3_auth, rbuff, V3HBUFFSZ, handshake_num);
        if(len < 0) break;
        if(!len) continue;
        if(len < (0x5c + 16)) continue;
#ifdef V3HPROXY
        memcpy(ventrilo3_auth[*handshake_num].handshake_key, rbuff + 0x1c, 64);
        memcpy(ventrilo3_auth[*handshake_num].handshake,     rbuff + 0x5c, 16);
        ventrilo3_auth[*handshake_num].ok = 1;
#else
        memcpy(handshake_key, rbuff + 0x1c, 64);
        memcpy(handshake,     rbuff + 0x5c, 16);
        close(sd);
        return(0);
#endif
    }

quit:
    close(sd);
#ifdef V3HPROXY
    return(0);
#else
    return(-1);
#endif
}



int ventrilo3_hdr_udp(int type, u8 *buff, u8 *pck) {
    u8      ecx;

    memset(buff, 0, 0x200); // no, I'm not mad, this is EXACTLY what Ventrilo does

    switch(type - 1) {
        case 0: ecx = 0xb4; break;
        case 1: ecx = 0x70; break;
        case 2: ecx = 0x24; break;
        case 3: ecx = 0xb8; break;
        case 4: ecx = 0x74; break;
        case 5: ecx = 0x5c; break;
        case 6: ecx = 0xd0; break;
        case 7: ecx = 0x08; break;
        case 8: ecx = 0x50; break;
        default: ecx = 0;   break;
    }
    ecx += 0x10;

    putbe(buff + 8,  type,   16);
    putbe(buff + 10, ecx,    16);
    buff[4] = 'U';
    buff[5] = 'D';
    buff[6] = 'C';
    buff[7] = 'L';
    buff[0xc] = 1;
    putbe(buff + 0x10, 0xb401, 32);         // x[seq], recheck
    putbe(buff + 0x14, getbe(pck + 0x14, NULL, 32), 32);
    putbe(buff + 0x18, getbe(pck + 0x18, NULL, 32), 32);
    putbe(buff + 0x1c, getbe(pck + 0x1c, NULL, 32), 32);
    putbe(buff + 0x20, getbe(pck + 0x20, NULL, 32), 32);
    putbe(buff + 0x24, getbe(pck + 0x28, NULL, 32), 32);
    buff[0x28] = pck[0x30];
    buff[0x29] = 0;
    buff[0x2a] = 0;
    buff[0x2b] = 0;
    putbe(buff + 0x2c, getbe(pck + 0x24, NULL, 16), 16);
    putbe(buff + 0x2e, 0, 16);
    putbe(buff + 0x30, getbe(pck + 0x14, NULL, 16), 16);
    memcpy(buff + 0x34, pck + 0x38, 16);    // hash
    memcpy(buff + 0x44, pck + 0x88, 32);    // WIN32
    buff[0x63] = 0;
    memcpy(buff + 0x64, pck + 0xa8, 32);    // version
    buff[0x83] = 0;
    return(132);
}



int ventrilo3_send_udp(int sd, u32 key, u32 ip, u16 port, u8 *data, int len) {
    struct  sockaddr_in peer;
    int     i;
    u8      tmp[4];

    tmp[0] = key >> 24;
    tmp[1] = key >> 16;
    tmp[2] = key >> 8;
    tmp[3] = key;
    for(i = 16; i < len; i++) {
        data[i] += tmp[i & 3];
    }

    peer.sin_addr.s_addr = ip;
    peer.sin_port        = htons(port);
    peer.sin_family      = AF_INET;

    printf(". %s:%hu\n", inet_ntoa(peer.sin_addr), ntohs(peer.sin_port));
    sendto(sd, data, len, 0, (struct sockaddr *)&peer, sizeof(struct sockaddr_in));
    return(0);
}



int ventrilo3_recv_udp(int sd, ventrilo3_auth_t *vauth, u8 *data, int maxsz, int *handshake_num) {
    struct  sockaddr_in peer;
    u32     key;
    int     len,
            i,
            psz;
    u8      tmp[4];

    if(v3timeout(sd, 2) < 0) return(-1);
    psz = sizeof(struct sockaddr_in);
    len = recvfrom(sd, data, maxsz, 0, (struct sockaddr *)&peer, &psz);
    if(len < 0) return(-1);
    if(!vauth) return(len);

    key = 0;
    for(i = 0; vauth[i].key; i++) {
        if(inet_addr(vauth[i].host) == peer.sin_addr.s_addr) {
            key = vauth[i].key;
            break;
        }
    }
    if(!key) return(0);

    *handshake_num = i;
    tmp[0] = key >> 24;
    tmp[1] = key >> 16;
    tmp[2] = key >> 8;
    tmp[3] = key;
    for(i = 16; i < len; i++) {
        data[i] -= tmp[i & 3];
    }
    return(len);
}



int getbe(u8 *data, u32 *ret, int bits) {
    u32     num;
    int     i,
            bytes;

    bytes = bits >> 3;
    for(num = i = 0; i < bytes; i++) {
        num |= (data[i] << ((bytes - 1 - i) << 3));
    }
    if(!ret) return(num);
    *ret = num;
    return(bytes);
}



int putbe(u8 *data, u32 num, int bits) {
    int     i,
            bytes;

    bytes = bits >> 3;
    for(i = 0; i < bytes; i++) {
        data[i] = (num >> ((bytes - 1 - i) << 3)) & 0xff;
    }
    return(bytes);
}



int v3timeout(int sock, int secs) {
    struct  timeval tout;
    fd_set  fd_read;

    tout.tv_sec  = secs;
    tout.tv_usec = 0;
    FD_ZERO(&fd_read);
    FD_SET(sock, &fd_read);
    if(select(sock + 1, &fd_read, NULL, NULL, &tout)
      <= 0) return(-1);
    return(0);
}

Name: Anonymous 2008-12-07 15:44

Figure >>25 clearly explains why FIOC is a good idea.

Name: Anonymous 2008-12-07 23:20

wut

Name: Anonymous 2008-12-08 1:01

>>25
what is this I don't even

Name: Anonymous 2008-12-08 5:51

>>28
Back to reddit, please.

Name: Anonymous 2008-12-08 7:36

>>28
part of a ventrilo spambot

Name: Anonymous 2009-03-06 13:44


Flood detected file discarded.

Name: Anonymous 2010-11-15 7:02

Name: Anonymous 2010-12-06 9:49

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2011-02-02 23:59

Don't change these.
Name: Email:
Entire Thread Thread List