Basic zen

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

I just want to leave a little margin: you're all right. But, often, no one notices this. But since a one-line post is too small, you have to expand it a bit.

Each time a new language appears (or rather, it becomes popular), the holivar immediately begins “how everyone is obliged to turn their gyrus correctly” and “why change something if the old is completely enough.” But is it possible to describe the essence that distinguishes languages, is distinguished 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 arrogant to say that this is “42”, yet my experience is Q-basic, S-basic, C # (sniffed), PHP, SQL - in chronological order, so I’m judging with my the belfry.

If you can describe it better, I will be glad to read it.

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

And, in general, an ordinary holivar is conceived precisely because the solution is generally adequate, but the solution zen does not match the one that suits the author of the negative comment.

So, before I say "what the hell", I first ask myself: "why so?" And sometimes - I can’t say anything bad, because if the means of a language or a specific program suggest 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 comply with the same style can and should appear in it. An example is the HTML version, which from a simple markup language has changed (evolved / degraded) into an interesting mixture of CSS and internal elements with different content. In general, I’m personally rooting instead



write



since except for the case of auto-replacements in the IDE, it does not give anything decisively, and the Zen of the original HTML, in my personal understanding, breaks.

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

But, I repeat, there is no judge from me, this is more of an observation. And, most likely, at least in some ways 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 much. Well, so ...

In many books on programming, it was written: "when numbering lines, indicate numbers in increments of not 1, but 10, so 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 10000, while you can also cram a 0-line, i.e. 10001 items. That is: the restriction is set manually.

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

What does it give? In general, nothing but the attitude: everything stands strictly in its place. If you need to change the operation of the program, you can replace (a la include) some 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 certain firm place in reality, determined not even by functionality, but directly by meaning.

This feeling of control over the program is not in the sense of understanding the work, but in the sense of neurosurgery, when each neuron of the program is under full control.

Returning to the recommendation, write line numbers “after 10”.

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

So let's take a random line number:

  • "4208", i.e. 4-2-0-8, i.e. Chapter 4, part 2, 0-block (yeah, description), line 8 (sequential, most likely - description of the 2nd block, or even bug tracking).
  • "3586", i.e. 3-5-8-6, i.e. Chapter 3, 5th part, 8-block, 6th line (sequential, most likely - instrumentation, the comment lies in the line “xxxx”, ie “3580”).
  • "2145", i.e. 2-1-4-5, i.e. 2 chapter, 1 part, 4 block, 5 line (IF block is possible! Comment in line “xxx0”, ie “2140”.)

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

But here is one small problem.

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

And yes - this slows down the execution of the program at least for the operation of addressing to the array. But you have to pay for something, and control always generates bureaucracy.

Crossing a hedgehog with a snake


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

First off, I love arrays. I like to know where what value may be. And taking into account the hoster's floating glitches and lack of access to the battle server - this is the only (as I understand it) way to distribute program elements for the sake of testability, to ensure the convenience of unlocking (debug), although sacrificing memory to a large extent.

Secondly, the simplest way was found to make the code convenient for navigation: braces with a comment in the “zero” line. Curling up, they create a structure that is pleasing to the eye, a composition that has long been familiar to me, where the first line is a comment on the block, and then the instructions. By pressing alt + 0, the code turns into an almost wiki page where, having scrolled to the desired comment, you can read the desired piece of code.

I repeat: this slows down the execution of the program. But you have to pay for something, 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 it’s right, I’m just saying that it works. And, IMHO, people underestimated the possibilities that true BASIC gave them, and yielding to the corrupting influence of more primitive languages, they 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.

Also popular now: