TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python’s tug of war between beginner-friendly and advanced features

227 pointsby arobergeover 4 years ago

23 comments

yout2over 4 years ago
I think the time is ideal for the &quot;next Python&quot;. A new, general-purpose, beginner-friendly language focused on readability, but designed from the ground up with the techniques &amp; features learned in the past 2 decades.<p>Python has added lots of features to stay current with the latest trends in programming languages, but this has come at the cost of complexity and redundancy (e.g. look at all the ways to format strings or do filesystem operations). And many of the new features such as type annotations have a compromised design due to their being added to Python late in the game. Python&#x27;s &quot;batteries included&quot; approach of a large standard library was a great asset in the days before package managers but these days I think it would be better to start with a much leaner stdlib and add things in more stringently.
评论 #26031291 未加载
评论 #26031618 未加载
评论 #26034838 未加载
评论 #26031405 未加载
评论 #26034359 未加载
评论 #26031655 未加载
评论 #26034539 未加载
评论 #26036989 未加载
评论 #26031540 未加载
评论 #26032134 未加载
评论 #26032242 未加载
评论 #26032370 未加载
评论 #26046138 未加载
评论 #26034301 未加载
评论 #26034163 未加载
评论 #26032834 未加载
评论 #26031687 未加载
评论 #26032111 未加载
评论 #26032209 未加载
评论 #26035857 未加载
评论 #26034846 未加载
评论 #26032410 未加载
评论 #26033794 未加载
评论 #26031964 未加载
评论 #26035309 未加载
评论 #26032463 未加载
评论 #26037326 未加载
评论 #26032380 未加载
评论 #26033304 未加载
评论 #26034117 未加载
评论 #26034949 未加载
评论 #26040191 未加载
评论 #26034559 未加载
评论 #26033551 未加载
评论 #26031318 未加载
Animatsover 4 years ago
I thought that article was going to be about the newer stuff like decorators, &quot;async&quot;, and unchecked type hints. But no.<p>The Rust compiler is doing a reasonably good job on error messages. It&#x27;s especially good at explaining that thing A being done here is incompatible with thing B way over there. It prints the source for both places, which is a rare feature.<p>A compiler that does global analysis can tell you more about what&#x27;s wrong. Python, in its interpreter implementation, doesn&#x27;t have the global info to tell you about global problems.
评论 #26031250 未加载
评论 #26035905 未加载
评论 #26034169 未加载
评论 #26031757 未加载
CivBaseover 4 years ago
Python is a very intuitive and easy-to-read language for experienced programmers, but I wouldn&#x27;t consider it a &quot;beginner-friendly&quot; one. It&#x27;s packed to the brim with features that are hard for beginners to understand without first coming to grips with a more simple language. Those features are extremely useful for experienced programmers who want to get stuff out the door quickly and easily, but they&#x27;re overwhelming for novices. Most <i>experienced developers</i> I work with produce what I would consider to be pretty bad Python code - not because they are bad developers but because they haven&#x27;t had enough experience with Python to understand everything it comes with out-of-the-box.
评论 #26031469 未加载
评论 #26031125 未加载
评论 #26031497 未加载
评论 #26031379 未加载
评论 #26031067 未加载
评论 #26042572 未加载
评论 #26031207 未加载
评论 #26032423 未加载
franklytover 4 years ago
I teach Python to learners.<p>It has substantial pain points, the most significant in my opinion being the semantic white space that never really ever stops being a problem.<p>JavaScript runs in the browser, has relatively trivial syntax, no semantic white space, C-like, a superior and more useful GUI, etc.<p>I see no reason to teach Python per se unless people request it.
评论 #26031415 未加载
评论 #26031278 未加载
评论 #26031321 未加载
评论 #26031395 未加载
评论 #26033843 未加载
评论 #26034240 未加载
评论 #26032987 未加载
评论 #26031467 未加载
评论 #26035111 未加载
ledauphinover 4 years ago
the reason this is a conversation is because of how massively successful Python has been at the intersection of &quot;reasonably simple syntax, reasonably simple language, reasonably simple runtime, reasonably simple builtins&quot;.<p>Python is the biggest victim of its own success. There have been warts in Python since the beginning, but they mostly only look like warts in retrospect because of how much Python has shifted the conversation about what a language _could_ be.<p>I hope someday something truly better along all the relevant axes will replace Python. But Python has maximized utility along so many of those axes that it&#x27;s an (observably) uphill battle for everybody who is currently trying.
mayankkaizenover 4 years ago
I am a noob in programming. My impression is Python is easy language but only for day to day simple task. When you start to delve deeper, it is actually very big and complex language. Sometimes I feel like it is the C language which is actually a very small language and <i>easier</i> to learn (I know writing correct and complex C program is hard).
评论 #26032840 未加载
pansa2over 4 years ago
Another example of the support for type hints turning code which should be invalid into valid code with unexpected behaviour:<p><a href="https:&#x2F;&#x2F;mobile.twitter.com&#x2F;reuvenmlerner&#x2F;status&#x2F;1290317124997648386" rel="nofollow">https:&#x2F;&#x2F;mobile.twitter.com&#x2F;reuvenmlerner&#x2F;status&#x2F;129031712499...</a>
评论 #26031316 未加载
评论 #26031345 未加载
londons_exploreover 4 years ago
What is this vodoo syntax:<p>x = list[1, 2, 3, 4]<p>I assume yet another new bit of python syntax thats unguessable what it means...
评论 #26031101 未加载
评论 #26033557 未加载
评论 #26031050 未加载
评论 #26031069 未加载
评论 #26031051 未加载
评论 #26031159 未加载
lwnealover 4 years ago
Python is my favorite programming language because of its simplicity and ease of use. For example, working with lists in a REPL is easy:<p><pre><code> &gt;&gt;&gt; print range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] </code></pre> Integer math works exactly the way you would expect with no horrible surprises at all:<p><pre><code> &gt;&gt;&gt; print [x * 3 for x in range(10)] [0, 3, 6, 9, 12, 15, 18, 21, 24, 27] &gt;&gt;&gt; print [x &#x2F; 3 for x in range(10)] [0, 0, 0, 1, 1, 1, 2, 2, 2, 3] </code></pre> Python is great for little one-off tasks; say you want a color half the brightness of #308cfb<p><pre><code> &gt;&gt;&gt; hex(0x30 &#x2F; 2) &#x27;0x18&#x27; &gt;&gt;&gt; hex(0x8c &#x2F; 2) &#x27;0x46&#x27; &gt;&gt;&gt; hex(0xfb &#x2F; 2) &#x27;0x7d&#x27; </code></pre> The built-in support for dictionaries and JSON parsing make data conversion easy:<p><pre><code> &gt;&gt;&gt; import json &gt;&gt;&gt; json.dumps({&#x27;foo&#x27;: 42, &#x27;bar&#x27;: 132}.values()) &#x27;[42, 132]&#x27; </code></pre> If there&#x27;s one thing I love about Python, it&#x27;s how easy and consistent it is. It sure is great that we&#x27;ve spent the last decade teaching Python to every scientist, academic, and hobbyist.<p>If there are two things I love about Python, it&#x27;s that and the reliable, well-supported Python package manager.
评论 #26031400 未加载
评论 #26032689 未加载
Lucasoatoover 4 years ago
Is there a strongly, statically typed language with a syntax similar to Python? Why even newest languages embrace the braces and can&#x27;t tolerate python indentation block system? (I do understand that these are controversial features, please forgive me!)<p>I was so upset when Boo was ditched from Unity, I loved it so much!
评论 #26036495 未加载
评论 #26039810 未加载
评论 #26040403 未加载
unwindover 4 years ago
This was interesting, although slightly confusing to read since it was written in the context of using the author&#x27;s &quot;Friendly Traceback&quot; [1] system.<p>I would humbly suggest that maybe the <i>name</i> &quot;friendly traceback&quot; is not the most beginner-friendly thing, since if you are a beginner programmer you are perhaps not 100% sure what a &quot;traceback&quot; is, and why you would benefit from friendlier tracebacks.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;aroberge&#x2F;friendly-traceback" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aroberge&#x2F;friendly-traceback</a>
评论 #26034747 未加载
estover 4 years ago
Or a beginner-friendly REPL could link errors directly to Stackoverflow search results page.
nromiunover 4 years ago
I thought the article would talk about new features like optional types and asyncio and how beginners are having trouble understanding them (specially asyncio). But it is only about error messages. To be honest the only hint I nedded was the line number and the error became pretty obvious. Sure, new languages like Rust and Elm are doing exciting work in this space, and I am excited to see how other languages will adopt them. But, TBH, I had more problems with complex language constructs (like asyncio and the borrow checker) than with error messages.
peterkellyover 4 years ago
To generate a more helpful error message in this case, you could just look at the arguments to the list type to check if they are values or other types. In the case of list[1, 2, 3, 4] it should be straightforward for the error reporting mechanism to see that these are values and based on that, suggest list(1, 2, 3, 4).<p>I don&#x27;t see type annotations as adding a fundamental difficulty to the sorts of error reporting described in the article, just something which makes it a bit more challenging to achieve.
AuthorizedCustover 4 years ago
I teach R in a graduate course. As long as you teach the concept of vectors right, and it’s not hard, you’ve overcome R’s main cognitive hurdle, in the eyes of computer science people. The rest of R is beautiful, assuming a focus on the Tidyverse.<p>Python feels like a mess by comparison. As a computer science type myself, my tribe’s provincialism towards “languages like C”, like Python, just gets old.
kuroguroover 4 years ago
Python&#x27;s really as good as the underlying libraries and bindings. As long as you play within the standard library everything&#x27;s fine but for most large projects that require a button of dependencies I&#x27;ve quickly ran up to the wall of needing more features &#x2F; performance and ended up patching the underlying C++ code...
KaiserProover 4 years ago
Why is this an either or?<p>That level of debug information is useful to &quot;advanced&quot; users. Sometimes the hardest things to debug are brain fart moments. also when a library raises an exception that you&#x27;ve never seen before, extra context is useful.<p>I frankly couldn&#x27;t give a shit about :=, but I would give money for GIL-less multithreading.
pansa2over 4 years ago
I’m not interested in using type annotations in Python. But, whenever I express my wish that they hadn’t been added to the language, the reply is always “they’re optional, you don’t have to use them”.<p>Thank you for yet another example of why there’s really no such thing as an “optional” feature.
whalesaladover 4 years ago
I honestly can’t think of a better language for beginners and experts alike with the exception of perhaps JavaScript.
j45over 4 years ago
If you can’t create beginners, you can’t create juniors, or seniors.
jnxxover 4 years ago
There are three observations which are really interesting to me.<p>One is that traditionally, there was a clear split between &quot;system languages&quot; which were usually fast, compiled languages that were relatively verbose, not very comfortable, and comparatively unsafe -- and &quot;scripting languages&quot;, which were dynamically typed, dynamic memory management, often interpreted, offered more data types and facilities, but were slower.<p>C belonged clearly to the first group and shell scripts, Perl and Python to the second.<p>But the gap between these two groups has been shrinking, as languages are overall converging: Java uses dynamic memory management, Go has a very fast compiler, C++, Scala and Rust have iterators, type inference and such. On the other hand, script-like languages added type annotations, got generally faster, and so on. Much of this is due to better and better compilers.<p>Python stands out in this landscape like a sore thumb - its performance did not profit much from better compilers.<p>There is another axis which is the range between direct low-level manipulation of bits and bytes and symbolic computation and functional languages. Lisps, OCaml, Scala and Haskell are from the family tree of symbolic computation. Traditionally, these languages were heavy-weights and slow compared to the system languages, but they also have seen enormous progress from better compilers - Common Lisp implementations like SBCL can now produce code which is almost as fast as C. As a consequence, there is also a convergence of general languages with &quot;symbolic&quot; features like first-class functions, type inference, list comprehensions, and so on.<p>The third observation which I find very interesting is how much Python and modern Lisps&#x2F;Schemes do have in common. If one has a close look, the extend of this convergence is really astonishing.<p>Here are some things that modern Lisps like SBCL, Schemes and functional languages on the one hand side, and Python3 do have in common:<p>* a Read-Eval-Print Loop (REPL)<p>* strong dynamic typing<p>* automatic memory management<p>* memory safety<p>* exceptions<p>* a wide choice of built-in data types: lists, strings, vectors, arrays, dictionaries &#x2F; hash maps, tuples, sets<p>* keyword arguments and optional arguments in functions<p>* handling of names in scopes and names spaces<p>* closures and lambda functions<p>* list comprehensions<p>* pattern matching (limited support for tuples and lists in Python)<p>* Unicode strings<p>* arbitrarily long integers<p>* complex numbers<p>* rational numbers<p>* number type are part of a hierarchical type hierarchy (numeric tower)<p>* empty sequences, containers and strings are logically false<p>* support for threads (but no real parallelism in Python)<p>* low-level bit operations (a bit limited in Python)<p>* easy way to call into C code<p>* type annotations<p>* if ... else can be used as an expression<p>* string formatting is a mini language<p>* hexadecimal, octal and binary literals<p>* standard functions for functional programming like map and filter<p>* support for OOP (e.g. by the Common Lisp Object System)<p>* support for asynchronous execution<p>The few remaining distinctions between Lisps and Python are:<p>1. Lisps use parentheses to determine scope, while Python uses indentation and white space.<p>2. Lisps usually compile either to native code or to JIT-compiled byte code, while standard Python uses interpreted byte code.<p>3. Python does not support true parallel execution within the same process.<p>4. Lisps have of course the typical macro system which, for example, allows to define new control constructs, while Python does not have macros.<p>5. Lisps and Schemes have with conditions, restarts, and continuations some unique way to handle errors and manipulate the control flow (see <a href="http:&#x2F;&#x2F;www.gigamonkeys.com&#x2F;book&#x2F;beyond-exception-handling-conditions-and-restarts.html" rel="nofollow">http:&#x2F;&#x2F;www.gigamonkeys.com&#x2F;book&#x2F;beyond-exception-handling-co...</a> )<p>So, what I find really interesting is that for example Common Lisp, which was standardized first in 1984, has so many features in common with more recent languages - and still much better performance than python:<p><a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;fastest&#x2F;python3-java.html" rel="nofollow">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a><p><a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;fastest&#x2F;lisp.html" rel="nofollow">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a><p><a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;fastest&#x2F;racket-java.html" rel="nofollow">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a><p><a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;fastest&#x2F;ocaml-java.html" rel="nofollow">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a>
f430over 4 years ago
hmm I really didn&#x27;t find the examples in this article to be compelling reasons to suggest the problems highlighted in its main thesis: that there is an inherent problem with fitting its audience.<p>In fact I think Javascript fits the title better. Python3 is still simple and advanced enough over Python 2, I just don&#x27;t really agree with the author here.
offtop5over 4 years ago
This article felt a little bit silly to me, Python intentionally is one of the easiest languages to use. And this article kind of argues it needs to get even easier?<p>The only thing I can dream about is some type of typescript like version of Python with good old-fashioned type checking. I prefer C# and Flutter only because I really need types when my applications get larger.
评论 #26031014 未加载
评论 #26031049 未加载
评论 #26030997 未加载
评论 #26031003 未加载