LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-09-2013, 12:58 AM   #16
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 557
Blog Entries: 2

Rep: Reputation: 73

Quote:
Originally Posted by psionl0 View Post
I'd second that.
I'm having second thoughts about python now that I have evaluated it more thoroughly.

Although you can run the python interpreter, it doesn't appear that you can enter and save programs interactively. You still have to load external files to run. It also appears that things like "linked lists" are too basic for an advanced language like python to bother much with. You can still create them but the process is very unintuitive. Yes, I know that python would have a comprehensive set of linked list classes but if you are learning programming principles then just using pre-made classes (the internals of which you know nothing about) is not very instructive.

My original philosophy still seems to be best. Use BASIC (Liberty Basic is a good one) to learn the programming fundamentals because BASIC is easy to learn. Once you can write programs in BASIC then you would switch to something more modern like Java. (C would be an ideal next step but it is not OOP and C++ is a far more complicated beast).
 
Old 04-09-2013, 07:56 AM   #17
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Quote:
Originally Posted by psionl0 View Post
I'm having second thoughts about python now that I have evaluated it more thoroughly.
I agree with you there. Backwards compatibility is also a major issue with python. I'm done with it. I'll stick with C/C++ and bash, of course.
 
Old 04-09-2013, 11:20 AM   #18
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,667

Rep: Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440
Quote:
Originally Posted by psionl0 View Post
Although you can run the python interpreter, it doesn't appear that you can enter and save programs interactively. You still have to load external files to run. It also appears that things like "linked lists" are too basic for an advanced language like python to bother much with. You can still create them but the process is very unintuitive. Yes, I know that python would have a comprehensive set of linked list classes but if you are learning programming principles then just using pre-made classes (the internals of which you know nothing about) is not very instructive.
I have no idea what you're talking about, and I suspect you don't either. Creating a linked list in Python (if you really don't want to use the built-in list data type which is an integral part of the language and not "a comprehensive set of list classes" in its standard library) is exactly the same as in C# or Java.

Code:
class Node(object):
    def __init__(self):
        data = None
        next = None

tail = Node()
head = tail
head.next = Node()
head = head.next
Hardly what I would call "very unintuitive".

More on this discussion:

How, when, and why do developers use custom data structures in python?

Of course, your real point is that a language where you never have to built a linked list is not suitable for a first language, and my opinion is that you're wrong. I'd recommend picking up that skill with your second language, and my recommendation is consistent with how MIT's computer science curriculum is designed. (Python first, then Scheme).

Last edited by dugan; 04-09-2013 at 05:51 PM.
 
Old 04-09-2013, 01:24 PM   #19
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,455

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by dugan View Post
Creating a linked list in Python (if you really don't want to use the built-in list data type which is an integral part of the language and not "a comprehensive set of list classes" in its standard library)

...your real point is that a language where you never have to built a linked list is not suitable for a first language, and my opinion is that you're wrong.
Small nitpick: Python's built-in list is a resizeable array, not a linked list.

How, when, and why do developers use custom data structures in python? (@WinstonEwert's answer):
Quote:
Originally Posted by Winston Ewert
For example, python doesn't have any builtin tree-based structures, or linked lists, etc.
 
Old 04-10-2013, 02:33 AM   #20
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 557
Blog Entries: 2

Rep: Reputation: 73
Quote:
Originally Posted by dugan View Post
Code:
class Node(object):
    def __init__(self):
        data = None
        next = None

tail = Node()
head = tail
head.next = Node()
head = head.next
Hardly what I would call "very unintuitive".
That is quite an improvement on the references that I found.
http://stackoverflow.com/questions/2...on-linked-list gave a rather puzzling coding for the same thing:
Quote:
A linked list is either:
  • the empty list, represented by None, or
  • a node that contains a cargo object and a reference to a linked list.
Code:
class Node: 
      def __init__(self, cargo=None, next=None): 
        self.car = cargo 
        self.cdr = next    
      def __str__(self): 
        return str(self.car)


    def display(lst):
      if lst:
        w("%s " % lst)
        display(lst.cdr)
      else:
        w("nil\n")
http://en.literateprograms.org/Singl...t_%28Python%29 seems slightly clearer:
Code:
<<ListNode class>>=
class ListNode:
    def __init__(self, data, next):
        self.data = data
        self.next = next

node3 = ListNode(3, None)
node2 = ListNode(2, node3)
node1 = ListNode(1, node2)

<<List class>>=
    def insert(self, node, data):
        new_node = ListNode(data, node.next)
        node.next = new_node
        if self.tail == node:
            self.tail = new_node
The fact that you have to look up discussion forums to find out stuff like this is not a plus for python.

Quote:
Originally Posted by dugan View Post
Of course, your real point is that a language where you never have to built a linked list is not suitable for a first language, and my opinion is that you're wrong. I'd recommend picking up that skill with your second language, and my recommendation is consistent with how MIT's computer science curriculum is designed. (Python first, then Scheme).
Just because you disagree doesn't mean that either of us is "wrong". A complete beginner would do best with a completely interactive language (which is why I suggest a form of BASIC). Once he has grasped control structures and arrays, then is the time to move to something more sophisticated. I would still choose Java but you obviously have more experience with Python so I won't argue.
 
Old 04-10-2013, 12:12 PM   #21
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,667

Rep: Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440
The first link you posted links to a chapter on linked lists from a frequently recommended free Python ebook. I just skimmed the chapter and it's not bad at all.

http://greenteapress.com/thinkpython/html/chap17.html

Of course, I didn't look up anything before writing the linked list sample code. I know Python and I know linked lists.

Last edited by dugan; 04-10-2013 at 12:53 PM.
 
Old 04-10-2013, 09:19 PM   #22
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
I would suggest C++ and Ruby. Those stuffs are more in uniform. Just be aware of the difference.
 
Old 04-10-2013, 10:02 PM   #23
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
I suggest to start from https://en.wikipedia.org/wiki/Programming_paradigm -> https://en.wikipedia.org/wiki/Compar...ming_paradigms .
 
Old 04-10-2013, 10:03 PM   #24
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 557
Blog Entries: 2

Rep: Reputation: 73
Quote:
Originally Posted by konsolebox View Post
I would suggest C++ and Ruby. Those stuffs are more in uniform. Just be aware of the difference.
For a beginner?
 
Old 04-10-2013, 10:07 PM   #25
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
And https://en.wikipedia.org/wiki/Turing_completeness .
 
Old 04-11-2013, 12:12 AM   #26
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by psionl0 View Post
For a beginner?
Why not? Sometimes it's better if you get a better perspective of languages at start.
 
Old 04-11-2013, 09:42 AM   #27
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,377

Rep: Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108
The first program that I ever wrote ... at about your age, by the way ... was written in BASIC on a timesharing computer (there were no PCs yet), took me six months to write, was 12 lines long, and had a bug in it.

About thirty-five(!) years later, the fascination with causing a machine to do useful things under its own direction shows no signs of stopping with me ... and I hope that you have the same happy experience. I still say, quite truthfully, that I have made a living from my hobby.

Probably the trickiest thing to wrap your mind around is ... "thinking like a programmer." Figuring out how to create an algorithm to do a particular problem ... learning how to devise those algorithms on your own, and yet to also avail yourself of information resources throughout the Internet to help in your learning. There's no place on this planet that is "too isolated" if you've got an Internet connection.

Here's a problem that I'm going to suggest to you: the "eight queens problem." Consider this problem, without using the Internet to "peek in the back of the book." How would you go about solving it? Here's the problem:
Quote:
In the game of chess, a queen can capture anything on a vertical, horizontal, or diagonal line at any distance. Write a program that will find all of the positions for eight queens on a chessboard such that none of them can capture any other.
What I'm suggesting is ... knowing that "the answer in the back of the book" is readily available to you, but without immediately rushing out to find one, let it first be a mental exercise. (Caution: the WikiPedia page contains a "give-away" solution in Python ... choose not to go there yet. Or, if you have already done so and happen to find that solution to be obtuse (I do...), devise another one that produces the same correct answer. The world's your oyster, really.

There are 92 unique solutions, which are actually 4 "rotations" of 23 unique positions. A well-chosen algorithm can produce them instantaneously. A poorly-chosen one might take days. The solution can be made in any language; that's not the point. The point is what the solution is, not a particular implementation.

Many folks suppose that "what a programmer does" is "to write code." But that's really not the case. The most engaging thing that programmers do is to devise algorithms that will efficiently solve a particular problem, then implement those algorithms in software in such a way that it can be demonstrated that they work properly. You have to have patience, a high capacity for frustration, and a meticulous ability to find and shoot-down problems. Most of all, "perseverance and patience."

If you find this task to be engaging, for its own reasons alone, then "you're one of us." Welcome aboard.

Last edited by sundialsvcs; 04-11-2013 at 09:51 AM.
 
Old 04-11-2013, 09:45 AM   #28
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,667

Rep: Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440Reputation: 1440
Quote:
Originally Posted by sundialsvcs View Post
Probably the trickiest thing to wrap your mind around is ... "thinking like a programmer."
Think Python: How to Think Like a Computer Scientist
 
Old 04-11-2013, 08:25 PM   #29
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 557
Blog Entries: 2

Rep: Reputation: 73
Quote:
Originally Posted by Sergei Steshenko View Post
Quote:
Originally Posted by sundialsvcs View Post
Here's a problem that I'm going to suggest to you: the "eight queens problem." Consider this problem, without using the Internet to "peek in the back of the book." How would you go about solving it?
Wow, some of this stuff would challenge an experienced programmer. It would almost certainly convince the beginner that programming was incredibly difficult and complex.

What ever happened to "just do it"? Write a line of code and see if it runs. Write two lines and see if they work. etc.

It is easy when you have been programming for a while to forget how foreign some of the basic concepts can be. Schools seldom teach logic so some of the logic seen in conditional statements (especially negated logic) can be completely novel to beginners. Arrays - especially where the index is a variable or an rvalue (algebraic expression) - are also a difficult concept for beginners to grasp. Appreciating the difference between y = x + 1 in mathematics and in computer programming is crucial to appreciating why a statement like x = x + 1 has no solution in mathematics but is a perfectly natural statement in a computer programming language.

The best way to teach students something new is to make links to what they already know. Approaching programming as an extension to using a hand held calculator is one of the more effective ways to start. It might take at least a couple of weeks before the student is ready to be introduced to concepts such as structured and modular programming, object vs procedural orientated programming, scoping, encapsulation and inheritance etc.

Last edited by psionl0; 04-11-2013 at 08:27 PM.
 
Old 04-11-2013, 08:51 PM   #30
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
@psionl0: Learning is not always the way of procedure-oriented schools and ABCs. Sometimes it only slows down the potential of a learner. If you want to teach someone real programming let them see the whole picture first. There's no hiding, unless you want them to quit somewhere in the middle. Not all people learn just by coloring books and blackboards. You should let them discover their own pace.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to filter the linux kernel code based on config file. removing unnecessary code atulmt Linux - Kernel 4 06-29-2013 11:14 PM
100's of files infected by the same hacker code - any way to mass replace bad code? SirTristan Linux - Newbie 11 06-24-2012 08:08 AM
[SOLVED] Small matlab code to convert Morse code to plaintext using regular expressions gregorian Programming 3 03-31-2010 12:34 PM
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM


All times are GMT -5. The time now is 04:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration