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...

Name: Anonymous 2010-12-19 6:36

>>22
oh you

Name: Anonymous 2010-12-19 7:24

>>22
say, why are you choking on that phalloid object in your mouth so much?

also, semi-colons in a FIOC. huarhuarhuar

... anyway, let's just ignore >>22-san, and continue the thread with ontopic stuff:

since Lua has pcall() anyway, which is used to execute a function 'safely', why not just add try .. catch in the first place?

old code:

    local status, err = pcall(function () error({code=121}) end)
    print(err.code)  -->  121


new code:

    try
        error({code=121})
    catch err, status
        print(err.code)
    end


actually, there is a patch for it, but it never made it into the main source. :(

Name: Anonymous 2010-12-19 10:15

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

Anyway, old Lisp:
(defun factorial (n)
   (if (<= n 1)
       1
       (* n (factorial (- n 1)))))


new, stylish, FIOC'd Lisp:
defun factorial n
  if <= n 1
    1
    * n
       factorial
         - n 1

Name: Anonymous 2010-12-19 10:17

>>22
YHBT

Name: Anonymous 2010-12-19 11:14

>>22
EPIC WIN

Name: Anonymous 2010-12-19 12:08

>>25
Because programs are represented as lists, and that is the read syntax for lists in Lisp. Lose that and you lose most of what makes Lisp interesting.
If you really can't get over it, then there's always Dylan.

Name: Anonymous 2010-12-19 12:14

>>28
Your Asperger's is showing.

Name: 2010-12-19 18:43

Name: Anonymous 2010-12-19 20:32

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

Anyway, old Whitespace:












new, stylish, empty Whitespace:

Name: Anonymous 2010-12-19 20:58

I'll start with... Haskell. Pretty awesome language in general, but the whole HAKSAL ruins it for me, so why not just use VUISALBACISICS instead?

Anyway, old HAKSAL:

module Main where

main = putStrLn "Hello, World!"


new, stylish, ENTERPRISE'd HAKSAL:

Imports System

Public Module modmain
   Sub Main()
     Console.WriteLine ("Hello, World!")
   End Sub
End Module

Name: Anonymous 2010-12-19 21:03

I'll start with... PUDDI. Pretty awesome language in general, but the whole PUDDI ruins it for me, so why not just use PUDDI instead?

Anyway, old PUDDI:

PUDDI


New, stylish, PUDDI'd PUDDI:
[code]
PUDDI
[code]

Name: Anonymous 2010-12-23 17:37

Name: Anonymous 2013-01-19 23:18

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

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