Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Beginning to code my first real program

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
15 posts • Page 1 of 1
Author
Message
Donman
Tux's lil' helper
Tux's lil' helper
Posts: 117
Joined: Mon Sep 05, 2005 5:14 pm

Beginning to code my first real program

  • Quote

Post by Donman » Sun Jan 13, 2008 3:33 am

So I've gotten the idea in my head to code a program for novel writing. Something similar to what Celtx has to offer, just for novels (and short stories, general character development, etc). This really will be my first coding project, aside from a backup script I wrote in Python in the fall of '06. I just need something to keep me busy until I go into college in the fall.

I was wondering, as a beginner with a little Python experience (I barely know enough of the language to write a backup script), what language should I start out with? I was thinking just continue with Python, then in the future I could rewrite it in whatever other language I choose. Or, I could jump into something far more extreme, like C or Java...Recommendations? I have nothing against the various languages, I just don't really know which one would be best suited for the task at hand.

Links to tutorials or guides or anything similar, tips, comments, they are all appreciated as well.
Top
dev_zero
n00b
n00b
User avatar
Posts: 28
Joined: Thu Nov 01, 2007 8:53 pm
Location: Somewhere in the kernel source

  • Quote

Post by dev_zero » Sun Jan 13, 2008 5:04 am

Well it doesn't really mather which programming language you start with, but you might be easier off with java since it got classes for gui programming so you won't have to bother learning to program with any gui libraries like gtk, qt etc. However if you want to continue with python there is several gui toolkits implemented. http://www.python.org/doc/faq/gui/ As for C and C++, the same toolkits are availible. It just depends on what you like, C is a very handy programming language to know, it's efficient and fast. It is kind of a portable assembly language ( "lowlevel" highlevel language ). C++ can be very powerful when used right, but when used with wrong techniques it will produce a memory heavy product and not very efficient.

Python: http://docs.python.org/tut/tut.html , http://www.python.org/doc/faq/gui/
C++: http://www.cprogramming.com/tutorial/print/lesson1.html , http://www.cplusplus.com/doc/tutorial/introduction.html
C: http://www.cprogramming.com/tutorial/c/lesson1.html
Java: http://java.sun.com/docs/books/tutorial/java/index.html
Dell Latitude D630 DSDT
Top
krinkle
Guru
Guru
User avatar
Posts: 337
Joined: Tue Feb 04, 2003 2:48 am
Location: Garden Grove, CA

  • Quote

Post by krinkle » Sun Jan 13, 2008 5:28 am

Sounds like quite an ambitious task! I would definitely recommend sticking with python. Java would come after that because at least you have garbage collection and no pointers. I'd stay away from C++.

I'm not quite sure what you have in mind for the project, but you might want to build your coding skills up doing a few smaller projects first. If nothing else, it will help you keep your project/code much more organized, which in turn will make it MUCH easier to develop. Best of luck to you though!
Top
Donman
Tux's lil' helper
Tux's lil' helper
Posts: 117
Joined: Mon Sep 05, 2005 5:14 pm

  • Quote

Post by Donman » Sun Jan 13, 2008 5:38 am

I didn't really think it would much matter what language I chose in the end. I have been looking around some, and I think I may just go with Python, simply due to having dabbled with it in the past, may as well go back and finish learning the language. Java, er, looking at some source code for it and me being a noob when it deals with programming scared me a bit. C and all those as well...

Recalling my little experience with Python, it seemed pretty straightforward and easy to use. As this is also a time to learn the language and new things, having to work with a gui toolkit as well wouldn't be too much of a problem. Hrm..

I think I may just stick with python + I don't know, wxWindows maybe or perhaps GTk+ for now. Isn't it easy to embed C into Python code? Cause then I could program in Python, and play with C some and embed it into wherever I can use it. Though honestly, I have a lot of studying up to do before I can actually start laying down code, as I'm not too sure where to start off. Any tips there? Here is a brief description of what I want to be able to do with this program once it becomes functional:

1) Document formatting, for writing the main text of the novel/short story.
2) Able to create character biographies and histories and maintain them separately from the novel text
3) Ability to tag these characters in the novel, so one can easily glance over the story and see where and when characters come into play
4) Ability to break the novel down into parts, map them out, rearrange them, stuff like that.

Yes, this may seem like a biting off more than I can chew for a beginner, but I've got plenty of spare time. I suppose the first place to start would be to code a basic notepad-like program, and add on to it from there. I'm open to any suggestions and tips and pointers, thanks in advance!

EDIT:
Thanks krinkle! It is ambitious, but it is something I would really like to do and be able to use. There just isn't really anything like what I want/need out there like this aside from proprietary programs, but I don't want to fiddle with wine and I've always wanted to program.
Top
8086
n00b
n00b
User avatar
Posts: 52
Joined: Wed Dec 12, 2007 6:25 pm

  • Quote

Post by 8086 » Sun Jan 13, 2008 6:53 am

Have a look at Ruby (and some cartoon foxes !?!?)
Top
dmitchell
Veteran
Veteran
User avatar
Posts: 1159
Joined: Sat May 17, 2003 4:51 pm
Location: Austin, Texas

  • Quote

Post by dmitchell » Sun Jan 13, 2008 9:00 am

I would use C++ and Qt. But then, I already know C++ and Qt.
Your argument is invalid.
Top
Donman
Tux's lil' helper
Tux's lil' helper
Posts: 117
Joined: Mon Sep 05, 2005 5:14 pm

  • Quote

Post by Donman » Sun Jan 13, 2008 6:02 pm

8086 wrote:Have a look at Ruby (and some cartoon foxes !?!?)
Hah, that is a pretty cool guide. Thanks for that. I'll code something basic in Python and then in Ruby and see where my preference lies, they both have what I need.

As for C++ and Qt, I would love to learn them at some point in time so I may use try to use C/C++/Java a little bit along the way. Later on, in the far future, I'll probably rewrite it in something like C. For now though, I'm off to start coding a simple text editor. Yay.
Top
barophobia
Apprentice
Apprentice
User avatar
Posts: 229
Joined: Tue Apr 27, 2004 4:37 am
Location: somewhere

Re: Beginning to code my first real program

  • Quote

Post by barophobia » Mon Jan 14, 2008 12:27 am

Donman wrote:Or, I could jump into something far more extreme, like C or Java...Recommendations? I have nothing against the various languages, I just don't really know which one would be best suited for the task at hand.
Which one is best suited is difficult to answer.
1) what are you doing?
2) how are you going to deploy it?
3) design requirements? memory limitations, real time app, licensing
4) is it just a prototype for an idea?
5) personal preference

You will have a much better idea of which language to use once you program more.
An apple is an apple unless you say it is not an apple!
Top
psomas
Retired Dev
Retired Dev
User avatar
Posts: 212
Joined: Sat Sep 23, 2006 2:09 pm
Location: Greece

  • Quote

Post by psomas » Mon Jan 14, 2008 1:02 am

maybe for the program, an object oriented language would be easier to use, but if you want to learn programming:

C rulz!!...
it's the best language to begin with...it is simple, but it has everything...

after you are familiar with C(and generally with programming) i suggest that you try learning some functional language(haskell is awesome) or a language that combines everything, like ocaml... ;)
myblog
FOSS NTUA Community
Top
bmichaelsen
Veteran
Veteran
User avatar
Posts: 1277
Joined: Sun Nov 17, 2002 2:38 am
Location: Hamburg, Germany

  • Quote

Post by bmichaelsen » Mon Jan 14, 2008 1:51 am

The language doesnt matter too much. Getting the basic concepts right is far more important.
If you want a good beginners introduction, I recommend:
http://www.oreilly.com/catalog/hfjava2/index.html
Top
Donman
Tux's lil' helper
Tux's lil' helper
Posts: 117
Joined: Mon Sep 05, 2005 5:14 pm

  • Quote

Post by Donman » Mon Jan 14, 2008 3:20 am

barophobia wrote: Which one is best suited is difficult to answer.
1) what are you doing?
2) how are you going to deploy it?
3) design requirements? memory limitations, real time app, licensing
4) is it just a prototype for an idea?
5) personal preference

You will have a much better idea of which language to use once you program more.
I listed a little bit of what I was wanting to do a few posts up. 1-3 are the main things I want to get working. Get a simple working prototype going, then begin to actually implement everything. That way I can get my hands dirty and get the basics of what I need down.

As for languages, I've decided I will begin with Python. After I feel comfortable with it, I'll jump headfirst into C/Java or something like that.
Top
Donman
Tux's lil' helper
Tux's lil' helper
Posts: 117
Joined: Mon Sep 05, 2005 5:14 pm

  • Quote

Post by Donman » Sun Mar 02, 2008 2:41 am

Ok, so I've been reading up and everything, and managed to come up with this extremely basic text editor. It's a start, nothing special really, just had to figure out what modules and everything I needed to use. Here is the code, so you can try it out, or critique it, flame it, etc. Yes, its currently named NegativeInfinity, coded in pure Python, and licensed under the GPL. Enjoy.

NegativeInfinity.py

Code: Select all

#! /usr/bin/env python

############################################################################
#    Copyright (C) 2008 by Donavan Lance                                   #
#    tusklahoma @ gmail . com                                                  #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################



## NOTE TO SELF: COMMENT THE CODE UP SOME!!


from Tkinter import *
from tkFileDialog import *
import os.path
import sys

class NegativeInfinity:
	ftypes = [('Text', '*.txt'), ('HTML', ('*.htm', '*.html')), ('All Files', '*.*')]
	startfiledir = os.path.expanduser('~/')

	def __init__(self, master):
		self.mainFrame = Frame(master)
		self.mainFrame.pack(side = TOP, anchor = NW)

		self.openButton = Button(self.mainFrame, text = 'Open', command = self.openButtonCommand)
		self.openButton.pack(side = LEFT)

		self.newButton = Button(self.mainFrame, text = 'New', command = self.newButtonCommand)
		self.newButton.pack(side = LEFT)

		self.saveButton = Button(self.mainFrame, text = 'Save', command = self.saveButtonCommand)
		self.saveButton.pack(side = LEFT)

		self.textFrame = Frame(master)
		self.textFrame.pack(side = BOTTOM, fill = BOTH, expand = YES)

		self.textEditor = Text(self.textFrame, wrap = WORD)	# Ok, time to add comments. This needs to be customizable by the user,
		self.textEditor.pack(fill = BOTH, expand = YES)		# not arbitraily defined. (regarding "wrap = WORD"
		self.textEditor.focus()
		
		## Just threw this in here so one can supply a file from the command line. Indeed, it really shouldn't be right here, but whatever.
		## I'll split it out when I split the other things out as well.
		try:
			if sys.argv[1]:
				try:
					self.file = open(sys.argv[1], 'U')
					self.lines = self.file.read()
					self.file.close()
				except IOError:
					self.lines = 'No such file! Feel free to delete me and start anew!'
				self.textEditor.insert(0.0, self.lines)
		except IndexError:
			pass

	## This is set up to automatically clear any text that is on screen when opening a new file. Perhaps there should be a warning? No no,
	## this just needs to be redone.
	def openButtonCommand(self):
		self.openFile = askopenfile(mode = 'U', initialdir = self.startfiledir, filetypes = self.ftypes)
		if self.openFile:
			self.openFileText = self.openFile.read()
			self.openFile.close()
			self.textEditor.delete(0.0, END)
			self.textEditor.insert(0.0, self.openFileText)

	## Whoa. This one is much more iffy than the open one. Press "New", and bye-bye any text you have written. Be sure to save before
	## hitting this button. Yes, a window should pop up to warn, and I'll get around to it if I find it appropriate.
	def newButtonCommand(self):
		self.textEditor.delete(0.0, END)
		#self.newFile = None						## Commented out, to retain it just in case its needed again.
		#self.newwindow = Toplevel()
		#self.newwindowFrame = Frame(self.newwindow)
		#self.newwindowFrame.pack()
		#self.newwindowLabel = Label(self.newwindowFrame)
		#self.newwindowLabel['text'] = 'Not Implemented!...yet!'
		#self.newwindowLabel.pack()

	## This works, but is hackish. Could be better somehow? Try/Except would help, something else though? Don't really know at the moment
	## but do come back to this.
	def saveButtonCommand(self):
		self.saveFile = asksaveasfile(initialdir = self.startfiledir, filetypes = self.ftypes)
		if self.saveFile:
			text = self.textEditor.get(0.0, END)
			self.saveFile.write(text)
			self.saveFile.close()

root = Tk()
negativeInfinity = NegativeInfinity(root)
root.title('NegativeInfinity-0.0-prealpha-r0')
root.mainloop()
Top
Phenax
l33t
l33t
User avatar
Posts: 972
Joined: Fri Mar 10, 2006 8:12 pm

  • Quote

Post by Phenax » Sun Mar 02, 2008 3:57 am

I've recently started using Ruby, it is truly excellent. I'm sure the same can be said for Python.
Top
MostAwesomeDude
Guru
Guru
Posts: 373
Joined: Sun Aug 12, 2007 2:44 pm

  • Quote

Post by MostAwesomeDude » Sun Mar 02, 2008 7:45 am

In GUI programming, there is no way to stay away from icky GUI code and stick purely to plumbing, so a language that's very explicit is useful. I personally like wx and Python, but anything can work if you know what you want.
Don't believe the "n00b" under my name.
Top
pjp
Administrator
Administrator
User avatar
Posts: 20668
Joined: Tue Apr 16, 2002 10:35 pm

  • Quote

Post by pjp » Sun Jul 06, 2008 4:35 am

Any updates? Just curious if you're still working on this or not. I've often though about something similar, but never manage to find the time.
Quis separabit? Quo animo?
Top
Post Reply

15 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic