• Python & GTK/Glade

    From Alexander@amrowsell@frozenelectronics.ca to tilde.python on Fri Mar 26 21:52:23 2021
    Sad to see the python newsgroup has no messages! I started using Python
    a few years ago after many years of using C for embedded devices. I
    wanted to create simple GUIs that I could use to send commands to
    embedded devices over serial or USB, and so I took a look around at what languages best fit the bill.

    Python was what I decided on, and so I threw myself into Python 3
    (completely avoiding Python 2 at all costs, as all the references I had available said it was on its way out and 3 was the future). Using it to
    create GUIs with GTK isn't terribly difficult, but it does get quite
    verbose when you have to specify each GUI element with an API call. And
    so I gave Glade a try! For those of you who have never used GTK or
    Glade, essentially Glade creates an XML file that describes the GUI you
    want. It has a wonderful GUI builder interface, and is very easy to
    use. For each widget in your app, you can easily add the name of a
    function to attach to a signal that widget emits (e.g. on-button-click,
    etc.). This speeds up GUI creation considerably. You just import a
    library, add a line of code telling it to use the Glade-generated file,
    and then you focus on what the app actually _does_ instead of messing
    around with GUI stuff.

    Recently, I started contributing to the GNOME project, and many of the
    GNOME apps use Vala + Glade. Vala is a fascinating language. It has a
    C#-like syntax, but gets cross-compiled to C before being compiled by
    GCC. It integrates exceptionally well with GTK and the GObject system,
    and it's absolutely perfect for writing GNOME apps. In some ways I find
    it even faster and easier than Python, but Python's libraries for
    low-level access to serial ports and USB devices is a bit easier to use
    (and better documented!). The only downside is it's still a
    (relatively) young language. The documentation is great, it's just a bit
    tough to navigate at first. There's really only one or two books that
    teach you the fundamentals from the group up. Most of what I've learned
    about Vala was from reading source code of other apps, whereas with Python I started with a few excellent books (including the O'Reilly classic
    Learning Python by Mark Lutz, which I still think is one of the best
    Python books out there).

    I also (sort of) started to learn Lua, which has a fascinating structure
    and a really interesting table-based variable/class system. If you're
    into Python, check Lua out. The syntax is quite different, and it's got
    some quirks, but it's a really neat language also.

    As Python is a scripting language, I often use it for boring or
    repetitive tasks in the shell. For simpler stuff I will write zsh/bash
    scripts, but Python is a much easier language to read and write.

    So, how did YOU start using Python? What kind of things do you use it
    for? What do you like/dislike about it? Have you moved on to other
    languages, or is it still your primary programming language?

    Cheers!
    -amr
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.python on Sat Mar 27 08:03:46 2021
    Alexander <amrowsell@frozenelectronics.ca> writes:

    Recently, I started contributing to the GNOME project, and many of the
    GNOME apps use Vala + Glade. Vala is a fascinating language. It has a
    C#-like syntax, but gets cross-compiled to C before being compiled by
    GCC.

    Does Vala still include Genie (Python like syntax instead of a C#ish
    one)? Have you looked at it?
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From Alexander@amrowsell@frozenelectronics.ca to tilde.python on Sat Mar 27 07:09:32 2021
    Yup! I've never played around with it but Genie syntax is still
    supported by the Vala compiler. Another neat feature of Vala... strange
    to see a compiler that supports two completely different syntaxes for
    the same "language" so to speak. Well, at least without having to
    specify any command-line options when compiling. It just detects which
    syntax you're using and "just works".

    I do like the C# syntax because it is a bit more C-like and for GNOME
    apps it's all they use, as far as I can see.

    Have you ever played around with Vala, yeti?
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From yeti@yeti@tilde.institute to tilde.python on Sat Mar 27 12:51:38 2021
    Alexander <amrowsell@frozenelectronics.ca> writes:

    I do like the C# syntax because it is a bit more C-like and for GNOME
    apps it's all they use, as far as I can see.

    I never got used to C#.

    Have you ever played around with Vala, yeti?

    Looong ago I played a bit with Genie only, just ignoring Vala.
    --- Synchronet 3.18b-Linux NewsLink 1.113
  • From klu@klu@tilde.club to tilde.python on Sun May 9 07:26:14 2021


    In grad school, A best friend of mine said he was learning Python and I
    checked it out and loved it! Before that I knew a little C, which I
    didn't quite get at the point. I then learned TCL, which was the first language I felt practically useful, easy to learn and use.

    It's been my hobby language and favorate for many years. My first job
    was programming in C#. I still remember how much I hated C# then and
    told all my coworkers how awesome Python is :) After many years of using
    C# and Visual Studio, I absoluately love it and it changed my mindset a
    lot.

    Python's been my hobby language until recent years I started to use it
    at work, mostly ML/data related stuff. Wrote more lines of Python than I
    did in all the previous years... and that gets into the next point -
    what I like/dislike about it -


    What do you like/dislike about it?

    To me the biggest problem is dynamic typing. For large scale project, refactoring huge Python code base is a pain. Code base
    discovery/learning usually gets easier if you have a good IDE with
    precise autocomplete and goto-definiation. For that, the best
    experience I had is C#/VisualStudio, or Java/IntelliJ. For Python, I
    tried all, but the best is PyCharm, however, due to its dynamic typing,
    even with heavy Python3 type annotations, I still don't feel it's as
    reliable and precise as C# or Java. So I have never been confident
    refactoring Python code base.

    What I love about Python, is its tool chain, and its interpreted
    language. virtual env and pip is the best. For a new project, I would:

    python3 -m venv .ve
    . .ve/bin/activate
    pip3 install ...

    and off I go.

    The fact Python is interpreted, so that you can `eval` a python file as
    a way of configuration - this is something I appreciate more and more.
    In most cases where you need an "embeded" language into your program,
    this comes very handy. Many interpreted languages can do that. But
    that's where I found compiled languages are lacking - they can't use
    themselves embedded.

    To me, Python's `subprocess` module is the best subprocess management
    library across all the languages. Especially the `check_output()` really
    gets it right, makes it a breeze to call external command or shell capabilities. Whenever I needed subprocess in other languages, I always
    wanted to port Python's subprocess APIs to those languages :)


    Have you moved on to other languages, or is it still your primary
    programming language?

    At work yes right now it's my primary language, but I hope it's not:) I
    can't say it's my favorate still, but I use it a lot for hobby. I'm
    still on the journey looking for "the one", but I feel this journey
    won't end :)


    so I threw myself into Python 3 (completely avoiding Python 2 at all
    costs, as all the references I had available said it was on its way
    out and 3 was the future).

    Yeah I highly recommend Py3 over Py2, and try use `dataclasses` a lot
    and a lot of type annotations:)
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From klu@klu@tilde.club to tilde.python on Sun May 9 07:37:12 2021

    Alexander <amrowsell@frozenelectronics.ca> writes:

    I do like the C# syntax because it is a bit more C-like and for GNOME
    apps it's all they use, as far as I can see.

    Miguel de Icaza started Gnome, who also started mono which is .NET's
    open source implementation. Mono is now Xamarin, and he brought it onto
    all platforms iOS, android. Very interesting project!
    --- Synchronet 3.19a-Linux NewsLink 1.113