Erlang Mailing Lists

Author Message

<  Erlang questions mailing list  ~  Erlang Syntax - again

rvirding
Posted: Mon Mar 10, 2008 10:27 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
Hello all,

I have read Damien's post and Yariv's reply. My question is: they say what they don't want, but what do they actually want? I mean this question seriously. Perhaps someone who is new to the language could answer and tell what they found most difficult when learning the syntax. I have spoken Erlang so long that I see it as natural, warts and all.

Even records look like they do for a specific reason and it is harder than you would think to change them. Other Erlang features force issues.

Getting back. What do people want? Do they want something that looks like Java, or C++, or Python, or Perl, or ... ? This is actually possible to do, BUT (there is always a but) you would not have the Java or C++ or Python or ... semantics, you would still have Erlang semantics. Would we then get complaints that while it looks like Java it doesn't behave like Java, and why not?

As I said I am serious about this question, even if we don't do a JFE (Java Flavoured Erlang) it would be interesting to know what people want. Do people know what they want? Is or is it just that it looks and behaves differently to what they are used?

Robert


Post recived from mailinglist
View user's profile Send private message Visit poster's website MSN Messenger
kscaldef
Posted: Mon Mar 10, 2008 11:22 pm Reply with quote
User Joined: 12 Feb 2008 Posts: 27
On Mar 10, 2008, at 3:26 PM, Robert Virding wrote:

> Hello all,
>
> I have read Damien's post and Yariv's reply. My question is: they
> say what they don't want, but what do they actually want? I mean
> this question seriously. Perhaps someone who is new to the language
> could answer and tell what they found most difficult when learning
> the syntax. I have spoken Erlang so long that I see it as natural,
> warts and all.

"if" is very unintuitive. As best as I can remember, everything else
was a minor annoyance at worst. I certainly wouldn't complain if
lambda functions and records were less verbose, but they weren't
_difficult_ to learn the syntax.

>
> Even records look like they do for a specific reason and it is
> harder than you would think to change them. Other Erlang features
> force issues.
>
> Getting back. What do people want? Do they want something that looks
> like Java, or C++, or Python, or Perl, or ... ? This is actually
> possible to do, BUT (there is always a but) you would not have the
> Java or C++ or Python or ... semantics, you would still have Erlang
> semantics. Would we then get complaints that while it looks like
> Java it doesn't behave like Java, and why not?

Personally, I would like it if functional programming were better
supported and less verbose. (i.e., function composition, lambda
functions, currying and partial application, etc). user-defined infix
operators might also be nice.


-kevin
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
View user's profile Send private message
chandru.m
Posted: Mon Mar 10, 2008 11:30 pm Reply with quote
User Joined: 24 Oct 2007 Posts: 85
On 10/03/2008, Robert Virding <rvirding@gmail.com> wrote:
> Hello all,
>
> I have read Damien's post and Yariv's reply. My question is: they say what
> they don't want, but what do they actually want? I mean this question
> seriously. Perhaps someone who is new to the language could answer and tell
> what they found most difficult when learning the syntax. I have spoken
> Erlang so long that I see it as natural, warts and all.

I was new to the language ten years ago. I didn't understand how I
could write serious programs with single assignment. 30 minutes later
that problem was solved. I've never really looked back since then. All
the complaints about erlang seem whimsical at best and attention
seeking at worst.

I've written a fair amount of erlang code over the years, and I
honestly can't think of any time when I felt that the erlang was
impeding my progress. And it is getting better by the day. The bit
syntax, xref, dialyzer, typer, SMP erlang...

I remember being quite delighted when records came along in erlang.
Suddenly it became much easier to maintain state in servers. All these
complaints remind me of this article:
http://www.kenrockwell.com/tech/notcamera.htm

cheers
Chandru
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
View user's profile Send private message
Guest
Posted: Tue Mar 11, 2008 12:20 am Reply with quote
Guest
On Mar 10, 2008, at 4:28 PM, Chandru wrote:

> I was new to the language ten years ago. I didn't understand how I
> could write serious programs with single assignment. 30 minutes later
> that problem was solved. I've never really looked back since then. All
> the complaints about erlang seem whimsical at best and attention
> seeking at worst.

I find the syntax termination to be annoying, I never get it right,
the complier always gives me some misplaced ';', '.', or ','
somewhere so it slows me down, I do slowly get better at it
overtime, but it's extra mental energy. So what I'd like the syntax
to allow reordering of lines via editor's cut in paste to less
frequently break code, not to mention be simpler to enter the first
time.

Maybe that's whimsical.

However, imagine all the mental energy as each programer re-learns
some idiosyncratic thing that could be saved in the cases where those
idiosyncrasies can be eliminated. Say it takes 30mins to get over
Single Assignment, that probably has enough value to be worth it.
[ well at least I think it does ] but if you can give back 30min
[ more? ] to millions of programmers who keep getting compiler
errors do to a reordering of lines causing the wrong terminator in
the wrong place well, that's a whole lot of time to give back to the
world. Of course then they'll just use that time to complain about
whimsical stuff.

Anyhow, it seems that code is the humans interface to instructing
the machines what to do, and as such it should be a very human
interface. Of course what that is is very debatable, but in the end
it's probably worth it to constantly improve the interface.

--fess


_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 12:49 am Reply with quote
Guest
Hi,

If I could change just one thing about Erlang's syntax, I would want to allow an optional semicolon before a "case" expression's "end", just so I could do:

case myfun(abc) of
zot -> bar;
zing -> baz;
end,

and swap the "zot" and "zing" lines without getting a compilation error.

Following this through to its natural (but uglier) conclusion would be to allow trailing commas in -record definitions, -export and -import lists, and before a "fun" expression's "end".

In short, I have never thanked the compiler for pointing out to me that I forgot that a statement was the last one in a comma or semicolon-separated list. If there was a nice-looking way to terminate a top-level function without putting a period behind the return value, I'd suggest that too, but I can't think of any.

These changes are all motivated because I use an editor where cutting and pasting a single line is really easy, but manipulating punctuation is not.

Thanks for listening,

--
Michael FIG <fig@marketelsystems.com>, PMP
MarkeTel Multi-Line Dialing Systems, Ltd.
Phone: (306) 359-6893 ext. 528

_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 1:26 am Reply with quote
Guest
Hi again,

[Sorry for the self-reply, but on reading more e-mail it seems a lot of people are focusing on this issue. This is a continuation of my prior mail.]

My suggestion for top-level functions would be:

doit(abc) ->
some(),
other(),
stuff(),
;
doit(def) ->
some(),
stuff(),
;

fruit(apple) ->
ok,
;


In other words, allow semicolon to be used as a substitute for period (by eliminating the "head mismatch" error when it is followed by another function, and the "unterminated function" error when it is at the end of file), and allow an optional comma before the function terminator.

Then, people can program as if "," means "end expression" and ";" means "end block". Note that all of these suggestions are backward-compatible with the old syntax. I think that would help satisfy the separator vs. terminator debate without having to force anybody to change their existing style (or (heaven forbid!) introduce whitespace into the syntax ala Python or Haskell).

I hope this answers your question as to my own personal annoyance, and how I would solve it if I had a choice,

--
Michael FIG <fig@marketelsystems.com>, PMP
MarkeTel Multi-Line Dialing Systems, Ltd.
Phone: (306) 359-6893 ext. 528

_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 1:33 am Reply with quote
Guest
On Mon, Mar 10, 2008 at 5:46 PM, Michael FIG <fig@marketelsystems.com> wrote:
> Hi,
>
> If I could change just one thing about Erlang's syntax, I would want to allow an optional semicolon before a "case" expression's "end", just so I could do:
>
> case myfun(abc) of
> zot -> bar;
> zing -> baz;
> end,
>
> and swap the "zot" and "zing" lines without getting a compilation error.
>
> Following this through to its natural (but uglier) conclusion would be to allow trailing commas in -record definitions, -export and -import lists, and before a "fun" expression's "end".
>

Allowing trailing commas in lists would be very convenient as well,
that's one thing I really like about Python's grammar.

-bob
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 3:50 am Reply with quote
Guest
On 11 Mar 2008, at 1:46 pm, Michael FIG wrote:

> Hi,
>
> If I could change just one thing about Erlang's syntax, I would want
> to allow an optional semicolon before a "case" expression's "end",
> just so I could do:
>
> case myfun(abc) of
> zot -> bar;
> zing -> baz;
> end,

I wish I could remember which programming language it was that allowed
an optional occurrence of its equivalent of the semicolon at the
BEGINNING.
Because what I've always wanted is
case myfun(abc) of
; zot -> bar
; zing -> baz
end

Currently I write
case myfun(abc)
of zot -> bar
; zing -> baz
end
and it seems to work out OK.

Ada of course uses 'when' the way I'm using ';', and it's not optional.

Why do I want to put the ';' at the beginning of a line?
Because patterns in Erlang designedly look a whole lot like expressions,
and I want it to be *obvious* to the reader, especially me, that
"here is a pattern".

_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 6:43 am Reply with quote
Guest
Hi Robert,

I think the "issues" with Erlang's syntax are quite overblown. They
took me about a day to master and I hardly notice any of them when I'm
actually writing and editing code. I certainly don't want Erlang to
look any more like Java/C than it does now. I'm pretty happy with the
Erlang syntax (I also think that LFE provides a very interesting
option for those who are curious about Lisp Smile )

The main change I would like to see is to have the compiler
automatically infer the types of record variables (when possible) to
shorten the amount of code required for accessing their properties. I
created an unfinished solution here:
http://code.google.com/p/recless/. This page has a couple of examples
for how it could be used.

I would also like to be able to overload macro names with different
arities and to have some mechanism for introspecting the properties of
records and accessing them dynamically at runtime.

Best regards,
Yariv


2008/3/10 Robert Virding <rvirding@gmail.com>:
> Hello all,
>
> I have read Damien's post and Yariv's reply. My question is: they say what
> they don't want, but what do they actually want? I mean this question
> seriously. Perhaps someone who is new to the language could answer and tell
> what they found most difficult when learning the syntax. I have spoken
> Erlang so long that I see it as natural, warts and all.
>
> Even records look like they do for a specific reason and it is harder than
> you would think to change them. Other Erlang features force issues.
>
> Getting back. What do people want? Do they want something that looks like
> Java, or C++, or Python, or Perl, or ... ? This is actually possible to do,
> BUT (there is always a but) you would not have the Java or C++ or Python or
> ... semantics, you would still have Erlang semantics. Would we then get
> complaints that while it looks like Java it doesn't behave like Java, and
> why not?
>
> As I said I am serious about this question, even if we don't do a JFE (Java
> Flavoured Erlang) it would be interesting to know what people want. Do
> people know what they want? Is or is it just that it looks and behaves
> differently to what they are used?
>
> Robert
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@erlang.org
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
Guest
Posted: Tue Mar 11, 2008 9:03 am Reply with quote
Guest
Yariv Sadan wrote:
> Hi Robert,
>
> I think the "issues" with Erlang's syntax are quite overblown. They
> took me about a day to master and I hardly notice any of them when I'm
> actually writing and editing code. I certainly don't want Erlang to
> look any more like Java/C than it does now. I'm pretty happy with the
> Erlang syntax (I also think that LFE provides a very interesting
> option for those who are curious about Lisp Smile )
>
> The main change I would like to see is to have the compiler
> automatically infer the types of record variables (when possible) to
> shorten the amount of code required for accessing their properties. I
> created an unfinished solution here:
> http://code.google.com/p/recless/. This page has a couple of examples
> for how it could be used.
>
> I would also like to be able to overload macro names with different
> arities and to have some mechanism for introspecting the properties of
> records and accessing them dynamically at runtime.

This is almost what I was about to write (except that I don't have partial
solution to the problem Smile

For me, the syntax is still a bit too noisy. Whenever I write a module and
compile it I have two or three comile-error cycles on errors that wouldn't
be there if the syntax was a little bit different. But as many pointed out
this is not a big deal really.

But what I would like to have in Erlang is definitely better introspection /
reflection capabilities. I would like to have records as runtime structures,
so I could write:

Var#{x = foo, y = bar}

where Var could be any record that has slots x and y (it might have others),
record_info would be a normal function that can operate on variables.

I would also very much like to be able to programmatically create/inspect/modify
receive (and other) clauses at runtime. But this is just wishful thinking I think.

Ladislav Lenart


_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
uwiger
Posted: Tue Mar 11, 2008 10:02 am Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
Richard A. O'Keefe skrev:
>
> Currently I write
> case myfun(abc)
> of zot -> bar
> ; zing -> baz
> end
> and it seems to work out OK.
>
> Ada of course uses 'when' the way I'm using ';', and it's not optional.
>
> Why do I want to put the ';' at the beginning of a line?
> Because patterns in Erlang designedly look a whole lot like expressions,
> and I want it to be *obvious* to the reader, especially me, that
> "here is a pattern".

And for those who continuously have problems with the different
trailing deliminators, this could pretty much solve the problem.

Of course, using Emacs, one would have to turn off the "electric
semicolon" feature, which often gets it wrong, anyway. The
auto-indentation of the emacs mode also butchers this style of
writing. So any emacs user who hasn't dug into the .emacs file
changing the defaults, would most likely go bezerk if they had
to edit a program written in this style - that - or turn off the
emacs erlang-mode completely.

(Not saying this couldn't be fixed. I also find the style visually
appealing.)

BR,
Ulf W
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
View user's profile Send private message Visit poster's website
uwiger
Posted: Tue Mar 11, 2008 10:19 am Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
Robert Virding skrev:
>
> Getting back. What do people want? Do they want something that looks
> like Java, or C++, or Python, or Perl, or ... ? This is actually
> possible to do, BUT (there is always a but) you would not have the Java
> or C++ or Python or ... semantics, you would still have Erlang
> semantics. Would we then get complaints that while it looks like Java it
> doesn't behave like Java, and why not?

I think this is a very valid question.

Differences in syntax actually play an important role in conveying
differences in semantics. Deliberately copying the syntax of another
language might lead to lots of confusion if one doesn't copy the
semantics as well.

It reminds me of one of my favorite gripes about UML. The main
point of a standard notation is that everyone should be able to
look at a symbol an immediately agree on what it means. The UML
approach has been to include everything in the standard, leading
to a huge specification that no mortal fully understands, and then
leaving enough vital details undefined so as to allow tool makers
to make their own UML adaptation with the same symbols, but slightly
different semantics...

Some aspects of the syntax could perhaps be polished without
falling into this quagmire of semantics confusion, though.
I haven't used Erlang as long as you have (few have, obviously),
but long enough to have developed a similar blindness to its
faults.

If I were to make some suggestions, I would perhaps choose:

- A more compact lambda notation (Haskell envy) (*)

- Record syntax improvements that make record operations more
portable across modules, and reducing the very unfortunate
compile-time dependencies.

- A way to parameterize receive clauses (or perhaps pattern
matching in general, but it hurts the most in receive).

BR,
Ulf W

(*) I will say, though, that the erlang lambda syntax is
much more obvious (if a bit verbose) than the Haskell version.
When damaged by other languages, one can stare for quite a
while at a Haskell expression and not have a first clue about
what it does, since the syntax is so different. This surely
scares people, when they could learn to love the syntax if
they only set aside a full day of intense study.

Someone said "learning haskell is hard, but /programming/
haskell is easy. In a way, I think this gives a very important
perspective on the syntax debate. It's less important what
you think of the syntax at first sight, than it is what you
think of it after a year or more. Having said that, Damien
Katz is obviously no beginner, so he ought to fall in the
latter category...
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Post recived from mailinglist
View user's profile Send private message Visit poster's website
Guest
Posted: Tue Mar 11, 2008 10:22 am Reply with quote
Guest
On Tue, Mar 11, 2008 at 10:02 AM, Ladislav Lenart <lenartlad@volny.cz (lenartlad@volny.cz)> wrote:
Quote:
Yariv Sadan wrote:
> Hi Robert,
>
> I think the "issues" with Erlang's syntax are quite overblown. They
> took me about a day to master and I hardly notice any of them when I'm
> actually writing and editing code. I certainly don't want Erlang to
> look any more like Java/C than it does now. I'm pretty happy with the
> Erlang syntax (I also think that LFE provides a very interesting
> option for those who are curious about Lisp Smile )
>
> The main change I would like to see is to have the compiler
> automatically infer the types of record variables (when possible) to
> shorten the amount of code required for accessing their properties. I
> created an unfinished solution here:
> http://code.google.com/p/recless/. This page has a couple of examples
> for how it could be used.
>
> I would also like to be able to overload macro names with different
> arities and to have some mechanism for introspecting the properties of
> records and accessing them dynamically at runtime.


This is almost what I was about to write (except that I don't have partial
solution to the problem Smile

For me, the syntax is still a bit too noisy. Whenever I write a module and
compile it I have two or three comile-error cycles on errors that wouldn't
be there if the syntax was a little bit different. But as many pointed out
this is not a big deal really.

But what I would like to have in Erlang is definitely better introspection /
reflection capabilities. I would like to have records as runtime structures,
so I could write:

noss
Posted: Tue Mar 11, 2008 11:09 am Reply with quote
User Joined: 09 Oct 2005 Posts: 290
> It is misunderstand what record is. Record is not this sort of things. Use
> our own structure for this purpose. Record is not object, hash, dictionary
> or whatever you really want. Record is not designed for some sort of
> inheritance. Record is structure for memory friendly storage of fixed
> "records" a which one will be changed very rare and just only by design.

That is what they are. What we want might be something else though.


Thinking out loud:

Would it be possible to create a pattern matching syntax for some kind
of association map?

As I understand it, guards without near O(1) properties are not that
popular. But others do exist already.

Perhaps something that recognizes {[Fields::atom()],
FieldValue1::term()} so that
both {[gurka, avocado, sallad, dressing], 1, 2, 3, 4} and {[tacos,
salsa, avocado], 8, 4, 2} could be
matched when asking for avocado=2 in this something.

%% What better character to use for a beta feature than
View user's profile Send private message
Guest
Posted: Tue Mar 11, 2008 12:30 pm Reply with quote
Guest
On Tue, Mar 11, 2008 at 12:05 PM, Christian S <chsu79@gmail.com (chsu79@gmail.com)> wrote:
Quote:
> It is misunderstand what record is. Record is not this sort of things. Use
> our own structure for this purpose. Record is not object, hash, dictionary
> or whatever you really want. Record is not designed for some sort of
> inheritance. Record is structure for memory friendly storage of fixed
> "records" a which one will be changed very rare and just only by design.


That is what they are.

Display posts from previous:  

All times are GMT
Page 1 of 3
Goto page 1, 2, 3  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum