How to program in Puppy?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
ViejoVizcacha
Posts: 4
Joined: Mon 04 Apr 2011, 15:57

How to program in Puppy?

#1 Post by ViejoVizcacha »

Hi. I just run Puppy 5.1 from CD on a T30 Thinkpad without hard-drive, and plan to use a USB for my files and for my compiler. I am poor and have no other computer available.
I know a bit of logic of programming and always wanted to program in C, but had to survive instead.
Since Puppy is so powerful as I heard it and am confirming, I chose it to start my adventures in programming.
Something I cannot figure out is how to create a screen with many fields, each one with its own row/col position and attributes and then prompt the screen on C.
Could you please give me a lead, or samples to follow?
Any help and suggestion will be thankfully absorbed.
Thank you for your attention.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#2 Post by nooby »

I am surprised none have wanted to help you, me now writing something maybe even make that harder. I guess you need to check how much RAM memory one need for the overhead of doing C++ programming when the compiler run. I guess you would need at least 512 MB or more???

I trust you should start using the wellminded search and look for threads about C programming. Most likely you need the Dev for Developer extensions?
So search for that one too and see if your USB can have it without getting into trouble.

http://www.wellminded.com/puppy/pupsearch.html
Here is a wikka on how to use puppy to compile in C.

http://puppylinux.org/wikka/compiling

They have this important text
Appendix 1
To convert Puppy into a complete compiler environment it is necessary to acquire a special SFS file that corresponds with the version of Puppy Linux that will be used for compiling. The file has "devx" in its name.
So first you need to decide on which puppy that suites your computer bet with regard to how much RAM memory you have.

I would add a Swap file so you can have some margin and not get hang when it use more RAM than you have.

Beware that Flash memoryies still even if they are better now due to them try to randomly spread the usage of bits they still wear out after some 100,000 writes to a bit. So I would prefer you find a scrapyard that have relatively old computers where you can fine a HDD that works in your computer. Maybe not so easy.

Or get in contact with a firm that give you an old decent computer.
That is more a hit and miss but sometimes do work out if you tell them your interest in getting to know how to program. Sorry that could be difficult if you live where there are few such rich firms with kind managements.

Sometimes schoolteachers knows about such firms.

Others than me have to take over and help you further I wanted you to feel wellcome. Tell more about your computer.

How much RAM does it have and how big is your USB Flash?
I use Google Search on Puppy Forum
not an ideal solution though

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#3 Post by 2lss »

Why don't you give Bacon a try:

http://basic-converter.org/

http://bkhome.org/bacon/

http://www.murga-linux.com/puppy/viewtopic.php?t=48901

You write code in a BASIC style language, then convert it to C using the 'bacon' converter (which also compiles the code).

Its also pretty easy to create a gui using the HUG library listed on the basic-converter site.

Basically, anything you can do in C can be done in bacon....only easier 8)

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

Re: How to program in Puppy?

#4 Post by Moose On The Loose »

ViejoVizcacha wrote:Hi. I just run Puppy 5.1 from CD on a T30 Thinkpad without hard-drive, and plan to use a USB for my files and for my compiler. I am poor and have no other computer available.
I know a bit of logic of programming and always wanted to program in C, but had to survive instead.
Since Puppy is so powerful as I heard it and am confirming, I chose it to start my adventures in programming.
Something I cannot figure out is how to create a screen with many fields, each one with its own row/col position and attributes and then prompt the screen on C.
Could you please give me a lead, or samples to follow?
Any help and suggestion will be thankfully absorbed.
Thank you for your attention.
Before setting out to do the complex stuff do some simple things. You can write the classic "Hello world" program just to see that you can make a program.

For many things the best way to go is to break the user interface question away from the doing the work question. I would write a program that does what you want using the stdin as the control. Once you make it work then you can use gtkdialog to wrap it in a user interface.

ViejoVizcacha
Posts: 4
Joined: Mon 04 Apr 2011, 15:57

Just to acknowledge receipt, since I could not make time...

#5 Post by ViejoVizcacha »

Nooby:
Thank you very much for your concerns. Specially for your welcome. And for your sensible suggestions.
My recently gotten ThinkPad has the following characteristics:
Intel Pentium-4 1.8GHz, 774MB of memory, 1024x768 display, CD-RW, 2 USB (rev 02) ports, Serial, Parallel, PRO/Wireless 2200BG, and a 82801CAM PRO/100 VE Ethernet. And its battery runs a whoopie 20 minutes!
I will use a generic 4GB flash. And I will take caution with the (for me new) pendrive delicate life expectancy.
About devx for my Puppy 5.1.1, I found out this :
http://distro.ibiblio.org/quirky/wary-5 ... vx_511.sfs
Md5sum: 0004010204ac4d74dfa8b60a18b8b615 (I' have to figure out if I need to check-sum the Md5sum.)
What I do not know is whether is appropriate to download devx to the flash, since the "complete compiler environment" would be, in my mind, the CD with the OS plus the flash, in two devices? Or the flash would be the whole "compiler environment" using the Puppy in memory? I'll have to figure this out doing it.
What I could not find any reference to, was "Dev for Developer extensions". I'll search more thoroughly later. Or perhaps illumination will come in the doing.
I will try to avoid the investment of approx $50 in an Ebay 40GB 44-pins-HD, for the moment though. In my fantasy, me and my pendrive, going into the world carrying in my pocket a whole OS plus the ability to program an interactive application on the go for the amazement of my neighbor at the internet-cafe, will get me rich and famous.
About Swap file, I found out http://www.murga-linux.com/puppy/viewtopic.php?t=63585 with a suggestion like "is not needed above 512Mb memory", and carrying also this code for creating the Swap:
========if [ "$PUPMODE" = "12" ];then
if [ -f /initrd/mnt/dev_save/pupswap.swp ];then
echo -n "Activating swap file /initrd/mnt/dev_save/pupswap.swp..." >/dev/console
swapon /initrd/mnt/dev_save/pupswap.swp;check_status $?
else
#only create a swap file if no swap partition...
if [ "`free | grep 'Swap:' | tr -s " " | cut -f 3 -d " "`" = "0" ];then
#v2.02final for now, no auto creation of swap on ntfs partition...
if [ ! "`echo -n "$PUPSAVE" | cut -f 1 -d ',' | grep --extended-regexp 'msdos|vfat|ext2|ext3|reiserfs|minix'`" = "" ];then
'so serie 2 use after 2.02 seem to use swap file but not to create it..'
and running pizzapup (with really puppy 2.14 inside ) i find in /etc/rc.sysinit=========== ... and more.
I still think your proposal of regularly adding the swap is the best, and I will try to insert it in my environment and habits.

2lss:
I will try Bacon, and think will be helpful in my internal-need to be able to figure out how C handles screen-interchange/formating, since a conversion of a BASIC screen would teach me row/column-fields-positioning on C, if I understand it correct. Thank you very much for your help.

Moose On The Loose:
You are right, I should learn basics first. And I will. As soon as I get my hands in a compiler.
I agree with the convenience to look at the program as interface and work 'entities', each with its own dedication and tests. I sense that that is the way you guys do it, but nobody has slapped my head yet and showed me: See? "Do it like this and like that. Do it." and that is my stuck. I think you are stirring me to illumination, when you mention using the gtkdialog instruction? kind of "i/o port command" in my mind, which would send and retrieve a whole screen built up separately in other time(other software?), if I understand it correctly. I guess 'stdin' is the C definition of keyboard, being 'control' the C flow of execution, and these instructions will help me to 'google the going'.
Again, my thanks to all of you. I will post as I go.

2byte
Posts: 353
Joined: Mon 09 Oct 2006, 18:10

#6 Post by 2byte »

ViejoVizcacha

About a swap file. It's easy to make and use one. A swap partition isn't a requirement.
To create a 512 MB swap file:
dd if=/dev/zero of=my.swp bs=1M count=512
mkswap ./my.swp

To use the swap file on a USB mounted as /mnt/sdc1:
swapon /mnt/sdc1/my.swp

Whether a swap file is needed or not depends on what apps are loaded and what they are doing. For instance, Puppy crashed on me once without a swap file when I used Rox to look at a Windows directory with a huge number of files in it. I also had Open Office loaded with a large document, was downloading a video from youtube, had Thunderbird email loaded and Firefox with a bunch of tabs open. That machine had 750 MB of memory too. Consider a swap file to be insurance as it will only be written to if it is necessary.

FWIW


nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#7 Post by nooby »

ViejoVizcacha thanks for kind words.

I know too little but as you are aware of the Devx seems too big indeed.

What about the following thread then? some 6 pages where they talk about C/C++ programming using puppy OS so hopefully they do talk about using small memory and maybe maybe even USB but I ahve not read it but hope it should give example on how others have done it.

http://www.murga-linux.com/puppy/viewto ... 75&t=28629
C/C++ Development in Puppy Linux

I know too little so I friendly bow out of the thread and hope those that do programming find your thread and them share experiences or you have to find them and ask them using PM maybe.
I use Google Search on Puppy Forum
not an ideal solution though

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

#8 Post by vovchik »

Dear ViejoVizcacha,

Welcome to the kennels. Ted Dog has packaged up bacon and tcc in about 770k, which will give you a minimal compiling environment, without the need for devx. Tcc will work for C programming and BaCon and tcc for BaCon. Please be aware that the bacon binaries generated in this fashion are ridiculously large, but they work. Gcc does a much better job, or some tcc optiions need to be invoked so that the binaries are kept small.

Here is the link:

http://www.murga-linux.com/puppy/viewto ... 91&t=65837

With kind regards,
vovchik

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

#9 Post by Moose On The Loose »

nooby wrote:ViejoVizcacha thanks for kind words.

I know too little but as you are aware of the Devx seems too big indeed.

What about the following thread then? some 6 pages where they talk about C/C++ programming using puppy OS so hopefully they do talk about using small memory and maybe maybe even USB but I ahve not read it but hope it should give example on how others have done it.

http://www.murga-linux.com/puppy/viewto ... 75&t=28629
C/C++ Development in Puppy Linux

I know too little so I friendly bow out of the thread and hope those that do programming find your thread and them share experiences or you have to find them and ask them using PM maybe.
There is a tool that lets you add an SFS on the fly. You could perhaps only include the devx when you need to compile. You can make a swap file on the memory stick or a harddisk and if the compile process needs the memory it would get used. The result would be very slow operation but it would not fail. Once the program is compiled, you no longer need the devx.

I have found that I spend way more time composing a program than compiling. Your experience is almost certain to be like mine. I also make certain rules that I impose on myself that help to reduce the number of times I need to pass it through the compiler:

(1) Comment each function with what it accepts of each argument

(2) Check all calls for the passed things being what is required.

(3) Avoid variables called i,j,k or x,y,z unless that is the natural name for what you are using.

(4) Settle on a standard way to spell things like:
"percent" is the name I use not "percentage"

The last one takes a little explaining. We seem to remember concepts and not words so if you use two words that are a lot alike and mean sort of the same thing you will mix them up. The most common problem at compile time (I find) is a wrong variable name.

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

Re: Just to acknowledge receipt, since I could not make time...

#10 Post by 2lss »

ViejoVizcacha wrote: My recently gotten ThinkPad has the following characteristics:
Intel Pentium-4 1.8GHz, 774MB of memory, 1024x768 display, CD-RW, 2 USB (rev 02) ports, Serial, Parallel, PRO/Wireless 2200BG, and a 82801CAM PRO/100 VE Ethernet. And its battery runs a whoopie 20 minutes!
I will use a generic 4GB flash. And I will take caution with the (for me new) pendrive delicate life expectancy.
You should be ok running puppy + devx on the flash drive. With 774 MB of memory you could get away without a swap partition/file for doing small things. My eeepc has 512 MB ram and I am able to run puppy + devx on a two gb sdcard without swap. I can compile bacon programs, and moderately sized C programs (never tried anything big).
ViejoVizcacha wrote: About devx for my Puppy 5.1.1, I found out this :
http://distro.ibiblio.org/quirky/wary-5 ... vx_511.sfs .
As far as I know, that is the wrong devx. Wary is a derivative of puppy, and (I think) uses a different kernel. Try this instead:

http://distro.ibiblio.org/pub/linux/dis ... vx_511.sfs

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

Re: How to program in Puppy?

#11 Post by RetroTechGuy »

ViejoVizcacha wrote:Hi. I just run Puppy 5.1 from CD on a T30 Thinkpad without hard-drive, and plan to use a USB for my files and for my compiler. I am poor and have no other computer available.
I know a bit of logic of programming and always wanted to program in C, but had to survive instead.
Since Puppy is so powerful as I heard it and am confirming, I chose it to start my adventures in programming.
Something I cannot figure out is how to create a screen with many fields, each one with its own row/col position and attributes and then prompt the screen on C.
Could you please give me a lead, or samples to follow?
Any help and suggestion will be thankfully absorbed.
Thank you for your attention.
I believe that if you add in the devx sfs file for your Puppy version, and reboot (you have to do this "add" thru a menu option), that you have a C compiler available.

You can also get gfortran, which also requires the devx file.

However, I don't believe that there are visual/gui editor/compilers available (command line tools).
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#12 Post by L18L »

going into the world carrying in my pocket a whole OS plus the ability to program an interactive application on the go for the amazement of my neighbor at the internet-cafe
Your neighbor might be more impressed by a multilingual wary in his language ? :)

ViejoVizcacha
Posts: 4
Joined: Mon 04 Apr 2011, 15:57

Sorry for the disappearance.

#13 Post by ViejoVizcacha »

I get late and tire-eyed at home, but am very happy and thankful to all of you and for your suggestions that will get me going, this weekend. Meanwhile, please receive my greetings and good wishes.

Post Reply