5 ms·
Last time I've read this, it had too much code golf with FP Python. No one is using Python like that in the professional world. The most complex you'll see are
by wheelerof4te 3y ago
Last time I've read this, it had too much code golf with FP Python.
No one is using Python like that in the professional world. The most complex you'll see are simple comprehensions.
Python is supposed to be a readable language for newbies, like Golang.
- globular-toast 3y agoPython is supposed to be whatever you want it to be. It's free software. Who cares what people do in the "professional world"? This is Pytudes and it's quite fun. Learning to program in different paradigms helps your mind to grow, even if you won't use them yourself. I see quite a lot of higher-order functions in "real" Python anyway. I'm not sure what other FP concepts there are in Pytudes.
- freilanzer 3y ago> No one is using Python like that in the professional world. The most complex you'll see are simple comprehensions. That's part of why much of the software industry is incredibly boring work. And also this isn't work, it's supposed to be fun, do whatever you want.
- evgen 3y ago> No one is using Python like that in the professional world. The most complex you'll see are simple comprehensions. It is possible that blub-Python and "let's code it in Java-flavoured Python" rules your particular slice of the profession, but in my world of getting shit done I see more FP and using simple built-in data structures in a >1 KLoc line script/module than I do of traditional OO and GoF styles. Most objects I deal with in Python are from libraries I call and not from our own code. Different strokes I guess, but I think you underestimate the breadth of Python usage and how much of it is semi-complicated scripting that picks from FP-style and OO-style depending on what is easiest to accomplish the task.
- hk__2 3y agoI think OP refers more to the "code-golf" part than FP: the repo contains code that uses OO when necessary and FP (although in a very light way) when it can. The biggest issue is that it tries to be as short as possible, which makes it hard to understand. Code should be simple, not short. Instead of looking at Loc, we should look at "how much time does someone need to understand this part of the code".
- rcarmo 3y ago$DIVINITY, I hate Java-flavoured Python with a passion. Sometimes I dive into corporate stuff that seems like it was done by the yard by interns measured in LOC per day, or literally code-generated from some overly abstract spec. Worse, sometimes I will have to dig down into accessors of accessors to find the actual logic for a library (which is why I often implement my own, shorter and easier to debug ones). I write Python in a mix of FP style (with the occasional class for handling specific contexts or tasks) that aims to be as concise and readable as possible, and yes, I will use global variables in a module if it saves me the trouble of herding some constants or common state around and making function invocations unnecessarily long.
- rcarmo 3y agoI guess that writing "Java Fanfic" is very popular, judging from the downvotes.
- hk__2 3y agoI have the same impression. Reading the code, he uses global variables [1], obscure variable (k, bw, fw, x) and module names ("pal.py" instead of "palindromes.py"), doesn’t respect conventions about naming in general (uppercase arguments [2], which even the GitHub syntax highlighter is confused about). This feels like code you write for yourself to play with Python and don’t plan to read later. Some parts of the code feel like what I would expect from a junior dev who started learning the language a couple weeks ago. [1]: https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a77a5c529fec95dc380bc/py/pal.py#L24 https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a7... [2]: https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a77a5c529fec95dc380bc/py/sudoku.py#L14 https://github.com/norvig/pytudes/blob/952675ffc70f3632e70a7...
- fsociety 3y agoWhen your code is under 200 LOC and not expected to be maintained for the next 10 years.. then a lot of the things you just mentioned don’t matter as much. This is not for running in an enterprise but for exercising the brain.
- hk__2 3y ago> When your code is under 200 LOC and not expected to be maintained for the next 10 years.. then a lot of the things you just mentioned don’t matter as much. This is not for running in an enterprise but for exercising the brain. The things I mentioned do matter in any situation. If you don’t take good habits when you exercise your brain, you won’t take them when you code "for real". In addition to that, this repository is not just to exercise the brain of the author, but to serve as example code for others to read it; it has a README and most functions have a docstring.
- indymike 3y ago> No one is using Python like that in the professional world. The most complex you'll see are simple comprehensions. I'm always surprised what I find when I move into a codebase. A lot of it is just what was fashionable when the application started. 90s and 00's everything is over objectified complete with lots of factories and tons of getters and setters. 10's you started seeing a lot more FP style usage, and now I'm seeing a lot more async code. > Python is supposed to be a readable language for newbies, like Golang. Python is supposed to be readable because most developers spend more time reading code than writing it.