Notes

My notes about life, work and other fascinating things around me.

Shown: 0 · Page

An Unexpected Drummer
9 February 2019 ·

I’ve been writing for the 1C platform for quite a while and have seen some shit, but honestly, this is a first.

Well, would you look at that!

At first, I didn’t even know where to begin. I looked up a translation of the character: Wikipedia just told me it was a type of cup, while Google Translate gave up entirely.

A colleague said it looked a bit like a warehouse worker moving stuff between boxes. I’m not so sure. To me, it looks more like a drummer at work. But what the hell does it mean? Is 1C trying to tell me something? Something about music?

Maybe I should have become a bass player instead of doing all this.

Deleting Temporary Tables
7 February 2019 ·

A curious detail: closing a temporary tables manager doesn’t remove its tables from tempdb. It doesn’t matter whether you call Close() yourself or let the manager object disappear when the method that created it finishes. In both cases, only TRUNCATE runs, deleting the table’s data. The table sticks around in case the user runs another query with the same fields. That’s cheaper than making it all over again.

The same thing, deleting data rather than the table itself, happens when you explicitly use DESTROY in query text. That command doesn’t come in handy very often anyway. Maybe if the manager hangs around for a while and you’ve got a huge temporary table you’d like to empty sooner rather than later.

The table is only deleted when the connection to the application server closes.

String Concatenation
27 January 2019 ·

Like many companies, we give applicants a test assignment. It’s intentionally straightforward, mainly to see how well the candidate understands the platform and how carefully they work with configuration objects and code.

One little thing we look at is how they put together a long message with lots of parameters in it. A developer can use StrTemplate() or StrConcat(), or simply concatenate strings. We mark that last option down a little: the user sees the same result, but the code makes it much harder to picture roughly what the message will look like.

But there’s something else to it. In the first half of last year, Rarus published a report about its work for Beeline. There’s lots of interesting stuff in there, but one bit floored me: dropping string concatenation cut CPU load by 40%! They didn’t even need those two extra servers anymore.

The problem was that worker processes spent too much time allocating memory to concatenate strings. Joining two strings once isn’t going to hurt, but building a large query in a loop and doing it repeatedly can make the load snowball. Don’t use concatenation in those cases. The right tools are the same StrTemplate() or StrConcat(). On older platform versions without those methods, you can use a text document object: add lines to it, then retrieve the text.

Uncompiled Code
27 January 2019 ·

Here’s something you might not expect: an external data processor runs noticeably slower than the exact same processor built into a configuration or extension. Its code has to be compiled again for every user, every time they run it. Built-in processors get compiled once for everyone. According to an article in 1C’s knowledge base, this was outright catastrophic in platform 8.3.10. But a fifty-percent increase in CPU load in 8.3.13 isn’t exactly good news either.

Storing code inside the infobase does the same thing, for example if you keep it in utility catalog attributes. Every time you run it, the platform fetches it from the database and compiles it. In our configuration, for example, scheduled jobs can be created without changing metadata: add an item to a special catalog, load the code into it, and set its schedule.

That’s more or less fine: scheduled jobs don’t usually run all that often, so compiling them probably won’t make a noticeable dent in the CPU. But the same catalog can also be used to run code automatically after pretty much any event, say saving a certain kind of document. If lots of users will be running that code all the time, move the logic into a common module method in an extension and leave only a call to that logic in the stored code.

Or you could ditch stored code altogether and put the whole thing in an extension. It might be less flexible, but that’s still better than staring at a low APDEX later.

A Trip to Kok-Kol
6 January 2019 ·

This summer, my friends and I traveled to the Mongolian border: by car to Tashanta, then by bicycle to Kok-Kol. We were absolutely knackered, but it was worth it: the mountain views were incredible! Shame we didn’t see more wildlife. We didn’t even run into the plague-carrying ground squirrels everyone, including the border guards, kept promising us :-)

The Ampersand in 1C
27 December 2018 ·

For ampersands in labels, the platform does the usual Windows thing: the ampersand itself disappears, and the following character becomes a keyboard shortcut for the action associated with the label, such as a command handler or a control event.

The example below shows up as “Project Costing.” The “P” is underlined and becomes the shortcut key; if this is a command title, for example, you can run it with Alt + P.

ТекстНадписи = "&Project Costing";

The only catch is when you want an actual ampersand in the label. Then you need to double it: the example below will appear as “Project P&L.” No shortcut keys will be created.

ТекстНадписи = "Project P&&L";
Like Valve in a China Shop
10 December 2018 ·

The folks at Valve keep teasing fans of their games, whether out of habit or because someone there really thinks it’s a great way to stay in people’s minds.

Sure, we all know where things stand with Valve making games. Few people seriously expect Half-Life 3 or, say, a Portal sequel. Still, I can’t help smiling at the effortless grace of Valve dealing with its fans. Like a bull in a china shop.

Tweet

Snowboard Effect
1 December 2018 ·

Standing! Sitting!

You're sliding down the side of a mountain and trying to feel an equilibrium point, for the hundredth time. However, your nagging back is the only thing you're able to feel, and the Vaas speech from Far Cry 3 isn't going out of your mind.

Did I ever tell you what the definition of insanity is? Insanity is doing the exact… Same fucking thing… Over and over again expecting… Shit to change… That. Is. Crazy.

― Vaas Montenegro, Far Cry 3

Surprisingly, you're certainly satisfied with the trip when it's done.

There's some kind of magic in it.

A New Object’s Reference
29 November 2018 ·

A unique identifier is a convenient way to match objects across configurations, for example when transferring invoices from one infobase to another. How can the receiving infobase tell whether an invoice has already been loaded? The first idea is simply to find the object by UUID:

ИнвойсЗагружен = Документы.Инвойс.ПолучитьСсылку(UUID).Пустая();

Sometimes, though, unique identifiers are used to link objects within the same configuration. Maybe the task won’t let us add a regular reference attribute, so document A can’t point straight to document B. Or perhaps we create a catalog item based on a document and want a direct link between them, assigning the item a reference obtained from the document’s unique identifier. The platform guarantees identifier uniqueness within a table, so such tricks are perfectly safe.

My point is: use SetNewObjectRef() carefully! Check whether a reference has already been assigned before your code runs:

СсылкаЗадана = ПолучитьСсылкуНового().Пустая();

If there’s already a reference, deal with it: leave it alone if that works for your task, or throw an exception. Otherwise, you can break the links between your data, and good luck tracking that down. Or even noticing it.

This works both ways, of course: some other code, such as an object event handler or subscription, might overwrite the reference you assigned. Testing is the only reliable way to catch that.

Distributed Design
20 October 2018 ·

A designer at Stack Overflow wrote about how they organize remote work. I liked the structure: it doesn’t just say “here’s how we do it,” but pairs each problem with a solution.

Almost all development at our company is remote, and I work remotely too. I really like working this way; the main thing is remembering how easy it is to pick up unexpected problems when your workplace and your home are the same place. Take the advice to drink water and get some sun: during a crunch, those things really are easy to forget.

Perfect Pronunciation
15 October 2018 ·

Tweet

A Bloomberg engineer told me much the same thing several years ago. We were writing an application for a client to track share prices automatically and had run into a pile of problems: Bloomberg provides a powerful but rather complicated API for working with financial instruments.

Eventually, we contacted technical support, and after a few messages, the engineer suggested a voice call. I was quite embarrassed and said that, well, we could, but “my English isn’t fluent enough.” He just shrugged: they were used to it. Everyone uses English, and everyone puts their own spin on it. Where I put the stress in a word was the last thing on his mind, as long as he could follow what I was saying.

A Principle of Non-Judgemental Attitude
2 September 2018 ·

There is a good note from Maxim Ilyahov about a way of analyzing something which doesn't concern you but annoys you anyway. It's reminded me of an American principle of non-judgemental attitude which I read about a couple of years ago. As for me, it uses different words to make the same point.

By the way, this principle presents in Russia too — there is even a famous adage “don't be judgemental so you won't be judged”. What a pity for us that it isn't so widespread yet.

DCS and View Rights
28 August 2018 ·

The Data Composition System goes by the rule “if the user can’t view it, it might as well not exist.” Sometimes that leads to some pretty weird behavior. For a nice simple textbook report, it works fine: if the user lacks view rights for a catalog, for example, that catalog won’t appear in the report. Real examples can be more complicated, though.

A couple of weeks ago, I was debugging a report that produced a seemingly clear error when generated:

Your settings are wrong, comrade!

The report is enormous: a query of a good thousand lines, complex settings, a huge template, and tangled composition code. We first suspected a settings error, but the investigation quickly led from a currency reference in the dataset to a constant holding that currency at the report’s lowest level. The user had no view rights for that constant.

I couldn’t tell you exactly what threw the platform off and made the error so unhelpful. Maybe it was what we did with the temporary table holding the constant. Maybe it was reading it inside a CASE expression. Or maybe it was that we had all the rights we needed for the currency catalog itself. I didn’t dig around to find the exact trigger. I think it’s simply an implementation detail of the DCS engine that may change between versions. Just keep view rights in mind, and you can avoid the problem.

If you encounter the error, try generating the problematic report with full rights. If that works, list the tables from which it reads data and check that both read and view rights are granted for all of them.

Tedious, but it can save a lot of time.

Beware the Daughter of the Sea
29 Jule 2018 ·

Natalia O'Shea has sung a Jaina's song in a Russian version of a trailer for a future update of World of Warcraft. As for me, she's extraordinary good in it — I mean, she knows how to make a proper mood and season a speech with steel.

By the way, speaking about her and “Melnitsa” as a whole thing — all of their most powerful songs are about something particular. We were at a concert dedicated to the “Luciferase” release and it's hard to compare, seriously. Perhaps, I didn't know something essential to understanding a context, but sometimes it was even barely possible to figure out a story which I was hearing.

Just watch a video I posted under. You don't need to know something special about the World of Warcraft universe, do you? For example, I haven't played WoW and not planning to do it, but the end of the song literally creeps me out :-)

HPMoR Printing
22 Jule 2018 ·

Perhaps you already know that Eliezer Yudkowsky's “Methods of Rationality” in Russian is going to be published as a standard book (thanks to “Evolution” and other information partners), but I still want to remind again.

The book is really good, I had written about it a couple of years ago. It teaches useful things in such an attractive way that it's really hard to stop reading. The whole text is in public access, but if you want a hard copy — you can make a request now.

FCE Results
15 Jule 2018 ·

Cambridge just sent me results of my FCE exam in June and — dramatic drum roll — I passed it! According to the statement of results, I made a bunch of mistakes in writing tasks but particularly took it out during a Speaking test. It's a pity that examiners don't give comments and reasons so it's hard to estimate the results properly; however, it's quite clear what to do next :) My English teacher said that Cambridge used to provide an overall score only earlier and it sounded like “take it any way you want, dear pretenders”.

Well, I guess I should begin my preparation for CAE in the next year.

Speaking about languages, I remembered Feynman with his famous “Surely You're Joking”. Among many things, he told that he learned to play on a frigideira when he lived in Brazil and had reached so high level of skill that he served as a model for local musicians.

My theory is that it's like a person who speaks French who comes to America. At first they're making all kinds of mistakes, and you can hardly understand them. Then they keep on practicing until they speak rather well, and you find there's a delightful twist to their way of speaking their accent is rather nice, and you love to listen to it.

― Richard Feynman, ”Surely You're Joking, Mr. Feynman!”

As for me, there is a lot of efforts between “all kinds of mistakes” and “love to listen”, but it is such a good synopsis. Working on it!

Kona
29 May 2018 ·

There’s plenty here that did its best to keep me interested: there are places to explore, things to read, things to think about, and sights to see. If you value that in games, you might like it. Almost nothing interrupts the walking and thinking: it’s pretty hard to get yourself killed. So is getting lost: the protagonist has a map and a car, and later you can get a snowmobile too.

But the story really disappointed me. It starts with an intriguing mystery, but before that can go anywhere, it all dissolves into supernatural stuff. Fine, except the mystery goes out the window with it. Why look for clues, form theories, or worry about anything? Unexplained visions from nowhere will tell and show you everything that happened. Before long, you catch yourself sharing the hero’s weary shrug at all the weirdness around him.

Meanwhile, the mystical side of the plot has gaping holes of its own. The tragedy becomes more or less clear toward the end, yes, but even the final, most complete vision raises a whole host of questions that nobody bothers to answer. The plot is a lot like the game’s map: it looks complete, but in practice you can access at most half of it, with the rest brushed aside under a plainly visible “well, because magic, that’s how magic works, you see?”

No, damn it, I don’t.

Message to User
30 April 2018 ·

1C:Enterprise has a convenient and accustomed method of showing information for a user — it's a UserMessage object. It outputs messages at the bottom of a form and suddenly it's a potential problem. The thing is, most users don't look at it. It's like: well, I see no critical errors for now so there is nothing to worry about.

Therefore, in case an error happens or you just have an essential message, you should show it through a dialogue window — by the ShowQueryBox() method or a ShowMessageBox() method, for example. Otherwise, a user may not notice a problem and continue to work in spite of some action might not be executed or might be executed in a wrong way. The issue will come out later and you will be rightfully blamed for it.

In addition, using of a UserMessage object should be prohibited in case of small service forms. Yes, in fact, it's hard to overlook a text if a window is small, but that's a different matter: the messages below literally devour form's workspace and it becomes hard to work with.

These Nasty Smartphones
31 Marth 2018 ·

Society

The artist is Adam Ellis.

As for me, it's a great illustration for an everlasting moan “why do you always stare at your smartphone blah blah blah”. A reason is quite simple: people have their friends, books, podcasts, games, and YouTube in their smartphones. It's much more fun than a frowning man or a grim women with guru syndrome next to them, for example.

The same is true of children. Social networks are full of arguments about it, but a reason is still the same: if a teenager flips through pictures in his phone in front of you, you bore him and a problem obviously is you.

Double “i”
9 Marth 2018 ·

I was trying to understand how to transliterate my surname properly yesterday. Ministry of Foreign Affairs says it should be written as “Kostianetskii” in English — with double “i” at the end. It's the quite rare combination: “skiing” is the only frequency word that I'm able to remember.

It caused my curiosity and I googled it. The possible reason I came across is funny: cursive writing! Double “i” looks well only on a computer screen but it suddenly turns into “u” when you try to write it on paper.

More details are here.