As the old saying goes, there are two kinds of programs

26 replies [Last post]
lanun
Offline
Joined: 04/01/2021

"As the old saying goes, there are two kinds of programs: those simple enough to obviously have no bugs, and those complicated enough to have no obvious bugs. It is by no means easier to make the simpler kind, in fact, it’s much more difficult. However, the simpler the system is, the easier it is to reason about all of its states and edge cases. You do not need a JavaScript-powered custom textbox widget. YOU DO NOT NEED A JAVASCRIPT-POWERED CUSTOM TEXTBOX WIDGET."

https://drewdevault.com/2021/10/17/Reliability.html

And now to something completely different:

https://proxy.vulpes.one/gemini/drewdevault.com/2021/10/05/Terminal-emulation-legacy.gmi

jahoti
Offline
Joined: 07/31/2021

> YOU DO NOT NEED A JAVASCRIPT-POWERED CUSTOM TEXTBOX WIDGET.

How else am I supposed to irritate users these days? The blink tag and pop-ups don't work.

lanun
Offline
Joined: 04/01/2021

"Why are programmers so slow?"

https://tube.cadence.moe/watch?v=7EmboKQH8lM&t=24m28s

--Spoiler alert--

"Because they want to go fast."

andyprough
Offline
Joined: 02/12/2015

To me, genius is not merely smarts, but smarts combined with discipline, causing perseverence that results in a massive output of valuable works by the genius in question.

When I first read about RMS, I realized that he fit this definition better than anyone ever had. He wanted a Unix-like OS that was free from licensing restrictions, so what did he do? He sat down and wrote the tools he would need to write a clone like that (including writing 3 entire versions of emacs from scratch) and he wrote the GNU core pieces from scratch, and he created the GPL. And formed the organization (FSF) to support it. His output in the 1980's along with the lasting power of his contributions is probably unmatched in human history, in terms of the contributions of a single person.

When you consider that his work literally changed the world through the widespread use of GNU/Linux servers which run the entire internet along with the billions of devices which use derivations of his work, it's pretty mind-boggling.

And the fact that he intended to change the world in just the way he did is fascinating. Linus Torvalds intended to write a kernel that would allow him to use his computer in his dorm to do his homework instead of trudging through the snow to use the university timeshare computer terminals. That was his motivation. RMS intended to change the entire world, and just sat down and personally did it.

jahoti
Offline
Joined: 07/31/2021

> genius is not merely smarts, but smarts combined with discipline, causing perseverence that results in a massive output of valuable works by the genius in question.

In some cases definitely; however, I'd argue there are actually two kinds of genius.

One, including RMS, has smarts, discipline, and vision: they have one problem and are willing to put the entire potential of their life's work into its solution.

The other, including mathematican Leonhard Euler (the first example I could think of), has smarts and insight: they have a wide variety of interests and can take a novel perspective on practically any of them. Disciplined or not, with an endless stream of problems and a constant supply of solutions these genii can maintain a tremendous output.

Interestingly- and somewhat of topic- the dichotomy of "people with one large idea" vs. "people with many small ideas" also appears to be applicable throughout the arts, where the evidence is that the former peak in their youth while the latter improve continuously over their lifetimes. Perhaps the same applies for genii?

Legimet
Offline
Joined: 12/10/2013
lanun
Offline
Joined: 04/01/2021

Most programming is not done by geniuses. That is not a requirement for clean code. It seems that the requirement for clean, readable, easily reusable code is, as stated in the video above, people who care, or to paraphrase the blog post, people who have empathy for users.

Because it means that they need to spend double the time, however fast they might be able to write code, in order to clean it.

It also means that they test extensively any piece of code they have written, making the whole process even more time consuming.

lanun
Offline
Joined: 04/01/2021

EDITED: I should have foreseen that Python would be a hellish circle of loops.

Do you think this diagram for the "continue" loop control statement is correct?

loop_control.jpg
Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

It is a "do while" loop (the conditional code is executed at least once, no matter what). If encountered, the "continue" statement, in the conditional code, aborts its execution jumping to the condition to either make another iteration (if the condition is satisfied) or exit the loop (if the condition is violated).

lanun
Offline
Joined: 04/01/2021

So, a 'break' statement instead of the 'continue' statement would have the same effect as if the condition is not satisfied, right? Except that the condition would not be examined at all.

Sorry, I am so painfully slow with this Python tutorial, it feels like it has in fact already eaten me alive and is digesting whatever is left. It all feels vague and fuzzy.

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

So, a 'break' statement instead of the 'continue' statement would have the same effect as if the condition is not satisfied, right? Except that the condition would not be examined at all.

Yes. Notice that early exits from loops may turn the loop harder to understand.

lanun
Offline
Joined: 04/01/2021

Is there by any chance a rule stating that a loop including a break statement can be replaced by an if statement followed by a loop, making everything clearer?

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

I am not sure I understand what you suggest. The test (inside the loop) leading to a break can be completed with a else (executing the end of an iteration not triggering the condition), the break can be substituted by setting a boolean value tested in the normal condition of the loop... but, in my humble opinion, that is not clearer and less efficient. I am however considering a rewrite that would always be possible. In some more specific circumstances, it is possible to avoid early exits without such a cumbersome rewrite.

lanun
Offline
Joined: 04/01/2021

I see. There is no rule, but things can be improved on a case-by-case basis. Thanks.

jahoti
Offline
Joined: 07/31/2021

> it feels like it has in fact already eaten me alive and is digesting whatever is left. It all feels vague and fuzzy.

Python will tend to do that; apparently other languages are even worse, not that I've had the tenacity to try them.

Except for JavaScript, that is. Now I understand why web development pays so well.

lanun
Offline
Joined: 04/01/2021

Yes, you seem to have mastered JavaScript, to say the least.

My hope was than Python would have a similar learning curve to cpp, but somehow smoother. For now I find it too smooth, paradoxically making the learning slower, if anything. A bit like crossing a room full of wool mattresses, while cpp would be rough, but solid, ground. Pascal would be somewhere in the middle.

I still have hope, though, it seems I am not the only one to find these tutorials somehow misleading. I have just found a book written by a seasoned teacher and not a random copy-paster, so I might change horse.

Legimet
Offline
Joined: 12/10/2013

While loops (including continue, break) and control flow in general are pretty much the same in every imperative programming language. Python is nothing special in this regard, and I think it's easier to learn than most other programming languages. People usually find C more difficult because of pointers. C was the first language that I tried to learn but I found it too difficult. Then I tried Java which I understood pretty well and then came back to C. I think once you learn one programming language and get used to the computational thinking, it shouldn't be too difficult to learn others. (At least the imperative ones. Functional programming is very different)

Also, besides just going through tutorials, I would recommend doing some experimentation on your own, as well as reading other people's code.

lanun
Offline
Joined: 04/01/2021

Not sure what made you think I was specifically referring to while loops. Putting the wrong diagram did not help, though, given that Python does not have "do...while" loops, as you know. C++ does have one, for instance.

C++ was not that hard to learn, although some stuff came a bit too early in the process to completely make sense at the time. Python is really smooth, which is good, but somehow surprising. It is not a bad idea to start with this one (except for the numerous references that many authors make to C, C++ or Pascal).

Not sure why people would start learning a language if not to use it. Although having at least some ideas about how source code looks like might arguably be a good thing for any computer user, and books might help getting a grasp on what's going on.

andyprough
Offline
Joined: 02/12/2015

>"Not sure why people would start learning a language if not to use it."

Clearly you haven't heard of whitespace - the programming language that only recognizes the space key, the tab key, and linefeeds. Some people spend good chunks of their lives learning a new programming language just to troll others.

Or intercal, which requires your program to use the word "please" exactly 4 times. Three or fewer times is rejected as "insufficiently polite", and 5+ times is rejected as "overly polite".

Cow only allows you to write variations of the word "moo" to write your program. Doesn't that sound fun?

Here's 'Hello World' - who wouldn't want to program in this language?:
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOoMOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo MooOOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo

[Note - I ripped off all this fine material from the geeksforgeeks website. Read about more fun programming languages here: https://www.geeksforgeeks.org/5-most-difficult-programming-languages-of-the-world/]

lanun
Offline
Joined: 04/01/2021

I'm getting new ideas about new rules to submit to the Troll Lounge Language Usage Subcommittee.

andyprough
Offline
Joined: 02/12/2015

This one is my favorite from about line 26: "MooOOO"

You can tell that's some kind of a special function. It probably compiles into a sequence of bytecodes which manipulate stack variables, mallocs megabytes of data on the heap, invokes the garbage collector, and swaps hundreds of thousands of values in and out of registers on the CPU all corresponding to doing the exponentiation of an arbitrary size integer inside a CowObject struct.

lanun
Offline
Joined: 04/01/2021

There is only one CowObject, and MooOOO is her epithet.

NB: I have submitted my new proposal to the TLLUS, suggesting to make the use of Malbolge compulsory at all times. I have received insider information that using cow had preemptively been banned for fear of steak overflow.

I'm mildly disappointed, I thought we might have been able to transform this place into a Hell of MoOs. Malebolge is supposed to be the eighth circle of Hell, though, so we still have a chance.

andyprough
Offline
Joined: 02/12/2015

Some bright Dev needs to combine Cow and Malbolge to create the 8th circle of MooOOO Hell.

Obligatory 'Cows With Guns' reference: https://tube.cadence.moe/watch?v=FQMbXvn2RNI

lanun
Offline
Joined: 04/01/2021

> combine Cow and Malbolge

LaMalaCow?

andyprough
Offline
Joined: 02/12/2015

Moobolge

Legimet
Offline
Joined: 12/10/2013

Python does not have do while loops.

lanun
Offline
Joined: 04/01/2021

Thanks, I now see that the author of that tutorial misused what is in fact a diagram for a "do while" loop.

What it was supposed to illustrate is a "for" loop with a "continue" statement in it. The looping condition comes first, then the continue condition is examined, then either the conditional code is executed or the looping condition is examined again. So that diagram totally misses the point.

It is indeed an accurate description of the "do...while" loop, though, which in Python would probably be a while loop with nested if/break/continue statements.

EDIT: I just noticed that the original pic is called "cpp_continue_statement". I should be more careful when choosing my tutorials.