📜 ⬆️ ⬇️

Basic Zen

As far as I can tell, according to statistics, many people write their first article on the principle “I know how to live correctly”, and those who are more experienced - from the point of view “wow, look what I’ve dug here.” In general - I will try not to spoil the statistics much.

I just want to leave a little tick in the margins: you are all right. But, often, no one notices. But since the post in one line is too small, you will have to expand it a bit.

Every time a new language appears (or rather, it becomes popular), a holivar immediately begins, “as everyone is obliged to turn his convolutions correctly” and “why change something, if the old one is completely enough”. But is it possible to describe the essence that distinguishes languages, distinguishes somewhat more than just the words “architecture”, “paradigm”, “command set”? The name of this entity is “Zen.”

Zen is reached at the moment when language becomes part of consciousness, when thought can flow in the same way as the logic of language. However, it would be presumptuous to say that this is “42”, after all, my experience is Q-basic, S-basic, C # (smelled), PHP, SQL — in chronological order, so I’m judging with my own bell tower.
')
If you can describe better - I will be glad to read.

SQL is a straight-line system. A minimum of cycles, a direct expression of thought, a rake right under the rug.
C # - interaction with the system, which seemed to me like the sea, from which whales jump, where the sea is the environment, and emerging whales are the resources used.
PHP - sandbox filled with iron constructor, with a socket.
Basic (true) - “everything is an array, and what is not an array is addressing in (array) memory”.
Basic (all that do not require to write the line number) is the same as PCP.

And, in general, the usual holivar is conceived precisely because the decision as a whole is adequate, but the Zen of the decision does not correspond to the one that suits the author of the negative comment.

So, before saying “what the fuck”, I first ask myself: “why is that?”. And sometimes - I can’t say anything bad, because if the means of a language or a specific program imply a different Zen, then my perception is no longer correct.

Mutually exclusive paragraphs


However, since different people work on the project, elements that do not follow the same style can and should appear in it. An example is the HTML version, which has changed from a simple markup language (evolved / degraded) into an interesting mix of CSS and internal elements with different content. In general, I personally korezhit instead

<br> 

write

 <br /> 

since, apart from the case of autocorrect in the IDE, this does not give absolutely nothing, and the Zen of the original HTML in my personal understanding breaks.

As I can tell, it is usually this moment that is the trigger for any holivar: the difference in the minor part, but which changes the perception of the element. And as soon as someone makes a judgment that does not fall under the mask of the appraiser Zen, the minus immediately flies into karma. Or plus, if you managed to dilute the flame correctly.

But, I repeat, the judge is none of me, this is more an observation. And, most likely, at least in something I am mistaken.

Basic Zen


And, as I said above, according to statistics, most novice authors write in the spirit of “I know better” and promised not to spoil the statistics too much. So…

In many books on programming it was written: “when numbering lines, specify numbers in increments not in 1, but in 10 - it will be easier to edit the listing”.

But why exactly?

Riddle: “What is the size of the map in the first Sim City and Civilization and the limitation of the VB script in modern Excel?”

Answer:
100x100, 50x200, 10000.

What's the point:
The maximum line number in the ZX-Spectrum is also 10,000, and you can also push a 0-line, i.e. 10001 items. That is: the limit is set manually.

That is: the line numbers in true BASIC are the positions of the elements of the array. Like the map in Civilization.

What does this give? In general, nothing but the attitude of the world: everything is strictly in its place. If you need to change the work of the program - you can replace (a la include) any element of the array and not restart the entire program. On the other hand, it teaches us to perceive the program as a single structure, each of the modules of which has a definite firm place in reality, which is determined not even by functionality, but directly by meaning.

This sense of control over the program is not in the sense of understanding work, but in the sense of neurosurgery, when every neuron of the program is under complete control.

Returning to the recommendation to write line numbers "after 10".

With experience, I liked a slightly different numbering: x000 is the program chapter, x00 is part, x0 is a block of instructions, x is an element. In this case: 0 - REM (block description); 1, 5 or 1,3,5,7,9 - IF; 1, 2, 4..8 - linear elements.

Thus, we take a random row number:


The architecture of my code in such conditions was as follows: initialization block -> main loop -> selection of the necessary block -> request of the necessary actions -> return of the pointer to the loop. Thus, the “20xx” part was often a “subcycle”, which redirected a pointer to “2x00” or “2xx0”, depending on the detail. Line 2x9 - RETURN.

But there is one small problem.

This system (on the ZX-Spectrum 48k) did not perceive a line feed and it was impossible to write a code block inside the line. Which put an end to a similar hybrid scheme of the programming environment, when the database is built into the program's engine, and the program itself initially represents such a small OS, where the code blocks are applications. That to me, as the last of the Mohicans, is somewhat sad and insulting.

And yes - it slows down the program at least for the addressing operation into an array. But you have to pay for everything, and control always generates bureaucracy.

Crossing a hedgehog with a snake


How can this be used now, on the same PHP?

First, I adore arrays. I like to know where what value can be. And taking into account the floating glitches of the host and the lack of access to the combat server, this is the only (as I understand it) way to break down the program elements for the sake of testability, to provide ease of debugging, although sacrificing memory to a great extent.

Secondly, the simplest way was found to make the code easy to navigate: braces with a comment in the “zero” line. Folding, they create a pleasant-looking structure, a long-known and familiar composition for me, where the first line is a comment to the block, and then instructions. By pressing the alt + 0 code turns into almost a wiki page, where you can read the desired piece of code to the desired comment.

I repeat: it slows down the execution of the program. But you have to pay for everything, and control always generates bureaucracy.

Yes, I am a retrograde and I am not going to give up habits as long as they help me. And I'm not saying that this is right, I'm just saying that it works. And, IMHO, people underestimated the possibilities that the true BASIC gave them, and succumbing to the pernicious influence of more primitive languages ​​left the most painful minus (array size), removing the main feature (“everything is an array!”).

A language without its own zen is like Chinese balloons.

Source: https://habr.com/ru/post/273961/


All Articles