* * *

Author Topic: Thoughts on Python?  (Read 12545 times)

tsiros

  • Newbie
  • Posts: 4
Re: Thoughts on Python?
« Reply #15 on: July 07, 2016, 02:10:59 pm »
My thoughts on python? "Laughable".

I never once in my life felt that the begin/end keywords were a nuisance.

Making whitespace semantically significant, though? What does that accomplish, except add one literally invisible thing to look out for?

Oh, it's for defining *blocks of code*? Oh well, there are blocks of code and there are lines of code. Why not also require each line of code to terminate in one, exactly one, space character? Imagine the headache.

graemex

  • New member
  • *
  • Posts: 12
Re: Thoughts on Python?
« Reply #16 on: July 09, 2016, 12:16:55 pm »
Python is what I use for everything - but I rarely desktop GUI applications. In fact, I came to the forum today to ask a question about using Pascal/Lazarus to write a GUI wrapper around some Python code.

Stuff I have developed in Python:

  • Lots of web sites using Django - the best web dev framework IMO.
  • Data visualisation
  • A cross platform GUI to run on low resource embedded devices
  • APIs for Solr based search
  • Web crawlers
  • A simple GUI around an existing script

I do use a lot of Python GUI software, even though I have never written anything non-trivial myself.

Examples of Python GUI software I use:

  • Zim - desktop wiki
  • Deluge - torrent client
  • Quod Libet - music player
  • Calibre - ebook library manager
  • TortoiseHg - GUI for Mercurial

That excludes all Python development related stuff, and non-GUI applications such as Mercurial. I am probably missing a lot because Python is so pervasive on Linux and I often do not know what language applications I use are written in.

Python is a brilliant language. Significant whitespace makes it extremely readable and means you never do things like forgetting a end of line semi-colon or a closing brace. It is concise, multi-paradigm, and has lots of libraries. It has a huge breadth of application. Its biggest weaknesses are:

  • it is slow, so it can be a bad choice for computationally intensive stuff (Pypy and Cython can help a lot with that, as does the availability of a lot of C libraries for Python).
  • lack of GUI RAD tools (except for Boa Constructor with is unmaintained)

Quote
Oh, it's for defining *blocks of code*? Oh well, there are blocks of code and there are lines of code. Why not also require each line of code to terminate in one, exactly one, space character?]

Python does use whitespace to define lines of code. A newline ends a line of code. It uses the appropriate whitespace in each case. Your rhetorical question is a bit like asking "oh it uses words to end blocks of codes. Why not end each line of code with "antidisestablishmentarianism"?  Imagine the headache."

Quote
I have had instances in the past of whitespace being trashed in files and the thought of that happening to a large Python program leaves me stone cold]

Python has been my main language for the last 10 years and that has never happened. How did it happen to you? What trashed the whitespace?

Quote
it seems to fall short when I try it on a major desktop app.  I usually fall back to Lazarus, C# or C/C++.

That may be the case. That is why I am interested in learning Free Pascal and Lazarus. That said, other people seem to use Python for desktop apps successfully.

Quote
Instead of QT look at PySide http://wiki.qt.io/PySide it is basically PyQT but allows both free open source and proprietary software development.

I think PyQt is more actively developed, and if you are selling proprietary software you should be able to afford the license.

There are also a LOT of other GUI libraries for Python: tkinter (part of the standard library), wxPython, PyGTK, Kivy (good for mobile) and others. That is part of the problem though - I am not sure which one to use in a particular case.

Quote
The problem is that being a Python application, it really shows in the speed of queries

I do not really see how that can happen. All the Python code really does is hand the queries to a C library that then sends them to the DB server. Something else must be going wrong.

Thaddy

  • Hero Member
  • *****
  • Posts: 6558
Re: Thoughts on Python?
« Reply #17 on: July 09, 2016, 01:08:44 pm »
I do not really see how that can happen. All the Python code really does is hand the queries to a C library that then sends them to the DB server. Something else must be going wrong.
Well the thing is indeed that Python is a -some would say glorified - scripting system to access high performance C (or FPC!) libraries. It is a weak typed scripting languange. If you need real performance in Python it is either by accident or because libraries written in a strongly typed compiled language are available. Mind you, I know 'Python can be compiled to native code' excuses, but that is half the story.

And: I use Python a lot and like it. Don't confuse the purposes of languages. One is convenience the other is performance.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

graemex

  • New member
  • *
  • Posts: 12
Re: Thoughts on Python?
« Reply #18 on: July 09, 2016, 02:03:59 pm »
Quote
It is a weak typed scripting languange.

It is dynamically strongly typed. Unlike, for example, Javascript, TCL, or PHP which are dynamically weakly typed. For example "2" + 2 in Python will give you a TypeError, whereas expr {"2" +2} in TCL will return 4.

Quote
Mind you, I know 'Python can be compiled to native code' excuses, but that is half the story.

There is a bit more to it than that. You can improve Python performance by doing certain things (e.g. using comprehensions instead of for loops), you can call existing libraries, you can rewrite performance critical code in Cython (essentially a statically typed subset of Python), or you can use PyPy (a lot faster than the usual Python implementation, but still a lot slower than C or Pascal).

Quote
Don't confuse the purposes of languages. One is convenience the other is performance.

I agree with the principle. I use Python for almost everything I do because I usually find the performance bottlenecks are outside my code (database or network), or there are existing libraries for in a faster language (e.g. numpy, lxml, etc.), or Python is fast enough and using a faster language will not make a difference users will notice.

Going back to the original question:

Quote
Is it an easy language to learn?

Yes, and there are lots of tutorials, documentation, and online courses.

Quote
What kind of programs are best suited for it?

It is good for a lot of different things, because it has a lot of libraries. Anything that does not require really high performance (not for games, not for numerical work that requires higher performance than Numpy can deliver) or lots of low level system access (device drivers, OSes).

The languages may well complement each other quite well. I can imagine writing a application in Python, with performance critical stuff in Pascal, and wrapped in a Lazarus GUI.

Thaddy

  • Hero Member
  • *****
  • Posts: 6558
Re: Thoughts on Python?
« Reply #19 on: July 09, 2016, 02:17:09 pm »
Quote
It is a weak typed scripting languange.
It is dynamically strongly typed.
Yes it is typed after first use. Half-baked compared to strongly typed. This is not really a criticism, it is not strong typing but something in between.
Quote
Quote
Mind you, I know 'Python can be compiled to native code' excuses, but that is half the story.

There is a bit more to it than that. You can improve Python performance by doing certain things (e.g. using comprehensions instead of for loops), you can call existing libraries, you can rewrite performance critical code in Cython (essentially a statically typed subset of Python), or you can use PyPy (a lot faster than the usual Python implementation, but still a lot slower than C or Pascal).
Any self respecting scripting language has the ability to call out existing libraries. Have you seen any Phyton code that is really build in Python from the ground up? Of course not.
With FPC or C you have that ability.To the extend that you can write real OS's in it. Impossible in Phyton. And not the use-case for Phyton.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

graemex

  • New member
  • *
  • Posts: 12
Re: Thoughts on Python?
« Reply #20 on: July 10, 2016, 10:39:32 am »
With regard to strong typing, we are just using slightly different definitions. I prefer the definition that treats strong vs weak as separate from static vs dynamic, because then you can pin languages down as dynamic and weakly typed, dynamic and strongly typed, static and strongly typed or static and weakly typed.

My ideal language would probably be something like Python with type inference.

As for the rest, I am not suggesting you can do everything any developer may want to do in Python, but that it is a productive and easy to maintain language you can use for a lot of different things.

Leledumbo

  • Hero Member
  • *****
  • Posts: 7937
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Thoughts on Python?
« Reply #21 on: July 10, 2016, 01:14:56 pm »
With regard to strong typing, we are just using slightly different definitions. I prefer the definition that treats strong vs weak as separate from static vs dynamic, because then you can pin languages down as dynamic and weakly typed, dynamic and strongly typed, static and strongly typed or static and weakly typed.
Correct, the two should indeed be separated so there are 4 possibilities.
My ideal language would probably be something like Python with type inference.
Have you tried Nim? It looks like Python with type inference, influenced by Pascal units functionalities and LISP metaprogramming capabilities.

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Thoughts on Python?
« Reply #22 on: July 10, 2016, 03:59:17 pm »
My ideal language would probably be something like Python with type inference.
Have you tried Nim? It looks like Python with type inference, influenced by Pascal units functionalities and LISP metaprogramming capabilities.
Wow ~!
I see the Nim's syntax is sexy. as sexy as Python's syntax.
Personally I felt Nim's syntax is sexier than Python's syntax.
Plus, Nim's syntax is more similar/familiar as pascal declaration syntaxes.
@Leledumbo, thanks you for letting us know about Nim existence.
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

tsiros

  • Newbie
  • Posts: 4
Re: Thoughts on Python?
« Reply #23 on: July 11, 2016, 12:24:13 am »
Python does use whitespace to define lines of code. A newline ends a line of code. It uses the appropriate whitespace in each case. Your rhetorical question is a bit like asking "oh it uses words to end blocks of codes. Why not end each line of code with "antidisestablishmentarianism"?  Imagine the headache."

can you tell the difference between spaces and a newline or a word, or do i need to show you a screenshot?

graemex

  • New member
  • *
  • Posts: 12
Re: Thoughts on Python?
« Reply #24 on: July 11, 2016, 09:19:19 am »
Yes, Nim looks really nice. I have not tried it yet, but plan to.

Its main disadvantage at the moment is it is still not mature (and there are still changes that break thing) and it lacks libraries. Both will be fixed with time, hopefully (and I gather it is easy to use C libraries with Nim which will help in the meantime).

Leledumbo

  • Hero Member
  • *****
  • Posts: 7937
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Thoughts on Python?
« Reply #25 on: July 11, 2016, 01:24:21 pm »
and it lacks libraries.
Actually, it has quite a lot, just not shipped by default. Nimble is its package manager (yes, it has working package manager already, which fppkg trails behind despite being much older). `nimble list` will show a bunch of existing packages.

serbod

  • Full Member
  • ***
  • Posts: 121
Re: Thoughts on Python?
« Reply #26 on: July 11, 2016, 02:28:01 pm »
Typed parameters in Nim is very good step. But Nim have same trouble, as Golang - weak class definition. Methods and properties can be added anytime and anywhere, and it's brings disorder, increase chance of design mistakes.

Thaddy

  • Hero Member
  • *****
  • Posts: 6558
Re: Thoughts on Python?
« Reply #27 on: July 11, 2016, 05:40:28 pm »
My ideal language would probably be something like Python with type inference.
I somewhat agree with that... would look a lot like Object Pascal with type inference, though :) Except for whitespace  O:-)
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Leledumbo

  • Hero Member
  • *****
  • Posts: 7937
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Thoughts on Python?
« Reply #28 on: July 11, 2016, 07:45:45 pm »
Typed parameters in Nim is very good step. But Nim have same trouble, as Golang - weak class definition. Methods and properties can be added anytime and anywhere, and it's brings disorder, increase chance of design mistakes.
Yup, same as golang too, it is by design. Well at least it doesn't abuse the already well known semantics of := operator.

Quiser

  • Newbie
  • Posts: 2
  • Love Forever
Re: Thoughts on Python?
« Reply #29 on: May 23, 2018, 11:49:52 am »
I apologize, guys, I know that this topic is very old, but maybe my answer will help someone in the future.
JavaScript - because it was always the dark horse, has had the huge advantage of monopoly over front end. And server side JavaScript is finally becoming mature enough. It just needs one meaty web framework to spice things up.

Python - because it is the equivalent of Java in scripting world. Has been around for a long time. Has tons of libraries. Any big project is unlikely to have only web dev concerns. At some point they are going to need other generic or domain specific libraries. Python wins here by miles. Add maintainability as another plus. They got one thing damn right - the emphasis on readability and explicitness. This alone will ensure that it will continue to remain the most favorite general purpose language for a long time to come.

Scala - because it combines the best of several worlds and the smartest minds are already moving there. Being on JVM is a big plus, as is the flexibility of using both functional and OO approaches. Those who cannot use Clojure ( due to lack of frameworks or developers ) will switch to Scala and this will keep the quality of the community high.
PHP will still hang around for a lot of time as legacy language. The code base is huge and it is not going to go away anytime soon.
If you interesting, check out this article where compare this two languages between each other https://diceus.com/what-technology-is-better-for-big-data-projects-comparing-python-and-java-r/ I hope it helps

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus