« first day (3790 days earlier)      last day (1141 days later) » 
01:00 - 13:0013:00 - 00:00

1:41 AM
 
 
4 hours later…
Is it possible to have a implementation of AsyncDelegateCommand with CanExecuteAsync method?
 
 
1 hour later…
mr5
7:06 AM
 
🥐
 
Hi
@nyconing sup? :)
 
Good morning
 
good morning!!
 
@Comraid I mean, just build it I guess?
 
7:18 AM
@Squirrelkiller are you angry with me?
 
Never ;)
 
@Squirrelkiller I'm talking about ICommand.CanExecute
 
Ah so an implementation of ICommand
You can't make CanExecute async, no. It has to directly return a bool.
 
<3
 
I see workarounds for ICommand.Execute method
 
7:24 AM
I mean, since Execute is void, you can just make it async void and made it async.
It is an event handler after all
 
 
2 hours later…
9:22 AM
if only we didnt invent async :(
 
Then we'd still have to fuck around with threads manually
 
depends
 
Or invent something else
Like async
 
you probably dont have to do it manually
there are quite a few technologies which use virtual threads
making a thread has nothing to do with the OS or with the cores of the hardware
 
async is "I want these things to run but still want the main thread to not block and dont care how you do it"
 
9:23 AM
then what is wrong with:
 
Before that, you'd have to put something in a thread and then communicate across threads
Now you just make it async and be done with it
 
A();

RunThisThingAsASeparateProcess(() => {
    while (true) {
        DoTheThing();
    }
});

B(); // runs because it didnt get blocked
 
You can't stop the other process is what's wrong
 
why cant you?
 
Because it's while(true)
You have to kill it
 
9:25 AM
and?
 
You're supposed to give it some signaling mechanism to gracefully shutdown, like while(File.NotExists("myLockfile")
 
if you have a while (true) in async, you also have to kill it
 
Also I just used a file because I'm too lazy for the right way
@Wietlol Correct, and it also would be the thing that is wrong
 
ok, so... can you give me an example that shows how bad threads are and how good async is?
 
Old question, task vs thread
use task inside a thread so you can get both of the benefits from them
 
9:30 AM
Without async, every long running task goes
Start task in new thread
Have some kind of callback or polling
When thread is done continue with whatever you wanna do after the task is done

With async it's
Call long running task
Do whatever you want to do after it's done
 
you dont need callback or polling
just wrapped tasks
which works exactly the same as everything else you already know
 
In what? How do I get back to the main thread?
 
why do you need to get back to the main thread?
 
Because I can't update the UI from a background thread
 
ah, you blame ui framework issues on threads
requiring ui thread execution is just stupidity of ui frameworks
 
9:34 AM
I don't think there is any UI framework that lets you update UI from the background
 
there are many
 
There are, Control.Invoke
 
how they do it depends on the design though
 
That right there is a call invoking something on the main thread
 
react similar ui frameworks use state... when the state changes, then the ui updates
shared state can be accessed from anywhere
actual ReactJS probably doesnt actually have multithreading, but the similar frameworks do
most Java ui frameworks just allow multithreaded ui control
how they do it is more of a mystery for me... maybe they do some weird synchronization on the background
but I dont have to care
 
9:40 AM
Fine scrap the UI then. Webservice gets triggered, is supposed to calculate a few hundred insurance policies for a given input.
Using threads, I'd trigger the calculations, maybe make something smart about using only 50 threads or so at once (who knows, maybe it's 2000 policies tomorrow?)
Build something that waits for all the calculations to be finished
Then return the aggregated results.
With async I just tell TPL "yo here's a few calculations, do it"
Then return the results.
And I don't have to care about how many calculations there are and if I should worry about how many threads to use, or about how to wait for all those calculations.
 
TPL?
 
task parallel library
 
so, why wouldnt there be a Thread Parallel Library?
 
There isn't
 
but why?
is it impossible? or did they just say "nah, we just blame threads for sucking, so we dont actually write solutions"
meanwhile in Java, with the simplest thing:
 
9:42 AM
Because threads are a low level construct where, if you want a high level construct to simplify it, can be exchanged for tasks.
The solution is TPL
Task parallel library because you think in tasks, not in threads
High level
 
List<Result> results = calculations
    .parallelStream()
    .map(calc -> calc.compute())
    .collect(toList())
 
Same in C#:
var results = calc
  .AsParallel()
  .Select(calc => calc.Compute())
  .ToList();
 
so, with threads, doing parallel processing is also not a biggie
 
The point is that tasks are smarter than threads: They don't block a whole thread when they wait for IO.
 
obviously, the problem comes when you get more into the details
if I have a million calculations, would it make sense to do them all at the same time? would I get IP blocked because I am doing a million requests at once?
stuff like that
for which, you would need some way to specify how many parallel processes are allowed at the same time, etc
 
9:46 AM
That's a different perspective though and not part of theads vs tasks
 
indeed
so, threads are equal to tasks
except... without the pain of Task<T>
 
Both threads and tasks let you add options about how many you can have at once
 
just T
 
@Wietlol They are not. Again. Tasks are higher level.
Tasks wrap a unit of work
 
@Squirrelkiller how significant is that problem?
 
9:48 AM
@Wietlol Depends on how many units of work you have
 
what is the thread still consuming while it is waiting that a task is not?
 
It exists and can not be used.
 
as do tasks
they also exists
the task, what needs to be run with what arguments, is still queued as to run when the IO is done
 
But only as objects, not as threads. Threads actually exist for the CPU. Tasks do not.
 
and?
 
9:50 AM
If I have 2k calculations, the threadpool will make me wait at some point.
 
and if you just have 2k threads?
 
But with tasks, a few threads will start all the IO without making me wait
iDunno, does the threadpool give my application 2k threads?
 
if you make 2k threads, you have 2k threads
 
But now I have to handle 2k threads
 
"handle"
they are background concepts
 
9:52 AM
Make sure I dispose of them properly
 
you never "handle" them
 
They are not concepts - they are actually registered with the OS
 
do you "handle" stack frames? do you "handle" exception jumping?
tasks also need to get disposed of just as well as threads
but both should be handled by the library
when a thread is done, it gets closed
 
Tasks are handled by just awaiting them and then forgetting about them
My result will have any exceptions thrown from within the tasks
And dont tell me to do proper exception handling within the threads, that goes both ways
 
I just fail to see the difference
with one exception, Task<T>
 
9:56 AM
The difference is that with threads, you have to consider things on an OS level. On a low level.
 
do you?
not with virtual threads
not with green threads
 
Threads aren't virtual though
 
they are if they are virtual threads
 
Not sure what language does virtual threads, but I can imagine them doing the same stuff as tasks
The point is to not have threads, but units of work.
You just want your units of work done.
 
Java has virtual threads
 
9:58 AM
So what do they do? Wait for IO so the OS thread can do other things?
 
they are not linked to OS threads
they are just a process within your application
 
Same as tasks in dotnet then?
 
an OS thread in the main thread pool (often of the size of your cores + 1) is each running a virtual thread
until all scheduled threads are done
when a virtual thread is waiting, it is simply not queued
when IO events fire, the virtual thread is again queued to be processed
2k virtual threads, but still only 9 or 17 OS threads work perfectly fine
and they work exactly the same as C# Tasks
except, they dont use Task<T>
so, they dont have duplication of code, leaking abstractions, breaking contracts, etc
 
Then how do you decide whether or not to immediately halt execution until it's done, or do a few other things before waiting for that result?
 
that depends on when you want to join threads
 
10:02 AM
Like, in the old days dotnet had things like .BeginInvoke and .EndInvoke
 
when you join two virtual threads, the joining thread looks at the state of the joined thread
if it is waiting or running, then the joining thread will just start waiting as well
then, when the joined thread is done, it will let the joining thread continue (aka, get queued again)
if it was already done, then the join just gets ignored and continues
 
wietlol! <3
 
but that is similar to Tasks with how their result works
when you do await, it looks at the state of the awaited task
 
But it wont let my directly assign a local variable like var x = networkCall(); then?
Or does it just immediately join then
 
what are your discord names?
 
10:06 AM
that depends
var x = await networkCall();
just becomes
var x = networkCall();
because you dont use async
when you do
 
Then how would I
 
Task<X> xt = networkCall(foo);
Task<Y> yt = networkCall(bar);
var x = await xt;
var y = await yt;
only then, you have to create new threads
because you want parallel processing
 
^exactly my question lol
How do I defer one to start another one and then wait for the former or both?
 
in which case, in the ideal situation, you would do something like this
 
Are you seriously arguing for threads over tasks?
 
10:08 AM
It's either that or I kick him
 
val xt: VirtualThread<X> = vthread { networkCall(foo) }
val yt: VirtualThread<Y> = vthread { networkCall(bar) }
val x = xt.join()
val y = yt.join()
now, this is where the problem is
in the old Thread api, this wasnt an option
C# simply had to introduce a join function that would return a value
and introduce a type like ValueThread<T>
 
But this is exactly the case TPL solves
 
... It doesn't have to. It has tasks and TPL.
 
one that would explicitly return a value when completed
so, iirc, C# Thread.Join just returns void
 
...which is Task but with different names
 
10:11 AM
how do you know so much? >:(
 
@Squirrelkiller exactly
but you dont need to be an async function in order to invoke join
 
@Wietlol Because threads don't produce values. They do stuff.
 
You don't use threads directly in C#. You use tasks. Tasks are added to a Task Scheduler. The Task Scheduler manages the tasks (units of work) and assigns them to threads (thread pool). It's the most efficient strategy for distributing infinite work over limited threads.
 
@Wietlol Because it's not async, it will block the joining thread
 
@Shad We old.
 
10:12 AM
@Squirrelkiller which wasnt a problem, as demonstrated earlier (assuming .net would use virtual threading)
 
But...it does
ffs
tasks are the same concept than virtual threading
 
you block context, not OS threads
 
Except they change names so people don't constantly confuse them with OS threads
 
I am old too xD
 
@Squirrelkiller exactly
 
10:13 AM
It's hard enough to get people to understand that tasks aren't threads.
 
so, why does C# have virtual threads + abusive syntax of hideous limitations?
 
Having to explain how virtual threads arent OS threads must be even more annoying.
@Wietlol Tasks
 
@Wietlol You really don't grasp Tasks, do you?
 
@Deathspike I am afraid I do grasp them
 
He likes Kotlin, he's afraid of tasks
 
10:15 AM
which is why I grasp why they are absolutely the worst thing that could have happened
in simple terms, they could have made tasks, but you dont have to make your function async in order to use await
but they didnt
instead, they made this thing that just haunts your every move
 
Maybe your method is just a task factory
 
where you need both async and non async operations for every execute-around function, where you need interfaces to leak implementation detail, where you need heavy noise on normal flows, etc
 
You should know that a Task is a work unit. Doing an async/await puts the work for another task on the task scheduler, and adds a continuation to that, then exits the running method. The executing method is done. It's not assigned, doesn't exist, and doesn't use resources. When the requested task is assigned by the task scheduler to run, it runs, then puts the continuation on the scheduler. When it gets ran, your "code" continues (in reality a new task).
The task scheduler is free to do whatever it wants. You can even write your own. The default is to assign tasks to thread pool threads (has a default). It's super efficient and transparent.
 
yes, I understand that
 
Then what are you bitching about.
 
10:18 AM
I also understand that using virtual threads, you get exactly the same benefits
without the major drawbacks
 
What drawbacks?
 
obviously, after that, there are new major drawbacks, but they start at a negligible level instead of hitting you in the face
> where you need both async and non async operations for every execute-around function, where you need interfaces to leak implementation detail, where you need heavy noise on normal flows, etc
as a start
 
so much knowledge :'(
wow
 
I don't understand this drawback. Please explain. You don't like using async to use await?
You'd rather have magic?
 
I'd rather have magic that is well documented...
everything is basically magic until you understand it
for most things on this level, you would read the docs to understand it
 
10:21 AM
Having experience with both coroutine-like mechanisms and async/await, I strongly prefer async/await.
It's not surprising that other languages have adopted it.
I feel that this virtual threading just adds unwanted noise.
 
what noise?
 
Hey Rob, here to join a pointless conversation too?
 
@Squirrelkiller Rob is an Observer<Conversation>
 
Unless somebody reported us lol
 
he wont Join();
 
10:23 AM
He might await though
 
xD
 
@Deathspike afaik, async/await introduces noise where you dont care about async/await
which is the worst kind of noise
> where you need both async and non async operations for every execute-around function
this is true for most functions that accept a lambda as parameter
mostly the ones that expect a certain result
such as IEnumerable.Where
you cant use async in Where because then you return a Task<Boolean> instead of a Boolean
you cant Where after a Select with an async call, except if you put a Task.WhenAll between it, which introduces another level of problem
so, you have to have both WhereAsync as well as Where
 
I feel like you're overcomplicating scenarios for the sake of going "Look at Kotlin"
 
I am sure you know many more cases like that
actually, Kotlin did a poor job too
 
I wish I could be a part of this conversation :'(
 
10:27 AM
I don't really have situations where this is a problem.
 
I havent even mentioned Kotlin until now
 
I also like the fact that C# and JS work exactly the same.
 
> where you need interfaces to leak implementation detail
which is where the conversation started
where ICommand.CanExecute is expecting a boolean
the interface now has to assume that the operation is not an async task
 
1 min ago, by Deathspike
I also like the fact that C# and JS work exactly the same.
visible confuu
 
the interface author has to predict that an implementor could in theory want the CanExecute to have IO operations
it leaks the implementation details of being async or not
 
10:29 AM
@nyconing The async/await mechanism in both is the same
 
often again introducing duplication of code and effort to solve it by having both CanExecute and CanExecuteAsync
 
[...] work exactly the same regarding async processing.
 
> where you need heavy noise on normal flows
 
why is everyone growing except me?
 
when invoking async functions, but not wanting to use parallelism or any other special thing, such as cancellation and stuff, you still need to have all the ceremonial noise
 
10:31 AM
@Wietlol I'd pin this on the fact that WPF hasn't evolved in forever and has no intention to.
Right now you should just default to async support.
 
var x = await DoTheThingAsync(); instead of just var x = DoTheThing();
 
I bet you're growing too @Shad, just in a different context right now ;)
 
You can even get away with just async functions, no sync
 
lol :(
 
on top of the outer function then also having to be async Task<T>
and unfolding the chain of terror I mean... refactoring without purpose
 
10:33 AM
It's there for a reason. It's called explicit control. E.g.
var personTask = GetPersons();
var callersTask = GetCallers();
var persons = await personTask;
var callers = await callersTask;
If the `await` was implicit then you couldn't do this common thing.
 
explicit control is perfectly fine
but explicit defaults are stupid
I would much rather have it like this
Person person = GetPerson(); by default
and
Task<Person> personTask = Task.Run(() => GetPerson());
Person person = await personTask;
^ with explicit control
 
Tell that to somebody in 2001
 
if you want explicit control, you have to explicitly declare responsibility of control
 
I personally disagree. You should be informed that a call can run in parallel so you can decide how to act on it. There's nothing more telling than a compiler throwing shit in your face and forcing you to think.
 
and a compiler cannot throw a suggestion in your face?
 
10:36 AM
No, because I don't want to see endless suggestions I'm not going to follow up on.
 
Do you know what happens with suggestions and warnings
 
Also, I want to force the less competent developers to be explicit in their intentions.
So, yes, I like the current async/await.
 
Wanna know what happens if I do npm i currently?
found 9316 vulnerabilities (9292 low, 6 moderate, 18 high)
 
@Squirrelkiller lol same, I don't care about the warnings
 
"oh, it looks like your if condition is always going to be true, do you want to replace it with the then branch?"
or
"oh, it looks like you are doing two, unrelated, IO tasks after each other, do you want to parallelize these?"
 
10:37 AM
That's what happens to warnings and suggestions
@Deathspike Technically I do but I also don't have time to fix them because some customer usually slams a kilogram of cash on the table of my boss and goes "this has to be in the next update"
 
maybe you say "pls no, first IO task is writing to a file, second is reading, they cant be parallel" or "yes please, refactor as needed"
compilers are not the old ones that only complain when they cant possibly do their job... or just to yell at you for the lack of semicolons
a compiler, especially more modern ones, can understand much more information than the type system can even handle
 
That's a static analyzer then
 
having the type system inform you of IO tasks and demand answers of how to handle them is just a small piece
if you would use that for everything, your code would mostly be noise created as "yes, I want the defaults"
public void Foo() create-stack-frame, handle-exception-jumping, read-caller-location, return-to-caller-as-usual {
    ...
}
yes, all of that is default
no, no one cares about them being default
similar with direct awaits
 
 
1 hour later…
mr5
12:05 PM
I just bought this because I need hard copy for employment
 
where is the screen? ... and the keyboard? ... does it support hdmi?
also, does it have a webcam that most people want to put some duct tape over?
 
We got a printer for free, just because our universities wanted stuff hard copied lol
From an app where people get rid of stuff they don't need anymore
It's like 10 years old at least, but it works
 
mr5
tbf, it can scan and copy documents.
 
12:20 PM
Noice
 
mr5
I'm looking for a smaller one. Can't find in our local shop
 
you are good with sql?
I want to repeat the Stuff function
SELECT @columns = STUFF((SELECT  ',' + QUOTENAME(x.MonthNames) + QUOTENAME(x.MonthNames2)
                        FROM (SELECT distinct convert(varchar(50),tmpp.RYear) + '-' + tmpp.RMonthName + '-ProductMonth'  MonthNames,
                         convert(varchar(50),tmpp.RYear) + '-' + tmpp.RMonthName + '-ProductMonth(Negative)'  MonthNames2,
                        tmpp.RMonthID  FROM #Tempproductsource AS tmpp ) AS x ORDER BY x.RMonthID
                FOR XML PATH(''), TYPE
                ).value('.', 'NVARCHAR(MAX)')
Error is with QUOTENAME(x.MonthNames2)
I checked this
5
Q: How can i use stuff function for multiple columns in SQL server?

SqlLearnerI have a requirement for concatenating two values of two rows having same Id's and averaging for other column. Here is the sample table I have: Now my requirement is I need to concatenate the Response column, concatenate Response Rating column and average the Rating Avg column if it has same ...

but I don't know how to write
 
mr5
STUFF hmm
Didn't know that thing exists
Are you doing raw SQL?
 
yup
 
mr5
do you have the same requirement as that question?
why are you doing raw SQL?
is this for API response?
 
12:27 PM
yes, if you see my query
QUOTENAME(x.MonthNames2)
this is the second column
column1s, column2s that's how I want with Stuff
 
mr5
QUOTENAME is suppose to wrap it with quotes?
 
currently it is just column1s
no
 
mr5
maybe QUOTENAME is returning an error because of preceding ',' no?
 
there is... an actual function... called "stuff" in sql...
why does that surprise me?
 
this is how it is currently
SELECT @columns = STUFF((SELECT  ',' + QUOTENAME(x.MonthNames)
                        FROM (SELECT distinct convert(varchar(50),tmpp.RYear) + '-' + tmpp.RMonthName + '-ProductMonth'  MonthNames, tmpp.RMonthID  FROM #Tempproductsource AS tmpp ) AS x ORDER BY x.RMonthID
                FOR XML PATH(''), TYPE
                ).value('.', 'NVARCHAR(MAX)')
            ,1,1,'')
 
mr5
12:30 PM
I can't remember if you're supposed to "morph" variables in SELECT or after it.
 
I want to repeat STUFF one more time
so what will be the way
 
mr5
can't you do it in C#?
best we can do is C# :D
 
SELECT @columns = Stuff(column1) + Stuff(column2)
:(
 
mr5
SELECT @columns =
	STUFF(
		(
			SELECT
				',' + QUOTENAME(x.MonthNames)
			FROM
				(
				SELECT DISTINCT
					convert(varchar(50),tmpp.RYear) +
					'-' +
					tmpp.RMonthName +
					'-ProductMonth'
						AS MonthNames,
					tmpp.RMonthID
				FROM
					#Tempproductsource AS tmpp
				) AS x
			ORDER BY x.RMonthID
	        FOR XML PATH(''),
	        TYPE
        )
        .value('.', 'NVARCHAR(MAX)') ,1,1,'')
god damn. this is hard to format xD
 
@mr5 hisssss
 
mr5
12:35 PM
I still can't understand it
@Deathspike no u
 
okay it was basic logic
I just did Stuff() +Stuff()
lol
:(
 
mr5
izz working now?
 
stuff() returns varchar
yes xD
varchar + varchar
simple
 
mr5
avoid that STUFF thing
 
Why not use CONCAT and CONVERT?
 
mr5
12:36 PM
seems hacky
 
sp is written already by someone else
 
is "stuff" actually the function name you use?
 
it's from T-sql @Wietlol
 
just checking
 
haha
@Deathspike it's written by someone else
 
12:37 PM
"stuff" is mostly used like "foo" and "bar"
 
hm
 
mr5
they probably forgot to rename that function when they ship it
 
// TODO: 2001-01-09: Rename this func.
// TODO: 2010-05-19: This should be renamed already, but we ship now, do it next time.
// TODO: 2019-12-01: Can't rename, refactor first.
// TODO: 2021-01-01: Oh lord.
7
 
// (05/09/2018) rename method... maybe...
// (18/09/2018) nope, this method name is perfectly fine
public static void EverythingSucks(Page page, Action action)
{...}
^ actually from our codebase
there used to be todos, but considering we agreed that the name was perfectly fine, the todos were removed
what it does? well... it avoids blocking the main thread because of async
ironically...
 
mr5
you're allowed to put those kind of words in your code base?
 
12:46 PM
well... who is gonna stop us? :)
 
@Deathspike oh gawd what?
 
@Wietlol Somebody who does code review hopefully
 
@Freerey your welcome
 
What about her welcome?
 
@Squirrelintraining how are you?
 
12:49 PM
bruh
 
@Shad God?
I don't know, tell me please
 
no angel
 
:D
 
@Squirrelkiller this particular project is one that no one dares to code review
we dont even want to touch it
it is our legacy asp.net webforms application...
.net framework and stuff
 
mr5
12:52 PM
I barely make any progress with those kind of projects. Particularly right now with my current employer :(
Simple page is taking me 3 days to finish
 
01:00 - 13:0013:00 - 00:00

« first day (3790 days earlier)      last day (1141 days later) »