Cuttings: Consenting Pythonic Adults Consenting Pythonic Adults | Cuttings
 

Things of interest.

 
 
August 13, 2020

Consenting Pythonic Adults


Do it as you want it. Do it Pythonically, preferably.

I encountered an interesting thread today on Reddit - ‘Developers whose first programming language was Python, what were the challenges you encountered when learning a new programming language?’

Reading that, here’s my quick thoughts on why I’ve chosen not to move from Python to other languages:

  1. In Python, I can expose, modify or access virtually all properties/interfaces and protocols with ease. The syntactic sugars using or affecting them (e.g. via dataclasses and decorators/wrappers like functools.wraps) are also clear and well-documented through PEPs. Iterators act intuitively, as well as functions like len(). Python’s philosophy is one of consistency without restraints.

  2. Following from the above, I’m free to write (if I wish) insanely tightly-coupled, low-cohesion code with numerous side effects first, and be allowed to come back and resolve that technical debt later when I have time. The language doesn’t force me to think deeply in terms of private/public access, or about serious architectural or memory management concerns at the outset just to get something to work now (or be scared that I can’t even dissect my code later), as I may be put to with Java or C. Yes, I should think deeply about those, but I may not want to. Python lets me do so.

  3. I’m a lawyer - more accurately, a litigator. In my line of work, we think of time on the order of days, weeks, months and years. Not seconds. Ultra-performant code, optimization and Big O notation issues (and being too precious with shaving off seconds) aren’t concerns directly relevant to my overall work, nor would it affect it much. In fact, even if the code could only process things within minutes or hours, that’s perfectly acceptable. Where I need to batch out things, Python’s threading and concurrency libraries are good enough for most applications. I see no need to resort to specific concurrency-friendly languages like Go.

  4. I tend to be rigorous with parameters/returns and docstrings. And I’m very testing-driven, and do not want to change substantive code or write more tests than would be necessary. Python’s type hints are flexible, and non-invasive. With PyCharm’s superb linting/inspection and static analysis, it counterbalances duck typing’s drawbacks enough without affecting its advantages.

  5. In Python, I can shift between programming styles - procedural, object-oriented or functional - with ease, for different code achieving different purposes. Compare this to the enforced paradigms of other languages, which could be useful for full-time professional programmers to learn, but provides little to no learning incentive (beyond intellectual curiosity) for full-time professional court advocates like me:

    … Where your noodle really gets baked is when you jump paradigms:

    1. List based languages like Lisp or Tcl
    2. Logic based languages like Prolog
    3. Stack based languages like Forth
    4. Functional Programming Languages like Haskell and Elm
    6. Systems programming language with ZCA like Rust
    7. Hardware Description Languages like VHDL or Verilog

  6. When I read source code in other languages, I find them outwardly limiting for prototyping ideas - e.g strict typing/casting requirements, inherently-required design patterns (given a language’s design/constraints) and an almost-necessary requirement for IDEs (given the verbosity of certain languages, like Java and C#). When sketching code and when my data structures aren’t yet rigid or definite, I don’t need more mental overhead. Consider this comment, for someone who has moved from Python to Java:

    1. Does no one trust each other?? Why must all goddamn properties of a class be private by default? I had gotten so used to the “consenting adults” paradigm of python that Java just felt patronising. Libraries tend to be incredibly narrow minded and impossible to extend. If the creators did not anticipate your use case then you are often SOL.

    2. Oh god the verbosity… I don’t think you can code without a good IDE and expect to keep your sanity. Oftentimes 50% of my code is auto-generated.

    3. Having to learn “Design patterns” because certain easy tasks in python is an insanely complex framework of builders, factories and god knows what.

    4. Beginners can test fairly easily in python due to how easy it is to just monkey patch. Testing in Java takes a lot of learning in order to understand how to mock stuff correctly. And still you find yourself designing business logic in ways that is explicitly easier to test with no other benefit.

  7. Enforced indentations and snake_case makes code more consistent and readable to me. I prefer that look over curly brackets, semicolons and CamelCase - and the fact that indentations/snake_case are an expected and recognized / ‘official’ style of Python, makes digesting code an even quicker process, all the more so with autoformatters like Black being in vogue these days.

  8. I can fire up Sublime Text and immediately write productive, debugged, and readable code, thanks to Anaconda’s auto-completion/jump-to/doc hints, SublimeREPL, and various packages/tools (e.g. SQL Tools, Text Pastry, Origami). Until I have to think about projects and package/module management and juggling sources, I don’t want to have to launch a full-blown IDE, even though I love PyCharm. This approach may not work for verbose enterprise languages like Java and C#.

All the above, and a ton more things.


 

 
- Areas: Code / Music / Gaming
- Lang: Japanese / French / English
- Hume: Law / Work / Learning / People
- All: Tags / Posts
 
© 1997 - 2020 / Info