Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Mon Mar 24, 2008 11:52 pm UTC

Without any testing whatsoever, I'm guessing it's similar to the distinction that Lisp makes between functions and special forms. Perhaps control structures require the parentheses delimiters for some reason. Why does it make this distinction? Who knows? I don't think there's any reason to remove the parens anyway, so shrug.

As for the lack of escaping, screw them. I hate that crap (the lack of appropriate escaping). It's not hard at all.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Tue Mar 25, 2008 12:02 pm UTC

Dear Web Designers:
Before handing horrible prototype HTML to your actual developers and saying "MAKE THIS A WEBSITE!" please make sure your HTML works in all browsers.

Example: I'm being contracted to PHPify a webpage. In addition to being a crufty pile of non-compliant broken shit, the HTML doesn't work in IE. I didn't know this, because I develop on Linux. I figured that, you know, it works. Because it was given to me and I was told "this works. Make it dynamic".

Now I'm getting bitched at because my shit has rendering glitches in IE.

H.A.T.E.
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
Arancaytar
Posts: 1642
Joined: Thu Mar 15, 2007 12:54 am UTC
Location: 52.44°N, 13.55°E
Contact:

Re: Coding: Fleeting Thoughts

Postby Arancaytar » Tue Mar 25, 2008 1:05 pm UTC

photosinensis wrote:While adding two randomly generated integer matrices of size 16834 * 16834:

"Damn, this is taking a long time."

I looked, and sure enough, I was doing a crapload of disk swapping. Too bad I've only got 2 GB of memory on that machine. The code didn't finish running before I had to pack up the laptop and run, though.


A long time usually occurs only if you're storing milliseconds rather than seconds. Otherwise an int suffices.

(Sorry.)
"You cannot dual-wield the sharks. One is enough." -Our DM.
Image

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: Coding: Fleeting Thoughts

Postby Sc4Freak » Tue Mar 25, 2008 10:43 pm UTC

Arancaytar wrote:
photosinensis wrote:While adding two randomly generated integer matrices of size 16834 * 16834:

"Damn, this is taking a long time."

I looked, and sure enough, I was doing a crapload of disk swapping. Too bad I've only got 2 GB of memory on that machine. The code didn't finish running before I had to pack up the laptop and run, though.


A long time usually occurs only if you're storing milliseconds rather than seconds. Otherwise an int suffices.

(Sorry.)

Ah, but in the world of Microsoft, long int == int. :P

User avatar
LDJosh
Posts: 242
Joined: Fri Oct 26, 2007 6:07 pm UTC
Location: South Central, PA
Contact:

Job opening, Hanover, PA - PHP / MySQL developer

Postby LDJosh » Thu Mar 27, 2008 1:27 pm UTC

Hey all.
A few weeks ago, a Programmer left the company I work at. It's in HANOVER, PA, USA, it's an 89 year old company with a large inhouse IT department. We're interviewing next week for replacements for him, so if you've got an PHP / MySQL experience (especially SMARTY templates, since he worked with those a lot. ew.) toss me a PM with your resume and i'll add it to the list.

Right now, we've been taking resumes for 3 weeks,and we've only got 2 interviews set up. and one of them doesn't have any php experience...

salary job, full benefits, and relaxed work environment (i'm on here all day, aren't i?)
--------
~Lameduck Josh
ninjajosh.com

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Thu Mar 27, 2008 3:40 pm UTC

Any possibility of long-distance working? I've built up quite a bit of php and mysql experience, but I'm down South and wouldn't want to move.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

communism
Posts: 4
Joined: Fri Mar 28, 2008 6:08 pm UTC

Python/Perl coders wanted

Postby communism » Fri Mar 28, 2008 8:48 pm UTC

Though my post count isn't > 5, I know, I want to go ahead and post this and get it out of the way. I'm not a computer program or a spammer, I promise :D

Two of us (me and someone else) have been working on a program called sifu (the name was not my choice). Basically, it's a peer-to-peer system written in combination perl and python, being currently developed on Linux (fedora 8 ), but whose target platforms include Windows, Mac OS X and Linux. The purpose of our initial implementation is to be able to share lists of online proxies, but in the future, we want to expand it to be able to share other information, and possibly files, as well.

We would really appreciate any python or perl savvy individuals who could help us put this program together. We have a google code page, and the svn repository that goes with it. You don't have to be a python or perl expert (god knows we aren't) but knowledge of either or, or better yet, both, is what we're looking for.

Please send me a PM if interested.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Sat Mar 29, 2008 6:07 am UTC

I wrote my first assembly program today! It was for an imaginary processor used only in the course book, but we'll be using the ARM assembly for the GBA later in the semester...

Incidentally, assembly is evil. It is kind of interesting, just a bit a lot tedious (finding a way to divide with only add, and, and not operators using 16bit 2s complement integers).

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Sat Mar 29, 2008 7:36 am UTC

When I wrote my first assembly program, I first wrote a custom CPU and then an assembler.
Yeah, it was pretty simple, with something like ten opcodes...
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

joeframbach
Posts: 1478
Joined: Sun Nov 05, 2006 12:49 am UTC

Re: Coding: Fleeting Thoughts

Postby joeframbach » Sat Mar 29, 2008 9:11 am UTC

Berengal wrote:When I wrote my first assembly program, I first wrote a custom CPU and then an assembler.
Yeah, it was pretty simple, with something like ten opcodes...

Ah yes, good ole Simpletron.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Sat Mar 29, 2008 12:41 pm UTC

The point was really to make a stored-program computer with variable length instructions capable of sequential execution and conditional jumps. I then found writing programs directly was sort of incredibly annoying, so I made an assembler to set all the boring bits for me. I wrote a fibonacci sequence program as a test. The fun part was when it recursed just enough so the stack overwrote part of the program, making it print 'Y' endlessly. The boring part was converting numbers to ascii strings without modulo or division...
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

qbg
Posts: 586
Joined: Tue Dec 18, 2007 3:37 pm UTC

Re: Coding: Fleeting Thoughts

Postby qbg » Sat Mar 29, 2008 4:51 pm UTC

Berengal wrote:When I wrote my first assembly program, I first wrote a custom CPU and then an assembler.
Yeah, it was pretty simple, with something like ten opcodes...

I did something similar recently. I found it surprisingly easy to program in the resulting assembly despite the fact that it only had a MOVE operation (although I cheated a bit with regards to arithmetic so I wouldn't need to have a large amount registers devoted to math operations).

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Apr 01, 2008 9:58 am UTC

*Googles LISP BNF*

Code: Select all

s_expression = atomic_symbol \
              / "(" s_expression "."s_expression ")" \
              / list

list = "(" s_expression < s_expression > ")"

atomic_symbol = letter atom_part

atom_part = empty / letter atom_part / number atom_part

letter = "a" / "b" / " ..." / "z"

number = "1" / "2" / " ..." / "9"

empty = " "

Well... okay. I can regex that...
(Making a lisp interpreter)
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Tue Apr 01, 2008 5:02 pm UTC

Berengal wrote:*Googles LISP BNF*

Code: Select all

s_expression = atomic_symbol \
              / "(" s_expression "."s_expression ")" \
              / list

list = "(" s_expression < s_expression > ")"

atomic_symbol = letter atom_part

atom_part = empty / letter atom_part / number atom_part

letter = "a" / "b" / " ..." / "z"

number = "1" / "2" / " ..." / "9"

empty = " "

Well... okay. I can regex that...
(Making a lisp interpreter)

No, no you can't. A context-free grammer is equivalent to an NPDA, which is strictly more powerful than a regex.

This sort of situation (learning what can and can't be read by a regexp) was cited in the Theory of Automata class as a good reason to take the class even if one didn't find it interesting.

You need to actually implement a parser to read that properly, which means implementing a (surprise!) Nondeterministic Pushdown Automaton.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Apr 01, 2008 5:46 pm UTC

Well, true, but I'm using regexes along with some extra states to create a rather simple parser.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Apr 01, 2008 5:50 pm UTC

I agree, but with two comments:

First, what a lot of languages and such call "regular expressions" aren't. Almost all of them are more powerful. In fact, something like "\(.*\)\1" (I'm half making up syntax here) recognizes strings of the form ss, which isn't even context-free. Once you have backreferences, you're more than a regular expression. But they are still universally referred to as such. (I would hazard a guess that most CS people and programmers hear "regex" used to refer to things that aren't more than they do things that are.) That said, I don't know a way even with more-than-regular regular expressions to accept the language of balanced parentheses.

Second, you may be able to get away with a DPDA instead of an NPDA.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Apr 01, 2008 6:44 pm UTC

It doesn't take much to do the balanced parens, even though they're not doable with pure regexes. Simply use two different symbols for parens, one representing outer paren, one inner paren. Apply the transforming function (simple paren counter function with if unmatchedParens == 0: replaceParen(outerParenSymbol)) to the original string, regex the groups out of it and recurse as needed.

Of course, it's probably easy to do without regexes as well. Just build lists of atoms, and whenever a paren is encountered, recurse on the string up to the matching paren and add the resulting list. I'm still in the "experimenting in python interpreter" stage as far as the parser goes, so I've not decided on which approach to use yet.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: Coding: Fleeting Thoughts

Postby Rysto » Tue Apr 01, 2008 7:07 pm UTC

I really question why on earth you'd want to ad-hoc a parsing method like that when parser generators are simple and efficient to use.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Apr 01, 2008 7:52 pm UTC

I don't know how to use parse generators, maybe? Oh, I will probably learn to use them sometime in the future, but right now I bet I could make a parses that parses LISP faster and less painfully than I could learn to use a parse generator and use that to make a LISP parser.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: Coding: Fleeting Thoughts

Postby mrkite » Tue Apr 01, 2008 9:23 pm UTC

Rysto wrote:I really question why on earth you'd want to ad-hoc a parsing method like that when parser generators are simple and efficient to use.


I wouldn't call them simple. Anyone who's ever used yacc or bison knows the dreaded shift/reduce conflicts.

qbg
Posts: 586
Joined: Tue Dec 18, 2007 3:37 pm UTC

Re: Coding: Fleeting Thoughts

Postby qbg » Tue Apr 01, 2008 9:48 pm UTC

Berengal wrote:I don't know how to use parse generators, maybe? Oh, I will probably learn to use them sometime in the future, but right now I bet I could make a parses that parses LISP faster and less painfully than I could learn to use a parse generator and use that to make a LISP parser.

Maybe, just maybe you want to take a look at the reader algorithm in Common Lisp. Might be overkill for what you want though...

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: Coding: Fleeting Thoughts

Postby Rysto » Tue Apr 01, 2008 10:45 pm UTC

mrkite wrote:I wouldn't call them simple. Anyone who's ever used yacc or bison knows the dreaded shift/reduce conflicts.

I'd consider that more of a failing of bison/yacc than of parser generators in general. I've written a parser generator myself, and if it hits any conflicts, it prints out the shortest string that demonstrates the ambiguity. In most of the conflicts I've see, this gives enough information to find and correct the problem. Here's an example from a C grammar that has the standard if if else ambiguity:

Code: Select all

249 productions, 91 non-terminals and 90 terminals
Giving a total of 1922 unique parse states
Error in state 131
Lookahead: [ELSE]
        Actions: Reduce selection_statement --> IF OPEN_P expression CLOSE_P statement
                 Shift 163
        Shortest path to conflict:
        declaration_specifiers declarator optional_declaration_list OPEN_B DO IF OPEN_P expression CLOSE_P IF OPEN_P expression CLOSE_P statement
Error in state 884
Lookahead: [ELSE]
        Actions: Shift 27
                 Reduce selection_statement --> IF OPEN_P expression CLOSE_P statement
        Shortest path to conflict:
        declaration_specifiers declarator optional_declaration_list OPEN_B IF OPEN_P expression CLOSE_P IF OPEN_P expression CLOSE_P statement


It's far from perfect but it at least gives you a starting point. And this is something that I threw together in about half of an hour -- it's a trivial application of Dijkstra's algorithm. If I have some time this summer I might look into ways of improving the error messages you get.

Anyway, it should be dead simple to get your hands on a LALR grammar for Lisp, so this discussion is a digression.

TraumaPony
Posts: 5
Joined: Tue Jan 15, 2008 9:44 am UTC
Location: QUT, Brisbane.
Contact:

Re: Coding: Fleeting Thoughts

Postby TraumaPony » Wed Apr 02, 2008 3:28 am UTC

wing wrote:Dear Web Designers:
Before handing horrible prototype HTML to your actual developers and saying "MAKE THIS A WEBSITE!" please make sure your HTML works in all browsers.

Example: I'm being contracted to PHPify a webpage. In addition to being a crufty pile of non-compliant broken shit, the HTML doesn't work in IE. I didn't know this, because I develop on Linux. I figured that, you know, it works. Because it was given to me and I was told "this works. Make it dynamic".

Now I'm getting bitched at because my shit has rendering glitches in IE.

H.A.T.E.


Why didn't you test it at least once in IE?

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Wed Apr 02, 2008 4:26 am UTC

TraumaPony wrote:
wing wrote:Dear Web Designers:
Before handing horrible prototype HTML to your actual developers and saying "MAKE THIS A WEBSITE!" please make sure your HTML works in all browsers.

Example: I'm being contracted to PHPify a webpage. In addition to being a crufty pile of non-compliant broken shit, the HTML doesn't work in IE. I didn't know this, because I develop on Linux. I figured that, you know, it works. Because it was given to me and I was told "this works. Make it dynamic".

Now I'm getting bitched at because my shit has rendering glitches in IE.

H.A.T.E.


Why didn't you test it at least once in IE?

Because I develop on a Linux system and all my Windows boxes are down.
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Sat Apr 05, 2008 11:38 am UTC

I had just written this:

Code: Select all

   private boolean listIsSorted() {

      // empty list
      [snip]
      
      // single element
      [snip]

      // more elements
      [snip]
   }

Then I took some time off to explore the interweb and encountered the concept of "Two is not a number. The only valid numbers are zero, one and infinity", and I realized how true this is. I then remembered my code, and realized that I had already realized this without realizing it.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

masher
Posts: 821
Joined: Tue Oct 23, 2007 11:07 pm UTC
Location: Melbourne, Australia

Re: Coding: Fleeting Thoughts

Postby masher » Thu Apr 10, 2008 11:58 pm UTC

I just realised how much good regexes can do.


I had a 13242 line input file for one of my programs. Sprinkled liberally throughout the file were the lines:

Out_Quant(outFileName, -1, -1, csanal1_##,-1,OW_occ_anal_##)
Out_Quant(outFileName, -1, -1, csanal2_##,-1,OW_occ_anal_##)

where ## is a number from 32 to 120

Search:
Out_Quant\(outFileName\, -1\, -1\, csanal([1|2])_([0-9]*)

Replace:
Out_Quant_surface\(outQuantDataFileName\, filename_$2\, seqno_$2\, -1\, -1\, csanal$1_$2

turned them all into:
Out_Quant_surface(outQuantDataFileName, filename_##, seqno_##, -1, -1, csanal1_##,-1,OW_occ_anal_##)
Out_Quant_surface(outQuantDataFileName, filename_##, seqno_##, -1, -1, csanal2_##,-1,OW_occ_anal_##)


yay for regex. A half-hour by hand turned into a 2 min test and 0.5242 s implementation!

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: Coding: Fleeting Thoughts

Postby '; DROP DATABASE;-- » Sun Apr 13, 2008 6:51 am UTC

Xeio wrote:Incidentally, assembly is evil.
If by evil you mean fun. :D
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

btilly
Posts: 1877
Joined: Tue Nov 06, 2007 7:08 pm UTC

Re: Coding: Fleeting Thoughts

Postby btilly » Sun Apr 13, 2008 8:48 am UTC

EvanED wrote:First, what a lot of languages and such call "regular expressions" aren't. Almost all of them are more powerful. In fact, something like "\(.*\)\1" (I'm half making up syntax here) recognizes strings of the form ss, which isn't even context-free. Once you have backreferences, you're more than a regular expression. But they are still universally referred to as such. (I would hazard a guess that most CS people and programmers hear "regex" used to refer to things that aren't more than they do things that are.) That said, I don't know a way even with more-than-regular regular expressions to accept the language of balanced parentheses.

It has been possible in Perl for several years now. See http://perldoc.perl.org/perlfaq6.html#C ... ed-text%3f for proof. It is now easier in Perl 5.10, see http://search.cpan.org/dist/perl-5.10.0 ... xpressions for details.

wing wrote:
TraumaPony wrote:Why didn't you test it at least once in IE?

Because I develop on a Linux system and all my Windows boxes are down.

http://www.tatanka.com.br/ies4linux/page/Main_Page may be of great assistance to you in avoiding this problem in the future.
Some of us exist to find out what can and can't be done.

Others exist to hold the beer.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Mon Apr 14, 2008 1:16 am UTC

'; DROP DATABASE;-- wrote:
Xeio wrote:Incidentally, assembly is evil.
If by evil you mean fun. :D


You can be both. :wink:

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: Coding: Fleeting Thoughts

Postby '; DROP DATABASE;-- » Tue Apr 15, 2008 2:17 am UTC

Touché.
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

User avatar
Toeofdoom
The (Male) Skeleton Guitarist
Posts: 3446
Joined: Wed Jan 10, 2007 10:06 am UTC
Location: Melbourne, Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby Toeofdoom » Tue Apr 15, 2008 6:54 pm UTC

Yay for staying up until 4 am coding html and css. I mean, it was a group assignment... with the html being the group part, but I ended up doing practically all of that myself...

the css being our individual part looks pretty cool for my one.

EDIT: I had seen another group members CSS and it was pretty cool, and had a colour scheme and stuff. Now the guy whos been working on his css for ages now, well, all the other files are finalised, as soon as he's done he'll submit it.

I just asked to see his css.

When I saw it, I cracked up laughing so goddamn hard. Funniest shit I've seen all week. Now that I look at it again, it kinda has a colour scheme but basically, the design is O.O wtf.
Hawknc wrote:Gotta love our political choices here - you can pick the unionised socially conservative party, or the free-market even more socially conservative party. Oh who to vote for…I don't know, I think I'll just flip a coin and hope it explodes and kills me.

Website

User avatar
bridge
Posts: 195
Joined: Sun Feb 03, 2008 2:24 pm UTC
Location: Zurich < x < Rome

Re: Coding: Fleeting Thoughts

Postby bridge » Tue Apr 15, 2008 7:19 pm UTC

wing wrote:Sometimes I wish someone would write quick reference cards for different languages syntaxes.

i whished it too, and i found
The cheatsheet database
Excuse my Super Mario accent

User avatar
ash.gti
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Coding: Fleeting Thoughts

Postby ash.gti » Tue Apr 15, 2008 8:40 pm UTC

wing wrote:Because I develop on a Linux system and all my Windows boxes are down.


I gave up on letting just about everyone I know that thinks they know CSS do any templating. In almost 100% of the cases I have to re-write over half of it anyways.

also check IE4Linux out. You *MIGHT* find it useful. It works fine for me for IE6. Haven't tried their hack for IE7 though.

http://www.tatanka.com.br/ies4linux/page/Installation

It even works on OS X, which is nice. Although, I use a VM to run Windows (I have one with IE6 and another with IE7).
# drinks WAY to much espresso

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Apr 29, 2008 3:17 pm UTC

Frustrated rant:
Spoiler:
They give me idiots to work with! The first idiot seemed okay at first. At least he was the kind of idiot who knew what he was talking about, so I could actually hold a conversation with him about the program we were making. What made him an idiot? "It's all just bits and bytes anyway, so why can we program this in assembly? Who needs patterns anyway?" He was tasked with making a class somewhat similar to another class I had already made for a previous assignment which this was built upon. I had made an interface that made perfect sense to use, but what did he do? He subclassed my class, COPY-PASTED EVERYTHING and changed five lines! HE COPY-PASTED THE ENTIRE SUPERCLASS INTO HIS SUBCLASS! Oh, and when did he do this? At 4am the night before it was due. The Main class, which had originally just contained a single 20-line main function, which was what the first assignment required, had grown to a beast as I had filled it with simple, basic test code to singularly test the parts I had written. This assignment couldn't be reduced to a such a simple main-function anyway, and would have to be rewritten. The code was littered with statements such as "//TODO: This is a load of quick hacks to test my code in an environment containing everything. WHEN YOU FINISH YOUR PART, WE SHOULD REWRITE THIS!" Of course, he never finished his part in time for us to work together on making the main function function, but when we met up, one hour before the deadline, his first words were "Hi, I've been having some trouble integrating my parts with this..." "Well, you didn't rewrite it?" "Rewrite? We should do that?" Every tenth line was "//XXX: REWRITE THIS CLASS! DON'T EVER USE IT! I'M JUST WAITING FOR YOU TO FINISH!" Of course, the easy rewrite wasn't as easy as I had anticipated. He had used absolutely none of my interfaces, and the little that he had done was done in a completely incompatible way with the interfaces. That is, where he actually made his own classes. Where my classes checked their return-values for validity before returning, his relied on the calling code to check the validity, and if necessary call the code again. We had one hour to integrate his work into my horrible, unreliable test-code. When I pointed out to him that instead of spending three hours trying to find a way to integrate his stuff into my test-beast, he should have just rewritten it like it said he should in the comments, his reaction was "Huh? Comments? Oh, right, the multitude of '//HACK: REWRITE' that has overrun the code. I didn't realize you meant I should rewrite it." Oh, and as for his comments? I found two: In the subclassed copy-pasted class he wrote "// This is the new part" followed by the five lines he added. On top of it, below the "/* This class written by $ME*/" he had appended "/* And then modified by $IDIOT */". His other class, the completely incompatible one, had no comments at all.

Now the second idiot. I haven't had the chance to fully explore her level of intelligence, but what I've seen thus far has been less than promising. This assignment is all about GUI. I had to explain to her, at length, why our previous Main classes were now void, as the logic would have to be taken care of in a completely different fashion. Also, when comparing our previous assignments, hers had five times as many classes and twice as many packages as mine. I would be hard-pressed to find a way to make more classes in my assignment, but it seems she and her previous partner had found the perfect way of generating lots of classes: Let all functions take a single argument, and let that argument be an object of a class that is only used for this function. Then let's overload the function with different argument types, so we can make a new class for each and every default argument we want. Worse, they didn't actually have to overload functions as all default argument classes inherited from the original argument class for that function. They apparantly had to anyway so they could copy-paste the code from the original function, but replace the argument unpacking with the already-known default values hardcoded into the function, making the default values set in the constructor of the subclassed argument class completely void. Also, on which universe is it necessary to prefix each and every class with some inconsistent abbreviation of the application name and the packages it is in? (I realize a simple prefix for library classes might be useful, such as "J" in swing, but this?) There's also "What does 'mainloop: do {' do? (Named breaks were necessary in our beast of a main function. They were the solution to problems caused by the even bigger problem of the entire class). Oh, and 'I made the Board class iterable, so it's easy to iterate through every piece.' 'Huh?' 'I implemented an iterator.' 'Huh?'

I must say I'm looking forward to a career in programming. There's no ego-boost like it :D

tl;dr: *facepalm*

Edit:
Spoiler:
Now I've delved somewhat into my lastest project partner's previous code, I've found several new design patterns I've been completely oblivious to. Let me introduce you to what I've dubbed the "Grep traceback debugging pattern":

Code: Select all

Error on writing: java.io.FileNotFoundException: [filepath]

This was written when I tried to run their program. Now, I could click on the java.io.FileNotFoundException, but no traceback was contained so a simple breakpoint dialog box popped up instead of bringing me to the faulty code like tracebacks in Eclipse normally do. I had to resort to a global search to find the exit point. Thankfully they seem to be the anal retentive sort, inserting their own helpful error messages everywhere, so a simple search for "Error on writing:" did the trick. I found this:

Code: Select all

         }catch (IOException exception) {
            System.out.print("Error on writing: " + exception);
            // Aborts if IO-exception occurs.
            System.exit(1);
         }

If that were just a simple System.out.print(exception), I would've been very angry. Oh, and that is one of their better comments as well. About half the code is commented (since they were two working on it, I guess only one did comments beside javadocs, which aren't any better). About 90% of them are of the "// Set player to null" variety.

As for the error? She told me about having some trouble with that, and that they never seemed to be able to solve it. Sometimes it just worked though, probably because a file with the name they were using somehow had been created earlier in development and they never got rid of it. The program then had an existing file they could happily override, and didn't complain. What troubles me is they never figured out how to "if (!file.exists())file.createNewFile();"

This will be fun. And I hope my new friend isn't reading this.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Shai
Posts: 86
Joined: Wed Dec 12, 2007 2:59 am UTC
Location: Guelph, Ontario, Canada
Contact:

Re: Coding: Fleeting Thoughts

Postby Shai » Wed Apr 30, 2008 12:33 pm UTC

Berengal: Sounds REALLY frustrating. I consider myself lucky that I was generally in good teams in my undergrad career. We actually spent time arguing about how it should be designed, rather than having a design and ignoring it. In my grad career, though, I've had some frustrations. I had created a string comparison interface, and implemented a couple of string comparison algorithms (it's not trivial when comparing dna sequences :P), AND made a working driver/main file AND threw a gui on it. My partners job was to implement two other string comparison algorithms. He eventually came to me with the algorithms on paper asking me to explain them to him. So I learned his stuff, tried to explain it to him, ended up coding the damned thing myself.

So then we got onto the paper portion. His job was to explain how his algorithms were supposed to work. I wrote most of the rest of the paper. He copy and pasted his part, out of a PDF of a PPT he found online, without even referencing the PDF. This is wrong on SO many levels. If you're going to cheat, you should at least cheat off of a GOOD source, not a freakin' presentation you found online. He COPY and PASTED it. *twitches* And this is GRAD SCHOOL. *twitch twitch* And it was one of the top hits on Google!! *twitch*
I blame lag.

User avatar
evilbeanfiend
Posts: 2650
Joined: Tue Mar 13, 2007 7:05 am UTC
Location: the old world

Re: Coding: Fleeting Thoughts

Postby evilbeanfiend » Wed Apr 30, 2008 12:44 pm UTC

Berengal wrote:I don't know how to use parse generators, maybe? Oh, I will probably learn to use them sometime in the future, but right now I bet I could make a parses that parses LISP faster and less painfully than I could learn to use a parse generator and use that to make a LISP parser.


especially if you do it in lisp

Code: Select all

(eval script)
;) but yes its worth looking at parser generators at some point
in ur beanz makin u eveel

Posi
Posts: 111
Joined: Mon Jul 16, 2007 6:08 am UTC

Re: Coding: Fleeting Thoughts

Postby Posi » Thu May 01, 2008 8:02 am UTC

Berengal wrote:Frustrated rant:
Spoiler:
They give me idiots to work with! The first idiot seemed okay at first. At least he was the kind of idiot who knew what he was talking about, so I could actually hold a conversation with him about the program we were making. What made him an idiot? "It's all just bits and bytes anyway, so why can we program this in assembly? Who needs patterns anyway?" He was tasked with making a class somewhat similar to another class I had already made for a previous assignment which this was built upon. I had made an interface that made perfect sense to use, but what did he do? He subclassed my class, COPY-PASTED EVERYTHING and changed five lines! HE COPY-PASTED THE ENTIRE SUPERCLASS INTO HIS SUBCLASS! Oh, and when did he do this? At 4am the night before it was due. The Main class, which had originally just contained a single 20-line main function, which was what the first assignment required, had grown to a beast as I had filled it with simple, basic test code to singularly test the parts I had written. This assignment couldn't be reduced to a such a simple main-function anyway, and would have to be rewritten. The code was littered with statements such as "//TODO: This is a load of quick hacks to test my code in an environment containing everything. WHEN YOU FINISH YOUR PART, WE SHOULD REWRITE THIS!" Of course, he never finished his part in time for us to work together on making the main function function, but when we met up, one hour before the deadline, his first words were "Hi, I've been having some trouble integrating my parts with this..." "Well, you didn't rewrite it?" "Rewrite? We should do that?" Every tenth line was "//XXX: REWRITE THIS CLASS! DON'T EVER USE IT! I'M JUST WAITING FOR YOU TO FINISH!" Of course, the easy rewrite wasn't as easy as I had anticipated. He had used absolutely none of my interfaces, and the little that he had done was done in a completely incompatible way with the interfaces. That is, where he actually made his own classes. Where my classes checked their return-values for validity before returning, his relied on the calling code to check the validity, and if necessary call the code again. We had one hour to integrate his work into my horrible, unreliable test-code. When I pointed out to him that instead of spending three hours trying to find a way to integrate his stuff into my test-beast, he should have just rewritten it like it said he should in the comments, his reaction was "Huh? Comments? Oh, right, the multitude of '//HACK: REWRITE' that has overrun the code. I didn't realize you meant I should rewrite it." Oh, and as for his comments? I found two: In the subclassed copy-pasted class he wrote "// This is the new part" followed by the five lines he added. On top of it, below the "/* This class written by $ME*/" he had appended "/* And then modified by $IDIOT */". His other class, the completely incompatible one, had no comments at all.

Now the second idiot. I haven't had the chance to fully explore her level of intelligence, but what I've seen thus far has been less than promising. This assignment is all about GUI. I had to explain to her, at length, why our previous Main classes were now void, as the logic would have to be taken care of in a completely different fashion. Also, when comparing our previous assignments, hers had five times as many classes and twice as many packages as mine. I would be hard-pressed to find a way to make more classes in my assignment, but it seems she and her previous partner had found the perfect way of generating lots of classes: Let all functions take a single argument, and let that argument be an object of a class that is only used for this function. Then let's overload the function with different argument types, so we can make a new class for each and every default argument we want. Worse, they didn't actually have to overload functions as all default argument classes inherited from the original argument class for that function. They apparantly had to anyway so they could copy-paste the code from the original function, but replace the argument unpacking with the already-known default values hardcoded into the function, making the default values set in the constructor of the subclassed argument class completely void. Also, on which universe is it necessary to prefix each and every class with some inconsistent abbreviation of the application name and the packages it is in? (I realize a simple prefix for library classes might be useful, such as "J" in swing, but this?) There's also "What does 'mainloop: do {' do? (Named breaks were necessary in our beast of a main function. They were the solution to problems caused by the even bigger problem of the entire class). Oh, and 'I made the Board class iterable, so it's easy to iterate through every piece.' 'Huh?' 'I implemented an iterator.' 'Huh?'

I must say I'm looking forward to a career in programming. There's no ego-boost like it :D

tl;dr: *facepalm*

Edit:
Spoiler:
Now I've delved somewhat into my lastest project partner's previous code, I've found several new design patterns I've been completely oblivious to. Let me introduce you to what I've dubbed the "Grep traceback debugging pattern":

Code: Select all

Error on writing: java.io.FileNotFoundException: [filepath]

This was written when I tried to run their program. Now, I could click on the java.io.FileNotFoundException, but no traceback was contained so a simple breakpoint dialog box popped up instead of bringing me to the faulty code like tracebacks in Eclipse normally do. I had to resort to a global search to find the exit point. Thankfully they seem to be the anal retentive sort, inserting their own helpful error messages everywhere, so a simple search for "Error on writing:" did the trick. I found this:

Code: Select all

         }catch (IOException exception) {
            System.out.print("Error on writing: " + exception);
            // Aborts if IO-exception occurs.
            System.exit(1);
         }

If that were just a simple System.out.print(exception), I would've been very angry. Oh, and that is one of their better comments as well. About half the code is commented (since they were two working on it, I guess only one did comments beside javadocs, which aren't any better). About 90% of them are of the "// Set player to null" variety.

As for the error? She told me about having some trouble with that, and that they never seemed to be able to solve it. Sometimes it just worked though, probably because a file with the name they were using somehow had been created earlier in development and they never got rid of it. The program then had an existing file they could happily override, and didn't complain. What troubles me is they never figured out how to "if (!file.exists())file.createNewFile();"

This will be fun. And I hope my new friend isn't reading this.

Ouch, I've always been lucky enough to get either someone competent or obviously dumb enough that the other group members just plan on doing that person's work from the get go and conspire to make the idiot think he is actually contributing.

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Tue May 06, 2008 3:52 am UTC

So, I'm working on this ghetto photo gallery project - more or less just an excuse to exercise my JSP and Servlets while I'm professionally stuck in the cruddy world of PHPhail.

It actually does serve a need - I am utterly unimpressed by all the install-on-your-own-server image galleries, and I am not about to go anywhere fucking near a third party server with a lot of my images (I value my privacy and the privacy of those people I keep images of), and every public service out there allows the "guess the image ID" vulnerability for unauthenticated users.

I made the design decision to store the binaries in the database (partially because I want to play with BLOBs, partially because it simplifies my security model).

At first, my method for dealing with the upload problem was to read the file out of the POSTdata into RAM, and then shove it directly into the DB.

This wouldn't work, because the normal request object fails miserably at multipart form data. I found a lib containing a parser for the multipart form data output from that class. That worked somewhat unreliably - I couldn't figure out why. Sometimes I'd get a good image, sometimes I'd get a corrupted image, sometimes I'd get no image at all, especially with large images, or when I was doing parallel uploads.

So I was in the debugger, and noticed this handy little counter that they added to NetBeans (I just recently updated).... A memory counter. Between Tomcat, my code, and apparently several copies of the image floating around in RAM, I was filling the JVM's memory quite nicely. Upon checking the source for this lib, I discovered that the author had do-nothing catches for OutOfMemoryException... Instead preferring to corrupt my data.

I changed approaches and now momentarily cache the image in the filesystem. At a maximum, there is now one copy in RAM. As soon as it is commited to the database, the cache is deleted.

This wouldn't have been a problem on my production server, where Tomcat's JVM instance has 11ty trillion megs of RAM allocated, but on my dev box it only gets the default 160mb.

I suppose there's now the possibility of a security compromise from the filesystem, but they'd have to know what filename to grab, and they'd have a window of a split second during the upload process to do it --- unless they can manage to preempt the uploader's thread between the end of writing and the beginning of deleting. And even then I intend to add a layer of AES encryption with temporary keys (the encrypted image is inserted to the database, and a few moments later, selected and updated) later on.

Did I mention this project is made of 100% pure, unrefined scope creep? I could probably work on this thing until the day I die and just keep gluing on more features.
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: Coding: Fleeting Thoughts

Postby '; DROP DATABASE;-- » Tue May 06, 2008 7:42 am UTC

Interesting/terrifying idea: self-modifying C. A statement that says "change this other statement to this". Something like:

Code: Select all

for(int i=0; i<5; i++)
{
   fooequalsone:
   foo = 1;
   if(i > bar) break;
   change fooequalsone foo = 0;
}

The 'change' statement would replace the first statement after the 'fooequalsone' label with 'foo = 0;', that is, changing the machine code in memory at runtime. So on subsequent iterations, foo would be set to 0 instead.

In theory, if the compiler could identify all possible statements that a given statement might get changed to, and how many instructions the longest would require, it could pad out the others with NOPs. In practice, I imagine this is nearly impossible. (And I don't want to think about the abuse, obfuscation, and bugs/general terrible code that would result from its use.) Maybe in an interpreted language, though, changing the script itself in memory.

The only real use for it would be a tiny optimization by not having to do "if(i > 0) foo = 0; else foo = 1;", i.e. removing the conditional check each iteration. For a big, time-critical loop and a complex conditional, it might make a noticeable difference. But for the most part it'd probably be useless. :P Just fun to think about. Are there any languages with self-modification support? (Excluding the ability to write to arbitrary memory and using that to manually twerk your machine code.)

</mindless sleepy babbling>
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

User avatar
rrwoods
Posts: 1509
Joined: Mon Sep 24, 2007 5:57 pm UTC
Location: US

Re: Coding: Fleeting Thoughts

Postby rrwoods » Tue May 06, 2008 3:33 pm UTC

I'm not too familiar with it, but I think Lisp has pretty heavy self-modification support.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 5 guests