These are chat archives for mithriljs/mithril.js

25th
Jan 2018
Pierre-Yves Gérardy
@pygy
Jan 25 00:08

@sp3n about loading mithril-stream through the url you could do https://flems.io/mithril,mithril-stream ;)

I actually use it even when state is already in the url instead of the sidebar 🤫

@porsager that's awesome, I didn't know you could do that (add deps through the URL in a non-blank Flems)

Rasmus Porsager
@porsager
Jan 25 00:11
Anything to save a couple of clicks 🤣 It's just like those down'trodden paths on grass because people take the straight line instead of the paved road..
Pat Cavit
@tivac
Jan 25 00:28
"paving the cowpaths"
Isiah Meadows
@isiahmeadows
Jan 25 04:11
@porsager You need to document these things somewhere...
Dominik Dumaine
@Bondifrench
Jan 25 04:30
I feel like Eric Elliott must have been lurking into the Mithril chat recently, appropriating to himself @barneycarroll 's opinion on ternaries nested ternaries are great ;-)
Pat Cavit
@tivac
Jan 25 06:16
I disagree with most everything Eric Elliot says
surprise surprise this is no exception
he would say that I'm just not a very good developer
Barney Carroll
@barneycarroll
Jan 25 08:46
Get in the ring, @tivac
I have been trawling through this codebase which enforces prevention of nested expressions
Barney Carroll
@barneycarroll
Jan 25 08:51
Why don't you just use if? Even my dog understands if. It's more accessible / readable. But it doesn't scale. When you enforce this rule, you end up with reams of code whose intent is totally obscured.
Hundreds of lines, functions, temporary references.
Thinking pushing whenAthenBotherwiseC and severalExpressionsEvaluatingTheLast to enable to me to write standard ES3 that complies to eslint defaults.
Rishav Sharan
@rishavs
Jan 25 08:59
@JAForbes Sorry about being very late with the reply. I actually prefer hyperscript. JSX is not my cup of tea. BUt more I code, more i realize that a lot of developing is copy+pasting and then editing teh code. Specially when I work with HTML. I am working with a lot of snippets from a lot of sources and it is far more practical to just go with JSX.
Barney Carroll
@barneycarroll
Jan 25 09:02
Was talking to @gilbert about this the other day @rishavs, but I wonder if to a large degree things like this should be abstracted on the IDE level
Isiah Meadows
@isiahmeadows
Jan 25 09:03
@barneycarroll IMHO, if it requires an IDE to even be tractible, that alone introduces cognitive overhead when you could just be coding.
Some people prefer to avoid that.
Barney Carroll
@barneycarroll
Jan 25 09:03
I'm suggesting the opposite
As Prettier does
Isiah Meadows
@isiahmeadows
Jan 25 09:05
I'm aware. I was just pointing out that's not something everyone agrees with. (In particular, I like some automation like linting and auto-fixing, but not syntax transformation on paste. That's a little too magical.)
Barney Carroll
@barneycarroll
Jan 25 09:05
With procedural eslint fixing and prettier we have the drudge work of transforming content in procedural ways taken care of seamlessly. The net result is you don't have to think about the difference.
Isiah Meadows
@isiahmeadows
Jan 25 09:06
BTW, I have experience with that concept - IntelliJ has that feature built-in for Kotlin code, so you can paste Java and get equivalent Kotlin (mod a few idiomatic differences).
Patrik Johnson
@orbitbot
Jan 25 09:10
@rishavs there's a webapp for that (HTML / JSX -> hyperscript) http://arthurclemens.github.io/mithril-template-converter/
just throwing this up there, but the more I code the more I feel that it's important to "never" copy paste implementations. If you're going to borrow, then at least retype, you'll end up with a better understanding of what's going on (and you might end up being able to type faster after a while ;) )
Isiah Meadows
@isiahmeadows
Jan 25 09:12
@barneycarroll I'm personally of the opinion that after a point, enforcing specific style guidelines actually gets in the way of actual coding and occasionally even readability. For example:
  • Nested ternaries risk becoming illegible when it's not simple if/else chaining. cond1 ? cond2 ? foo : bar : baz is where things get hairy, and that's why I avoid it.
  • Sequence expressions are nice in quick debugging hacks (I use them with console.log and debugger on occasion), but they get unwieldy very quick with the number of parentheses they introduce. For this reason, I use IIFEs instead for anything non-trivial, and I generally don't commit sequence expressions.
  • Short functions are exceptionally nice and pretty to look at, but when you're doing stuff that's inherently complex, a big, long function can't really be avoided all the time.
  • Short lines are much easier to work with than long lines, but sometimes, when you're dealing with definitions of bit masks and such, it's much more readable to have long lines that are aligned like a table than short lines that happen to fit (with equal signs all over the place).

@orbitbot

If you're going to borrow, then at least retype, you'll end up with a better understanding of what's going on (and you might end up being able to type faster after a while :wink: )

That's actually part of it. (The former, not the latter.) That's part of why I avoid copy/pasting others' code. (Also, you never know if there's a bug in it if you aren't inspecting it as you type it in, which is easy to not do when you just copy/paste it in.)

Patrik Johnson
@orbitbot
Jan 25 09:20
also f.e. go enforces a specific syntax, IIRC your code won't be possible to compile if it doesn't adhere to standard form
(which is extremely inflexible)
Isiah Meadows
@isiahmeadows
Jan 25 09:24
Yeah...thanks for adding to the list of reasons why I have little-to-no interest in Go.
Patrik Johnson
@orbitbot
Jan 25 09:25
:)
Barney Carroll
@barneycarroll
Jan 25 09:53
I don't like universally enforced style guides either @isiahmeadows
Which is why personal IDE side procedural transforms are useful.
To a degree. Once a nested expression has been transformed into temporary references and a bunch of statements and assignments it becomes harder to transform it back into the more expressive style.
Isiah Meadows
@isiahmeadows
Jan 25 09:56
I'd just rather type it out. It may take a bit longer, but you still get the actual point of the code.
Barney Carroll
@barneycarroll
Jan 25 09:57
But to a large degree, JSX v Hyperscript is a developer preference that needn't be dictated universally. I can read it as JSX, your IDE can read it as Hyperscript.
Isiah Meadows
@isiahmeadows
Jan 25 09:57
As for factoring out a nested expression into statements, I see it as more of an issue with the language that you can't go between the two easily rather than a thing that could conceivably be seen as opinion.
Patrik Johnson
@orbitbot
Jan 25 09:57
might as well just commit ASTs and have the IDE figure it out :P
Isiah Meadows
@isiahmeadows
Jan 25 09:58
As for templating languages... @orbitbot why do you have to beat me to it?
Patrik Johnson
@orbitbot
Jan 25 09:58
or, ya know, lisp, which is more or less the same thing.
Isiah Meadows
@isiahmeadows
Jan 25 09:58
:stuck_out_tongue:
Patrik Johnson
@orbitbot
Jan 25 09:58
it's all the retyping practice I get, fleet fingers ;)
Isiah Meadows
@isiahmeadows
Jan 25 09:58
@orbitbot I'd personally prefer templating languages to be ASTs internally, where the IDE is merely a front-end.
Some people do well with drag/drop interfaces. Some people do well with JSX. Some people do well with JS.
I've witnessed similar with languages, although ironically to a lesser extent...
Patrik Johnson
@orbitbot
Jan 25 10:00
yeah, I guess the problem with these kind of things is that you'd probably end up with random and subtle bugs where the IDE to AST implementation isn't perfect, and then people have to be able to read ASTs to figure out wth is going on...
in the same way that you can only get so far with all these "compile to" languages until you have to understand the target language and it's idiosyncrasies as well
Isiah Meadows
@isiahmeadows
Jan 25 10:01
That's akin to a bug in LLVM, as opposed to Clang.
Barney Carroll
@barneycarroll
Jan 25 10:02
Full circle: the IDE is a front end for code
Isiah Meadows
@isiahmeadows
Jan 25 10:02
But at a higher level, consider the vast number of proposed pretty-printing formats for WebAssembly, ranging from type-inferred expressions to basically stack machine instructions.
Also, there's a reason C decompilers exist. (They're not all that complex until you get to self-modifying code and the like.)
But you can take the concept to a higher level to say, an AST.
(Consider OCaml vs Reason as a good example of this - they are mostly the same language apart from syntax.)
(That's a mild lie: both share the same pre-bytecode IR, but not the initial parse tree.)
But I know there's ways.
Barney Carroll
@barneycarroll
Jan 25 10:12
Yes, it's not black and white
But I think in a few ways enabling such changes as can be done procedurally might shed insights
James Forbes
@JAForbes
Jan 25 10:57
@rishavs interesting. Yeah I agree with @orbitbot but I also see sense in that point of view. I found that if I rewrite everything in a tutorial, or when researching online I get so much more out of it and it stays in my memory. I think it probably depends on the task you are working on though. If you have a design team that happens to spit out HTML prototypes, maybe then it makes sense? Or if you are porting an old server rendered stack to be an SPA that could make sense too.
Yatekii
@Yatekii
Jan 25 11:37
hey folks, how would you detect that a copy paste has taken place on an input field? :S
TL;DR: use onpaste on your <input>, and it's available in e.clipboardData.getData("text").
(Remember to use e.preventDefault() if you don't want text to actually be pasted.)
Yatekii
@Yatekii
Jan 25 12:02
hmm the posts I found suggested it's IE only, so I wasn't sure
ty
James Forbes
@JAForbes
Jan 25 12:07
Out of interest, what's the usecase?
Yatekii
@Yatekii
Jan 25 12:38
@JAForbes I have a multiselect (textinput with pills for verified items) in which I want to paste a list of items (separated by spaces, commas or newlines) and automatically verify them ...
Dominik Dumaine
@Bondifrench
Jan 25 12:40

Hello smart devs, do you know why this in CSS displays a circle:

div {
  width: 200px;
  height: 200px;
  background-color: black;
  margin: auto;
  margin-top: 20vh;
  border-radius: 50%;
}

like in this demo,
but when I try to implement the same in Mithril it doesn't show anything, demo here

Yatekii
@Yatekii
Jan 25 12:41
also, does anyone know what the overhead of dereferencing an attribute is? I mean that can't really be optimized right? since it's dynamic ...
Arthur Clemens
@ArthurClemens
Jan 25 12:42
@Bondifrench vnode.dom.animate is not a function
Dominik Dumaine
@Bondifrench
Jan 25 12:43
@porsager I don't know if you were aware, but there is actually a web animation API with animate() function
Arthur Clemens
@ArthurClemens
Jan 25 12:43
and your style object is broken
Dominik Dumaine
@Bondifrench
Jan 25 12:43
Arthur Clemens
@ArthurClemens
Jan 25 12:43
borderRadius is now outside of it
not in Safari
so you need to provide a polyfill
Dominik Dumaine
@Bondifrench
Jan 25 12:44
true, it is so far only in Chrome and Firefox
Arthur Clemens
@ArthurClemens
Jan 25 12:45
Dominik Dumaine
@Bondifrench
Jan 25 12:47
Thanks, I actually had tried, to put everything in the style object, for some reason, it didn't work previously
James Forbes
@JAForbes
Jan 25 13:00
But why listen for paste specifically and not just input/change? @Yatekii
Yatekii
@Yatekii
Jan 25 13:01
@JAForbes I figrued it's easier to do this way :) because it would automatically convert. with input it will just convert if you select an item from the list (can be done with click or enter (arrows can strafe the list))
James Forbes
@JAForbes
Jan 25 13:04
oh I mean, won't pasting trigger an input event?
Sorry that was my assumption I actually have no idea
wait I see the benefit I think yeah
Yatekii
@Yatekii
Jan 25 13:07
@JAForbes nah I didn't want it to trigger an input event :)
Isiah Meadows
@isiahmeadows
Jan 25 14:20
@Yatekii I'd just do the verification in onpaste, and set the value accordingly in the <input>.
cavemansspa
@cavemansspa
Jan 25 14:28
ot: ui/ux -- any opinions on full screen loading mask vs masking just the action (i.e. just show loading mask on button)?
Barney Carroll
@barneycarroll
Jan 25 14:39
I would just mask UI elements that have no actionable result during loading
cavemansspa
@cavemansspa
Jan 25 14:50
i'm thinking it get's kind of funny looking when you have several buttons that you temporarily mask during a loading op. where you don't want any other actions taken until the one completes.
prob in that case full mask, but in other cases just mask the single element. guess it's a "depends on" question... :)
Barney Carroll
@barneycarroll
Jan 25 14:52
Depends, I'd like to be able to escape / return, show / hide meta data
James Forbes
@JAForbes
Jan 25 14:52
In my app, we have a details pane. We disable a section relevant to an action but not other panes.
Barney Carroll
@barneycarroll
Jan 25 14:53
I was for some reason thinking in the context of media playback
James Forbes
@JAForbes
Jan 25 14:53
yeah this is data entry file uploads and stuff
Barney Carroll
@barneycarroll
Jan 25 14:53
As central content of the current step
James Forbes
@JAForbes
Jan 25 14:53
where you can save different things
cavemansspa
@cavemansspa
Jan 25 14:53
yes, section masking is prob a nice mix
Barney Carroll
@barneycarroll
Jan 25 14:53
Yeah
James Forbes
@JAForbes
Jan 25 14:54
yeah I played with it a lot, disabling individual elements feels ok until you have several disabled on page at once in close proximity
it was also just practical, we make sure anything that's disabled explains why it's disabled
disabling an entire context means you only need to do it once
Yatekii
@Yatekii
Jan 25 14:55
@isiahmeadows that's exactly what i'm doing
cavemansspa
@cavemansspa
Jan 25 14:56
sounds good @JAForbes / @barneycarroll -- that was easy. :)
James Forbes
@JAForbes
Jan 25 14:56
:thumbsup: but who knows, in another app that may not work at all :D
Barney Carroll
@barneycarroll
Jan 25 14:56
When you're talking about the primary entity of the current restful state, it's desirable to highlight the few pieces of data & actions that aren't dependent on the principle stuff loading. If it's a contextual part of a wider UI, then that's confusing – you're seeing this thing appear half-formed and highlighting the least relevant information points
James Forbes
@JAForbes
Jan 25 14:57
yeah
disabling sections draw a lot of attention to itself sort of ironically, and sometimes you might not want to do that. It can make a small action seem like a major action.
I can't wait til we get to a point where there is no (or almost no) concept of saving
cavemansspa
@cavemansspa
Jan 25 14:58
in some cases saving some data on backend can result in the whole page changing e.g saving a "new" thing turns the page into "update" thing on a successful save.
James Forbes
@JAForbes
Jan 25 14:58
it feels so 90's
Isiah Meadows
@isiahmeadows
Jan 25 15:02
I want to like the whole idea of implicit saving, but I feel it's still not optimal for some things, like important actions where you don't want to screw up just by typing a wrong thing. I always end up using it with the concern that erroneous data is going to end up saved when I didn't want it to be saved, especially when the control in question is a text input.
If it's persistent, I feel locking/unlocking might be better in some circumstances, while if it's not truly important, if it doesn't require text, auto-saving is fine.
James Forbes
@JAForbes
Jan 25 15:05
Yeah I think implicit save has to be coupled with infinite undo
we're starting to use append only lists for some parts of the site and I'm thinking of trying it there, datomic style
it's my latest postgres experiment :D
materialized views as an accumulation of micro writes that leads to fast fetches of complete records
then you get undo because its basically like what redux/meiosis does but on the server
Isiah Meadows
@isiahmeadows
Jan 25 15:09
Or, to put it another way:
  • If it's like filling out a tax document/payment form, it should be a form in every sense of the word. This includes when you're putting in card info for online purchases.
  • If it's a set of important switches, it should be guarded with a lock (saved when locking) like in a breaker box. You shouldn't be able to edit it by default, but you need to still be able to see it's there. (Apple did this right with their system settings.)
  • If it requires actual text input of some sort, it should be guarded with a save mechanism, but ideally only really for the control in question (and not for the whole thing).
  • If it is just a bunch of unimportant switches/toggles (that are easy to revert), it can just be auto-saving.
Infinite undo/redo is more domain-specific, and settings changes only really belong to it if it's actually useful. (For example, if things could catch fire, it'd be helpful to save the previous state to see if that can fix whatever issues are at hand. Also, in this particular case, you'd want it behind a locking mechanism as well, to prevent accidental mistakes.)
James Forbes
@JAForbes
Jan 25 15:12
Yeah I disagree respectfully :D
the padlock thing in settings drives me up the wall
And save doesn't necessarily mean apply
so the web is kind of different
I mean I half agree. I think there's times where auto saving doesn't work, but its exceedingly rare. And even then there's usually a design trick or two you can use to make it work. But you are right, there are times where it's not good.
Isiah Meadows
@isiahmeadows
Jan 25 15:16

And save doesn't necessarily mean apply

Example?

James Forbes
@JAForbes
Jan 25 15:17
E.g. you're writing a long gitter comment and they decide to refresh the page and you haven't submitted your post yet.
When it refreshes, your comment should be right where you left it, unsubmitted.
Which is sometimes the case on gitter, sometimes not
I'd love it if git just sent all my stuff to origin in little packets all the time. And then I commit, but I never push.
I have this weird phonetic typo thing I keep doing
Isiah Meadows
@isiahmeadows
Jan 25 15:20

That's actually possible to do, just it requires a degree of batching and frequent syscalls.

As for Gitter not saving comments, that's dumb - you could literally store that in localStorage and just pop it back out. That's the cheapest way of doing it. (No excuse for that kind of bug.)

James Forbes
@JAForbes
Jan 25 15:20
Yeah I think they do it, but it's flaky
Isiah Meadows
@isiahmeadows
Jan 25 15:20
But you could do that with Git, have it auto-push.
James Forbes
@JAForbes
Jan 25 15:21
Another example just came to mind is nix and how it uses symlinks
Isiah Meadows
@isiahmeadows
Jan 25 15:25
As for Gitter, if it's flaky, they're seriously screwing up. It should be as simple as this + calling them in the view on input:
const backupChat = _.debounce(({text, multiline}) => localStorage.chatState = JSON.stringify({text, multiline}), 500)
const restoreChat = () => {
    const chatState = localStorage.chatState
    delete localStorage.chatState
    return chatState != null ? JSON.parse(chatState) : undefined
}
James Forbes
@JAForbes
Jan 25 15:25

When you upgrade your deployment, it doesn't copy all your files in place. It leaves the old deployment running but symlinks your new deployment on top of it. Because of how symlinks work, old handles for the existing files are retained, but the new deployment can begin. If it has no issues, the symlinks become hard links. But if it fails, your old app keeps on chugging along. Next time you deploy, it has already aggressively cached the previous deployment so it doesn't need to build each layer from scratch. I don't know if layer is the right term in nix world.

Or even things like software updates, I remember when we cared a lot more about latency and an app would be like "There's an update available". And then it would close your app and spend an hour downloading the new version. And now it's already downloaded these days, and it's a restart. In some apps, restarts aren't even acceptable anymore. E.g. hyper just patches the live app with new code.

So separating apply and save is great ux I think
Isiah Meadows
@isiahmeadows
Jan 25 15:26
@JAForbes Okay...I meant applying, not saving. (I do get there's a difference, I was just using "saving" slightly incorrectly.)
(Apologies for initially missing that.)
James Forbes
@JAForbes
Jan 25 15:26
yeah sorry
nah it's cool
so what's so fascinating about infinite undo is... apply and save sort of blurs
in a lot of use cases
Like, if I can always undo non destructively, what even is "apply" except the latest snapshot.
Isiah Meadows
@isiahmeadows
Jan 25 15:29
I agree, but it's not for everything. Not everything can be meaningfully undo'd, and other things make more sense to undo in batches rather than individually. (In particular, where I'm working on a language, that's come up.)
James Forbes
@JAForbes
Jan 25 15:29
And when we're snapshotting entire operating systems now we've got to the point where it sort of does apply almost anywhere.
Yeah definitely
Usually can't undo stuff that integrates with the physical world for example
But it really is applicable in so many cases now when you separate apply and save, and have infinite undo. Cases where it previously would have made no sense.
Isiah Meadows
@isiahmeadows
Jan 25 15:31
(Note: my language will eventually have reversibility built-in, so I've already had to start looking into how to best compose those. And since I plan to support things like reversible stream transforms, where functions are merely a special case, I'm having to look into category theory at this point.)
James Forbes
@JAForbes
Jan 25 15:31
undoing in batches is a great point
and identifying batches can be hard
I think you can sort of flatten your states the further they are into the past
in a lot of cases
but in some cases that's not enough
Barney Carroll
@barneycarroll
Jan 25 15:35
Interesting
Isiah Meadows
@isiahmeadows
Jan 25 15:37
@JAForbes That is true. You can flatten some of them. But that requires a lot of awareness about the nature of the action. In particular:
  • If the action was pure and did not modify state, it's sometimes better to just do it in reverse. (The mathematical term for this is "isomorphism".)
  • If the action modified state, it's usually better to retain the old state.
  • When batching actions, you have to be aware that some actions can just be done in reverse, while others require state to remember the action. It's also sometimes better to do things one at a time (particularly when one undo depends on another), while other times, it's better to apply the undos in parallel (like if it requires firing network requests).
It's one of those things that sounds simple, but in practice really isn't so much.
Barney Carroll
@barneycarroll
Jan 25 15:38
See it's funny, this is what I thought Redux-Saga was about
James Forbes
@JAForbes
Jan 25 15:38
yeah exactly
Yeah and Calmm.js which is a lens + observable framework is all in on this too
like it uses iso's eveywhere
Isiah Meadows
@isiahmeadows
Jan 25 15:39
Redux's redux-undo is very terrible at over-simplifying the model, and most everyone has that problem to some extent.
Barney Carroll
@barneycarroll
Jan 25 15:39
Tooling to associate state snapshots with IO callbacks so that you could retro-patch old state or slice off states from a no-longer-pertinent history
James Forbes
@JAForbes
Jan 25 15:39
yeah I think you need a specific undo model for each problem domain
and one way to model that is with an iso lens
but that doesn't cover batching
but observables can model that
Isiah Meadows
@isiahmeadows
Jan 25 15:40
In particular, the issue with doing it via a typical Iso(run, undo) is that it fails to recognize that some undos require state.
James Forbes
@JAForbes
Jan 25 15:40
so it's an interesting cross section
meiosis is by complete accident a lot like calmm
I remember @foxdonut in their gitter exchanging notes and it was so interesting
Barney Carroll
@barneycarroll
Jan 25 15:42
I like Meiosis because it doesn't try to over-formalise intent
James Forbes
@JAForbes
Jan 25 15:42
same
Isiah Meadows
@isiahmeadows
Jan 25 15:43
One example of where you need state to properly perform an undo is when any of the parameters are time-dependent.
James Forbes
@JAForbes
Jan 25 15:43
yeah true, that's why observables are a great fit for that part of the puzzle
( I've given up and I'm using the word observables now :D ( even though I think it's the worst term ) )
Isiah Meadows
@isiahmeadows
Jan 25 15:46
Another is when it's not one-to-one to its output (and this is the more general case when you require state to undo with). If it's not one-to-one with its output, you have to have state to know how to undo it. If it is one-to-one, you can just do the action in reverse without issue.
For example, if your action was moving an item across a 2D space, undoing it requires knowing where that item was, since you could've moved it from anywhere to its current position.
James Forbes
@JAForbes
Jan 25 15:48
scan helps there
Isiah Meadows
@isiahmeadows
Jan 25 15:49
True, but how do you undo a scan?
Or equivalently, a reduce?
(From a theoretical standpoint, they both have the same caveats.)
James Forbes
@JAForbes
Jan 25 15:53
you store the pair of states as a snapshot
so undo is just re-running the reducer with that pair
oh you mean higher level
another scan? :D
QED
Isiah Meadows
@isiahmeadows
Jan 25 15:57

so undo is just re-running the reducer with that pair

I hope you meant "running the opposite reducer"...

(or something to that effect)
James Forbes
@JAForbes
Jan 25 16:02
no, like say we're adding numbers (0, 1) (1, 2) (2, 3) and we feed those inputs in to x + y, if we're currently at (2, 3) and our output is 5, but we want to get back to our previous result, we just run the same reducer with the old data: (1,2) which comes out with 3
so if it's a 2d game, it's the same thing. the left is the world state, the right is the action
if we want to undo the player state, we just re-run the reducer with the previous snap shot
Isiah Meadows
@isiahmeadows
Jan 25 16:06
Except you can't usually trivially serialize the entire world state. That would eat up memory in a hurry, if not CPU as well. Note that I'm referring to just the action, not the render loop. (That can do its thing independent of the world state.)
It'd be much more efficient to just move things in reverse, basically multiply the time by -1.
Fred Daoud
@foxdonut
Jan 25 16:10
@JAForbes but if 1 is the state and 2 is the action and 3 is the next state, why not just go back to the 3 state directly instead of going back to the 1 state and re-running the reducer to get 3?
James Forbes
@JAForbes
Jan 25 16:10
there's ways to make it efficient, and yeah if you can use an iso for a lot of problems but you specifically posited a problem where you can't :D
See this is a great point @foxdonut :D
until you want to edit the past I guess
but even then that can work depending on how you design it
Fred Daoud
@foxdonut
Jan 25 16:12
For example --- and this is dev-only so no effort has been made for production-level performance or memory usage --- I think redux devtools replays actions through reducers. But, in the meiosis tracer, I just time-travel through snapshots of state, and re-render the view since view = f(state)
James Forbes
@JAForbes
Jan 25 16:12
Yeah that's great
Fred Daoud
@foxdonut
Jan 25 16:13
and that's why you can just type in or paste in a state in the textarea :)
James Forbes
@JAForbes
Jan 25 16:13
I think it depends
say you've got a big output but tiny inputs
Isiah Meadows
@isiahmeadows
Jan 25 16:14
@JAForbes Note: when you do the thing in reverse, you still need state to know how to do it in reverse - you have the end result, but knowing the arguments allows you to calculate how it was supposed to be undone.
Fred Daoud
@foxdonut
Jan 25 20:19
image.png
^^ no editing was done on this book I guess, lol
(I did "Look Inside" here)
Arthur Clemens
@ArthurClemens
Jan 25 20:23
yeah, that is hopeless
Scotty Simpson
@CreaturesInUnitards
Jan 25 20:55
holy jebeezus
Gilbert
@gilbert
Jan 25 20:57
that's definitely foreigner grammar
Scotty Simpson
@CreaturesInUnitards
Jan 25 20:57
heehee
love it
Fred Daoud
@foxdonut
Jan 25 20:59
I am not knocking people for whom English is not their first language, and I admire their efforts! But, a published book should not force the reader to "parse" through incorrect grammar to figure out the content.
What I just wrote is probably incorrectly structured as well =P
Gilbert
@gilbert
Jan 25 21:01
yeah, nothing wrong with non-native English speakers, but if you're publishing a book you really should hire an editor
Fred Daoud
@foxdonut
Jan 25 21:02
for the record, I learned English as a second language..
I agree @gilbert
Barney Carroll
@barneycarroll
Jan 25 22:00
I think this was written by a native Slav, the thing that is jarring is the lack of indefinite articles
It's totally grammatically coherent, but the lack of 'the', 'a', makes it look weird.
Less keywords, more expressions!
Anybody here with experience of programming languages not predicated on English?
Gilbert
@gilbert
Jan 25 22:05
I'd be curious to hear about that as well
Barney Carroll
@barneycarroll
Jan 25 22:08
I'm currently unaccountably obsessed with the received wisdom of avoiding 'arcane' logical operators in favour of 'if' statements
Gilbert
@gilbert
Jan 25 22:09
what do you mean?
spacejack
@spacejack
Jan 25 22:09
The ternary is very advanced stuff
Barney Carroll
@barneycarroll
Jan 25 22:09
Yes, exactly @spacejack
spacejack
@spacejack
Jan 25 22:10
Don't expect the typical enterprise dev to know how to use it
Barney Carroll
@barneycarroll
Jan 25 22:10
Temporarity, conditionality and forms of address are much richer in other languages on a low level
spacejack
@spacejack
Jan 25 22:11
what do you think of the new do expression?
Barney Carroll
@barneycarroll
Jan 25 22:11
I'm disappointed
spacejack
@spacejack
Jan 25 22:11
haha why am I not surprised
disappointed because the ternary is good enough or something about the spec?
Barney Carroll
@barneycarroll
Jan 25 22:13
The proponent, Kyle Simpson, is a genius who figured out plenty of wonderful stuff in isolation and never got proper recognition. He then went on to teach kids Javascript in volume and became obsessed with his observations of lowest common denominator
More labeling, more keywords, keywords to recondition the internal semantics of nested statements…
Because you see the average person just doesn't understand ?
spacejack
@spacejack
Jan 25 22:15
do allows you to create blocks of code within though
(I think... been a while since I read about it...)
Barney Carroll
@barneycarroll
Jan 25 22:15
Yes
But the semantics of what any given block means in isolation is thereby ambiguous
spacejack
@spacejack
Jan 25 22:16
So if you're thinking more pure/functional, you might replace if with do
Barney Carroll
@barneycarroll
Jan 25 22:17
It's similar to the way arrow functions gave these firm lexical restraints but then classes wanted hard-bound this so that was also ambiguated
Gilbert
@gilbert
Jan 25 22:18
reasonml has do blocks :)
let fontsToLoad = {
  let dict = Js.Dict();
  dict.set("x1", "y1");
  dict.set("x2", "y2");
  dict
};
code from my react native learning project
spacejack
@spacejack
Jan 25 22:19
I see arrows as a nice shorthand and useful when I must use classes (it is inevitable that you sometimes must use classes in JS)
I like them for anonymous functions especially
Barney Carroll
@barneycarroll
Jan 25 22:19
do in JS is a way to use more language to achieve what the simplest and least ambiguous logical operators allowed in the first place, but with more footgun room
spacejack
@spacejack
Jan 25 22:19
Prefer function for named functions though. And hoisting.
hah
I dunno... I feel like having multi-statement blocks with scope for temp variables might be useful.
Barney Carroll
@barneycarroll
Jan 25 22:20
Hoisting yes, convenient recursion too. But the simplicity and lack of external considerations in arrows is a blessing
Temp variables everywhere :(
spacejack
@spacejack
Jan 25 22:22
yeah well... better than temp variables and non-expression if blocks?
Barney Carroll
@barneycarroll
Jan 25 22:29
Haha
It definitely offers more room for expression
Where previously you would have constrained yourself to a question mark and a colon and a few evaluations now you can throw in a delete statement and maybe a return too! The gates are thrown open.
Definitely powerful, and it will stand out more when reading code in an IDE
Thinking about proposing wherefore to TC-39 ;P
Barney Carroll
@barneycarroll
Jan 25 22:36
You're right though, it allows less references while still retaining big keywords and total freedom within brackets
Oof. I'm going to bed and not touch the internet for 3 days. Good night everyone! Have a good weekend. I'm going to Whitby.
Gilbert
@gilbert
Jan 25 22:41
have fun :)
cavemansspa
@cavemansspa
Jan 25 22:54
is multiple transition-duration problematic? this flems does not transition the background color at a different duration.
Gilbert
@gilbert
Jan 25 22:55
@cavemansspa It working, but the transition time is 5s instead of .5s so it's hard to tell
cavemansspa
@cavemansspa
Jan 25 22:57
i don't think it's transitioning the background for 5s.
Gilbert
@gilbert
Jan 25 22:57
it is, at least for me. Try closing it, waiting 5s, then opening it again. You should see the background color fade in
cavemansspa
@cavemansspa
Jan 25 22:59
ha! -- i see... if you click too quick it's transitioning before finished.