jonathan mawson | 1 Feb 02:01
Picon

Re: Scala coding guidelines needed? NOT formatting style!


Mats Henricson-2 wrote:
> 
> Erik Engbrecht wrote:
>> If you go back to my original post, I was agreeing with Tony and Paul
>> that there shouldn't be some sort of "official" style guide linked off
>> of the main Scala website.  I would also expect a style guide to be more
>> than a collection of "don't do that"'s, and even if it was just that, I
>> think if it reached any depth there would be some strong differences of
>> opinion.  That's why I don't think it should be official.
> 
> I think this issue could be solved by having two levels of coding
> guidelines;
> 
> * Rules, which we could all agree with, and
> * Recommendations, which are more a matter of style, or areas
>   where there isn't agreement within the community, or where there
>   are well known exceptions
> 
> IMNSHO, this is the only way to get an official, i.e. respected by
> all, coding guideline.
> 
> If coding guidelines are codified in one (or two) statement each
> (with accompanying examples and text), instead of vague but well
> meaning texts, then it is also so much more simple to know what
> exactly the guideline says, and whether people agree with it or
> not.
> 
> Mats
> 
(Continue reading)

Ben Hutchison | 1 Feb 05:47
Picon
Gravatar

Possible bug in typechecker

For a fortnight I have been dogged by compiler typecheck errors in
code that I think is correct. I have narrowed down a small test case,
which I believe should typecheck, that illustrates the problem.

Either (a) would someone please explain why this isnt typesafe (and
ideally how to correct it), or (b) should I report this in trac?

trait Dimension {
	type ContainerType <: Container[X] forSome {type X <: Dimension}
}
object D1 extends Dimension {
	type ContainerType = Container[D1.type]
}
class Container[D <: Dimension] {
	def op(c: Container[D])
}
abstract class Context[Dim <: Dimension] {
	val c1: Dim#ContainerType
	val c2: Dim#ContainerType
	
/*
[error]  found   : Dim#ContainerType
[error]  required: Container[X] where type X <: Dimension
[error]         def test() = c1.op(c2)
[error]                            ^
*/
	def test() = c1.op(c2)
}

(Continue reading)

Meredith Gregory | 1 Feb 05:54
Picon
Gravatar

Re: Scala vs. X10

Dear Marius,


One of the slickest ways i've seen people introduce fork-join parallelism is Caires' parallel let-form. This is monadic (a big plus!), gives rise to some very nice syntactic sugar and fits the functional paradigm quite well. The basic form is

let ptn1 <- expr1, ..., ptnK <- exprK in expr

The semantics is that you don't get to do expr until all of the let-assignments (ptnj <- exprj) have completed. Then, the  usual sugar for sequential composition embeds perfectly.

expr1 ; expr2 := let dummy <- expr1 in expr2 // with dummy fresh in expr2

while the notion of simply running things in parallel embeds as

expr1 | expr2 := let dummy1 <- expr1, dummy2 <- expr2 in ()

As you can imagine, this has a very natural interpretation in terms of for-comprehensions. 

Beyond that, this approach fits well with a very intuitive behavioral type system.

Best wishes,

--greg

On Sun, Jan 31, 2010 at 6:47 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Greg, 

I agree that X10 is not in essence a functional language but a rather heavily imperative language (still they have function types but of course this doesn't make it a functional language :) ) with interesting concurrency control mechanisms. finish/async could be written in Scala as a library though ;) The concept of places is also interesting.. 

I was basically referring to its syntax to be similar with scala.

Br's,
Marius


On Sun, Jan 31, 2010 at 7:57 AM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Marius,

Thanks for the pointer to x10. Taken from a recent paper about x10, a featherweight version of the language can be captured by the grammar

Program : p ::= void f_i () { s_i }, i ∈ 1..u 
Statement : s ::= skip^l 
| i s 
Instruction : i ::= skip^l 
| a[d] =^l e; 
| whilel (a[d] =/= 0) s 
| async^l s 
| finish^l s 
| f i ()^l 
Expression : e ::= c 
| a[d] + 1 

Based on the syntax and semantics in that paper this language looks to be not a functional language, but a more traditional imperative language with a fork-join semantics built in (fork = async, join = finish). It's pretty much diametrically opposed to scala. Scala is functional at its core and add actors on top as a parallel execution model. 

Best wishes,

--greg


On Sat, Jan 30, 2010 at 9:16 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Hi all,

Did anyone look into X10 language? ... many things in there are very Scala-ish but I wonder if anyone used it and perhaps share the experience?

Br's,
Marius



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com
Klaus Havelund | 1 Feb 06:12
Picon

Re: Scala vs. X10

Now that the discussion is on X10 versus Scala: Fortress is also a language
one can compare with (if it has not been discussed earlier). I notice
in particular that Fortress has special syntax for sets, lists and
maps. I can see that Scala's library syntax for sets, lists and maps
makes these concepts simple. However, has it been considered to have
special syntax for these data structures?

I would like in this context to point to VDM, a formal specification
language that very early on (early 70ties) had special syntax for
sets, lists and maps, and contained as a subset an ML-like imperative
+ functional programming language (plus pre/post conditions and
quantifiers):

  http://en.wikipedia.org/wiki/Vienna_Development_Method
  http://www.vienna.cc/e/evdm.htm

Klaus

Meredith Gregory | 1 Feb 07:08
Picon
Gravatar

Re: Scala vs. X10

Dear Klaus,


i was waiting for someone to mention Fortress. It's another interesting variant in this space. Clearly, a lot of thought has gone into Fortress.

Best wishes,

--greg

On Sun, Jan 31, 2010 at 9:12 PM, Klaus Havelund <havelund <at> gmail.com> wrote:
Now that the discussion is on X10 versus Scala: Fortress is also a language
one can compare with (if it has not been discussed earlier). I notice
in particular that Fortress has special syntax for sets, lists and
maps. I can see that Scala's library syntax for sets, lists and maps
makes these concepts simple. However, has it been considered to have
special syntax for these data structures?

I would like in this context to point to VDM, a formal specification
language that very early on (early 70ties) had special syntax for
sets, lists and maps, and contained as a subset an ML-like imperative
+ functional programming language (plus pre/post conditions and
quantifiers):

 http://en.wikipedia.org/wiki/Vienna_Development_Method
 http://www.vienna.cc/e/evdm.htm

Klaus



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com
Marius Danciu | 1 Feb 08:40
Picon
Gravatar

Re: Scala vs. X10

Hi Greg,

Yup, pretty interesting way to do things and yes very intuitive and I love the monadic style.

Br's,
Marius

On Mon, Feb 1, 2010 at 6:54 AM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Marius,

One of the slickest ways i've seen people introduce fork-join parallelism is Caires' parallel let-form. This is monadic (a big plus!), gives rise to some very nice syntactic sugar and fits the functional paradigm quite well. The basic form is

let ptn1 <- expr1, ..., ptnK <- exprK in expr

The semantics is that you don't get to do expr until all of the let-assignments (ptnj <- exprj) have completed. Then, the  usual sugar for sequential composition embeds perfectly.

expr1 ; expr2 := let dummy <- expr1 in expr2 // with dummy fresh in expr2

while the notion of simply running things in parallel embeds as

expr1 | expr2 := let dummy1 <- expr1, dummy2 <- expr2 in ()

As you can imagine, this has a very natural interpretation in terms of for-comprehensions. 

Beyond that, this approach fits well with a very intuitive behavioral type system.

Best wishes,

--greg


On Sun, Jan 31, 2010 at 6:47 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Greg, 

I agree that X10 is not in essence a functional language but a rather heavily imperative language (still they have function types but of course this doesn't make it a functional language :) ) with interesting concurrency control mechanisms. finish/async could be written in Scala as a library though ;) The concept of places is also interesting.. 

I was basically referring to its syntax to be similar with scala.

Br's,
Marius


On Sun, Jan 31, 2010 at 7:57 AM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Marius,

Thanks for the pointer to x10. Taken from a recent paper about x10, a featherweight version of the language can be captured by the grammar

Program : p ::= void f_i () { s_i }, i ∈ 1..u 
Statement : s ::= skip^l 
| i s 
Instruction : i ::= skip^l 
| a[d] =^l e; 
| whilel (a[d] =/= 0) s 
| async^l s 
| finish^l s 
| f i ()^l 
Expression : e ::= c 
| a[d] + 1 

Based on the syntax and semantics in that paper this language looks to be not a functional language, but a more traditional imperative language with a fork-join semantics built in (fork = async, join = finish). It's pretty much diametrically opposed to scala. Scala is functional at its core and add actors on top as a parallel execution model. 

Best wishes,

--greg


On Sat, Jan 30, 2010 at 9:16 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Hi all,

Did anyone look into X10 language? ... many things in there are very Scala-ish but I wonder if anyone used it and perhaps share the experience?

Br's,
Marius



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Mats Henricson | 1 Feb 08:25
Picon

Re: Scala coding guidelines needed? NOT formatting style!

jonathan mawson wrote:
> That sounds sane to me. Surely there are guidelines that everyone must agree
> with? "Use val rather than var whenever possible." "Don't extend Application
> when performance matters" "Understand that Range uses lazy evaluation - and
> that it is contagious" (Although that one is about to be obsolete.) 
> 
> It isn't a question of "rules" as much as the knowledge that gives you a
> real feel for a language and how to use it safely and efficiently. It's a
> list of Why's rather than of Do's and Don'ts that is needed.

I think "why's" are too vague. Simply because they can't be used
at code reviews. Also, they can't be used for automatic code
inspections, performed by computers. Example:

   Understand that Range uses lazy evaluation - and that
   it is contagious

What is a computer to do with such a rule or recommendation?
It can't possibly know if the author of the code understands
ranges or not. And arguing about this at a manual code review
is dangerous; "You simply don't understand ranges", "Yes I do,
but in this case the laziness don't apply".

Therefore I think do's and don'ts are better, and in this
particular case I would start with something like this:

   Only use ranges when... "something"

If you can't replace "something" with well written text, then
this isn't well understood enough, or well agreed upon enough,
to become a rule or a rec.

My suggestion is to craft rules and recommendations only for
cases that

1. are important - it is better to have five recs too few than
   one rec too many, since petty nitpicking undermines the
   authority of a coding standard
2. are common - really weird corner cases will bite some people,
   but only so rarely that it is not worth the time to bother
   everyone with them
3. are specific - vague well meaning text makes noone happy

Mats

Stefan Langer | 1 Feb 09:45

Re: Scala vs. X10

Wouldn't this be better put on scala-debate as it is not, although interesting,  a question about scala

-Stefan

2010/2/1 Marius Danciu <marius.danciu <at> gmail.com>
Hi Greg,

Yup, pretty interesting way to do things and yes very intuitive and I love the monadic style.

Br's,
Marius


On Mon, Feb 1, 2010 at 6:54 AM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Marius,

One of the slickest ways i've seen people introduce fork-join parallelism is Caires' parallel let-form. This is monadic (a big plus!), gives rise to some very nice syntactic sugar and fits the functional paradigm quite well. The basic form is

let ptn1 <- expr1, ..., ptnK <- exprK in expr

The semantics is that you don't get to do expr until all of the let-assignments (ptnj <- exprj) have completed. Then, the  usual sugar for sequential composition embeds perfectly.

expr1 ; expr2 := let dummy <- expr1 in expr2 // with dummy fresh in expr2

while the notion of simply running things in parallel embeds as

expr1 | expr2 := let dummy1 <- expr1, dummy2 <- expr2 in ()

As you can imagine, this has a very natural interpretation in terms of for-comprehensions. 

Beyond that, this approach fits well with a very intuitive behavioral type system.

Best wishes,

--greg


On Sun, Jan 31, 2010 at 6:47 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Greg, 

I agree that X10 is not in essence a functional language but a rather heavily imperative language (still they have function types but of course this doesn't make it a functional language :) ) with interesting concurrency control mechanisms. finish/async could be written in Scala as a library though ;) The concept of places is also interesting.. 

I was basically referring to its syntax to be similar with scala.

Br's,
Marius


On Sun, Jan 31, 2010 at 7:57 AM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Marius,

Thanks for the pointer to x10. Taken from a recent paper about x10, a featherweight version of the language can be captured by the grammar

Program : p ::= void f_i () { s_i }, i ∈ 1..u 
Statement : s ::= skip^l 
| i s 
Instruction : i ::= skip^l 
| a[d] =^l e; 
| whilel (a[d] =/= 0) s 
| async^l s 
| finish^l s 
| f i ()^l 
Expression : e ::= c 
| a[d] + 1 

Based on the syntax and semantics in that paper this language looks to be not a functional language, but a more traditional imperative language with a fork-join semantics built in (fork = async, join = finish). It's pretty much diametrically opposed to scala. Scala is functional at its core and add actors on top as a parallel execution model. 

Best wishes,

--greg


On Sat, Jan 30, 2010 at 9:16 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Hi all,

Did anyone look into X10 language? ... many things in there are very Scala-ish but I wonder if anyone used it and perhaps share the experience?

Br's,
Marius



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com


Bill Burdick | 1 Feb 09:51
Picon

Nightly build logs page nonfunctional

I'm not sure whether this is intensional or not, but this has been nonfunctional for a while: http://scala-webapps.epfl.ch/hudson/view/Nightly/job/scala-nightly-main/  If it's intentional, maybe the "nightly build logs" link should be taken out of the "Nightly builds" section on the download page.


Bill
michid | 1 Feb 11:47
Picon
Gravatar

Re: Possible bug in typechecker

Ben,

> abstract class Context[Dim <: Dimension] {
> 	val c1: Dim#ContainerType
> 	val c2: Dim#ContainerType

I think the problem is that the existential X refers (expands to) to different
types for c1 and c2.

Michael


Gmane