Coding: Fleeting Thoughts

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

Moderators: phlip, Moderators General, Prelates

_Axle_
Posts: 253
Joined: Fri Sep 24, 2010 7:33 pm UTC

Re: Coding: Fleeting Thoughts

Postby _Axle_ » Tue Mar 22, 2011 7:05 pm UTC

Xeio wrote:Sometimes you don't realize how damn useful your IDE checking typos is until you're working with javascript and suddenly visual studio doesn't support it (not that it'd matter, because it wouldn't be an error anyway, damn you dynamic typing)...

ChecklistClearName
CheckListClearName

Doesn't help that I had find set to case insensitive...


Notepad++ would highlight both of those and treat them the same, for finding all occurrences of them. . . it was less than helpful.
Yakk wrote:Computer Science is to Programming as Materials Physics is to Structural Engineering.

User avatar
MHD
Posts: 630
Joined: Fri Mar 20, 2009 8:21 pm UTC
Location: Denmark

Re: Coding: Fleeting Thoughts

Postby MHD » Tue Mar 22, 2011 10:58 pm UTC

I have always thought of SQL pronounced as "Squirrel"... Not sure why.

In Unrelated News: I just realised how elegant haskell really is when I implemented a MT19937:

Code: Select all

mixArr a = runSTUArray mix

  where mix = do i <- newSTRef 0
                 a' <- thaw a
                 repeatM_ mM $ lfsro a' i (+ nN)
                 repeatM_ oO $ lfsro a' i (subtract oO)
 
        lfsro a' i c = do i' <- get i
                          x <- readArray a' $ c i'
                          y <- readArray a' i'
                          writeArray a' i' $ x `xor` magic y
   
        magic x = case x .&. 1 of
                       0 -> x `shiftR` 1
                       1 -> 0x8EBFD028 `xor` (x `shiftR` 1)


That is literally the entirety of the linear shift feedback register operation mapped over the entire array.
Notice how the "mix" is literally just 4 lines, and could be three if I hadn't optimized and factored out a modulo operation of "lfsro".

Also, here is the seeding code:

Code: Select all

makeArr w = runSTUArray $ newListArray (0, nN - 1) list

  where list = w : [ 0x6C078965 * (w' `xor` (w' `shiftR` 30)) | w <- list ]

That is two lines! Two lines!

Sadly the "get next Word32" code looks clunky

Code: Select all

genWord (MT i a) | i == nM = genWord $ MT 0 $ mixArr a
                 | otherwise = let r = correct (a ! i) in r `seq` (r, MT (i + 1) a)

  where correct = ixor (`shiftR` 11) >>>
                  ixor ((.&. 0x9D2C5680) . (`shiftL` 7)) >>>
                  ixor ((.&. 0xEFC60000) . (`shiftL` 15)) >>>
                  ixor (`shiftR` 18)

        ixor f = \x -> x `xor` f x
        f >>> g = \x -> g (f x)


The intent and equivalence of the correct function in there is however quite clear.
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"

User avatar
Briareos
Posts: 1940
Joined: Thu Jul 12, 2007 12:40 pm UTC
Location: Town of the Big House

Re: Coding: Fleeting Thoughts

Postby Briareos » Wed Mar 23, 2011 3:02 am UTC

FT: stackoverflow + searching for "plz" == hilarity.
Sandry wrote:Bless you, Briareos.

Blriaraisghaasghoasufdpt.
Oregonaut wrote:Briareos is my new bestest friend.

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 » Wed Mar 23, 2011 3:40 am UTC

MHD wrote:I have always thought of SQL pronounced as "Squirrel"... Not sure why.
I still pronounce it S Q L, where the hell did the e's and u come from anyway?

bytbox
Posts: 56
Joined: Wed Aug 19, 2009 5:43 am UTC

Re: Coding: Fleeting Thoughts

Postby bytbox » Wed Mar 23, 2011 4:15 am UTC

Xeio wrote:
MHD wrote:I have always thought of SQL pronounced as "Squirrel"... Not sure why.
I still pronounce it S Q L, where the hell did the e's and u come from anyway?

Agreed. The next person to call is "sequel" is getting whalloped with knuth.

Also: the PC-BSD developers really need to not have the installer paste things that look just like fatal error messages to the screen, and then leave them there for over 40 seconds while not appearing to do anything. Because most people reboot after about 20.

(Technically, it was a fatal error message - but fatal only for gpt, not for the installer itself. There was only one visible line, and no indication that the installation was going to continue.)

((Why the hell is the installer triggering gpt errors anyway? It was a "no such geometry" error - you can CHECK to make sure that doesn't happen! RARGGGHHH!!!))

</rant>

0xBADFEED
Posts: 687
Joined: Mon May 05, 2008 2:14 am UTC

Re: Coding: Fleeting Thoughts

Postby 0xBADFEED » Wed Mar 23, 2011 3:00 pm UTC

You, sir, name? wrote:Javascript is beautiful and awesome. It's such a shame it suffers from

Very poor documentation.
Very outdated documentation.
Terrible debugging capabilities.

I don't understand why this isn't a stand-alone language. If you clean out all the DOM gunk and give it access to some system calls, it could easily be a major competitor to python.

Javascript suffers from a number of semantic defects that seriously make me want to tear my hair out. The null/undefined distinction is awful. Seriously, wtf. The '==' truth-table across numbers/strings/boolean/null/undefined is similarly face-palm worthy. It doesn't have a language-level module system which means everyone rolls their own slightly different module system. And in what world is pushing a declaration out to the global scope a reasonable response to a missing 'var' keyword?

Plus lots and lots of other annoyances.

Don't get me wrong Javscript has some nice features, but I just don't think it's up to snuff for general purpose programming when compared to the other leading dynamic languages of today, e.g. Python, which is already great on all the points that you mentioned and has much cleaner language semantics on the whole I think.

I don't want to start a religious war over this, I'm just telling you why I wouldn't really consider Javascript for general purpose programming.

bytbox wrote:
Xeio wrote:
MHD wrote:I have always thought of SQL pronounced as "Squirrel"... Not sure why.
I still pronounce it S Q L, where the hell did the e's and u come from anyway?

Agreed. The next person to call is "sequel" is getting whalloped with knuth.


So sayeth Wikipedia:
Wikipedia wrote:SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. This version, initially called SEQUEL (Structured English Query Language), was designed to manipulate and retrieve data stored in IBM's original quasi-relational database management system, System R, which a group at IBM San Jose Research Laboratory had developed during the 1970s.[6] The acronym SEQUEL was later changed to SQL because "SEQUEL" was a trademark of the UK-based Hawker Siddeley aircraft company.[7]


So the "sequel" pronunciation actually predates the S-Q-L pronunciation. I say "sequel" because it's 2 syllables as opposed to 3 and rolls off the tongue more easily in a technical discussion.

bytbox
Posts: 56
Joined: Wed Aug 19, 2009 5:43 am UTC

Re: Coding: Fleeting Thoughts

Postby bytbox » Wed Mar 23, 2011 6:56 pm UTC

0xBADFEED wrote:
bytbox wrote:
Xeio wrote:
MHD wrote:I have always thought of SQL pronounced as "Squirrel"... Not sure why.
I still pronounce it S Q L, where the hell did the e's and u come from anyway?

Agreed. The next person to call is "sequel" is getting whalloped with knuth.


So sayeth Wikipedia:
Wikipedia wrote:SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. This version, initially called SEQUEL (Structured English Query Language), was designed to manipulate and retrieve data stored in IBM's original quasi-relational database management system, System R, which a group at IBM San Jose Research Laboratory had developed during the 1970s.[6] The acronym SEQUEL was later changed to SQL because "SEQUEL" was a trademark of the UK-based Hawker Siddeley aircraft company.[7]


So the "sequel" pronunciation actually predates the S-Q-L pronunciation. I say "sequel" because it's 2 syllables as opposed to 3 and rolls off the tongue more easily in a technical discussion.


"Squall" is only one syllable. (Yes, I've heard people actually say "My Squall".)

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Wed Mar 23, 2011 7:36 pm UTC

0xBADFEED wrote:
You, sir, name? wrote:Javascript is beautiful and awesome. It's such a shame it suffers from

Very poor documentation.
Very outdated documentation.
Terrible debugging capabilities.

I don't understand why this isn't a stand-alone language. If you clean out all the DOM gunk and give it access to some system calls, it could easily be a major competitor to python.

Javascript suffers from a number of semantic defects that seriously make me want to tear my hair out. The null/undefined distinction is awful. Seriously, wtf. The '==' truth-table across numbers/strings/boolean/null/undefined is similarly face-palm worthy. It doesn't have a language-level module system which means everyone rolls their own slightly different module system. And in what world is pushing a declaration out to the global scope a reasonable response to a missing 'var' keyword?

Plus lots and lots of other annoyances.

Don't get me wrong Javscript has some nice features, but I just don't think it's up to snuff for general purpose programming when compared to the other leading dynamic languages of today, e.g. Python, which is already great on all the points that you mentioned and has much cleaner language semantics on the whole I think.

I don't want to start a religious war over this, I'm just telling you why I wouldn't really consider Javascript for general purpose programming.

Javascript is surprisingly pleasant as an intermediate language, from what I have used it for so far. It has pretty clean syntax so it is easy to generate automatically. Add your own type system and suddenly most of your complaints disappear. You can eliminate one of null/undefined entirely, force (==) to be type-safe, and force everything to be lexically scoped. The module situation, I don't know enough to say. In the experimenting I have done, it works out quite nicely.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Wed Mar 23, 2011 9:59 pm UTC

http://programming-motherfucker.com/ (NSFW, mostly language, but also content that may be interpreted as subversive by bosses without a sense of humor)
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Wed Mar 23, 2011 11:29 pm UTC

Yep, I knew I would see that here. I didn't expect it to take so long though.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
Briareos
Posts: 1940
Joined: Thu Jul 12, 2007 12:40 pm UTC
Location: Town of the Big House

Re: Coding: Fleeting Thoughts

Postby Briareos » Wed Mar 23, 2011 11:32 pm UTC

I think that was at the top of Hacker News yesterday. Zed Shaw seems to get respect second only to Paul Graham over there.
Sandry wrote:Bless you, Briareos.

Blriaraisghaasghoasufdpt.
Oregonaut wrote:Briareos is my new bestest friend.

User avatar
b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Re: Coding: Fleeting Thoughts

Postby b.i.o » Thu Mar 24, 2011 4:12 am UTC

Briareos wrote:I think that was at the top of Hacker News yesterday.

Yeah. For a very long time.

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 » Thu Mar 24, 2011 9:23 pm UTC

So good rule of thumb, if you aren't ashamed of bad coding practices you used to have, you still have a lot of bad coding practices.

There is no guarantee you don't have any such practices anyway, of course.

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 » Thu Mar 24, 2011 9:42 pm UTC

What if I don't have any coding practices?
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
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Thu Mar 24, 2011 10:52 pm UTC

Obtaining the mac address of a network device that isn't connected to a network (because the computer operator needs it's mac address to connect to the network) is not an easy task. I spent a good hour trying to figure out how, wandering aimlessly in a maze of user friendly dialogues and helpful guides.

In the end, I just rebooted into linux, typed "ifconfig wlan0 up; ifconfig wlan0", and that was that.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

Lanzaa
Posts: 33
Joined: Fri Apr 06, 2007 6:24 am UTC

Re: Coding: Fleeting Thoughts

Postby Lanzaa » Fri Mar 25, 2011 12:03 am UTC

You, sir, name? wrote:In the end, I just rebooted into linux, typed "ifconfig wlan0 up; ifconfig wlan0", and that was that.


You could just run "ifconfig wlan0" without putting it up first. Also, if you are on windows I would give "ipconfig /all" a try. If you run that from the windows cmd prompt you may find the MAC. Oh, and switch to linux full time. ;)

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Fri Mar 25, 2011 12:10 am UTC

Lanzaa wrote:Also, if you are on windows I would give "ipconfig /all" a try. If you run that from the windows cmd prompt you may find the MAC.

Nope, if you're not connected to a wireless network, your wireless card doesn't even appear in an ipconfig /all listing. Back when I was using MAC filtering for my home wifi, whenever someone visited, the only way I could figure out how to set it up was to temporarily disable the filtering, let them connect, then get their MAC address, and reenable filtering and add the MAC to the list.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

Lanzaa
Posts: 33
Joined: Fri Apr 06, 2007 6:24 am UTC

Re: Coding: Fleeting Thoughts

Postby Lanzaa » Fri Mar 25, 2011 12:20 am UTC

phlip wrote:
Lanzaa wrote:Also, if you are on windows I would give "ipconfig /all" a try. If you run that from the windows cmd prompt you may find the MAC.

Nope, if you're not connected to a wireless network, your wireless card doesn't even appear in an ipconfig /all listing. Back when I was using MAC filtering for my home wifi, whenever someone visited, the only way I could figure out how to set it up was to temporarily disable the filtering, let them connect, then get their MAC address, and reenable filtering and add the MAC to the list.


That is disappointing. Windows XP, Vista, and 7 ? Also, since MAC filtering provides little protection why even enable it? Or even better, setup two networks, one high security and one low security for guests.

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: Coding: Fleeting Thoughts

Postby RoadieRich » Fri Mar 25, 2011 12:42 am UTC

Create an ad-hoc network? (If windows lets you, that is...)
73, de KE8BSL loc EN26.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Fri Mar 25, 2011 12:51 am UTC

phlip wrote:
Lanzaa wrote:Also, if you are on windows I would give "ipconfig /all" a try. If you run that from the windows cmd prompt you may find the MAC.

Nope, if you're not connected to a wireless network, your wireless card doesn't even appear in an ipconfig /all listing. Back when I was using MAC filtering for my home wifi, whenever someone visited, the only way I could figure out how to set it up was to temporarily disable the filtering, let them connect, then get their MAC address, and reenable filtering and add the MAC to the list.


Where I last worked, I had to give my mac address to the admin because I couldn't connect to the wireless network and it showed up when I ran ipconfig /all
Summum ius, summa iniuria.

User avatar
joshz
Posts: 1466
Joined: Tue Nov 11, 2008 2:51 am UTC
Location: Pittsburgh, PA

Re: Coding: Fleeting Thoughts

Postby joshz » Fri Mar 25, 2011 1:05 am UTC

Xeio wrote:So good rule of thumb, if you aren't ashamed of bad coding practices you used to have, you still have a lot of bad coding practices.

There is no guarantee you don't have any such practices anyway, of course.
Oh gods reading my old code is painful. It's either wholly uncommented or commented to the level of:

Code: Select all

i++; //increment i by one so it counts
You, sir, name? wrote:If you have over 26 levels of nesting, you've got bigger problems ... than variable naming.
suffer-cait wrote:it might also be interesting to note here that i don't like 5 fingers. they feel too bulky.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Fri Mar 25, 2011 1:08 am UTC

RoadieRich wrote:Create an ad-hoc network? (If windows lets you, that is...)


It's only an ad-hoc network if there are other computers connected to it.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Briareos
Posts: 1940
Joined: Thu Jul 12, 2007 12:40 pm UTC
Location: Town of the Big House

Re: Coding: Fleeting Thoughts

Postby Briareos » Fri Mar 25, 2011 1:11 am UTC

joshz wrote:Oh gods reading my old code is painful. It's either wholly uncommented or commented to the level of:

Code: Select all

i++; //increment i by one so it counts
One of either Kernighan or Ritchie once noted that there is a worse commenting practice than that:

Code: Select all

/**********************************
 *                                 *
 * increment i by one so it counts *
 *                                 *
 ***********************************/
i++;
Sandry wrote:Bless you, Briareos.

Blriaraisghaasghoasufdpt.
Oregonaut wrote:Briareos is my new bestest friend.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Fri Mar 25, 2011 1:35 am UTC

Code: Select all


/* * * * * * * * * * * * * * * * * * * * *
 * -----                                  *
 *   | here are many variables in this    *
 *   | fine program, one of which goes    *
 *  by the moniker of 'i'.                *
 *   We wish to perform an arithmetic     *
 * operation on this our variable-du      *
 * -jour; this operation is addition.     *
 * Although it is distributive an comm-   *
 * -utative, we will not make use of      *
 * either of these otherwise interesting  *
 * properties, as we only wish to add a   *
 * constant to the variable.              *
 *   Out of the many integers at our dis- *
 * -posal, we wish to add a small single- *
 * -digit number. Not '3', nor '5'; the   *
 * integer we wish to add is none other   *
 * than the number '1'.                   *
 * * * * * * * * * * * * * * * * * * * * */
i++;
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

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 » Fri Mar 25, 2011 6:52 am UTC

Code: Select all

i++; // Increment i by 2
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
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Fri Mar 25, 2011 7:09 am UTC

Speaking of comments, someone really didn't want this piece of code (found in a library header) to be used:

Code: Select all

/*
#if 0
// <line of code here>
#endif
*/

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Briareos
Posts: 1940
Joined: Thu Jul 12, 2007 12:40 pm UTC
Location: Town of the Big House

Re: Coding: Fleeting Thoughts

Postby Briareos » Fri Mar 25, 2011 3:45 pm UTC

That makes me wonder what order things get processed in the preprocessor: are comments first, or #if directives?
Sandry wrote:Bless you, Briareos.

Blriaraisghaasghoasufdpt.
Oregonaut wrote:Briareos is my new bestest friend.

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Fri Mar 25, 2011 6:40 pm UTC

This makes me really want to put an unmatched "*/" inside an #ifdef...
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

Postby TheChewanater » Fri Mar 25, 2011 6:41 pm UTC

This works as intended:

Code: Select all

#if 0
foo (/*10*/ 5);
bar (/*10*/ 5);
#endif   


This does not:

Code: Select all

/*
foo (/*10*/
 5);
bar (/*10*/ 5);
*/
 
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
joshz
Posts: 1466
Joined: Tue Nov 11, 2008 2:51 am UTC
Location: Pittsburgh, PA

Re: Coding: Fleeting Thoughts

Postby joshz » Fri Mar 25, 2011 6:46 pm UTC

Well, yeah. You can't nest comments.
You, sir, name? wrote:If you have over 26 levels of nesting, you've got bigger problems ... than variable naming.
suffer-cait wrote:it might also be interesting to note here that i don't like 5 fingers. they feel too bulky.

Dr. Willpower
Posts: 197
Joined: Wed May 28, 2008 3:55 pm UTC

Re: Coding: Fleeting Thoughts

Postby Dr. Willpower » Fri Mar 25, 2011 7:09 pm UTC

You, sir, name? wrote:

Code: Select all


/* * * * * * * * * * * * * * * * * * * * *
 * -----                                  *
 *   | here are many variables in this    *
 *   | fine program, one of which goes    *
 *  by the moniker of 'i'.                *
 *   We wish to perform an arithmetic     *
 * operation on this our variable-du      *
 * -jour; this operation is addition.     *
 * Although it is distributive an comm-   *
 * -utative, we will not make use of      *
 * either of these otherwise interesting  *
 * properties, as we only wish to add a   *
 * constant to the variable.              *
 *   Out of the many integers at our dis- *
 * -posal, we wish to add a small single- *
 * -digit number. Not '3', nor '5'; the   *
 * integer we wish to add is none other   *
 * than the number '1'.                   *
 * * * * * * * * * * * * * * * * * * * * */
i++;


Oh god I laughed for ten minutes.
Image
Hat me, bro

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Fri Mar 25, 2011 7:47 pm UTC

That's how I get the impression certain professors prefer code to be commented. Preferably also in dactylic hexameter.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Emu*
Posts: 689
Joined: Mon Apr 28, 2008 9:47 am UTC
Location: Cardiff, UK
Contact:

Re: Coding: Fleeting Thoughts

Postby Emu* » Sat Mar 26, 2011 12:40 pm UTC

I probably go a bit deep with my call stack but I like to bundle things into sensible functions so my Java & C# tend to look like

Code: Select all

public class thing{
    public void MakePDF(OutputStream out){
        Document doc = makeADocument();
        addFrontPage(doc);
        addIntro(doc);
        addTable(doc);
        addIndex(doc);

        new PDFRenderer().Render(doc, out);
    }

    //Lots of tidy functions to bury the implementation detail, sometimes with extra functions to make adding rows to long tables easier.
}
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Sat Mar 26, 2011 8:20 pm UTC

A stack isn't deep until it overflows, and nice code is definitely worth a few extra stack frames.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Sat Mar 26, 2011 9:08 pm UTC

Good news, everyone! The new C++ standard is final.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

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 26, 2011 10:58 pm UTC

You, sir, name? wrote:Good news, everyone! The new C++ standard is const.

FTFY. "final" is a Java keyword. In C++ it's "const".
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.

elminster
Posts: 1560
Joined: Mon Feb 26, 2007 1:56 pm UTC
Location: London, UK, Dimensions 1 to 42.
Contact:

Re: Coding: Fleeting Thoughts

Postby elminster » Sun Mar 27, 2011 2:20 am UTC

Berengal wrote:
You, sir, name? wrote:Good news, everyone! The new C++ standard is const.

FTFY. "final" is a Java keyword. In C++ it's "const".
I laughed pretty hard at that.
Image

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Sun Mar 27, 2011 2:40 am UTC

Code: Select all

#define final const

Berengal wrote:
You, sir, name? wrote:Good news, everyone! The new C++ standard is final.

FTFY. /*"final" is a Java keyword.*/ In C++ it's "final".

Not any more.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

Postby TheChewanater » Sun Mar 27, 2011 4:57 am UTC

You, sir, name? wrote:

Code: Select all

#define final const

Berengal wrote:
You, sir, name? wrote:Good news, everyone! The new C++ standard is final.

FTFY. /*"final" is a Java keyword.*/ In C++ it's "final".

! any more.

While we're speaking Java instead of C++, you should be using an exclamation point, not "not".
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
Ephphatha
Posts: 625
Joined: Sat Sep 02, 2006 9:03 am UTC
Location: Bathurst, NSW, Australia

Re: Coding: Fleeting Thoughts

Postby Ephphatha » Sun Mar 27, 2011 9:54 am UTC

While we're on the topic of Java, does anyone have a suggestion for a cross-platform Java IDE that doesn't suck? Eclipse is ok until you try to do anything more advanced that basic text editing, then it crashes. Netbeans is nice, looking past the code-completion and immediate error highlighting, but its "Run" does not equal "Build+Run" no matter how much it would want you to believe it.

Is there an IDE that will let me specify a command line argument to pass to the program when running it from the IDE? That'd be a damn useful feature I don't think I've seen yet.
I'm not lazy, I'm just getting in early for Christmas is all...


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 4 guests