View mode: basic / threaded / horizontal-split · Log in · Help
January 15, 2013
Re: Exceptional coding style
On Tuesday, 15 January 2013 at 15:49:34 UTC, Russel Winder wrote:
> On Tue, 2013-01-15 at 15:07 +0100, monarch_dodra wrote:
> […]
>> 
>> I do not know of any editor that does not support "ctrl + 
>> scroll" to change the font sizes on the fly.
>
> Emacs, VIM,…
>
> […]
>> Your editor's font size should not be statically dictated by a 
>> single number.
>
> It depends on whether you want all the text to be a single size 
> in which
> case yes just one number to set the font size ;-)

monospaced fonts everywhere to rule them all! :)
January 15, 2013
Re: Exceptional coding style
On Tue, Jan 15, 2013 at 12:01:46PM +0100, Chris wrote:
[...]
> The spacing section is exactly the coding style I use, and omitting
> the curly braces will rather sooner than later lead to more work.
> Also, "a function should only do one thing" has proven to work for
> me. Although there might be a slight performance penalty if you have
> more function calls, code maintenance is by far easier.

+1. Premature optimization is the bane of aspiring programmers. Code
maintainability should be foremost; merging functions for "performance"
should only be done after extensive profiling has proven that having too
many function calls is the bottleneck.

Too many projects waste too much time "optimizing" the code, with no
proof whatsoever that said "optimizations" are actually helping
performance, with the result that the code is fragile and hard to
maintain, thus costing much more time & effort than it should.  What
programmers habitually blame for performance bottlenecks are usually red
herrings; the real bottlenecks are rarely where people imagine they are.
You don't know until you actually profile the code.  (I learnt this the
hard way.)


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.
January 15, 2013
Re: Exceptional coding style
On 01/15/13 16:27, bearophile wrote:
> Artur Skawina:
> 
>> static assert(checkArgs!A(fmt), "Invalid or unsupported printf args");
> 
> A template constraint is better, I think.

Not necessarily, if you want helpful error messages.

>> You can't get any less overhead than this; not even when using a "well designed
> statically compiled language".<
> 
> Maybe if you compile that with dmd and you look in the binary I think you will find some stuff related to that that's not needed.

Never used DMD.
D is designed with an sufficiently smart compiler in mind, for some realistic and
practical definition of a SSC. Therefore failure to perform certain optimizations,
which are reasonably required by the language (like inlining), is a mere quality
of implementation issue.

Yes, it's not the best approach, not relying completely on the optimizer would have
been better, but the D design is as it is, and until that changes blaming the
compiler is the only option.

>>> void foo(int x)(string s) {}
>>
>> A /run-time value known at compile-time/ is an oxymoron.
>>
>> How would your above function to differ from this one
>> 'void foo(alias x)(string s) {}' ?
>> Are you asking for 'void foo(alias int x)(string s) {}'?
> 
> That wasn't an important request, feel free to ignore it.

I'm trying to understand what you're asking for.


> What I was trying to say is not impossible. The run-time semantics of this:
> 
> void foo(static int x)(string s) {}
> 
> Is meant to be the same as:
> 
> void foo(int x, string s) {}
> 
> The only difference is that the compiler requires x to be statically known (but then you can't use specialize code on the value of x, because that's really not a template function).
> 
> This is also allowed, and it's similar to what we were discussing about:
> 
> void foo(static int x)(string s) if (predicate(x)) {}

Define "x to be statically known".

  void foo()(int x, string s) { import std.stdio; writeln(x, s); }

  auto foo(alias X)(string s) /*@inline*/ /*if (__traits(compiles, foo(X, s)))*/ {
     return foo(X, s);
  }

  void main() {
     foo!1("one");
     foo!2("two");
     int three = 3;
     foo!three("three");
  }

  /*  The last foo!three case fails with the template constraint enabled,
      but /does/ compile w/o it, btw */

I still have no idea *why* you'd want such a thing...

artur
January 15, 2013
Re: Exceptional coding style
On Tue, Jan 15, 2013 at 03:07:08PM +0100, monarch_dodra wrote:
> On Tuesday, 15 January 2013 at 13:55:53 UTC, Timon Gehr wrote:
> >On 01/15/2013 11:57 AM, mist wrote:
> >>Well, probably I am playing "good vision nazi" here, as 12 font size
> >>seems HUGE to me, far beyond the comfort zone.
> >
> >It's just preference. I do not have any problems with font size 9.
> 
> I do not know of any editor that does not support "ctrl + scroll" to
> change the font sizes on the fly.

I'm a vim nazi. :-P


> I always change the font size of my editor, depending on how
> concentrated I am, my position in my seat, or by how complicated the
> current algorithm is. Or simply if somebody is looking over my
> shoulder.

Huh. I'm glad I don't have the latter problem. Well, good ole ctrl-Z to
return to the shell, or just ctrl-T ctrl-T (I use ratpoison) to switch
to another window, etc., works for me. But then I don't work in a
situation where people I don't want looking at my code can simply walk
by and look over my shoulders. Office security, man! ;-)


> Your editor's font size should not be statically dictated by a
> single number.

I rather prefer to stick to a single font size. It's easier on the brain
to always see the same layout of a particular piece of code. It's like
navigating by landmarks -- you get familiar with where things are laid
out, and it's easier to find things. It just costs too much effort to
keep changing things around.


T

-- 
People demand freedom of speech to make up for the freedom of thought
which they avoid. -- Soren Aabye Kierkegaard (1813-1855)
January 15, 2013
Re: Exceptional coding style
On Tue, Jan 15, 2013 at 11:56:34AM +0100, mist wrote:
> On Monday, 14 January 2013 at 23:57:18 UTC, Timon Gehr wrote:
> >This generally comes up as an argument in these discussions, but I
> >don't buy it. Not all development is done on a desktop with a huge
> >screen. And even then, there is always something to put on it.
> >What window manager are you using?
> 
> Well, I hardly can imagine rationale behind using netbook for
> serious development aside from being on trip. Even being forced to
> work in ssh to some legacy shell ( I have that unpleasant experience
> :( ) usually limits your term width, not height.

Heh. On the contrary, I find ssh to be a pleasant experience. Most
GUI-heavy editors are so painfully inefficient to use that I find VT100
emulators far more pleasant to work with.


> I am using Gnome Shell, but working mostly in full-screen
> undecorated terminal. It is approximately 75 to 85 lines of vertical
> space in my setup.

I have a 1600x1200 screen, and an 18-point font, which gives me 93*41
terminal size. I find that just about right. (Like I said, I maximize
everything, and anything significantly smaller than 18-point font, I
find quite unreadable.)


T

-- 
People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG
January 15, 2013
Re: Exceptional coding style
On Tuesday, 15 January 2013 at 16:17:27 UTC, H. S. Teoh wrote:
> On Tue, Jan 15, 2013 at 03:07:08PM +0100, monarch_dodra wrote:
>> On Tuesday, 15 January 2013 at 13:55:53 UTC, Timon Gehr wrote:
>> >On 01/15/2013 11:57 AM, mist wrote:
>> >>Well, probably I am playing "good vision nazi" here, as 12 
>> >>font size
>> >>seems HUGE to me, far beyond the comfort zone.
>> >
>> >It's just preference. I do not have any problems with font 
>> >size 9.
>> 
>> I do not know of any editor that does not support "ctrl + 
>> scroll" to
>> change the font sizes on the fly.
>
> I'm a vim nazi. :-P
>
>
>> I always change the font size of my editor, depending on how
>> concentrated I am, my position in my seat, or by how 
>> complicated the
>> current algorithm is. Or simply if somebody is looking over my
>> shoulder.
>
> Huh. I'm glad I don't have the latter problem. Well, good ole 
> ctrl-Z to
> return to the shell, or just ctrl-T ctrl-T (I use ratpoison) to 
> switch
> to another window, etc., works for me. But then I don't work in 
> a
> situation where people I don't want looking at my code can 
> simply walk
> by and look over my shoulders. Office security, man! ;-)

ROFL, I meant when a colleague is helping me debug. Things are 
easier if I bump up the font size by a couple of points, so they 
don't have to bend down to my level or sit next to me just to see 
my code.
January 15, 2013
Re: Exceptional coding style
On Tuesday, 15 January 2013 at 16:22:19 UTC, H. S. Teoh wrote:
> On Tue, Jan 15, 2013 at 11:56:34AM +0100, mist wrote:
>> On Monday, 14 January 2013 at 23:57:18 UTC, Timon Gehr wrote:
>> >This generally comes up as an argument in these discussions, 
>> >but I
>> >don't buy it. Not all development is done on a desktop with a 
>> >huge
>> >screen. And even then, there is always something to put on it.
>> >What window manager are you using?
>> 
>> Well, I hardly can imagine rationale behind using netbook for
>> serious development aside from being on trip. Even being 
>> forced to
>> work in ssh to some legacy shell ( I have that unpleasant 
>> experience
>> :( ) usually limits your term width, not height.
>
> Heh. On the contrary, I find ssh to be a pleasant experience. 
> Most
> GUI-heavy editors are so painfully inefficient to use that I 
> find VT100
> emulators far more pleasant to work with.

I am vim user myself, but some legacy shells did not support more 
than 80 symbol width, thus the pain and according code style 
guidelines for us poor programmers on that project :)

>
>> I am using Gnome Shell, but working mostly in full-screen
>> undecorated terminal. It is approximately 75 to 85 lines of 
>> vertical
>> space in my setup.
>
> I have a 1600x1200 screen, and an 18-point font, which gives me 
> 93*41
> terminal size. I find that just about right. (Like I said, I 
> maximize
> everything, and anything significantly smaller than 18-point 
> font, I
> find quite unreadable.)

Well this is probably the main reason of different spacing 
tastes. I have literally twice as much vertical space fitting ( 
1920x1080 @ 9pt ), can imagine how it makes you favor more 
compact style.
January 15, 2013
Re: Exceptional coding style
On Tue, 2013-01-15 at 17:02 +0100, mist wrote:
[…]
> monospaced fonts everywhere to rule them all! :)

Monospace fonts are an aberration of the typewriter era.

All text, including code, should be displayed in proportional fonts, in
my case Ocean Sans Std on my machines.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
January 15, 2013
Re: Exceptional coding style
On Tuesday, 15 January 2013 at 16:31:05 UTC, Russel Winder wrote:
> On Tue, 2013-01-15 at 17:02 +0100, mist wrote:
> […]
>> monospaced fonts everywhere to rule them all! :)
>
> Monospace fonts are an aberration of the typewriter era.
>
> All text, including code, should be displayed in proportional 
> fonts, in
> my case Ocean Sans Std on my machines.

:O You are probably the very first programmer I have encountered 
so far that prefers proportional fonts for code. I need some time 
to even try to imagine how this may look.
January 15, 2013
Re: Exceptional coding style
On 1/15/13 11:33 AM, mist wrote:
> On Tuesday, 15 January 2013 at 16:31:05 UTC, Russel Winder wrote:
>> On Tue, 2013-01-15 at 17:02 +0100, mist wrote:
>> […]
>>> monospaced fonts everywhere to rule them all! :)
>>
>> Monospace fonts are an aberration of the typewriter era.
>>
>> All text, including code, should be displayed in proportional fonts, in
>> my case Ocean Sans Std on my machines.
>
> :O You are probably the very first programmer I have encountered so far
> that prefers proportional fonts for code. I need some time to even try
> to imagine how this may look.

I, too, prefer proportional fonts in code and tried hard to use them in 
TDPL. I couldn't find a reasonable way to make them work in 
LaTeX/listings (indentation and vertical align are pervasive issues) and 
besides there are really elaborate monospace fonts to be had nowadays, 
so I chose Bitstream Vera which is beautiful. (Took me a week to decide 
on TDPL fonts alone but it was time well spent.)

Same deal in Emacs - there's just no good editor support for 
proportional fonts in code yet. Russel, what editor do you use?


Andrei
2 3 4 5 6 7 8 9 10
Top | Discussion index | About this forum | D home