November 07, 2008
On Thu, 6 Nov 2008 17:14:13 -0500, Jarrett Billingsley wrote:

> On Thu, Nov 6, 2008 at 5:07 PM, Walter Bright <newshound1@digitalmars.com> wrote:
>> BCS wrote:
>>>
>>> Reply to Walter,
>>>
>>>> Steven Schveighoffer wrote:
>>>>
>>>>> Even experienced developers fall into some of these traps.  I know I occasionally fell into this trap:
>>>>>
>>>>> if(x);
>>>>> x->doSomething();
>>>>> But no more with D, because it's not allowed.  Those kinds of things
>>>>> can be easily prevented, and are common mistakes by all programmers.
>>>>>
>>>> Here's another fun one:
>>>>
>>>> printf("%d\n", 8l);
>>>>
>>>> What does that print?
>>>>
>>>
>>> 8
>>
>> If I hadn't said it was a trap, I bet you'd have said "81".
> 
> I wouldn't've, because I use a font that actually distinguishes things 1, I, l, and | properly.  <_<

Same here. I thought the 'trap' was using %d with a *long* value.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
November 07, 2008
Lars Kyllingstad wrote:
> Bill Baxter wrote:
>> On Fri, Nov 7, 2008 at 7:37 AM, Walter Bright
>> <newshound1@digitalmars.com> wrote:
>>> Jarrett Billingsley wrote:
>>>> On Thu, Nov 6, 2008 at 5:07 PM, Walter Bright
>>>> <newshound1@digitalmars.com> wrote:
>>>>> BCS wrote:
>>>>>> Reply to Walter,
>>>>>>
>>>>>>> Steven Schveighoffer wrote:
>>>>>>>
>>>>>>>> Even experienced developers fall into some of these traps.  I know I
>>>>>>>> occasionally fell into this trap:
>>>>>>>>
>>>>>>>> if(x);
>>>>>>>> x->doSomething();
>>>>>>>> But no more with D, because it's not allowed.  Those kinds of things
>>>>>>>> can be easily prevented, and are common mistakes by all programmers.
>>>>>>>>
>>>>>>> Here's another fun one:
>>>>>>>
>>>>>>> printf("%d\n", 8l);
>>>>>>>
>>>>>>> What does that print?
>>>>>>>
>>>>>> 8
>>>>> If I hadn't said it was a trap, I bet you'd have said "81".
>>>> I wouldn't've, because I use a font that actually distinguishes things
>>>> 1, I, l, and | properly.  <_<
>>> 0 and O is another fun one. In any case, 8l is legal C, but illegal D.
>>
>> Threre are various good programmer fonts out there today that are
>> designed to make the 1 l | and 0 O distinctions clear.
>> I use the Proggy fonts.  http://www.proggyfonts.com/index.php?menu=download
>>
>> These days I'd say if you're not using one of these fonts for
>> programming you're being an extremely silly person.
>>
>> --bb
> 
> I use and recommend the DejaVu Sans Mono font. With this font there is no chance of confusing those troublesome characters, and it's very easy on the eyes. Also, the DejaVu fonts are available in the repositories of many (most?) Linux distributions.
> 
>    http://dejavu.sourceforge.net/
> 
> -Lars

I was surprised to learn I already have several versions of Deja Vu installed (on Windows). I've configured all of my text editors and even Thunderbird to use it now. What a difference! Thanks for pointing it out.
November 07, 2008
"Derek Parnell" <derek@psych.ward> wrote in message news:16rwvaqsxxzdx.hzsh3le743yv$.dlg@40tude.net...
> On Thu, 6 Nov 2008 17:14:13 -0500, Jarrett Billingsley wrote:
>
>> On Thu, Nov 6, 2008 at 5:07 PM, Walter Bright <newshound1@digitalmars.com> wrote:
>>> BCS wrote:
>>>>
>>>> Reply to Walter,
>>>>
>>>>> Steven Schveighoffer wrote:
>>>>>
>>>>>> Even experienced developers fall into some of these traps.  I know I occasionally fell into this trap:
>>>>>>
>>>>>> if(x);
>>>>>> x->doSomething();
>>>>>> But no more with D, because it's not allowed.  Those kinds of things
>>>>>> can be easily prevented, and are common mistakes by all programmers.
>>>>>>
>>>>> Here's another fun one:
>>>>>
>>>>> printf("%d\n", 8l);
>>>>>
>>>>> What does that print?
>>>>>
>>>>
>>>> 8
>>>
>>> If I hadn't said it was a trap, I bet you'd have said "81".
>>
>> I wouldn't've, because I use a font that actually distinguishes things 1, I, l, and | properly.  <_<
>
> Same here. I thought the 'trap' was using %d with a *long* value.
>

In my newsgroup client, the lower-case 'L' renders as a straight vertical line with no serif or anything else. I can't remember ever seeing a (non-oddball) font where the "one" digit looked like that, so I instinctively saw it as "8L" and thought the intended gotcha was a mismatched number of bits causing a zero on a system of the wrong endianness. That said, I do still like D's requirement that the "L" suffix be capitalized.


November 09, 2008
Steven Schveighoffer wrote:

> To be honest though, I more disagree with your assertion that only novice programmers are affected.  I sometimes make these types of mistakes, and I definitely don't consider myself a novice ;)
>
> -Steve

A good point.

We seem to have a lot of super programmers who don't make simple mistakes ever and know C++ back to front.  That's Great!

For myself, after programming in C++ for 7 years (and other languages before that) I still find myself making coding typo's and discovering new things about C++.  Keeping an open mind is key to getting better.

I bet even Bjarne Stroustrup himself does not know all the pitfalls he left in the language.

A couple of quotes to put names to:

"Anyone who has never made a mistake has never tried anything new."

"...it's essential to keep an open mind, and to be willing--better yet, eager--to try new things."

"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it."

-Joel
November 09, 2008
Janderson Wrote:

> We seem to have a lot of super programmers who don't make simple mistakes ever and know C++ back to front.  That's Great!

Who knows C++? I know C, C# and javascript.

> For myself, after programming in C++ for 7 years (and other languages before that) I still find myself making coding typo's and discovering new things about C++.  Keeping an open mind is key to getting better.

Yeah, C++ is a continuous discovery, may be because of this C++ pros can't get used to if statement syntax? I thought, fingers know syntax, not brain... well, it's C++ after all :3
November 09, 2008
ore-sama wrote:
> Janderson Wrote:
> 
>> We seem to have a lot of super programmers who don't make simple mistakes ever and know C++ back to front.  That's Great!
> 
> Who knows C++? I know C, C# and javascript.

I see then this kinda makes sense from where your coming from.  C# has a load of restrictions that help detect possible gotchas that you don't get with C++.  They could be removed to allow for more "expressive" code but then you'd have C++.  For example, trying to change the size of an array your iterating over will flag an error in C#.

> 
>> For myself, after programming in C++ for 7 years (and other languages before that) I still find myself making coding typo's and discovering new things about C++.  Keeping an open mind is key to getting better.
> 
> Yeah, C++ is a continuous discovery, may be because of this C++ pros can't get used to if statement syntax? I thought, fingers know syntax, not brain... well, it's C++ after all :3
November 09, 2008
Janderson wrote:
> "The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it."

"An open mind is an empty mind." -- Mark Stroberg
1 2 3
Next ›   Last »