Recommendation for simple programming language for utilities

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
veronicathecow
Posts: 559
Joined: Sat 21 Oct 2006, 09:41

Recommendation for simple programming language for utilities

#1 Post by veronicathecow »

Hi, I want to try and muck around making a few little utilities to do things like mount drives.
Can anyone recommend a simple language for me to use (I've used Spectrum Basic, QBasic, Visual Basic and many years ago some hex 8085)
Something to make some simple boxes and to be able to use command like Mount.
Any thoughts appreciated but please remember I really am a beginner here and work best by seeing example programs that are commented.
Many thanks

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#2 Post by Lobster »

:)

There are many reasons why I suggest using BASH
Dialects of Basic (such as Puppy Basic) still await a comprehensive manual / tutorial

Bash is VERY powerful, the chances are you will be calling BASH (Bourne Again SHell) from your choosen language

http://puppylinux.org/wikka/ProgrammingLanguage
http://puppylinux.org/wikka/PuppyBasic
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

wdef
Posts: 91
Joined: Fri 13 Apr 2007, 20:16

#3 Post by wdef »

You can make simple boxes and things with bash using dialog or one of its variants. Not that pretty but it works.

If you know and love any perl: perlgtk or perlgtk2 is quite a powerful gui methodology, I've used it. A good example of a well-known program with a perlgtk GUI would be dvd::rip. It's not trivial to learn, and you need to know a little perl.

Lua guis using flua (is it?) and John Murga's own MurgaLua is a very light and fast GUI language, used with great effect in damnsmalllinux. Lua addicts swear by it..

BTW, the two most useful languages you can learn in linux are bash and perl. The former glues most systems together and is the lingua franca; the latter can just about do anything.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#4 Post by GuestToo »

Puppy 216's devx has FreeBasic, which is based on Qbasic/QuickBasic syntax ... if you are familiar with Qbasic, you will feel at home using FreeBasic ... though you would need to interface with other libraries/programs to create gui windows

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Simple programming languages

#5 Post by vovchik »

Dear VtC,

If you really don't like bash's crypting syntax, you can use a variety of interpreters out there as shells. FreeBasic comes with fbsh - which is a scripting Basic you can use to write your own "bash-like" scripts in Basic. You could also get brandy (BB Basic V, as in Acorn and Archimedes), WSbasic or MoleBasic. They are rather small. WS weighs in at 119k and BBC basic (brandy) is not much larger (at 194k). You need to include the "shebang" character combination at the top of your basic script to get it to run "automatically". All the above allow you to execute external (i.e. Unix) commands and to get the results back from either stderr or stdout. What follows is just a silly WSbasic example I did for demonstration purposes. What is key here is that I get the ls listing (or any output) into a variable and can then manipulate it or use it, for instance, to control conditional branching. If you're interested I could upload my recently compiled verions brandy and wsbasic for you to have a look at.

With kind regards,
vovchik

-------------------

#!/usr/local/bin/wsbasic
# usage: p <target address for ping> (the default is my ISP gateway)

# -------------------------------------------------------------------

# This script pings a target address five times every 60 seconds and
# then shows the results in a terminal. The program continues in
# an endless loop until Ctrl-C is pressed. All functions must be defined
# at the top, before the actual program is invoked. The default target
# address can be changed via the default_addr var in the initialize
# variables section (set to my local IP by default).

# 29 April 2007, vovchik
# -------------------------------------------------------------------
# define printx - print external function
# -------------------------------------------------------------------

# this function removes the last byte from stringvars
# passed to wsbasic via an external call - i.e. run(x) - that terminate with a
# a superfluous LF.

function printx(xstring)
begin
print left(xstring,len(xstring)-1)
end # end function printx()

# -------------------------------------------------------------------
# define makeline - string concatenation function
# -------------------------------------------------------------------

# this function creates a long string of hyphens, used to separate
# elements of the screen display.

function makeline(stringvar,integer)
begin
catstring = ""
for xx = 1 to integer
begin
catstring = catstring + stringvar
end
return catstring
end # end function makeline()

# -------------------------------------------------------------------
# initialize variables - some only for the sake of Pascal-like formality
# -------------------------------------------------------------------

cmd_line = "" # only a formalism
xstring = "" # only a formalism
target_addr = "" # only a formalism
default_addr = "192.168.0.1" # default ping target - change to suit your needs
null_string = "" # just initialization of string
dummy_var = 0 # dummy var value for endless loop
run_count = 0 # iteration counter - only for information
hyphen = "-" # char passed to makeline function
long_line = makeline(hyphen,70) # invocation of function to create long hyphen string
ping_cmd="ping -c 5 " # actual unix ping command for 5 ping requests
delay = 60 # duration of delay (seconds) between invocations
getdate="date" # unix date command
usr_msg = "Pausing for " + delay + " seconds... Interrupt program with Ctrl-C."

# -------------------------------------------------------------------
# check the command line for arguments
# -------------------------------------------------------------------

# Wsbasic, when run as a shell interpreter, assigns #$ to the complete
# command line. This includes arg $0 as /usr/local/bin/wsbasic (in
# my case) and arg $1 as the actual program being run (p in this case).
# The first real arg - i.e., the first parameter passed to the program - is $2.

cmd_line = $2
if cmd_line==""
begin
target_addr = default_addr
end
else
begin
target_addr = $2
end # end of cmd_line argument check

# -------------------------------------------------------------------
# start main program - endless loop
# -------------------------------------------------------------------

while dummy_var < 1
begin
print long_line
run_count = run_count + 1
print "Iteration: ", run_count
a=run(getdate)
printx(a)
print long_line
do_ping=run(ping_cmd + target_addr)
printx(do_ping)
print long_line
print usr_msg
do_delay=run("sleep " + delay)
print null_string
end # end of main endless while loop

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#6 Post by Gekko »

I recommend Ruby. http://www.ruby-lang.org Theres an online tutorial on the side.

User avatar
drongo
Posts: 374
Joined: Sat 10 Dec 2005, 23:35
Location: UK

#7 Post by drongo »

vovchick,

If I could get hold of a version of BBC Basic (aka brandy) that worked in Puppy I would never ask for anything else on this forum ever again! (Until I think of something else.)

How could I get a copy and what would I have to do to get it working in Puppy?

25 years ago many people in the UK (including lots of school-children) cut their programming teeth on BBC Basic. I'm sure all of the more modern languages have many fine features, but a structured basic on linux sounds perfect.

drongo

User avatar
drongo
Posts: 374
Joined: Sat 10 Dec 2005, 23:35
Location: UK

#8 Post by drongo »

deleted - double post - it wasn't me it was the Forum software made me do it!

drongo

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Brandy here

#9 Post by vovchik »

Dear Drongo - and VtC,

Here is a little archive containing the brandy interpreter, documentation and some examples. Please unpack the archive to /tmp and then copy the contents to appropriate directories. Brandy (located in the archive within /usr/local/bin) should be copied into your /usr/local/bin. The documentation and examples (some also by me - and rather crude but very structured) should go into /root/my-applications/bin/brandy (or wherever you wish). Let me know whether brandy runs on your system. I compiled it under Puppy 2.10 and all dependecies were satisfied in my setup. When running as a shell, brandy needs the -quit parameter on the unix shebang line. Look at my program d1 in the examples and you'll understand.

With kind regards,
Vovchik

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#10 Post by Lobster »

:) seems to be working OK

BBC Basic is a nice procedural language, I last used it on a BBC Master, when I was learnng Pascal and C (I was rubbish at both)

Many thanks for making it available :)

I only ever wrote one useful program in C - it was actually faster in BBC Basic . . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
drongo
Posts: 374
Joined: Sat 10 Dec 2005, 23:35
Location: UK

#11 Post by drongo »

Thanks vovchick,

This seems to work fine. I can get it to work interactively from the CLI. How do I make one of your examples run? I get an "event not found" error.

It runs a bit faster than a 1981 vintage BBC Micro as well!

Thanks again

drongo

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Examples

#12 Post by vovchik »

Dear drongo,

I never got around to finishing the brandygtk and xec1 examples, since I was only playing with brandy and had about one hour of experience with the language at the time of writing them. At some point I will actually finish them - particularly ones that launch gtk menu-builders - and will then post them. As to your question, to run my examples, simply type:

./progname

when in a terminal.

I agree with Lobster that brandy is a nice language, and it satisfies my requirement for structure and strong variable typing - fewer mistakes that way and the coding is much more transparent than would be otherwise. As you might be able to tell from my little examples, I come from the ancient "Pascal school".

By the way, has anybody seen a reasonable Pascal interpreter? As far as compilers go, there is FreePascal, GNU Pascal, Kylix and something beginning with the letter "N", but I am looking for a small interpreter something like brandy (although, perhaps, brandy will suffice, since I can rewrite most of the statements as procedures with pascal-like names and throw them all into an external lib).

With kind regards,
vovchik

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#13 Post by sunburnt »

veronicathecow must be rather confused by now, all the choices & no clarity.

For the simple GUIs that I made for LanPuppy I used Bash & GTKdialog.
It's crude but simple... Just what you've asked for.

The most complex is a TabPanel of 5 tabs for: AddUsers, AddHosts, Options, etc.
I've also made a file mounter, partition boot mounter, & Samba share mounter.

If your interested, ask & I'll PM you several GUIs & some text help.

User avatar
veronicathecow
Posts: 559
Joined: Sat 21 Oct 2006, 09:41

#14 Post by veronicathecow »

Hi Everyone, my apologies for not being around for a while but a combination of computer problems and lack of cash means that I am having to spend my time doing my book business and sorting out my VERY late Tax. Many thanks for your information and I hope to be back helping in what way I can in a few weeks and I'm sorry for letting you down.
All the best
Tony

Post Reply