Page 68 of 251

Re: Coding: Fleeting Thoughts

Posted: Tue Mar 22, 2011 7:05 pm UTC
by _Axle_
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.

Re: Coding: Fleeting Thoughts

Posted: Tue Mar 22, 2011 10:58 pm UTC
by MHD
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.

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 3:02 am UTC
by Briareos
FT: stackoverflow + searching for "plz" == hilarity.

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 3:40 am UTC
by Xeio
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?

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 4:15 am UTC
by bytbox
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>

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 3:00 pm UTC
by 0xBADFEED
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.

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 6:56 pm UTC
by bytbox
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".)

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 7:36 pm UTC
by headprogrammingczar
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.

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 9:59 pm UTC
by You, sir, name?
http://programming-motherfucker.com/ (NSFW, mostly language, but also content that may be interpreted as subversive by bosses without a sense of humor)

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 11:29 pm UTC
by headprogrammingczar
Yep, I knew I would see that here. I didn't expect it to take so long though.

Re: Coding: Fleeting Thoughts

Posted: Wed Mar 23, 2011 11:32 pm UTC
by Briareos
I think that was at the top of Hacker News yesterday. Zed Shaw seems to get respect second only to Paul Graham over there.

Re: Coding: Fleeting Thoughts

Posted: Thu Mar 24, 2011 4:12 am UTC
by b.i.o
Briareos wrote:I think that was at the top of Hacker News yesterday.

Yeah. For a very long time.

Re: Coding: Fleeting Thoughts

Posted: Thu Mar 24, 2011 9:23 pm UTC
by Xeio
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.

Re: Coding: Fleeting Thoughts

Posted: Thu Mar 24, 2011 9:42 pm UTC
by Berengal
What if I don't have any coding practices?

Re: Coding: Fleeting Thoughts

Posted: Thu Mar 24, 2011 10:52 pm UTC
by You, sir, name?
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.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 12:03 am UTC
by Lanzaa
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. ;)

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 12:10 am UTC
by phlip
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.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 12:20 am UTC
by Lanzaa
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.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 12:42 am UTC
by RoadieRich
Create an ad-hoc network? (If windows lets you, that is...)

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 12:51 am UTC
by Thesh
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

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 1:05 am UTC
by joshz
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

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 1:08 am UTC
by You, sir, name?
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.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 1:11 am UTC
by Briareos
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++;

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 1:35 am UTC
by You, sir, name?

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++;

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 6:52 am UTC
by Berengal

Code: Select all

i++; // Increment i by 2

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 7:09 am UTC
by phlip
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
*/

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 3:45 pm UTC
by Briareos
That makes me wonder what order things get processed in the preprocessor: are comments first, or #if directives?

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 6:40 pm UTC
by headprogrammingczar
This makes me really want to put an unmatched "*/" inside an #ifdef...

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 6:41 pm UTC
by TheChewanater
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);
*/
 

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 6:46 pm UTC
by joshz
Well, yeah. You can't nest comments.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 7:09 pm UTC
by Dr. Willpower
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.

Re: Coding: Fleeting Thoughts

Posted: Fri Mar 25, 2011 7:47 pm UTC
by You, sir, name?
That's how I get the impression certain professors prefer code to be commented. Preferably also in dactylic hexameter.

Re: Coding: Fleeting Thoughts

Posted: Sat Mar 26, 2011 12:40 pm UTC
by Emu*
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.
}

Re: Coding: Fleeting Thoughts

Posted: Sat Mar 26, 2011 8:20 pm UTC
by headprogrammingczar
A stack isn't deep until it overflows, and nice code is definitely worth a few extra stack frames.

Re: Coding: Fleeting Thoughts

Posted: Sat Mar 26, 2011 9:08 pm UTC
by You, sir, name?
Good news, everyone! The new C++ standard is final.

Re: Coding: Fleeting Thoughts

Posted: Sat Mar 26, 2011 10:58 pm UTC
by Berengal
You, sir, name? wrote:Good news, everyone! The new C++ standard is const.

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

Re: Coding: Fleeting Thoughts

Posted: Sun Mar 27, 2011 2:20 am UTC
by elminster
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.

Re: Coding: Fleeting Thoughts

Posted: Sun Mar 27, 2011 2:40 am UTC
by You, sir, name?

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.

Re: Coding: Fleeting Thoughts

Posted: Sun Mar 27, 2011 4:57 am UTC
by TheChewanater
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".

Re: Coding: Fleeting Thoughts

Posted: Sun Mar 27, 2011 9:54 am UTC
by Ephphatha
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.