Pull to refresh

Development

Show first
Rating limit
Level of difficulty

.NET Reference Types vs Value Types. Part 1

Reading time16 min
Views7K

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.

Read more →
Total votes 33: ↑32 and ↓1+31
Comments1

Introduce Static Analysis in the Process, Don't Just Search for Bugs with It

Reading time15 min
Views5.2K
This article is an authorized translation of the original post. The translation was made with the kind help of the guys from PVS-Studio. Thank you, guys!

What encouraged me to write this article is considerable quantity of materials on static analysis, which recently has been increasingly coming up. Firstly, this is a blog of PVS-Studio, which actively promotes itself on Habr posting reviews of errors, found by their tool in open source projects. PVS-Studio has recently implemented Java support, and, of course, developers from IntelliJ IDEA, whose built-in analyzer is probably the most advanced for Java today, could not stay away.

When reading these reviews, I get a feeling that we are talking about a magic elixir: click the button, and here it is — the list of defects right in front of your eyes. It seems that as analyzers get more advanced, more and more bugs will be found, and products, scanned by these robots, will become better and better without any effort on our part.

Well, but there are no magic elixirs. I would like to talk about what is usually not spoken in posts like «here are things that our robot can find»: what analyzers are not able to do, what's their real part and place in the process of software delivery, and how to implement the analysis properly.


Ratchet (source: Wikipedia).
Read more →
Total votes 32: ↑31 and ↓1+30
Comments0

My Pascal compiler and Polish contemporary art

Reading time5 min
Views7K

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.

image
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.
Total votes 27: ↑26 and ↓1+25
Comments1

Building a Private Currency Service Using Exonum

Reading time9 min
Views1.4K
Zero-knowledge proofs/arguments are an emerging cryptographic technology that promises to bring us closer to the Holy Grail of blockchain: providing data privacy and auditability.

Potential applications for zero-knowledge include, but are not limited to:


Another application for zero-knowledge proofs is helping blockchains scale. ZKPs allow for the “compressing” of computations for blockchain transactions without sacrificing security.

In this article, we describe how zero-knowledge (specifically, Bulletproofs) can be applied to build a privacy-focused service using Bitfury’s Exonum platform.

Read more →
Total votes 28: ↑28 and ↓0+28
Comments1

Making Git for Windows work in ReactOS

Reading time10 min
Views4.7K

Good day to you! image


My name is Stanislav and I like to write code. This is my first english article on Habr which I made due to several reasons:



This article is an english version of my very first article on russian.


Let me introduce the main figures in this story who actually fixed the bug preventing Git from running in ReactOS — the French developer Hermès Bélusca-Maïto (or just Hermes with hbelusca nickname) and of course me (with x86corez nickname).


The story begins with the following messages from the ReactOS Development IRC channel:


Jun 03 18:52:56 <hbelusca> Anybody want to work on some small problem? If so, can someone figure out why this problem https://jira.reactos.org/browse/CORE-12931 happens on ReactOS? :D
Jun 03 18:53:13 <hbelusca> That would help having a good ROS self-hosting system with git support.
Jun 03 18:53:34 <hbelusca> (the git assertion part only).
Read more →
Total votes 44: ↑43 and ↓1+42
Comments1

Server-provided animations in iOS apps

Reading time5 min
Views2.7K


Hi everyone! About six months ago we launched one of Badoo’s most exciting features: Live Streaming. One of its main functionalities is that viewers can send gifts to their favourite streamers to express their appreciation. We wanted to make the gifts as fancy and as engaging as possible, so it was decided to make some of them really lively, and by this I mean animated. And to engage people even more, we, the Badoo team, planned to update those gifts and animations every few weeks.

As an iOS engineer, you might have already guessed the challenge we faced here: the need to add new animations and remove the old ones was going to require a fair amount of work from the client side. We’d need both the Android and the iOS development teams for every release — which, when combined with the amount of time App Store reviews and approval often take, would mean it might be days before each update could go live. But we solved the problem, and I’m going to explain to you how.

Solution overview


By this stage, we already knew how to export Adobe After Effects (AAE) animations into the format readable by our iOS app using the Lottie library. This time though, we went a bit further: we decided to create a kind of animation storage service, available via the internet. In other words, we would store all the actual animations on the server and deliver them to the client apps on demand:
Read more →
Total votes 33: ↑32 and ↓1+31
Comments1

Wanna Play a Detective? Find the Bug in a Function from Midnight Commander

Reading time5 min
Views6.5K

bug

In this article, we invite you to try to find a bug in a very simple function from the GNU Midnight Commander project. Why? For no particular reason. Just for fun. Well, okay, it's a lie. We actually wanted to show you yet another bug that a human reviewer has a hard time finding and the static code analyzer PVS-Studio can catch without effort.
Read more →
Total votes 31: ↑31 and ↓0+31
Comments0

PC Speaker To Eleven

Reading time12 min
Views35K
Known now as a «motherboard speaker», or just «beeper», PC Speaker has been introduced in 1981 along with the first personal IBM computer. Being a successor of the big serious computers for serious business, it has been designed to produce very basic system beeps, so it never really had a chance to shine bright as a music device in numerous entertainment programs of the emerging home market. Overshadowed by much more advanced sound chips of popular home game systems, quickly replaced with powerful sound cards, it mostly served as a fallback option, playing severely downgraded content of better sound hardware.

«System Beeps» is a music album in shape of an MS-DOS program that features original music composed for PC Speaker using the same basic old techniques like ones found in classic PC games. It follows the usual retro computing demoscene formula — take something rusty and obsolete, and push it to eleven — and attempts to reveal the long hidden potential of this humble little sound device. You can hear it in action and form an opinion on how successful this attempt was at Bandcamp, or in the video below. The following article is an in-depth overview of the original PC Speaker capabilities and making of the project, for those who would like to know more.

Total votes 34: ↑32 and ↓2+30
Comments3

Generic Methods in Rust: How Exonum Shifted from Iron to Actix-web

Reading time13 min
Views5.9K
The Rust ecosystem is still growing. As a result, new libraries with improved functionality are frequently released into the developer community, while older libraries become obsolete. When we initially designed Exonum, we used the Iron web-framework. In this article, we describe how we ported the Exonum framework to actix-web using generic programming.

Read more →
Total votes 28: ↑27 and ↓1+26
Comments0

Manifest of Smart Home Developer: 15 principles

Reading time12 min
Views4.1K
Today I’d like to speak about Smart homes and IoT devices. But it is no ordinary article. You won’t find description of hardware, links to manufacturers, batches of code or repositories. Today we’ll discuss something of a higher level — principles that are used to organize “smart” systems.

image



Smart home is a system that can do some everyday routines instead of a person. It leads us to the first and the main principle:
Read more →
Total votes 29: ↑27 and ↓2+25
Comments1

Sixth Chromium Check, Afterword

Reading time6 min
Views2.1K
severe unicorn

At the beginning of 2018 our blog was complemented with a series of articles on the sixth check of the source code of the Chromium project. The series includes 8 articles on errors and recommendations for their prevention. Two articles sparked heated discussion, and l still occasionally get comments by mail about topics covered in them. Perhaps, I should give additional explanations and as they say, set the record straight.
Read more →
Total votes 30: ↑29 and ↓1+28
Comments0

Xcode 10.2, macOS Mojave 10.14.4, iOS 12.1 and other betas

Reading time8 min
Views6.6K


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.
Read more →
Total votes 35: ↑34 and ↓1+33
Comments0

Lua in Moscow 2019 conference

Reading time1 min
Views1.6K


On the first Sunday of March, Mail.ru Group’s Moscow office will be hosting the third international Lua conference, Lua in Moscow 2019. The program features talks by Roberto Ierusalimschy and the leading experts in Lua and LuaJIT from Russia and other countries.

Lua is a unique programming language used not only in computer games, but also as an embedded language in such web-programming products as Redis, nginx, Tarantool, OpenResty. Lua is also used for big data analysis and scientific calculations. You can find Lua in many routers, printers and other devices.

You are welcome to join, even if you haven’t been writing in Lua so far. We bet the conference will give you unexpected insights!
Read more →
Total votes 33: ↑31 and ↓2+29
Comments0

Searching for errors in the Amazon Web Services SDK source code for .NET

Reading time17 min
Views1.5K

Picture 1


Welcome to all fans of trashing someone else's code. :) Today in our laboratory, we have a new material for a research — the source code of the AWS SDK for .NET project. At the time, we wrote an article about checking AWS SDK for C++. Then there was not anything particularly interesting. Let's see what .NET of the AWS SDK version is worth. Once again, it is a great opportunity to demonstrate the abilities of the PVS-Studio analyzer and make the world a bit better.
Read more →
Total votes 34: ↑34 and ↓0+34
Comments0

Translating Dust templates to JSX

Reading time5 min
Views1.8K


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.
Total votes 34: ↑33 and ↓1+32
Comments2

The Fall and Recovery of a Mold

Reading time4 min
Views1.5K
Software component developers tend to be far removed from the end users of the products in which their components are employed. Recently, however, we connected directly with a KOMPAS-3D MCAD user to solve an issue involving mold design. It seems that 3D models were being exported incorrectly to data exchange formats like STP, X_T, and SAT. The cause, unhappily for us, turned out to be in our С3D Modeler geometric modeling kernel. Here is how we solved the problem, quickly.

image
Читать дальше →
Total votes 28: ↑27 and ↓1+26
Comments1

PVS-Studio for Java

Reading time12 min
Views2.5K
PVS-Studio for Java

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've come, and what is in our further plans. Of course, this article will list first analyzer trials on open source projects.
Читать дальше →
Total votes 31: ↑31 and ↓0+31
Comments2

$10 million in investments and Wozniak's praise — creating an educational computer for children

Reading time14 min
Views2K
We interviewed Mark Pavluykovskiy — the creator of the Piper educational computer. We asked him about immigrating from Ukraine to the US, how he almost died in Africa, graduated from Princeton, dropped out of a doctorate in Oxford and created a product that deserved a praise from Satia Nadella and Steve Wozniak.



In mid-October the Sistema_VC venture capital fund hosted a conference called Machine Teaching, where creators of various educational startups assembled to talk about technical advancements.

The special guest was Mark Pavluykosvkiy, the creator of Piper. His company created an educational computer — a children’s toy that, using wires, circuit boards and Minecraft teaches programming and engineering to children. A couple of years ago Mark completed a successful Kickstarter campaign, got a couple of Silicon Valley investors on board and raised around $11 million dollars in investments. Now he’s a member of Forbes’ “30 under 30” list, while his project is used by Satia Nadella and Steve Wozniak, among others.

Mark himself is a former Princeton and Oxford student. He was born in Ukraine, but moved to the US with his mother when he was a child. In various interviews Mark claimed that he doesn’t consider himself a genius, but simply someone who got very lucky. A lot of other people aren’t so lucky, however, and he considers it unfair. Driven by this notion, during his junior year he flew to Africa, where he almost died.
Total votes 28: ↑27 and ↓1+26
Comments0