|
View:
New views
19 Messages
—
Rating Filter:
Alert me
|
|
|
Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)So, today on the #scala IRC channel, the perennial question of how to do string interpolation in Scala came up.
The most recent student of Scala was informed that the feature as he expected it did not exist, but that "escaping from string and "+concatenating+" some "+variables+" had been declared just a character or two longer than the ${alternative}". Now, I have a lot of respect for Martin's decisions about language design. It's not a blind respect. Over time I've learned that when I disagree with him, it often turns out that I was wrong. However, on the issue of string interpolation I've always found Martin's stance to be rather puzzling. It just -looks- ugly. And it's so hard to -type-! And then it hit me. Maybe Swiss keyboards have much more convenient access to the "+ and +" key combinations needed to concatenate strings. I did a little research, and indeed, they do: http://en.wikipedia.org/wiki/Keyboard_layout#Swiss_German.2C_Swiss_French.2C_Swiss_Italian.2C_Liechtenstein.2C_Luxembourg Typing "+ and +" are just Shift+2+1 and Shift+1+2 on the Swiss keyboard. Either can be completed with a quick flick of the left wrist. It's hard to imagine something more natural. Compare to the situation on the standard US keyboard: http://en.wikipedia.org/wiki/Keyboard_layout#United_States Typing "+ and +" involves Shift+<comma (,)>+<equals (=)> and Shift+<equals>+<comma>. Not only does this require both hands to type naturally, but even then the last two keys involve a reaching pinky finger. (One the Swiss keyboard, the similarly-positioned keys would be Shift+<a-grave (à)>+<circumflex-diacritic (^)>.) I don't know how other keyboards fare, but I doubt most of them are as blessed as the Swiss keyboard. But there you go: once again, Martin was right. Scala really doesn't need better string interpolation. I just need a more-Swiss keyboard. --j On Mon, Mar 17, 2008 at 12:14 PM, martin odersky <martin.odersky@...> wrote: Hi all, |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)As a user with a norwegian style keyboard I have considered buying a US keyboard in additon for doing programming. Should probably try to get hold of a Swiss one instead.
![]()
|
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)On Fri, May 29, 2009 at 6:47 AM, Jorge Ortiz <jorge.ortiz@...> wrote:
> And then it hit me. Maybe Swiss keyboards have much more convenient access > to the "+ and +" key combinations needed to concatenate strings. > > I did a little research, and indeed, they do: I read this on the Metro on the way in to EPFL this morning and was a little skeptical. But in the office I'm sitting in right now, one door down from Martin's, there are two keyboards, one swiss, one generic, and it is indeed exactly as you say: typing +" and "+ on the swiss keyboard is a great deal easier on the swiss keyboard than on the other. I'm not sure what layout Martin has on his laptop ... I'll find out when he gets in. Cheers, Miles -- Miles Sabin tel: +44 (0)7813 944 528 skype: milessabin http://twitter.com/milessabin |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)I used to work in the US where I got a laptop with US-keyboard (naturally). Programming C++/Java at that time I can confirm that it is much better suited for programming in these languages than the German layout I was used to (the typical specials like "{[]}@~|\" are AltGr-keys)
14 years ago we thought in the company I worked for about choosing a modern language ( we used Oracle*Forms & PL/SQL which have a Pascal-like syntax) for the next generation of our product. C++ was an obvious favorite, but the use of {} for blocks raised serious concerns - typing begin/end appeared faster/more natural to most of us. Lisp and Smalltalk became serious candidates - perhaps as well because they were more accessible on german keyboards. I am now in France and I recommended AppEngine to a french colleague - he was delighted about Python and the ease it lets him type in his little programms. Perhaps not a coincidence that Pascal and Python had been conceived by non-english speakers. -Carsten On Fri, May 29, 2009 at 8:59 AM, L Jantzen <ljantzen@...> wrote:
|
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)On Fri, May 29, 2009 at 8:59 AM, L Jantzen <ljantzen@...> wrote:
> > As a user with a norwegian style keyboard I have considered buying a US > keyboard in additon for doing programming. Should probably try to get hold > of a Swiss one instead. :wistle: > I did not know about the difference, I am using a US keyboard as well :-) Cheers -- Martin |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)On Fri, May 29, 2009 at 10:03 AM, martin odersky <martin.odersky@...> wrote:
> On Fri, May 29, 2009 at 8:59 AM, L Jantzen <ljantzen@...> wrote: >> >> As a user with a norwegian style keyboard I have considered buying a US >> keyboard in additon for doing programming. Should probably try to get hold >> of a Swiss one instead. :wistle: >> > I did not know about the difference, I am using a US keyboard as well :-) > Maybe that's why I never write the space around the + in strings. I always write "hello "+x+"!", say. Cheers -- Martin |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Jorge,
Your theory is far too good to be damaged by mere facts. I vote we throw this comment out as a...um.."statistical outlier". On Fri, May 29, 2009 at 1:03 AM, martin odersky <martin.odersky@...> wrote: I did not know about the difference, I am using a US keyboard as well :-) |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)On Friday May 29 2009, James Iry wrote:
> On Fri, May 29, 2009 at 1:03 AM, martin odersky wrote: > > I did not know about the difference, I am using a US keyboard as > > well :-) > > > > Cheers > > > > -- Martin > > Jorge, > > Your theory is far too good to be damaged by mere facts. I vote we > throw this comment out as a...um.."statistical outlier". 1 is prime 3 is prime 5 is prime 7 is prime 9 is prime ... experimental error 11 is prime 13 is prime Ergo, all odd numbers are prime. RRS |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Someone could make a fine little side-business on selling "Scala" keyboards!
~~ Robert. Miles Sabin wrote: > On Fri, May 29, 2009 at 6:47 AM, Jorge Ortiz <jorge.ortiz@...> wrote: >> And then it hit me. Maybe Swiss keyboards have much more convenient access >> to the "+ and +" key combinations needed to concatenate strings. >> >> I did a little research, and indeed, they do: > > I read this on the Metro on the way in to EPFL this morning and was a > little skeptical. But in the office I'm sitting in right now, one door > down from Martin's, there are two keyboards, one swiss, one generic, > and it is indeed exactly as you say: typing +" and "+ on the swiss > keyboard is a great deal easier on the swiss keyboard than on the > other. > > I'm not sure what layout Martin has on his laptop ... I'll find out > when he gets in. > > Cheers, > > > Miles > -- ~~ Robert Fischer. Grails Training http://GroovyMag.com/training Smokejumper Consulting http://SmokejumperIT.com Enfranchised Mind Blog http://EnfranchisedMind.com/blog Check out my book, "Grails Persistence with GORM and GSQL"! http://www.smokejumperit.com/redirect.html |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Hi All,
On Fri, May 29, 2009 at 1:33 PM, Robert Fischer <robert.fischer@...> wrote: > Someone could make a fine little side-business on selling "Scala" keyboards! > I wonder how hard it would be to reprogram one function key to the be the Unicode character for =>, another function key to be the Unicode character for <-, and still another function key the Unicode character for ->. That would make for a bit prettier code, and one could argue it would make for more "functional" programming. Sorry about that last one, but having some kind of downloadable file that would reprogram function keys to make scala programming quicker might be useful. Bill > ~~ Robert. > > Miles Sabin wrote: >> >> On Fri, May 29, 2009 at 6:47 AM, Jorge Ortiz <jorge.ortiz@...> >> wrote: >>> >>> And then it hit me. Maybe Swiss keyboards have much more convenient >>> access >>> to the "+ and +" key combinations needed to concatenate strings. >>> >>> I did a little research, and indeed, they do: >> >> I read this on the Metro on the way in to EPFL this morning and was a >> little skeptical. But in the office I'm sitting in right now, one door >> down from Martin's, there are two keyboards, one swiss, one generic, >> and it is indeed exactly as you say: typing +" and "+ on the swiss >> keyboard is a great deal easier on the swiss keyboard than on the >> other. >> >> I'm not sure what layout Martin has on his laptop ... I'll find out >> when he gets in. >> >> Cheers, >> >> >> Miles >> > > -- > ~~ Robert Fischer. > Grails Training http://GroovyMag.com/training > Smokejumper Consulting http://SmokejumperIT.com > Enfranchised Mind Blog http://EnfranchisedMind.com/blog > > Check out my book, "Grails Persistence with GORM and GSQL"! > http://www.smokejumperit.com/redirect.html > -- Bill Venners Artima, Inc. http://www.artima.com |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Bill Venners wrote:
> Hi All, > > On Fri, May 29, 2009 at 1:33 PM, Robert Fischer > <robert.fischer@...> wrote: >> Someone could make a fine little side-business on selling "Scala" keyboards! >> > I wonder how hard it would be to reprogram one function key to the be > the Unicode character for =>, another function key to be the Unicode > character for <-, and still another function key the Unicode character > for ->. That would make for a bit prettier code, and one could argue > it would make for more "functional" programming. Sorry about that last > one, but having some kind of downloadable file that would reprogram > function keys to make scala programming quicker might be useful. I'm on Ubuntu and I put together a small keyboard layout that extends US basic: partial alphanumeric_keys xkb_symbols "scala" { name[Group1]= "USA - Scala"; include "us(basic)" key <AB08> { [ comma, less, leftarrow, leftarrow ] }; key <AB09> { [ period, greater, rightarrow, rightarrow ] }; // Double right arrow key <AE12> { [ equal, plus, 0x10021D2, 0x10021D2 ] }; }; This should generally work on any Linux system using XKB, although configuration may be distro-specific. On Linux, you can paste the above text at the end of /usr/share/X11/xkb/symbols/us, then for Ubuntu >= 8.10, edit /usr/share/X11/xkb/rules/evdev.xml and find "olpc2". Insert the following XML after the </variant> tag for olpc2: <variant> <configItem> <name>scala</name> <description>Scala Layout</description> </configItem> </variant> Now, if you open the keyboard preferences and add a layout, there should be a new one under United States called "USA Scala Layout". Kinda crude having to hack on these files, but it works. Derek |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Sorry, I should mention the mappings:
Right Alt + > = → Right Alt + < = ← Right Alt + = = ⇒ Derek |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Math pedantry says 1 is not a prime either.
On Fri, May 29, 2009 at 6:05 AM, Randall R Schulz <rschulz@...> wrote: > On Friday May 29 2009, James Iry wrote: >> On Fri, May 29, 2009 at 1:03 AM, martin odersky wrote: >> > I did not know about the difference, I am using a US keyboard as >> > well :-) >> > >> > Cheers >> > >> > -- Martin >> >> Jorge, >> >> Your theory is far too good to be damaged by mere facts. I vote we >> throw this comment out as a...um.."statistical outlier". > > 1 is prime > 3 is prime > 5 is prime > 7 is prime > 9 is prime ... experimental error > 11 is prime > 13 is prime > > Ergo, all odd numbers are prime. > > > RRS > |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)>>>>> "Robert" == Robert Fischer <robert.fischer@...> writes:
Robert> Someone could make a fine little side-business on selling Robert> "Scala" keyboards! ~~ Robert. with big .asInstanceOf[ and .isInstanceOf[ keys for people who haven't unlearned their Java and Ruby habits yet :-) -- Seth Tisue / http://tisue.net lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/ |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)I'd like to introduce the concept of an "editor" into this thread. They fall in the category of useful software tools designed to wrangle code. I highly recommend them.
For example, Emacs' yasnippit mode for Scala has many predefined handy abbreviations and their expansions. Customize to suit, it takes literally 10 seconds to add or modify an abbreviation to something else. One of these prefined snippits allows one to type the word "cast", hit the tab key and (it's quite magical really) it expands to "asInstanceOf[Type]". The cursor is helpfully positioned over the letter 'T' in the color coded word Type. As soon as you type the first letter of the desired class name the word "Type" disappears. Of course I rarely type the full class name, only the first few letters and then alt-/ auto-complete it. Those unfamiliar with editors, suffused with a sense of deep accomplishment, may stop at backspace key mastery, however, editors are capable of additional and equally amazing things such as allowing one to redefine keys '"' key positions or shortcut expansion. Even horribly difficult ones like Scandinavian key positions, which due to their well thought out positioning, do not allow for proper exercising of the fingers. As a result they (the fingers) adopt the appearance of breakfast sausages. You may doubt, but I defer to the scientific method for validation. During Martin's visit to the West Coast observe if as he points to a slide you find yourself strangely and rather suddenly craving a good breakfast. On Sat, May 30, 2009 at 11:26 AM, Seth Tisue <seth@...> wrote: >>>>> "Robert" == Robert Fischer <robert.fischer@...> writes: |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Seth Tisue wrote:
> with big .asInstanceOf[ and .isInstanceOf[ keys for people who > haven't unlearned their Java and Ruby habits yet :-) We could reuse that one: http://www.seanmichaelragan.com/html/[2008-10-27]_CAPS_LOCK_TRAINER_KEY.shtml - Florian |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)Perhaps my lisp ( and ) foot pedals have a new use.
2009/5/31 Florian Hars <hars@...>: > Seth Tisue wrote: >> >> with big .asInstanceOf[ and .isInstanceOf[ keys for people who >> haven't unlearned their Java and Ruby habits yet :-) > > We could reuse that one: > > http://www.seanmichaelragan.com/html/[2008-10-27]_CAPS_LOCK_TRAINER_KEY.shtml > > - Florian > |
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)This reminds me of the (general) discussion whether optional semicolons are really worth it. It's true that they only save one character per line, but the result is much more readable. The same holds for string substitution: "test results: ${result1}, ${result2}" is much easier to parse for the eye than "test results: "+result1+", "+result2". One reason is that there is only one pair of quotes involved, making it unnecessary for your brain to judge if "+result1+" is inside or outside the string.
Cheers, Peter
|
|
|
Re: Why Martin hates string interpolation (Was: Re: Formatting Questions Summary)And the most ridiculous thing is... there's interpolation for XML!
The visual thing bothers me too. Honestly, I'd prefer writing ${{{result}}}$ -- or whatever -- number of characters notwithstanding, just so that I could easily understand what's inside or outside the string.
On Fri, Jun 5, 2009 at 4:59 PM, Peter Niederwieser <pniederw@...> wrote:
-- Daniel C. Sobral Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value. |
| Free embeddable forum powered by Nabble | Forum Help |