Archive for the ‘.NET’ Category
Posted by jpluimers on 2017/12/27
From my SO Question Archive:
Just curious: Why is the syntax for try catch in C# (Java also?) hard coded for multiple statements? Why doesn’t the language allow:
int i;
string s = DateTime.Now.Seconds % 2 == 1 ? "1" : "not 1";
try
i = int.Parse(s);
catch
i = 0;
The example is for trivial purposes only. I know there’s int.TryParse.
[WayBack] c# – Why does Try-Catch require curly braces – Stack Overflow.
I asked this question partially because of my Delphi background where there are two try statements (one for finally and one for except a.k.a. catch) neither having the braces problem as try/finally/except all are block boundaries.
The most interesting bit was the [WayBack] answer by [WayBack] Eric Lippert (ex C# compiler team, now at Facebook after an intermediate position at Coverty) referring to his [WayBack] Why are braces required in try-catch-finally? | Fabulous adventures in coding blog entry.
The answer and blog entry come down to preventing ambiguity.
His answer reveals that a compound try/catch/finally statement is converted by two try statements like this:
try
{
try
{
XYZ();
}
catch(whatever)
{
DEF();
}
}
finally
{
ABC();
}
This emphasises that catch and finally are conceptually indeed two different things which statistics show.
I need to dig up the numbers (I remember researching this for Java and Delphi code a very long time ago – think Delphi 7 era – and C# code a long time ago – think C# 2 era), but this comment should still hold:
–
–jeroen
Posted in C#, Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/12/26
Ever introduced an extra parameter on a method, tracked all its usages and made the compiler happy by providing a corresponding extra argument in all the calls of that method? Sure you have…
Things like that need a reminder: the joy of reflection and lambdas…
Very good train of thought (and solving!) at [WayBack] Head scratching with a TargetParameterCountException | Software on a String
By [WayBack] Marjan Venema – Google+
–jeroen
Posted in .NET, C#, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/12/18
This will bite me some time for sure, so for my link archive: [WayBack] TRestClient and Cipher restrictions to TLSv1.2 does not work on Windows7 and Server2008R2 … and how it can be solved… – Günther Schoch – Google+
References:
For at least some Windows 7 and Server 2008 R2 systems, that update (KB3140245) doesn’t automatically turns up in the Windows Update list.
To make matters worse, the page cannot be archived in either the WayBack machine or Archive.is (I tried multiple times with empty results).
Luckily, there is a copy at [WayBack] KB3140245 DefaultSecureProtocols – Security.NL.
After installing the update, you have to ensure you set the DefaultSecureProtocols registry value to the bitmap value that indicates with SSL/TLS versions you want to support:
The DefaultSecureProtocols registry entry can be added in the following path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp
On x64-based computers, DefaultSecureProtocols must also be added to the Wow6432Node path:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp
The registry value is a DWORD bitmap. The value to use is determined by adding the values corresponding to the protocols desired.
| DefaultSecureProtocols Value |
Protocol enabled |
| 0x00000008 |
Enable SSL 2.0 by default |
| 0x00000020 |
Enable SSL 3.0 by default |
| 0x00000080 |
Enable TLS 1.0 by default |
| 0x00000200 |
Enable TLS 1.1 by default |
| 0x00000800 |
Enable TLS 1.2 by default |
For example:
The administrator wants to override the default values for WINHTTP_OPTION_SECURE_PROTOCOLS to specify TLS 1.1 and TLS 1.2.
Take the value for TLS 1.1 (0x00000200) and the value for TLS 1.2 (0x00000800) then add them together in calculator (in programmer mode), the resulting registry value would be 0x00000A00.
–jeroen
Posted in .NET, Delphi, Development, Power User, Software Development, Windows, Windows 7, Windows Server 2008 R2 | 2 Comments »
Posted by jpluimers on 2017/12/13
A nice article [Archive.is] What is thread safety anyway? with a kind reference to the Deadlock Empire translation from C# to Delphi that I made.
In any language, multi-threading is hard, so I really love the quote below:
[WayBack] Multithreading can be hard to do right. The most common point of failure is assuming some code is thread safe when it actually is not... – Dalija Prasnikar – Google+
It reminded me of an old one:
A programmer had a problem. He thought to himself, “I know, I’ll solve it with threads!”. has Now problems. two he
–jeroen
Posted in .NET, C#, Delphi, Development, Fun, Multi-Threading / Concurrency, Quotes, Software Development, T-Shirt quotes | Leave a Comment »
Posted by jpluimers on 2017/12/13
Mads Torgersen shares future thinking of a fast-moving major programming language, C#. Torgersen discusses pattern matching, type classes, discriminated unions and much more.
A cool outlook of things that hopefully make it into the next upcoming major C# release: [WayBack] Herding Nulls and Other C# Stories From the Future
Via:
Slides (of which a few screenshots are below): [WayBack] herding_nulls.pptx
–jeroen
Read the rest of this entry »
Posted in .NET, C#, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/12/12
LINQ is certainly extraordinarily useful. It brings the power of query expressions to C#, allowing an easy way of getting the data you need from a variety of data sources. Up to now, there hasn’t been a VS debugger for LINQ that gives you the means to visualise the data at every point in the chain. Michael Sorens, a keen LINQ user, describes a third-party tool that now promises to make using LINQ something we can all participate in.…
Great read. [WayBack] LINQ Debugging and Visualization – Simple Talk
Via: [WayBack] LINQ Debugging and Visualisation – Jeroen Wiert Pluimers – Google+
–jeroen
Posted in .NET, Development, LINQ, Software Development | Leave a Comment »
Posted by jpluimers on 2017/12/07
Ah, C. The best lingua franca we have… because we have no other lingua francas. Linguae franca. Surgeons general? C is fairly old — 44 years, now! — and comes from a time when there were possibly more architectures than programming languages. It works well for what it is, and what it is is a relatively simple layer of indirection atop assembly. Alas, the popularity of C has led to a number of programming languages’ taking significant cues from its design, and parts of its design are… slightly questionable. I’ve gone through some common features that probably should’ve stayed in C and my justification for saying so. The features are listed in rough order from (I hope) least to most controversial. The idea is that C fans will give up when I call it “weakly typed” and not even get to the part where I rag on braces. Wait, crap, I gave it away.
Great re-read towards the end of the year: [WayBack] Let’s stop copying C / fuzzy notepad
Via: [WayBack] Old and busted: emacs vs vi. New and hot: Language war, everybody against everybody else. – Kristian Köhntopp – Google+
–jeroen
Posted in .NET, APL, Awk, bash, BASIC, C, C#, C++, COBOL, CoffeeScript, CommandLine, D, Delphi, Development, F#, Fortran, Go (golang), Java, Java Platform, JavaScript/ECMAScript, Pascal, Perl, PHP, PowerShell, PowerShell, Python, Ruby, Scala, Scripting, Software Development, TypeScript, VB.NET, VBScript | 3 Comments »
Posted by jpluimers on 2017/11/02
Quoted in full because even 2.5 years later, it’s just too funny:
- Python: What if everything was a dict?
- Java: What if everything was an object?
- JavaScript: What if everything was a dict *and* an object?
- C: What if everything was a pointer?
- APL: What if everything was an array?
- Tcl: What if everything was a string?
- Prolog: What if everything was a term?
- LISP: What if everything was a pair?
- Scheme: What if everything was a function?
- Haskell: What if everything was a monad?
- Assembly: What if everything was a register?
- Coq: What if everything was a type/proposition?
- COBOL: WHAT IF EVERYTHING WAS UPPERCASE?
- C#: What if everything was like Java, but different?
- Ruby: What if everything was monkey patched?
- Pascal: BEGIN What if everything was structured? END
- C++: What if we added everything to the language?
- C++11: What if we forgot to stop adding stuff?
- Rust: What if garbage collection didn’t exist?
- Go: What if we tried designing C a second time?
- Perl: What if shell, sed, and awk were one language?
- Perl6: What if we took the joke too far?
- PHP: What if we wanted to make SQL injection easier?
- VB: What if we wanted to allow anyone to program?
- VB.NET: What if we wanted to stop them again?
- Forth: What if everything was a stack?
- ColorForth: What if the stack was green?
- PostScript: What if everything was printed at 600dpi?
- XSLT: What if everything was an XML element?
- Make: What if everything was a dependency?
- m4: What if everything was incomprehensibly quoted?
- Scala: What if Haskell ran on the JVM?
- Clojure: What if LISP ran on the JVM?
- Lua: What if game developers got tired of C++?
- Mathematica: What if Stephen Wolfram invented everything?
- Malbolge: What if there is no god?
–jeroen
Read the rest of this entry »
Posted in .NET, APL, Assembly Language, BASIC, C, C#, C++, COBOL, Development, EPS/PostScript, Fun, Go (golang), Java, Java Platform, JavaScript/ECMAScript, LISP, Makefile, Pascal, Perl, PHP, Python, Quotes, Ruby, Rust, Scala, Scripting, Smalltalk, Software Development, T-Shirt quotes, TCL, Turbo Prolog, VB.NET, Visual BASIC, XML/XSD, XSLT | Leave a Comment »
Posted by jpluimers on 2017/10/12
I mentioned Asbjørn Heid on wiert.me before. While prepping for the Deadlock Empire workshop at EKON20, I needed a Delphi equivalent for the .NET [Way: Barrier Class (System.Threading)
The game uses that in level deadlockempire.github.io/#H4-Barrier [WayBack].
Edwin van der Kraan found the ThreadBarrier/ThreadBarrier.pas at master · lordcrc/ThreadBarrier implementation via [WayBack] Is there a way to create memory barriers in Delphi? Something like .NET’s System.Threading.Barrier class, java.util.concurrent.CyclicBarrier… – Horácio Filho – Google+
It’s from Asbjoørn who is known as lordcrc on GitHub. Cool stuff!
So yes, there is a Delphi version of If you thought you could do multi-threading, then play “The Deadlock Empire” games. You can find it at https://deadlockempire.4delphi.com/ There are two deadlockempire implementations there:
The workshop was great fun!
This is about a web game focussing on the concurrency issues in multi-threading environments. By the conference there will be a Delphi version of it. At the workshop we will play each round interactively: all attendees play the round followed by a short discussion. This is about collective learning, so the speakers will probably learn… Read More
Source: [Archive.is] If you thought you could do multi-threading, then play “The Deadlock Empire” games – Entwickler Konferenz
–jeroen
Posted in .NET, C#, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »