Pull to refresh
697.84

Programming *

The art of creating computer programs

Show first
Rating limit
Level of difficulty

Tips and tricks from my Telegram-channel @pythonetc, July 2019

Reading time 4 min
Views 1.3K

It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications


You can’t mutate closure variables by simply assigning them. Python treats assignment as a definition inside a function body and doesn’t make closure at all.
Read more →
Total votes 22: ↑21 and ↓1 +20
Comments 0

On the way to durable applications with PSKOV static site generator as an example

Reading time 4 min
Views 1.3K

Pskov's veche


Hi, my name is Michael Kapelko. I have been developing software professionally for more than 10 years. I develop games and game development tools in my spare time.


This article describes my first durable application for desktop PCs: PSKOV static site generator.


Durability


A durable application is an application that functions without a single change on operating systems released in years 2010-2030. In other words, a durable application has backward compatibility of 10 years and has the stability to run for 10 years. Actually, PSKOV runs even under Windows 2000, so PSKOV has backward compatibility of 19 years.

Read more →
Total votes 11: ↑9 and ↓2 +7
Comments 0

Saving Routing State to the Disk in a Cross-Platform .NET Core GUI App with ReactiveUI and Avalonia

Reading time 17 min
Views 6.9K

image


User interfaces of modern enterprise applications are quite complex. You, as a developer, often need to implement in-app navigation, validate user input, show or hide screens based on user preferences. For better UX, your app should be capable of saving state to the disk when the app is suspending and of restoring state when the app is resuming.


ReactiveUI provides facilities allowing you to persist application state by serializing the view model tree when the app is shutting down or suspending. Suspension events vary per platform. ReactiveUI uses the Exit event for WPF, ActivityPaused for Xamarin.Android, DidEnterBackground for Xamarin.iOS, OnLaunched for UWP.


In this tutorial we are going to build a sample application which demonstrates the use of the ReactiveUI Suspension feature with Avalonia — a cross-platform .NET Core XAML-based GUI framework. You are expected to be familiar with the MVVM pattern and with reactive extensions before reading this note. Steps described in the tutorial should work if you are using Windows 10 or Ubuntu 18 and have .NET Core SDK installed. Let's get started! Source code of the app described in this tutorial is available on GitHub.

Read more →
Total votes 16: ↑16 and ↓0 +16
Comments 0

Python Vs R — Data Science

Reading time 3 min
Views 3.7K
When mulling over the best programming language to use for data science, Python and R ring a bell (very quickly). While there are a lot of languages like C, C++, Java, Julia, Perl, and Scala, it's protected to state that Python and R are the harbingers in data science.

While a great deal of data researchers will discuss the customary shortcomings like data wrangling in R or data representation in Python, ongoing improvements like Altair for Python or R have adequately reacted to these shortcomings.

So which one would it be a good idea for you to decide for your next data investigation venture?

R has been ruling this space for a long time now. This bodes well as this programming language was explicitly intended for analysts.
Read more →
Total votes 11: ↑11 and ↓0 +11
Comments 0

What's the Use of Dynamic Analysis When You Have Static Analysis?

Reading time 6 min
Views 2.8K
In order to verify the quality of software, you have to use a lot of different tools, including static and dynamic analyzers. In this article, we'll try to figure out why only one type of analysis, whether static or dynamic, may not be enough for comprehensive software analysis and why it's preferable to use both.

Рисунок 1

Read more →
Total votes 21: ↑19 and ↓2 +17
Comments 0

Announcing XAML Hot Reload for Xamarin.Forms

Reading time 4 min
Views 1K
Today at Xamarin Developer Summit, we announced XAML Hot Reload for Xamarin.Forms, which enables you to make changes to your XAML UI and see them reflected live, without requiring another build and deploy.

XAML Hot Reload for Xamarin.Forms speeds up your development and makes it easier to build, experiment, and iterate on your user interface. And this means that you no longer have to rebuild your app each time you tweak your UI – it instantly shows you your changes in your running app!

When your application is compiled using XAML Hot Reload, it works with all libraries and third-party controls. It will be available for iOS and Android in Visual Studio 2019 and Visual Studio 2019 for Mac. This works on all valid deployment targets, including simulators, emulators, and physical devices.

XAML Hot Reload will be available later in 2019, but you can sign up to to participate in the preview phase:

Sign Up for the Preview Now

Read more →
Total votes 4: ↑4 and ↓0 +4
Comments 0

Detecting in C++ whether a type is defined: Predeclaring things you want to probe

Reading time 4 min
Views 2.2K
Last time, we used SFINAE to detect whether a type had a definition, and we used that in combination with if constexpr and generic lambdas so that code could use the type if it is defined, while still being accepted by the compiler (and being discarded) if the type is not defined.

However, our usage had a few issues, some minor annoyance, some more frustrating.

  • You had to say struct all the time.
  • If the type didn’t exist, the act of naming it caused the type to be injected into the current namespace, not the namespace you expected the type to be in.
  • You must use the struct technique with an unqualified name. You can’t use it to probe a type that you didn’t import into the current namespace.

We can fix all three of the problems with a single solution: Predeclare the type in the desired namespace.

Read more →
Total votes 13: ↑12 and ↓1 +11
Comments 0

Configuration file htaccess

Reading time 8 min
Views 11K
Let’s begin from a far distance with the goal that the novices can see how the file described in the article works. To work the website on the Internet, you need not just a PC and access to the network, yet additionally, extraordinary programming introduced on it, which gives access to information utilizing the HTTP and HTTPS conventions. This product is the web server. There are different sorts of web servers, however, the most widely recognized is Apache. It is based on the open-source code, free, is continually being improved and enhanced, compatible with many scripts, and works on almost all platforms, including Windows, Linux, Netware 5.x.
Read more →
Total votes 15: ↑11 and ↓4 +7
Comments 0

Checklist for writing great Visual Studio extensions

Reading time 3 min
Views 1K
Great Visual Studio extensions share a few key features that sets them apart from the rest. They look and feel well crafted, are performant and reliable, do what they advertise to perfection, and blend in naturally among Visual Studio’s own features.

To make it easier to write great extensions, we’ve worked with the extensibility community to come up with a simple checklist to follow. There’s even a GitHub issue template you can use so you remember to go through the checklist.

Read more →
Total votes 10: ↑10 and ↓0 +10
Comments 0

A declarative data-processing pipeline on top of actors? Why not?

Reading time 21 min
Views 2.6K

Some time ago, in a discussion on one of SObjectizer's releases, we were asked: "Is it possible to make a DSL to describe a data-processing pipeline?" In other words, is it possible to write something like that:


A | B | C | D


and get a working pipeline where messages are going from A to B, and then to C, and then to D. With control that B receives exactly that type that A returns. And C receives exactly that type that B returns. And so on.


It was an interesting task with a surprisingly simple solution. For example, that's how the creation of a pipeline can look like:


auto pipeline = make_pipeline(env, stage(A) | stage(B) | stage(C) | stage(D));

Or, in a more complex case (that will be discussed below):


auto pipeline = make_pipeline( sobj.environment(),
        stage(validation) | stage(conversion) | broadcast(
            stage(archiving),
            stage(distribution),
            stage(range_checking) | stage(alarm_detector{}) | broadcast(
                stage(alarm_initiator),
                stage( []( const alarm_detected & v ) {
                        alarm_distribution( cerr, v );
                    } )
                )
            ) );

In this article, we'll speak about the implementation of such pipeline DSL. We'll discuss mostly parts related to stage(), broadcast() and operator|() functions with several examples of usage of C++ templates. So I hope it will be interesting even for readers who don't know about SObjectizer (if you never heard of SObjectizer here is an overview of this tool).

Read more →
Total votes 12: ↑11 and ↓1 +10
Comments 2

Write Better Code Faster with Roslyn Analyzers

Reading time 3 min
Views 4.5K
Roslyn, the .NET compiler platform, helps you catch bugs even before you run your code. One example is Roslyn’s spellcheck analyzer that is built into Visual Studio. Let’s say you are creating a static method and misspelled the word static as statc. You will be able to see this spelling error before you run your code because Roslyn can produce warnings in your code as you type even before you’ve finished the line. In other words, you don’t have to build your code to find out that you made a mistake.



Roslyn analyzers can also surface an automatic code fix through the Visual Studio light bulb icon that allows you to fix your code immediately.

Read more →
Total votes 9: ↑9 and ↓0 +9
Comments 2

Lua in Moscow 2019: Interview with Roberto Ierusalimschy

Reading time 19 min
Views 2.4K


Some time ago, the creator of Lua programming language, Roberto Ierusalimschy, visited our Moscow office. We asked him some questions that we prepared with the participation of Habr.com users also. And finally, we’d like to share full-text version of this interview.
Read more →
Total votes 26: ↑25 and ↓1 +24
Comments 1

Simplify Your Code With Rocket Science: C++20’s Spaceship Operator

Reading time 8 min
Views 2K
C++20 adds a new operator, affectionately dubbed the «spaceship» operator: <=>. There was a post awhile back by our very own Simon Brand detailing some information regarding this new operator along with some conceptual information about what it is and does. The goal of this post is to explore some concrete applications of this strange new operator and its associated counterpart, the operator== (yes it has been changed, for the better!), all while providing some guidelines for its use in everyday code.

Read more →
Total votes 13: ↑11 and ↓2 +9
Comments 0

Tips and tricks from my Telegram-channel @pythonetc, June 2019

Reading time 3 min
Views 2.6K

It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications


The \ symbol in regular string have special meaning. \t is tab character, \r is carriage return and so on.

You can use raw-strings to disable this behaviour. r'\t' is just backslash and t.

You obviously can’t use ' inside r'...'. However, it still can be escaped by \, but \ is preserved in the string:
Read more →
Total votes 24: ↑20 and ↓4 +16
Comments 0

Tutorial: Update interfaces with default interface members in C# 8.0

Reading time 5 min
Views 1.3K

Beginning with C# 8.0 on .NET Core 3.0, you can define an implementation when you declare a member of an interface. The most common scenario is to safely add members to an interface already released and used by innumerable clients.


In this tutorial, you'll learn how to:


  • Extend interfaces safely by adding methods with implementations.
  • Create parameterized implementations to provide greater flexibility.
  • Enable implementers to provide a more specific implementation in the form of an override.

Read more →
Total votes 10: ↑9 and ↓1 +8
Comments 0

Why LLVM may call a never called function?

Reading time 11 min
Views 6.6K
I don’t care what your dragon’s said, it’s a lie. Dragons lie. You don’t know what’s waiting for you on the other side.

Michael Swanwick, The Iron Dragon’s Daughter
This article is based on the post in the Krister Walfridsson’s blog, “Why undefined behavior may call a never called function?”.

The article draws a simple conclusion: undefined behavior in a compiler can do anything, even something absolutely unexpected. In this article, I examine the internal mechanism of this optimization works.
Read more →
Total votes 8: ↑7 and ↓1 +6
Comments 0

Python in Visual Studio Code – June 2019 Release

Reading time 2 min
Views 2.2K
We are pleased to announce that the June 2019 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.

In this release we made improvements that are listed in our changelog, closing a total of 70 issues including a plot viewer with the Python Interactive window, parallel tests with pytest, and indentation of run selection in the terminal.

Read more →
Total votes 9: ↑9 and ↓0 +9
Comments 0

Evolution of every developer's most popular tool (in Visual Studio)

Reading time 2 min
Views 9.1K
Every development environment has a tool called «Output». There is no need to describe what it does, since all developers without exception use it in their work on a daily basis. It is simple and conservative. 

It has remained essentially unchanged for decades, and to this day looks something like this:


Text, text, and more text. Lots of text...

Even in this tiny example the line containing the error is not immediately apparent. Finding it takes time and effort. Simply because one has to read through the text and search for the words «error», «exception» or «warning». The programmer has to search, and the client has to pay for the time spent searching.
Read more →
Total votes 11: ↑9 and ↓2 +7
Comments 2

Just take a look at SObjectizer if you want to use Actors or CSP in your C++ project

Reading time 21 min
Views 3.3K


A few words about SObjectizer and its history


SObjectizer is a rather small C++ framework that simplifies the development of multithreaded applications. SObjectizer allows a developer to use approaches from Actor, Publish-Subscribe and Communicating Sequential Processes (CSP) models. It's an OpenSource project that is distributed under BSD-3-CLAUSE license.


SObjectizer has a long history. SObjectizer itself was born in 2002 as SObjectizer-4 project. But it was based on ideas from previous SCADA Objectizer that was developed between 1995 and 2000. SObjectizer-4 was open-sourced in 2006, but its evolution was stopped soon after that. A new version of SObjectizer with the name SObjectizer-5 was started in 2010 and was open-sourced in 2013. The evolution of SObjectizer-5 is still in progress and SObjectizer-5 has incorporated many new features since 2013.


SObjectizer is more or less known in the Russian segment of the Internet, but almost unknown outside of the exUSSR. It's because the SObjectizer was mainly used for local projects in exUSSR-countries and many articles, presentations, and talks about SObjectizer are in Russian.


A niche for SObjectizer and similar tools


Multithreading is used in Parallel computing as well as in Concurrent computing. But there is a big difference between Parallel and Concurrent computing. And, as a consequence, there are tools targeted Parallel computing, and there are tools for Concurrent computing, and they are different.

Read more →
Total votes 13: ↑11 and ↓2 +9
Comments 1

The big interview with Martin Kleppmann: “Figuring out the future of distributed data systems”

Reading time 25 min
Views 2.7K


Dr. Martin Kleppmann is a researcher in distributed systems at the University of Cambridge, and the author of the highly acclaimed «Designing Data-Intensive Applications» (O'Reilly Media, 2017). 

Kevin Scott, CTO at Microsoft once said: «This book should be required reading for software engineers. Designing Data-Intensive Applications is a rare resource that connects theory and practice to help developers make smart decisions as they design and implement data infrastructure and systems.»

Martin’s main research interests include collaboration software, CRDTs, and formal verification of distributed algorithms. Previously he was a software engineer and an entrepreneur at several Internet companies including LinkedIn and Rapportive, where he worked on large-scale data infrastructure.

Vadim Tsesko (@incubos) is a lead software engineer at Odnoklassniki who works in Core Platform team. Vadim’s scientific and engineering interests include distributed systems, data warehouses and verification of software systems.

Contents:


  • Moving from business to academic research;
  • Discussion of «Designing Data-Intensive Applications»;
  • Common sense against artificial hype and aggressive marketing;
  • Pitfalls of CAP theorem and other industry mistakes;
  • Benefits of decentralization;
  • Blockchains, Dat, IPFS, Filecoin, WebRTC;
  • New CRDTs. Formal verification with Isabelle;
  • Event sourcing. Low level approach. XA transactions; 
  • Apache Kafka, PostgreSQL, Memcached, Redis, Elasticsearch;
  • How to apply all that tools to real life;
  • Expected target audience of Martin’s talks and the Hydra conference.

Read more →
Total votes 13: ↑12 and ↓1 +11
Comments 0

Authors' contribution