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

Make the world a better place

Name: Anonymous 2010-12-18 22:15

ITT: Name one thing about a language that annoys you most, and how it could be made better in your opinion (with code examples).

I'll start with... Python. Pretty awesome language in general, but the whole forced intendation ruins it for me, so why not just use braces instead of whitespace?

Anyway, old python:

import string

def poopy(data):
    ret = {}
    i = 0
    while i < len(data):
        if data[i] == '+' or data[i] == '-':
            if data[i].isdigit():
                i = i + 1
                temp = "%d" % data[i]
                ret[len(ret)] = temp
                while i < len(data) and data[i].isdigit():
                    ret[len(ret) - 1] += data.at[i]
                    i = i + 1
            else:
                i = i + 1
                temp = "%s" % data[i]
                ret[len(ret)] = temp
        elif data[i].isdigit():
            ret[len(ret)] = ""
            while (i < len(data)) and data[i].isdigit():
                ret[len(ret)-1] = data[i]
                i = i + 1

        elif data[i].isalpha():
            ret[len(ret)] = ""
            while i < len(data) and data[i].isalpha():
                ret[len(ret)-1] += data[i]
                i = i + 1
        elif data[i] in string.whitespace:
            i = i + 1
        else:
            temp = "%c" % data[i]
            ret[len(ret)] = temp
            i = i + 1
    return ret


new, stylish, brace'd python:

import string

def poopy(data)
{
    ret = {}
    i = 0
    while i < len(data)
    {
        if data[i] == '+' or data[i] == '-'
        {
            if data[i].isdigit()
            {
                i = i + 1
                temp = "%d" % data[i]
                ret[len(ret)] = temp
                while i < len(data) and data[i].isdigit()
                {
                    ret[len(ret) - 1] += data.at[i]
                    i = i + 1
                }
            }
            else
            {
                i = i + 1
                temp = "%s" % data[i]
                ret[len(ret)] = temp
            }
        }
        elif data[i].isdigit()
        {
            ret[len(ret)] = ""
            while (i < len(data)) and data[i].isdigit()
            {
                ret[len(ret)-1] = data[i]
                i = i + 1
            }
        }
        elif data[i].isalpha()
        {
            ret[len(ret)] = ""
            while i < len(data) and data[i].isalpha()
            {
                ret[len(ret)-1] += data[i]
                i = i + 1
            }
        }
        elif data[i] in string.whitespace
        {
            i = i + 1
        }
        else
        {
            temp = "%c" % data[i]
            ret[len(ret)] = temp
            i = i + 1
        }
    }
    return ret
}


I really hope someone forks the python codebase someday and adds braces, and removes that fucking whitespace bullshit...

anyway, now it's your turn!

Name: Anonymous 2010-12-19 4:35

I'll start with... C. Pretty awesome language in general, but the whole forced braces ruin it for me, so why not just use whitespace instead of braces?

Anyway, old c:
#include <stdio.h>

#define N 4
#define M 1000000

static int distinct_factor_count(unsigned n);

int main(void)
{
  unsigned i, j = 0;
  for (i = 2; i < M && j < N; i++) {
    for (j = 0; j < N && distinct_factor_count(i+j) == 4; j++)
      ;
  }
  printf("%u\n", i-1);

  return 0;
}

int distinct_factor_count(unsigned n)
{
  unsigned count = 0;
  unsigned i;
  for (i = 2; i <= n; i++) {
    if (n % i == 0) {
      count++;
      n /= i;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  return count;
}


new, stylish, withspace'd c:

#include <stdio.h>

#define N 4
#define M 1000000

static int distinct_factor_count(unsigned n);

int main(void):
  unsigned i, j = 0;
  for (i = 2; i < M && j < N; i++):
    for (j = 0; j < N && distinct_factor_count(i+j) == 4; j++):
      ;
  printf("%u\n", i-1);
  return 0;

int distinct_factor_count(unsigned n):
  unsigned count = 0;
  unsigned i;
  for (i = 2; i <= n; i++):
    if (n % i == 0):
      count++;
      n /= i;
      while (n % i == 0):
        n /= i;
  return count;



I really hope someone forks the c codebase someday and adds FIOC, and removes that fucking braces bullshit...

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