Looking at some “exciting” features landing in Python 3.8, I’m still disappointed and frustrated by the language… like by quite a few other languages.
As an author of another programming language, I can’t stop thinking about how things “should have been done” from my perspective. I want to be explicit here. My perspective is biased towards correctness and “WTF are you doing?”. Therefore, take everything here with a appropriate amount of salt.
Yes, not talking about any “positive” changes here.
There is new syntax
:=that assigns values to variables as part of a larger expression.
A fix which couldn’t be the best because of previous design decision.
“Somebody” ignored the wisdom of Lisp, which was “everything is an expression and evaluates to a value” (no statements vs expressions), and made assignment a statement in Python years ago. Now this can not be fixed in a straightforward manner. It must be another syntax. Two different syntaxes for almost the same thing which is
= for assignment as a statement and
:= for expression assignment.
There is a new function parameter syntax
/to indicate that some function parameters must be specified positionally and cannot be used as keyword arguments:
def f(a, b, /, c, d, *, e, f): print(a, b, c, d, e, f)
Trying to clean up a mess created by mixing positional and named parameters. Unfortunately I did not give it enough thought at the time and copied parameters handling behaviour from Python. Now NGS also has the same problem as Python had before 3.8. Hopefully, I will be able to fix it in some more elegant way than Python did.
functools.lru_cache()can now be used as a straight decorator rather than as a function returning a decorator. So both of these are now supported
OK. Bug fix. But … (functools.py)
if isinstance(maxsize, int): # Negative maxsize is treated as 0 if maxsize < 0: maxsize = 0
If you are setting LRU cache size to a negative number, it’s 99% by mistake. In NGS that would be an exception. That’s the approach that causes
rm -rf $myfolder/ to remove
myfolder is unset. Note that the
maxsize code is not new but it’s still there in Python 3.8. I guess that is another mistake which can not be easily fixed now because that would break “working” code.
collections.namedtuple()now returns a
dictinstead of a
collections.OrderedDict. This works because regular dicts have guaranteed ordering since Python 3.7
OK. Everybody had the mistake of making maps unordered: Perl, Ruby, Python.
- Ruby fixed that with the release of version 1.9 in 2008 (according to the post).
- Python fixed that with the release of version 3.7 in 2018 (which I take as 10 years of “f*ck you, the developer”).
- Perl keeps using unordered maps according to documentation.
- Same for Raku, again according to the documentation.
NGS had ordered maps from the start but that’s not a fair comparison because NGS project started in 2013, when the mistake was already understood.
How all that helps you, the reader? I encourage deeper thinking about the choice of programming languages that you use. From my perspective, all languages suck, while NGS aims to suck less than the rest for the intended use cases (tl;dr – for DevOps scripting).
It looks like the article above needs some clarification about my perspective: background, what I am doing and why.
The main points of the article are:
- Everything still sucks, including Python. By sucks I mean does not fit well with the tasks I need to do neither aligned with how I think about these tasks.
- I am trying to help the situation and the industry by developing my own programming language
Background about my Thinking
In general, I’m amazed with how bad the overall state of programming is. That includes:
- All programming languages that I know including my own NGS. This is aggravated by inability to fix anything properly for any language with substantial amount of code written in it because you will be breaking existing code. And if you do break, you get the shitstorm like with Python 3 or Perl 6 (Raku).
- Code quality of the programs written in all languages. Most of the code that I have seen is bad. Sometimes even in official examples.
- Quality of available materials, which are sometimes plainly wrong.
- Many of existing “Infrastructure as code” solutions, which in most cases follow the same path:
- Invent a DSL or use YAML.
- “figure out” later that it’s not powerful enough (by the way there is an elegant solution – a programming language, forgot the name)
- Create pretty ugly programming language on top of a DSL that was intended for data.
I am creating new programming language and a shell out of frustration with current situation, especially with bash and Python. Why these two? Because that’s what I was and still using to get my tasks done.
Are these languages bad? I don’t think it’s a question with any good answers. These languages don’t fit the tasks that I’m trying to do nor are aligned with how I think while being apparently one of the best choices available.
This Article Background
- Seen some post on RSS about new features in Python 3.8.
- Took a look.
- Yep, everything is still f*cked up.
- Wrote a post about it which was not meant to be “deep discussion about Python flaws”.
I was not planning to invest more time in this but here I am trying to clarify.
And your Language is Better? Really?
Let’s clarify “better”. For me, it’s to suck less than the rest for the intended use cases.
author really does consider himself a superior language designer than the Python core-dev team
( From https://www.reddit.com/r/Python/comments/iartgp/python_38_makes_me_sad_again/ )
I consider myself in much easier circumstances:
- No substantial amount of code is written in NGS yet.
- I’m starting later and therefore have the advantage of looking at more languages, avoiding bad parts, copying (with adaptation) the good parts.
- NGS targets a niche, it’s not intended to be general purpose language. Choices are clearer and easier when you target a niche.
- The language that I’m creating is almost by definition is more aligned with how I think. Hoping that people out there will benefit from using NGS if it is more aligned with how they think too.
- See also my Creating a language is easier now (2016) post.
Will I be able to make a “better” language?
From technical perspective, that’s probable: I am a skilled programmer in several languages and I have languages to look at more than everybody else had before. My disadvantage is not much experience in language design. I’m trying to offset that with thinking hard (about the language, the essence of what is being expressed, common patterns, etc), looking at other languages and experimenting.
From marketing perspective, I need to learn a lot. I am aware that “technically better” doesn’t matter as much as I would like to. Without community and users that would be a failed project.
Also don’t forget luck which I might or might not have.
What if NGS fails?
I think that the situation today is unbearable. I’m trying to fix it. I feel like I have to, despite the odds. I hope that even if NGS fails to move the industry forward it would be useful to somebody who will attempt that later.