Quote:
Originally Posted by clowntable
daveT: Have you used a non-functional language before/for anything relevant? I have this suspicion that starting with a functional language is better but can't and don't want to prove it in any way. So it would be cool if you're indeed the "started with a functional language" guy so that I can follow your development a bit :P
Outside of creating some half-assed marketing tool I use at work, I havent created anything too major. That tool is basically Python + PostgreSQL w/ matplotlib. Honestly, 90% of what I do involves using the database and I haven't done anything amazing with the Python side of things. Assuming I quit working at this place one day, I'll probably release a modified version of the tool to the open source community.
I don't think I "started" with functional programming. The first class I took was in Python, which probably had a much more functional flavor than a class that may focus on imperative programming, but I can't be sure. The second course I took was on databases.
It just so happens that I have spend the majority of my learning time with functional programming a'la Scheme and I am working on my first major project in FP. If you are going to ask me if I am more comfortable with FP, then yes, you can say that, so in that sense I "started" to understand this stuff more using FP than IP, and this probably reflects in how I program in Python.
I think there are simply too many obscure concepts in functional programming for someone who never programmed before. It also doesn't help that functional programming languages just look weird. I also think that imperative programming is in many ways more intuitive than functional programming.
This is "illegal" in FP:
x = 5
x = x + 1
>> x
6
And by extension, this is illegal:
for i in range(6):
print(i)
To make this more "functional", you'd have to write:
Code:
def forLoop(x):
def innerLoop(begin, end, ans = []):
if begin == end:
return ans
else:
ans.append(begin)
return innerLoop(begin + 1, end, ans)
return innerLoop(0, x)
print(forLoop(9))
>>[0, 1, 2, 3, 4, 5, 6, 7, 8]
Actually, that may not be legal in more pure FP languages, and I can't write a tail-recursive function in Python, so there's no way to express it correctly, but it looks similar to:
Code:
def forLoop(x):
def innerLoop(begin, end):
if begin == end:
return None
else:
return ans.append(innerLoop(begin + 1, end, ans))
return innerLoop(0, x)
print(forLoop(9))
I simply can't see how fussing with this sort of stuff is useful to someone just starting out.
I think due the generally intuitive flavor of imperative programming and the easy and enforced syntax of Python, I would most certainly consider Python the best language to show a total newb. Functional program exists to solve way too many esoteric problems.