News for hackers. Stuff that matters.
Re:Writing Pythonic Rust by bjornjajayaja on Monday May 24, 2021 @03:18PM (#27268540)
I think the broader problem is that: one _cannot_ just arbitrarily “go” from a higher level language to a systems language.

Folks really ought to read the C/C++ literature to understand why Rust evolved in a unique direction. That gives better compare/contrast.

Also, a lot of Python idioms are actually from C++ (e.g. mixins, iterators, operator overloads, etc).

Anyway, to reiterate: folks interested in systems languages should read the C/C++ literature and actually become a systems engineer first.

Re:Writing Pythonic Rust by whatshisface on Monday May 24, 2021 @03:27PM (#27268638)
>Folks really ought to read the C/C++ literature to understand why Rust evolved in a unique direction. That gives better compare/contrast.

Sounds like a good idea for the post-singularity age of infinite lifespans, but what folks really need to do is learn what they need to learn as best they can when they need it.

Re:Writing Pythonic Rust by bjornjajayaja on Monday May 24, 2021 @06:32PM (#27270467)
Maybe if one just wants to scrape by. I wouldn’t want systems code from those folks to be honest... Maybe that’s fine up the layers but the whole point of Rust is correctness and stability—to get the that point, maybe invest a month hitting the books?
Re:Writing Pythonic Rust by nicoburns on Monday May 24, 2021 @04:06PM (#27269074)
> Folks really ought to read the C/C++ literature to understand why Rust evolved in a unique direction. That gives better compare/contrast.

Unfortunately the C/C++ literature is dense and not at all approachable. The Rust literature is much, much better for newcomers to systems programming (partly because it doesn't have to cover a load of weird failure cases that simply don't exist in Rust).

> one _cannot_ just arbitrarily “go” from a higher level language to a systems language.

I mean, it's like learning anything new. You have to do a bit of unlearning, and grasp the core concepts. I don't think there is anything especially difficult about systems languages. I had a background of JavaScript and PHP, and I was able to pick up Rust well enough to use it in my day job in a couple of weeks.

Re:Writing Pythonic Rust by bjornjajayaja on Tuesday May 25, 2021 @12:31PM (#27278945)
C/C++ has been around for a while and there is gobs of literature. For this I’m guessing you mean “the website literature.”

Many developers these days scarcely read books on subject matter. But if they did read books, they would find there’s actually more C/C++ literature and established best practices than there is for Rust (naturally).

The effective C++ series comes to mind as something not just approachable, but enjoyable and largely insightful.

The truth is... systems engineering is a discipline which requires an understanding of historical context. You get that with the C/C++ books! I highly recommend reading on it to better appreciate Rust.

Re:Writing Pythonic Rust by heresie-dabord on Monday May 24, 2021 @03:52PM (#27268916)
Whenever I see the word "pythonic" I am cautious. Not all languages are Python, nor should they all become Python, nor are they worse for _not being Python_.
Re:Writing Pythonic Rust by lmm on Tuesday May 25, 2021 @02:16AM (#27273366)
Python has a reputation as "executable pseudocode", a language that makes it easy to express the essence of what you're actually doing without clutter or ceremony. That's a worthy design goal for every language IMO.
Re:Writing Pythonic Rust by heresie-dabord on Tuesday May 25, 2021 @12:15PM (#27278715)
> a worthy design goal for every language

I suspect that every language in the world can be clear and direct. I am sure that some people can write unintelligible pseudocode.

We don't expect speakers of other languages to write more Englishonic phrases, although of course that does happen. (English speakers often criticise people for not speaking good English.)

Every language is readable by and intelligible to people who know the language.

Pseudocode is a useful concept. There is no "correct" pseudocode because it is meant as a DSL for _thinking_. Any non-trivial implementation of thinking will quickly become more detailed and more subtle in notation than a shopping list (for example). Opinions about the subtlety of notation abound.

I am not aware of any high-level language that makes a shopping list hard to understand. Above that, we are deeply into opinion about what defines "clutter", "ceremony", and effective notation.

Re:Writing Pythonic Rust by lmm on Tuesday May 25, 2021 @08:16PM (#27284542)
We pretend all human languages are equal for political reasons, not because it's reality. I would hope that programming language preference is still neutral enough that we can talk about what things different languages do better or worse. There are plenty of things wrong with the Python ecosystem, but the language syntax is widely known as a success.
Re:Writing Pythonic Rust by heresie-dabord on Wednesday May 26, 2021 @07:59AM (#27289335)
> We pretend all human languages are equal for political reasons, not because it's reality.

Hmm, what is the "non-political" reality in the question of equality of languages?

> the [Python] language syntax is widely known as a success.

There are other successful languages, too.

Re:Writing Pythonic Rust by lmm on Wednesday May 26, 2021 @09:19PM (#27298253)
> Hmm, what is the "non-political" reality in the question of equality of languages?

Human languages aren't equal; plenty of languages have problems either in specific areas or just generally, and any academic linguist can tell you (off the record) which.

> There are other successful languages, too.

Python is probably the most successful teaching language; I can't think of another language with a better reputation syntax-wise. (And if another language has such a reputation, it's probably because that language is also "Pythonic").

Re:Writing Pythonic Rust by bjornjajayaja on Friday May 28, 2021 @07:35AM (#27314127)
Just want to point out that Rust and Python live on opposite sides of the spectrum. A systems language requires good understanding of systems (whether rust or c/c++) and also some assembly language. So Pythons “ease of teaching” actually could yield bad systems engineers, because it shields users from the system...

Honestly, I would personally teach plain C for algorithms because it has the simple for loops and while loops, tail-call recursion, arrays and structures.

Python has a kitchen sink.

Re:Writing Pythonic Rust by lmm on Sunday May 30, 2021 @10:47PM (#27339491)
> Pythons “ease of teaching” actually could yield bad systems engineers, because it shields users from the system...

Not necessarily. Most of what it "shields" users from is unnecessary ceremony and clutter rather than relevant system behaviour.

> Honestly, I would personally teach plain C for algorithms because it has the simple for loops and while loops, tail-call recursion, arrays and structures.

C's loops are not simple, C implementations do not generally have tail calls, C makes the distinction between arrays and pointers far too subtle (which not only confuses learners but also causes bugs in real code), C's structure support is bad (primitive unchecked unions, but no support for proper disjoint sum types). It may have been useful as a portable assembler at one point (back when it was compiled in simple fashion), but it's not a good language for anything these days.

Re:Writing Pythonic Rust by heresie-dabord on Saturday May 29, 2021 @11:36AM (#27325919)
> any academic linguist can tell you (off the record) which.

Hmm, once again you allude to unspoken truth. What is your understanding of this unspoken truth about which languages are "better"? I assume that if you hold an opinion, you can present it clearly without vague references to unnamed sources.

> Python is probably the most successful teaching language; I can't think of another language with a better reputation syntax-wise. (And if another language has such a reputation, it's probably because that language is also "Pythonic").

In pseudocode, what you have written is: I assert P because I think P is best and prefer P; also, any other language that meets my requirements is P.

Re:Writing Pythonic Rust by lmm on Sunday May 30, 2021 @10:42PM (#27339465)
> I assume that if you hold an opinion, you can present it clearly without vague references to unnamed sources.

I don't want to get banned.

> In pseudocode, what you have written is: I assert P because I think P is best and prefer P; also, any other language that meets my requirements is P.

Your pseudocode has a type error.

I don't much care for Python myself. But I believe languages with reputations for good syntax are Python-like. If this isn't so, it should be easy to provide a counterexample: a language that has a reputation for a good syntax that isn't Pythonic.

Re:Writing Pythonic Rust by heresie-dabord on Monday May 31, 2021 @03:36PM (#27347422)
> I believe languages with reputations for good syntax are Python-like.

"Only syntax like P has a good reputation". That is your opinion and I uphold your right to hold it. I would however like to understand it better.

Given this dependency on the "reputation" of "pythonic syntax", whom do you accept as "recommenders" for reputation? What constitutes a "good reputation" to your mind?

Do the importance of project, or perhaps durability of code have any value in this reputation?

Is it possible that more detailed notation has a purpose, or is it always "clutter" because it is not "pythonic" or "Englishonic"? Math notation itself is eloquent in the extreme, yet it is not "pythonic" and certainly not "Englishonic".

Is it enough that millions of other people use different tools? Literally billions of other people speak and write a language that does not have the "Englishonic" properties of English, for example. Some of these languages have a notation that is superior to English. [see GB Shaw on English notation]

You say quite clearly in another comment that "C" is not a good language, despite its importance as a language and its influence on several other important, long-serving programming languages. I will just cite the TIOBE index as something tangible; if imperfect, it is at least not a mysterious allusion.

Take one of these languages. Javascript, for example, is a very successful language. Apart from the "ecosystems" of languages, I assume you accept that the notation of Javascript is -- by any measure other than aspersions -- a successful notation system.

Re:Writing Pythonic Rust by lmm on Wednesday June 02, 2021 @02:05AM (#27365426)
> Given this dependency on the "reputation" of "pythonic syntax", whom do you accept as "recommenders" for reputation? What constitutes a "good reputation" to your mind?

Do you actually disagree with me about the reputation of different language syntaxes? I don't have a specific list of influences, just a general impression from e.g. HN-like discussion sites, programming meetups, work colleagues...

> Do the importance of project, or perhaps durability of code have any value in this reputation?

No - we're talking solely about syntax.

> Is it enough that millions of other people use different tools? Literally billions of other people speak and write a language that does not have the "Englishonic" properties of English, for example. Some of these languages have a notation that is superior to English. [see GB Shaw on English notation]

I see your last two sentences as the demonstration that the answer to your question is "no". A language may become very popular despite having a very poor syntax, and even clear improvements to syntax are often not adopted.

> You say quite clearly in another comment that "C" is not a good language, despite its importance as a language and its influence on several other important, long-serving programming languages. I will just cite the TIOBE index as something tangible; if imperfect, it is at least not a mysterious allusion.

Sure, and I'm aware that this is a controversial view. I think few would defend C's syntax; rather they tend to claim that it has good performance or is close-to-the-machine (views that I disagree with, but would acknowledge the popularity of, and be prepared to argue my case against).

> Take one of these languages. Javascript, for example, is a very successful language. Apart from the "ecosystems" of languages, I assume you accept that the notation of Javascript is -- by any measure other than aspersions -- a successful notation system.

I don't accept that a language being popular means it has good syntax, if that's what you're saying.

Re:Writing Pythonic Rust by heresie-dabord on Tuesday June 08, 2021 @09:45AM (#27435135)
Your notion of "pythonic" syntax being superior remains vague. You haven't clearly said what non-biased measure supports your claim.

"Pseudo-code" itself can be anything, as it is a term coined for a loose notation of ideas.

If your objection were "line noise" (i.e. non-Pythonic or non-Englishonic characters), the bias in this is striking. There are other languages that are as effective or even better. The fact that we may not understand these other languages is not an elevated argument for converting them all to a language that we do understand, except perhaps as a study exercise.

As far as English itself is concerned, it is a disastrous confusion of phonemical artefacts. People learn to speak and write English despite the major problems with the writing conventions.

You say "reputation" is your measure, but this is nothing more than "group opinion". You responded that professional popularity is not your measure, so C, Java, and Javascript do not receive your approval. Yet they are successful languages. They are not perfect, but neither is Python.

As far as human languages are concerned, your position is untenable. A fluent speaker speaks $language and understands $language in its subtleties. A person who does not speak $language understands little (or perhaps nothing) and is either trying to learn or has installed opinions instead of knowledge.

Re:Writing Pythonic Rust by lmm on Tuesday June 15, 2021 @11:32PM (#27524586)
> You say "reputation" is your measure, but this is nothing more than "group opinion".

One could say the same about e.g. the scientific consensus on a given topic. Ultimately anything nontrivial in today's world relies on other people.

> You responded that professional popularity is not your measure, so C, Java, and Javascript do not receive your approval. Yet they are successful languages.

They are popular but not for their syntax. Their fans and advocates largely admit as much. Plenty of professionals will say things like "I use language X despite its cumbersome syntax, because ...".

> As far as human languages are concerned, your position is untenable. A fluent speaker speaks $language and understands $language in its subtleties. A person who does not speak $language understands little (or perhaps nothing) and is either trying to learn or has installed opinions instead of knowledge.

And yet it's possible to be fluent in multiple languages, and also to study languages in an objective way without being fluent in them. Linguistics is a legitimate field of study with a wide body of existing research (computer language design, on the other hand, has not yet reached that level of maturity).

Re:Writing Pythonic Rust by radicalbyte on Monday May 24, 2021 @04:06PM (#27269072)
Python developers try to write idiomatic Python in whichever language they use.

Learning the idioms and conforming to a new language are hard, especially at the beginning, and people are lazy.

Re:Writing Pythonic Rust by amyjess on Monday May 24, 2021 @05:35PM (#27270005)
Much of Python's influence is actually from Modula-3, not C++. The only reason C++ is similar is because C++ also borrowed liberally from Modula-3.

In particular, Python's import, exception handling, and object systems are based on Modula-3's (though IIRC it did also borrow some C++ innovations for the object system).

(Modula-3 is the Velvet Underground of programming languages: your average programmer/listener has never heard of it, but it influenced so many languages/musicians you have heard of)

Re:Writing Pythonic Rust by fastasucan on Tuesday May 25, 2021 @08:42AM (#27276114)
>Anyway, to reiterate: folks interested in systems languages should read the C/C++ literature and actually become a systems engineer first.

This is an extremely weird take. So before I can code some rust I should first get a new career and master C/C++? Talk about barriers of entry and gatekeeping. I think I may have toyed around a bit with rust - because its fun, and as I am not a systems engineer (just an other type of engineer) I am deeply sorry.