Erlang Mailing Lists

Author Message

<  Erlang  ~  erl vs escript

mcandre
Posted: Sat Feb 26, 2011 10:05 pm Reply with quote
Joined: 26 Feb 2011 Posts: 2
Disclaimer: This is NOT a rant but a plea for change. I am a Haskeller and I want to program in Erlang as swimmingly as I can in other language environments.

SHEBANGS

The disunity between erl and escript is killing me. My .escripts give me errors for recursive calls, saying functions "don't exist". Only when I compile them in erl does escript play nicely.

However, shebangs (#!/usr/bin/env escript) confuse erl. I've got a curses/cecho program that needs to use a shebang or it crashes, and erl refuses to compile it with the shebang.

Please, please, please add shebangs as comments to Erlang's syntax.

Also, I've like to be able to run Erlang scripts by calling "erl somescript" from the command line. There's no reason erl couldn't call escript in that case.

QUITTING ERL

I had no freaking clue how to quit erl until I Googled it. Python, Ruby, even CLISP let you exit by entering an "exit" command. There is no way Erlang newbies are going to guess that "q()." quits erl. They're just going to hold Control+C until erl shuts up. Oh, and mysteriously, Erlang takes several seconds to quit once the magic command, "q()." is entered.

ERL BREAKS

Which brings us to the (a)bort (c)ontinue (p)roc info menu. There's no option to stop evaluation and ask the user for further Erlang statements.

ERLANG SIGNALS

Erlang is designed for passing messages between processes. Unless I have been misinformed, Erlang ironically and infuriatingly has no POSIX signal capability. I want to do this:

Code:
main(_) ->
   receive
      {posix, sigint} ->
         save(UserData),
         io:format("Quitting...~n"),
         exit()
   end.

ERLANG SYNTAX

As a Haskeller, I understand much of Erlang's syntax and semantics. I wish that Erlang didn't borrow so much of its syntax from Prolog; Having to specify function arity and three different line endings (period, comma, semicolon), slow me down.

ERLANG ERRORS

Many errors are a product of Erlang's unwieldy syntax and the disunion between erl and escript. Failure to compile before running with escript for recursive calls, failure to export functions, failure to specify function arity, failure to use the right line ending, failure to surround io:format arguments inside brackets, ...

These things are easy mistakes for anyone to make, and Erlang just says "Missing )", something entirely unrelated semantically and spatially to the real error in the code.

ERLANG DOCUMENTATION

The official Erlang docs are often too vague to be helpful. More examples would be nice. I love erldocs.com; they should be the official docs.

ERLANG PACKAGE MANAGERS

I suppose Faxien is the de facto Erlang package manager, but I'm not sure. Is it EPM? Is it Agner? Erlang should adopt one of these as the official package manager and devote resources to porting as many packages as they can to a mainline Erlang repository. Something like CPAN, RubyGems, LuaRocks, etc.

CONCLUSION

I'm like to program more often in Erlang, but stupid little hurdles like "q()." keep getting in my way, shifting developmental resources to bug reporting. I have to spend literally hours tracking down problems, carefully explaining them online, and waiting for knowledgable replies. Usually, the replies are of the form, "Sorry, Erlang just doesn't have that ability."

This is because Erlang was invented before Unix-style scripting became popular. Well, it's time to enable Unix-style scripting. I'm not asking for Erlang to become a scripting language, just to add perfectly reasonable things like shebang comments to the ordinary syntax.
View user's profile Send private message
rvirding
Posted: Tue Mar 01, 2011 1:46 am Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
So many things here. I will try to take care of a few anyway.

The first thing to realise is that the erlang system internally behaves more like an operating system than a single program. There are at least 25 erlang processes running when you start the system, this before you actually do something. This I think can answer some of your questions.

mcandre wrote:
QUITTING ERL

I had no freaking clue how to quit erl until I Googled it. Python, Ruby, even CLISP let you exit by entering an "exit" command. There is no way Erlang newbies are going to guess that "q()." quits erl. They're just going to hold Control+C until erl shuts up. Oh, and mysteriously, Erlang takes several seconds to quit once the magic command, "q()." is entered.

ERL BREAKS

Which brings us to the (a)bort (c)ontinue (p)roc info menu. There's no option to stop evaluation and ask the user for further Erlang statements.


Doing 'q().' tells the Erlang systems to terminate itself, which it does by terminating all the servers running in a clean way. Doing Control+C and then abort just kills the OS process running erlang. Sort of like the difference between doing a shutdown on your computer compared to pulling out the power cable.

mcandre wrote:
ERLANG SYNTAX

As a Haskeller, I understand much of Erlang's syntax and semantics. I wish that Erlang didn't borrow so much of its syntax from Prolog; Having to specify function arity and three different line endings (period, comma, semicolon), slow me down.

The thing to realise is that comma and semicolon are NOT terminators but separators, they come between things (expressions and clauses) and not at the end of things. Here is a good comment On Erlang's Syntax. He has also written a very netbook on erlang Learn You Some Erlang.

mcandre wrote:
ERLANG DOCUMENTATION

The official Erlang docs are often too vague to be helpful. More examples would be nice. I love erldocs.com; they should be the official docs.


This I find a little strange as all the documentation in erldocs has been taken directly from the official documentation at erlang.org. What they have done is restructure to make it easier to search and find things in it. Though the official docs are not difficult once you grasp how they are structured. Have you looked through the System Documentation sections? There are quite a few examples there.

And shebang comments won't work as the # character is already in use.

I'll be back.

_________________
Robert Virding, Erlang Solutions Ltd.
View user's profile Send private message Visit poster's website MSN Messenger
dgulino
Posted: Tue Mar 01, 2011 7:45 pm Reply with quote
Joined: 01 Mar 2011 Posts: 5
I agree with with mcandre in spirit; there are tons of benefits if you go along with the *nix standards. And the erl console in *nix doesn't compare to something like 'ipython', but seems to have been a good ancestor of it.

Here's a kludge workaround if you compile with 'erlc' (not in the erl console): Remove the first line of the file and compile the rest.

Unfortunately, I haven't figured out how to make the new compiled code available in the console. You need to restart erl to use the new compiled code. It would be cool if erl auto checked the filesystem for updated .beam files; you more easily combine working with the console and build scripts.

example:
Code:

#!/usr/bin/bash
test=$1
echo $test

args=("$@")
file="$1"
echo ${file}
temp_file=$1.tmp
echo $temp_file
cp $file $temp_file
sed -n '1!p' $temp_file > $file
/usr/bin/env erlc $file
cp $temp_file $file
rm $temp_file
View user's profile Send private message
dongdongwu
Posted: Thu Sep 20, 2012 6:43 am Reply with quote
User Joined: 19 Sep 2012 Posts: 236
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
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