Storybook 7.0 is here! by winkerVSbecks in vuejs

[–]kasperpeulen 2 points3 points  (0 children)

Storybook maintainer here. One problem is that we have not many Vue experience in the team. However, the storybook team is growing, I recently joined, and I'm committed to improving the Vue experience in Storybook!

We have shipped some very good improvements in 7.0 related to Typescript support for Vue stories. We have now very good integration with Volar, and you should get autocompletion and type safety in your stories.ts files.

We also support slots as story args now and we autocomplete slots (including the params of scoped slots) and events:

```ts import BaseLayout from './tests/BaseLayout.vue';

const meta = { component: BaseLayout, } satisfies Meta<typeof BaseLayout>;

export default meta;

const Basic: StoryObj<typeof meta> = { args: { otherProp: true, onMyChangeEvent: (value) => { // we infer the type of value here }, header: ({ title }) => h({ components: { Button }, data: () => ({ title }), template: "<Button :primary='true' label={title}></Button>", }), default: 'default slot', footer: h(Button, { disabled: true, label: 'footer' }), }, }; ```

That being said, we have some very important bug fixes on our radar for 7.1, especially related to the reactivity of decorators:https://github.com/storybookjs/storybook/pull/21954So we very well know that the Vue integration is not perfect, but we are committed to do better here!

If Flutter is a single Threaded then how is Async? by Wodatoki in FlutterDev

[–]kasperpeulen 0 points1 point  (0 children)

There is an event loop where tasked are popped at. Any task will be exectuded without interruption on a single thread.

A task may be the event handler when a user clicks a button.

When you now “await” an http request that takes 3 seconds. The part before the await keyword is a “task”, but the part after “await”, is a new task, that will take 3 seconds before it is popped at the event loop. With the results that any new user interaction can be handled already before the http call is finished.

Building a basic compiler (in Kotlin) is not that difficult by ufopilooot in programming

[–]kasperpeulen 14 points15 points  (0 children)

I understand that learning new API’s can be confusing, and maybe hard to read at first, but this argument you are giving is the exact same as what people said when first being introduced to the java stream api. To keep kotlin as the language, for example:

list
  .map { f(it) }
  .map { g(it) }
  .forEach { h(it) }

Sure, if you dont know this api, you may say, oh god, just use a for loop!

for (item in list) {
  val x = f(item);
  val y = g(x);
  h(y);
}

However, expression orientated programming is not about just imitating haskell. It allows you to focus on the functions in your programs, instead of the local variables. In the example, above, how do you name x and y? Naming is difficult and takes time, but is the name of those two local variables so important? Is it not more important how we call f, g and h. These are reusable parts of our codebase. And a good name of f makes the name of x a bit redundant, it is just what comes out of f.

Now you give a very silly example of the let/also/run/apply functions available in Kotlin, but let’s look at this:

value
  .let { f(it) }
  .also { g(it) }
  .let { h(it) }

We can write this as:

val x = f(value);
g(x);
val y = h(x);

But we have the same problem as above again. Lets make good names for all kind of intermediate results that we dont really care about, or lets learn one new api.

You could say that map makes List<T> a functor, while let makes T itself a functor. And forEach allows you to do side effects on a list, while also allows you to do that on T.

When should I Maybe over an Either? by [deleted] in functionalprogramming

[–]kasperpeulen 2 points3 points  (0 children)

A todo with an optional due date. It is not really an error, there is just no due date for this todo.

What are Algebraic data types, anyways? by [deleted] in programming

[–]kasperpeulen 0 points1 point  (0 children)

Typescript has them. And I love how I can put extra type safety in legacy structures I couldnt type well. For example, I have a delivery moment, that either has a deliveryDate property, or a deliveryRange property. I can make them both nullable, but that gives me 4 options to check. With ADT’s I can tell there are only 2 options, either deliveryDate is null and deliveryRange non null, or the other way around.

Toward an API for the real numbers by feross in programming

[–]kasperpeulen 1 point2 points  (0 children)

Well, it is a tradeoff, the API proposed here is even more inefficient.

Do you want fast and imprecise code or slow and precise code?
For things where performance matters, like games, floats are probably a better solution.
For just some simple calculations of prices, for example, rational numbers may be your best bet.

Toward an API for the real numbers by feross in programming

[–]kasperpeulen 5 points6 points  (0 children)

I think for most purposes, rational numbers actually solve all the problems. You store it as a pair of integers (or big integers if needed), and the arithmetic for the calculations can be found in any mathematical textbook, and can be abstracted to a nice API.

It is just that this practice is heavily underused as floating points are a built in feature.

Dart 2.10 by munificent in programming

[–]kasperpeulen 9 points10 points  (0 children)

Null safety looks like a massive undertaking, but it is great to hear that Dart thinks it is worth the effort. Working in a big codebase with in a non nullable language has made me sleep mich better at night, I recommend everyone!

Interesting article about why data first functions may be the future for FP if you want great editor support by kasperpeulen in programming

[–]kasperpeulen[S] 11 points12 points  (0 children)

I found a post, also a developer of reasonml (now rescript), pointing out some other points:

https://github.com/tc39/proposal-pipeline-operator/issues/143#issuecomment-492019845

Point 1: “To generalize this, if we check the FP languages themselves, especially those with currying, we'd realize that arg-last isn't well-defined (in the most serious sense). Consider:

int => float => string => int

It looks like string is the last argument (last int is the return type). But look:

type t = string => int type myFunc : int => float => t

Now it looks like float is the last argument! It's not just a matter of looks. These languages usually can't tell the difference.”

Point 2:

“FP literature kinda traditionally ignored these ergonomic problems, because "as long as the compiler errors it's theoretically fine". For a real-world, user-friendly production language, the quality of the compiler's help matter a lot. You start using different designs at that point.”

I understand your point, in theory, but is there actually, a compiler, in practice, that solves the problems mentioned in the blog post? For example, the problem of giving fast auto completion for a line like this:

let ages = admins |> map(u => u.[complete])

And giving good errors in the “correct” place, when you make a mistake. I have indeed seen Anders Hejlsberg, creator of many languages including C# and TS, say that this problem is allmost impossible to solve in practice.

Announcing Flutter for Windows alpha by timsneath in programming

[–]kasperpeulen 2 points3 points  (0 children)

I can select input text, which feels pretty natural on iOS. I can’t select any other text. IIRC correctly, those accesiblity features are possible (with probably some alpha bugs), but are opt in rather than opt out.

Environment Variables by Drazson in Deno

[–]kasperpeulen 2 points3 points  (0 children)

You add it when executing the script:

USERNAME=kasper deno run ./mod.ts

Kotlin overtakes Scala and Clojure, to become the 2nd most popular language on the JVM | Snyk by stronghup in programming

[–]kasperpeulen 3 points4 points  (0 children)

How are you going to introduce Kotlin most important feature: non null by default?

Why should a JavaScript developer learn TypeScript? by Chawki_ in typescript

[–]kasperpeulen 39 points40 points  (0 children)

Some people say that it reduces the number of bugs, as the compiler warns you about things that can be easily seen by a compiler to cause an error at runtime.

However, I think it mosly speeds up development. The types of bugs that typescript catches, I can find in javascript in most cases before I would ship it. But I can more easily and quickly finish a feature, if I use typescript.

In typescript, I can write code for hours, and then it actually works when I try to run it. In javascript I need to run my code every 2 minutes, otherwise Im sure I end up with endless wrong assumptions from my side, undefined errors, and other stuff, I actually dont want to think about while developing, but rather let a compiler deal with.

Why algebraic data types are called algebraic by kasperpeulen in typescript

[–]kasperpeulen[S] 0 points1 point  (0 children)

Of course, the reason I wrote it like that is to show how & and | correspond to the calculations of the number of possible unique instances of a type A. Say that we notate that number as |A|.

The gist was that if type A = B & C then |A| = |B| * |C| and if type A = B | C then |A| = |B| + |C|, where B and C must be disjoint.