Programming *
The art of creating computer programs
Tips and tricks from my Telegram-channel @pythonetc, December 2019
It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
← Previous publications.
Different
asyncio
tasks obviously have different stacks. You can view at all of them at any moment using asyncio.all_tasks()
to get all currently running tasks and task.get_stack()
to get a stack for each task.Tips and tricks from my Telegram-channel @pythonetc, November 2019
Tips and tricks from my Telegram-channel @pythonetc, November 2019
It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
← Previous publications.
PATH
is an environment variable that stores paths where executables are looked for. When you ask your shell to run ls
, the shell looks for the ls
executable file across all paths that are presented in PATH.Tips and tricks from my Telegram-channel @pythonetc, October 2019
It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
← Previous publications
If you want to iterate over several iterables at once, you can use the
zip
function (it has nothing to do with ZIP file format):MacOS 10.15 no longer supports 32-bit apps. What can you do?
On October 7, 2019, Apple released a new version of its Mac operating system, macOS Catalina. Version 10.15 contains many changes and improvements. One of the significant is the complete phasing out of 32-bit applications. As a developer of such macOS apps, what can you do? That's right, port the app to the 64-bit platform. Will the application work properly from the first attempt? Perhaps, it's possible. Depends on the complexity and amount of the code. But most likely, developers will face a lot of non-obvious errors, which can previously detected using PVS-Studio.
Handling Objections: Static Analysis Will Take up Part of Working Time
Tips and tricks from my Telegram-channel @pythonetc, August 2019
It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
← Previous publications
If an instance of a class doesn’t have an attribute with the given name, it tries to access the class attribute with the same name.
>>> class A:
... x = 2
...
>>> A.x
2
>>> A().x
2
Tips and tricks from my Telegram-channel @pythonetc, May 2019
It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
← Previous publications
Exceptional situations: part 1 of 4
Introduction
It’s time to talk about exceptions or, rather, exceptional situations. Before we start, let’s look at the definition. What is an exceptional situation?
This is a situation that makes the execution of current or subsequent code incorrect. I mean different from how it was designed or intended. Such a situation compromises the integrity of an application or its part, e.g. an object. It brings the application into an extraordinary or exceptional state.
But why do we need to define this terminology? Because it will keep us in some boundaries. If we don’t follow the terminology, we can get too far from a designed concept which may result in many ambiguous situations. Let’s see some practical examples:
struct Number
{
public static Number Parse(string source)
{
// ...
if(!parsed)
{
throw new ParsingException();
}
// ...
}
public static bool TryParse(string source, out Number result)
{
// ..
return parsed;
}
}
This example seems a little strange, and it is for a reason. I made this code slightly artificial to show the importance of problems appearing in it. First, let’s look at the Parse
method. Why should it throw an exception?
In-App Updates Flexible Flow: Speed Up the App Update Process on Android
With a variety of new tools and features announced at Android Dev Summit, special attention should be given to the In-App Updates (IAUs) API allowing developers to increase the speed of delivering features, bug-fixes and performance improvements to active users. Since this feature was finally released after Google I/O 2019, in this article I’ll deep dive on IAUs API, describe in details recommended user flows and provide with some code samples. Moreover, I'll share some experience of IAUs integration in the Pandao app, a marketplace platform for Chinese goods.
Following in the Footsteps of Calculators: SpeedCrunch
Here we are, continuing to explore the code of calculators! Today we are going to take a look at the project called SpeedCrunch, the second most popular free calculator.
Introduction
SpeedCrunch is a high-precision scientific calculator featuring a fast, keyboard-driven user interface. It is free and open-source software, licensed under the GPL and running on Windows, Linux, and macOS.
The source code is available on BitBucket. I was somewhat disappointed by the build documentation, which could be more detailed. It says that you need «Qt 5.2 or later» to build the project, but it actually required a few specific packages, which wasn't easy to figure out from the CMake log. By the way, it is considered a good practice nowadays to include a Dockerfile into the project to make it easier for the user to set up the development environment.
.NET Reference Types vs Value Types. Part 1
First, let’s talk about Reference Types and Value Types. I think people don’t really understand the differences and benefits of both. They usually say reference types store content on the heap and value types store content on the stack, which is wrong.
Let’s discuss the real differences:
- A value type: its value is an entire structure. The value of a reference type is a reference to an object. – A structure in memory: value types contain only the data you indicated. Reference types also contain two system fields. The first one stores 'SyncBlockIndex', the second one stores the information about a type, including the information about a Virtual Methods Table (VMT).
- Reference types can have methods that are overridden when inherited. Value types cannot be inherited.
- You should allocate space on the heap for an instance of a reference type. A value type can be allocated on the stack, or it becomes the part of a reference type. This sufficiently increases the performance of some algorithms.
However, there are common features:
- Both subclasses can inherit the object type and become its representatives.
Let’s look closer at each feature.
This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.
Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
My Pascal compiler and Polish contemporary art
Origins
Several years ago I wrote a Pascal compiler. The motivation was simple: as a teenager, I had learnt from my first programming textbooks that a compiler is a very sophisticated thing. This claim eventually became a challenge and required to be tested by experience.
ha.art.pl
First, a simplistic PL/0 compiler came into being, and later an almost fully-functional Pascal compiler for MS-DOS has grown from it. My source of inspiration was the Compiler Construction book by Niklaus Wirth, the inventor of the Pascal language. I don't care if Wirth's views are now considered obsolete and have no direct connections to the IT mainstream, or if the compiler design fashion has changed. It is enough to know that his techniques are still simple, elegant, and — last but not least — bring much fun, since it is more appealing to parse a program source with a handwritten recursive descent parser and generate the machine code, rather than to call yaccs, bisons and all their descendants.
My compiler's fate was not so trivial. It has lived two lives: the first one in my own hands, and the second in the hands of computer antiquarians from Poland.
Generic Methods in Rust: How Exonum Shifted from Iron to Actix-web
Tips and tricks from my Telegram-channel @pythonetc, January 2019
It is new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
Previous publications:
Xcode 10.2, macOS Mojave 10.14.4, iOS 12.1 and other betas
New betas are here and these are some of the most important things that I have learned about them.
Swift 5 for Xcode 10.2 beta
Swift
Firstly, the latest Xcode beta is bundled with the following Swift version:
Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)
Target: x86_64-apple-darwin18.2.0
ABI version: 0.6
Let’s start with the most exciting news:
Swift apps no longer include dynamically linked libraries for the Swift standard library and Swift SDK overlays in build variants for devices running iOS 12.2, watchOS 5.2, and tvOS 12.2. As a result, Swift apps can be smaller when deployed for testing using TestFlight, or when thinning an app archive for local development distribution.Application Binary Interface stability is coming! And this is excellent news. I think this is the one of the most significant issues at the moment with Swift. Not because of side-effects but because of Swift’s failure to deliver on previous promises. Anyway, I even know people who rewrite their Apple Watch extensions to Objective C to reduce the size of binary (something like 15MB vs ~1MB in Objective C). If you want to know more about the state of ABI, follow the links: Swift — ABI Dashboard and Swift ABI Stability Manifesto.
Translating Dust templates to JSX
Hello Habr! I'm Miloš from Badoo, and this is my first Habr post, originally published in our tech blog. Hope you like it, and please share and comment if you have any questions
So… React, amirite???
It appeared in the middle of the decade (plagued by the endless JavaScript framework wars), embraced the DOM, shocked everyone by mixing HTML with JavaScript and transformed the web development landscape beyond recognition.
All those accomplishments, without even being a framework.
Love it or hate it, React does one job really well, and that is HTML templating. Together with a great community and a healthy ecosystem, it’s not hard to see why it became one of the most popular and influential JavaScript libraries, if not the most popular one of all.
Tips and tricks from my Telegram-channel @pythonetc, December 2018
It is new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.
Authors' contribution
alizar 4349.2olegchir 3450.6ru_vds 3193.2haqreu 2916.0tangro 2672.2nmivan 2585.0MaxRokatansky 2412.8kesn 2353.0DmitrySpb79 2296.0grigoryvp 2212.2