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

The /prog/matic programmer

Name: Anonymous 2012-09-27 15:16

ANyways, so... I was reading The Pragmatic Programmer [1] and it occurred to me that we should probably boil these principles down for the novices amongst us. ITT things you want to carve into your colleagues' faces.

* KEEP IT FUCKING SIMPLE, MOTHERFUCKER!
* You're code is not ``clever'', it is autistic.
* Code is /not/ poetry or art. Go away! Fuck your OCD.
* This shit has been solved a thousand times over.
* You do not need to design with the latest and greatest in gang-of-four approved OOP design patterns, using infinitely scalable NoSQL solutions in hip new languages that compile down to JavaScript (srsly WTF?!), just to create a CRUD application.
* Not everyone gets off on code, some of us just want to make a living doing the least amount of effort that is required to deliver a consistent quality for an extended period of time.

I swear by god if I see one more AbstractControllerFactoryInterface

[1] http://pragprog.com/the-pragmatic-programmer, easily found online.

Name: Anonymous 2013-05-16 9:03

>>120
Yes, and you originally said to not even think of using an array, while I maintain that if you don't think of using an array then you aren't approaching the problem correctly.

Name: Anonymous 2013-05-16 12:06

>>118
Well I completely missed it and now the problem doesn't seem as bad.

Name: Anonymous 2013-05-17 2:00

Well, since you don't like >>30, how about this?


(defpackage #:cudders-secret-box-of-treats
  (:use #:cl)
  (:export #:lines)
  (:shadow car cdr caar cadr cdar cddr))


(in-package #:cudders-secret-box-of-treats)


(defclass promise ()
  ((cached-value :initarg :value)
   (calculator :initarg :calculator)
   (evaluated :initform nil)))


(defmethod force ((self promise))
  (with-slots (cached-value calculator evaluated) self
    (if evaluated
      cached-value
      (progn (setf cached-value (funcall calculator))
             (setf evaluated t)
             cached-value))))

(defun make-promise (calculator)
  (make-instance 'promise :calculator calculator))

(defmacro promise (&rest body)
  `(make-promise (lambda () ,@body)))





(defmethod car ((self list))
  (cl:car self))

(defmethod cdr ((self list))
  (cl:cdr self))

;; need to redefine these so they use the new generic car and cdr.
(defun caar (list)
  (car (car list)))

(defun cadr (list)
  (car (cdr list)))

(defun cdar (list)
  (cdr (car list)))

(defun cddr (list)
  (cdr (cdr list)))



(defclass stream-cons ()
  ((car :initarg :car)
   (cdr :initarg :cdr)))

(defun stream-cons-f (car cdr)
  (make-instance 'stream-cons :car car :cdr cdr))

(defmacro stream-cons (car cdr)
  `(stream-cons-f ,car (promise ,cdr)))

(defmethod car ((self stream-cons))
  (with-slots (car) self
    car))

(defmethod cdr ((self stream-cons))
  (with-slots (cdr) self
    (force cdr)))

(defun stream-append (&rest lists)
  (cond ((null lists) nil)
        ((null (car lists)) (apply #'stream-append (cdr lists)))
        (t (stream-cons (caar lists) (apply #'stream-append (cons (cdar lists) (cdr lists)))))))

(defun for-each (fn list)
  (if (null list)
    nil
    (progn (funcall fn (car list))
           (for-each fn (cdr list)))))


(defun number-lines-stream-list (list)
  (labels ((start-line (line-number list)
             (stream-append (coerce (write-to-string line-number) 'list)
                            (stream-cons #\space
                                         (non-start-line line-number list))))
           (non-start-line (line-number list)
             (cond ((null list) nil)
                   ((eq (car list) #\newline) (stream-cons #\newline (start-line (1+ line-number) (cdr list))))
                   (t (stream-cons (car list) (non-start-line line-number (cdr list)))))))
    (start-line 1 list)))

(defun stream->char-stream-cons (stream)
  (let ((c (read-char stream nil 'eof)))
    (if (eq c 'eof)
      nil
      (stream-cons c (stream->char-stream-cons stream)))))




(defun main (file-name)
  (with-open-file (input file-name)
    (for-each #'write-char (number-lines-stream-list (stream->char-stream-cons input)))))

(main "data.tt")

Name: >>123 2013-05-17 2:03

ignore that export. also 123 get

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-05-17 3:01

>>121
You do not need to use an array to solve this problem, thus you should not think of using one.

>>123
Congratulations, you have managed to write a Lisp solution that takes more lines than the C one. FAIL.

Name: Anonymous 2013-05-17 3:18

>>125
FAIL

>LELLELELELEEEEEEEEEEEEEEEEEEELL
>LE FAIL FOR DA E/G/IN /G/IN /G/RO
>LELELLE LE EGIN  FAIL MEME
>LELELEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE GRO

Name: Anonymous 2013-05-17 4:12

>>121
Don't think, feel, and you will be tanasinn.

Name: Anonymous 2013-05-17 4:18

>>127
[aa]
      ____
     /∵∴∵∴\
    /∵∴/∴∵\\
   /∵∴●∴∴.● |   
   |∵∵∵/ ●\∵|    only yahew can great tanasinn
   |∵∵ /三 | 三| |  
   |∵∵ |\_|_/| | 
    \∵ | \__ノ .|/ 
   / \|___/\
[/a]

Name: Anonymous 2013-05-17 4:53

Name: Anonymous 2013-05-17 5:22

>>129
What the fuck are you doing? Go back to whatever shit board you came from. Your not wanted here goyim. I knew Judas should of killed Jesus earlier, so Christian scum like this one could never be born.

Name: Anonymous 2013-05-17 7:08

>>125
Bullshit. Good I/O uses buffers, therefore if I think about using good I/O I think about using arrays. If you want to say "Don't use realloc or critical section malloc" or whatever, say it. Don't pretend arrays are something they aren't.

Name: Anonymous 2013-05-17 10:57

>>130
You can go with him; you're not welcome here either.

Name: Anonymous 2013-05-17 15:50

>>113
MSVCRT's default buffer is 4K
not my msvcrt!

Name: Anonymous 2013-05-17 16:04

None of you are fucking welcome here because you keep posting bad programming that keeps making the e/a/in /a/roski imagefaggot post here.
Fucking stop.

Name: Anonymous 2013-05-17 16:44

>>134
LLLLLLLLLLEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
>LE EGIN BUTTHURT FACE

Name: Anonymous 2013-05-17 20:11

Yes, let the lel flow through you.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-05-19 7:53

>>131
Buffers of fixed-length, buffers that you shouldn't need to think about.

Name: Anonymous 2013-05-19 14:01

>>137
Bullshit. Now you're trying to claim that people don't think about buffers when writing I/O.  Just admit that your 'no thinking about arrays' statement was poorly worded.

Name: Anonymous 2013-05-19 17:52

>>134
Who's the e/a/in /a/roski here? I only see lel-cunt, Cudder, and that guy who's in love with Cudder.

Name: Anonymous 2013-05-19 22:12

#include <stdio.h>

int main()
{
    unsigned char s;
    char c;
    unsigned long n;

    s = 1;
    n = 1;

    while ((c = getchar()) != EOF) {
        if (s)
            printf("%lu\t", n++);

        putchar(c);

        s = (c == '\n');
    }

    return fflush(stdout) || ferror(stdin);
}

Name: Anonymous 2013-05-19 22:24

>>139
der shudderspace is the e/a/in /a/roski, if you don't know that then you've been here less than two weeks.

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