staltz / ama Goto Github PK
View Code? Open in Web Editor NEWThis project forked from aviflombaum/ama
Ask me anything!
Home Page: https://blog.sindresorhus.com/answering-anything-678ce5623798
This project forked from aviflombaum/ama
Ask me anything!
Home Page: https://blog.sindresorhus.com/answering-anything-678ce5623798
I hope it's also okay to post "philosophical" questions about Observables here.
I searched the internet but couldn't think of any more "philosophical" programming thinking about observables.
Observables can, right now, emit an "complete" event, when they are not going to emit any value again. It's justified in this video (https://www.youtube.com/watch?v=sTSQlYX5DU0&t=1717s) with the reasoning "We make an observable of peoples qoutes, but people can die, so then they are "completed"". I don't see why it is a vital part of an Observable, however. "alive" or "death" are both states of a person, which would make for a good "personLifeState$".
Why is it, that in all the tutorials I see online, and observable is explicitly not described as "Something that can emit values/change over time", but "Something that can emit values/change of time, and can complete too".
In thinking about the relation between observables and signals, and the different kinds of Observables, I sometimes hit a problem I could get around by ditching the necessity of "complete" on observables, so I figured I would need some more knowledge about why we need it :)
Thank you 😃
Hi Andre,
We have recently built a phone system using Twilio, our tech stack was React, Redux and Redux Saga. The app it's self is a mixture of API calls to a backend and websockets pushing data into our apps via middleware, which then dispatch redux actions. Depending on the data coming in from the websocket, drives what the UI looks like.
We didn't really follow design patterns when building the app, and in turn I feel it could of turned out better. (Lots of if statements and case statements in multiple components, strange errors due to state not being in sync etc) Looking at the reactive programming concepts maybe this would be a good fit for our app (Our app basically reacting to the new data passed to it from websockets, and then calling HTTP endpoints based on the users actions)? Would you agree?
Do you have any good ideas of refactoring from a big ball of Redux code to nice clean streams?
Hi Andre,
Context
Reactivity.. streams.. pushing effects to the edge of our apps, these concepts really talk to me. My gut feeling is that this is how I should be building web apps.
I tried Cycle.js last year and really liked it but I didn't feel I was very much productive. Also, last year there weren't many routing library (that I liked), but I saw that there is one on cycle-community.
My question is:
My question has two parts..
What habits should I develop to think of an app majorly in terms of streams and is there a line to draw?
The second part of my question is in reference to your talk at GOTO 2016 in November. You said that Cycle.js wasn't good for call-and-response mechanisms, for example HTTP requests. My real question here is probably more about: is it reasonable to think of streams everywhere or did you sometime have to tell yourself "Okay whoa.. this isn't working".
Thank you!
Thanks!
One big question that comes up often when discussing with folks about Cycle.js is the separation of writes/reads via drivers. A familiar example of Cycle's reactive loop:
function main(sources) {
const response$ = sources.HTTP
.select('foo')
.flatten()
.map(response => response);
const request$ = xs.of({
url: `https://api.github.com/users/foo`,
category: 'foo',
});
const sinks = {
HTTP: request$
};
return sinks;
}
When I show colleagues/friends this example they're immediately struck by the idea of having the request happen after the response in the program's natural reading flow. To me this makes programs more declarative, but others are willing to argue that reactive streams are declarative even when used in this way:
const fetchUserEpic = (action$, store, { getJSON }) =>
action$.ofType('FETCH_USER')
.mergeMap(() =>
getJSON(`/api/users/${payload}`)
.map(response => ({
type: 'FETCH_USER_FULFILLED',
payload: response
}))
);
To me however, even though this function is referentially transparent, the chain of observables will still cause a side-effect midway. The fact that it happens midway is what makes it more imperative in my opinion.
Apart from this declarative vs imperative discussion, I was wondering what do you think is the biggest advantage of not mixing flows that cause writes/reads, but rather separate them using drivers.
In other words: what are the pros and cons of the two snippets of code above?
Hi,
If you could write a topic in a book like "97 Things Every Programmer Should Know", what will you say ?
Basically, what is your personnal recommendation for doing our job.
What do you think about Solid, Tim Berners-Lee's new decentralized web project?
How does it compare to peer-to-peer technologies like SSB and Dat? Are they in direct competition or can they complement each other?
It seems like most of the spec assumes the functions to be highly polymorphic even then i think it could easily be modelled using typescript.
There is a nice blog by @staltz about "why all js libraries should be authored in typescript" :D
https://staltz.com/all-js-libraries-should-be-authored-in-typescript.html
You come from the former gb, doesn't you? :)
You are brazilian, even not living there I think you are aware of the Bolsonaro campaign. What's your opinion about him and his ideas?
If you had to choose one language or library of the past or present development, what one would you choose? Cycle.js is not eligible. 😋
André, I was thinking about how we could achieve a visual programming language with high debuggability and pretty visualization of events/signals flow, and came across https://noflojs.org/. I haven't tried (yet) to build some kind of integration with Cycle.js, but I think that this is possible, and maybe, could be integrated with a babel-parser to read existing code and babel-generator to keep source code in sync with NoFlo graphs.
Maybe this could contribute to cyclejs/cyclejs#579 and an idea that I registered on cyclejs-community/cyclejs-community#12.
What do you think about this?
Do you recommend any particular resources/projects/technologies/languages to invest time in with regard to decentralization? I find it a difficult topic to learn about as many concepts are foreign to me as simple web developer 😅
I'm asking for books/articles/insights or virtually any type of information (besides actually writing code) that you think is important to develop that kind of thinking, specifically intended for imperative/OOP style developers, if it helps to form your answer.
Thanks 😇
(This is less of a technical question and more about the way you think about the problem you are solving. It is motivated by my own Android app, in which I am using my own AHISBRIOHO* cycle.js and in which I am having trouble deciding whether to favor conceptual purity or a pragmatic approach.)
When I am modeling a problem with RxJava, I tend/prefer to think of Observables as some state varying over time, i. e. a Behavior. However, most sources are certainly Events (clicks, network responses, etc.) and sinks can be either, depending on whether I am using some "virtual DOM" library like Anvil or whether I have to produce imperative output, e. g. by controlling ExoPlayer through method calls. (In some cases all it takes a renaming to go from Event to Behavior, e. g. HIDE
/SHOW
vs. GONE
/VISIBLE
).
So, when writing stuff in cycle.js, do you keep a strict separation of Events and States or do you interpret the Observables in whatever way best suits the situation.
Thanks for any thoughts!
*
Ad-Hoc, Informally-Specified, Bug-Ridden, Implementation Of Half Of.
Hi Andre,
I've been following your work for a while and I can't overestimate how much value I get just by watching what you're up to and by reading your opinions on twitter re decentralisation and JavaScript in particular. Especially in the times when everything is bloated, low quality and so on.
There's one thing I find myself struggling to settle on is TypeScript vs JavaScript and OOP vs FP. As someone who've put a lot more hours in the craft, would you mind giving your opinion on why you prefer TypeScript to JavaScript. And also your view on the place of OOP in JavaScript ecosystem and the particular reason you use this approach in your own work.
Thanks in advance.
Maxim
Hi Maxim! Thanks for asking, if you don't mind, I'll answer here because it's publicly-useful information to share.
About OOP vs FP, I highly recommend checking a talk I gave in 2017, my opinion is still pretty much the same. In summary: there is no clear definition of "OOP" and no clear definition of "FP". Instead, there are 5 properties that sometimes OOP languages have or sometimes FP languages have:
This is a topic I could write a lot about, so I'll be brief:
Types is a big topic, but I nowadays believe that you don't need strong types (Haskell, PureScript, etc), but you shouldn't also do zero types (plain JS). I did some Haskell hobby project once, firmly believing it would be awesome for my productivity, and honestly after the project was done I felt underwhelmed with Haskell. I still had to do "runtime debugging", which was one the things I thought Haskell would shield me from.
Types are good when they help you from shooting yourself on the foot, like to avoid typos, or avoid using an API the wrong way. But too much types can kill your productivity (you end up focusing on precisely categorizing everything, which is a tangent to getting things done), can lead to confusing code (Haskell docs are famous for describing functions with 3 words from Category Theory), or in general types can restrict how much freedom you have while experimenting with code and building proof of concepts. My experience with Rust has been more positive than with Haskell, but Rust still restricts you from building proof of concepts and experiments. FP programmers tend to overemphasize correctness and verifiability, and de-emphasize experimentation and playfulness, which is very important. Programming is a flexible activity. Sometimes it's hard engineering (like if you're implementing a well-specified algorithm), sometimes it's art (like when you're building something that you're not yet sure what it is, you're discovering the goal while you are building it). Some languages favor one kind, other languages favor others.
What I like about TypeScript (and I absolutely choose it over JavaScript almost every single time) is the any
type, because it allows you to choose how strict types you want in your project. You can be light on types (using loose configurations in tsconfig.json
) and use any
whenever you want, or you can go strict (in tsconfig.json
) and refrain from any
as much as possible. Both of these approaches have their merits depending on what you're building (see paragraph above). I think it's a misconception that people have that TypeScript necessarily requires you to be very strict about all the types. But in reality, TypeScript is a gradient, you choose how strict it should be. And more often than not, even if you're building a creative proof-of-concept, you definitely want to shield yourself against silly mistakes such as typos, or using String functions on things like numbers. Who wants to lose time debugging those kinds of mistakes? So I would use TypeScript almost always, if the decision is up to me. This doesn't mean that I have to strictly type everything when I'm using it.
The one reason when to use JavaScript is when you want to avoid a build step, e.g. when you're writing inline JS inside HTML. But that's not so common nowadays.
Hi, andrestaltz! I hope you don't mind me DMing you. I'm wondering how can I help in the future with helping out solve the internet's centralization problem. Do you maybe have some links / suggestions where to start? I'm thinking about how to start giving back the community and this area is one of those where I could see myself in a couple of years.
Hi ${name}
! That's wonderful to hear.
It's a problem that's very large, so I suggest joining a group of other people working on it, and helping that group make a meaningful mark on the internet. Of course, you could also work alone if you are convinced you found a new approach and can make progress on that approach by yourself.
The following links and projects are ones that I keep an eye on and I believe they could/would succeed in making the internet more decentralized.
There are also several crypto(currency)-related projects that have a probability of becoming new infrastructure for the internet, but I don't follow that space very well (because too often there is "noise", either it's hard to figure out what the project is doing, or they're not committed to decentralization in the long-term, or they're too focused on money making, or a combination of these). You will have to ask someone else who follows that space closely and knows how to find the promising and unassuming projects.
Regarding what to do within those projects, I can only speak about SSB since I'm familiar with its current status.
If you're a UI developer, there are plenty of issues open that would accept contributions, and overall themes on our roadmap that need design and implementation.
If you're a systems developer, we need help with extensions to the protocol. Some ideas are written down here: SSB Roadmap.
If you're a Node.js developer, we need help with ssb-db2, implementing private groups, and SSB in the browser.
Hope this gives you some thoughts on what to do!
The only resource i find on the internet is https://shellmonger.com/2016/03/11/creating-javascript-libraries-with-typescript-and-webpack/. Having more resources for mere mortal to be able to do so might increase the number of JS libraries authored in Typescript. Thanks!
... and a question that must be asked with it: Do you think copyright is wrong?
Secretly, I wish for a debate, but this question isn't written with the intention of one; I'm just curious about your opinion. But if you do welcome a debate here, I'd be more than willing :-) (I'm not that hopeful, though).
Hi Andre,
Considering your recent efforts around scuttlebut and decentralized networks, I would like to hear your thoughts about Blockstack and the ideas presented in this talk from Larry Salibra (one of the members), specially around blockchains scalability and how to make all this decentralization a real thing for day-to-day.
Thanks.
Have you ever felt discouraged when doing opensource?
Like if someone says "Oh Cycle.js is good, but everyone use React/Vue and why should I use Cycle." Will you feel discouraged?
I do opensource too, but few people use them. I always feel discouraged because it makes me feel what I did is not useful.
How do you think of it?
Hi,
once again I have come here to ask about your thought process or design guidelines when writing cycle/MVI/nested dialogue programs. I have asked the same question a few months ago on Hannes Dorfmann's blog post about MVI so I am going to mostly repeat it here:
I'm currently doing a lot of stuff for AndroidTV and FireTV - and I am having trouble integrating the remote input on these devices with a MVI/cycle.js-ish architecture. I think it's fair to say that a screen interface always has some "implicit state" that controls which signals/intents it can send at any given moment: some Buttons may be disabled, EditTexts may be hidden, etc. On the remote, of course, any button can be pressed at any moment, but its meaning may vary with the current (UI-)state: Play/Pause may normally toggle video playback, but when seeking it may be used to confirm the new position and restart the stream at that position.
Therefore I am tempted to either:
between
and notBetween
here: https://github.com/cyclejs/cyclejs/blob/master/examples/autocomplete-search/src/app.jsI think I like the second approach best, but would be interested to hear your thoughts - do you also have "multi-pass" mappings in some of your main/model functions?
Thanks for any comments!
Do you think we will move towards a more visual way of coding? And if so how do you think these tools would look and behave?
Received this question by email:
Hi there,
I have been looking into different secure scuttlebutt apps and have been
comparing them for my own, family, and friend's, needs.I have just been comparing Manyverse with Planetary.
The Planetary developers explain that in order for their app to be
allowed in the Google and Apple stores, they must provide some method of
moderation to meet guidelines:https://developer.apple.com/app-store/review/guidelines/#user-generated-content
Therefore, planetary "must run a centralized kill list for content".
"In order to be in the apple appstore you've got to provide a customer
support team for reporting abusive, harassing, or illegal content. We
do that by having the app dial back to a server we run and it gets a
bloomfilter of content, messages, or feeds we block. We want to be in
the appstore and apple does not provide any way around this."So, my question is, since Manyverse is both in the google and apple
stores, does Manyverse also have the same implementation of having the
app 'dial back to a server' to have a filter of content run where
certain content, messages, or feeds are blocked?If so, is your F-Droid, Dat Installer different, i.e. no filter
implementation?One more question, which you may not have the answer to, but if
Manyverse does not run a filter as Planetary does, what's the difference
between Manyverse and Planetary which allows Manyverse to qualify for
the app stores without one, but Planetary is required to have one to be
in the app stores?Regards,
These questions are primarily for Apple to answer, because they have the final say on what gets approved and what gets rejected. In my experience, there are many Apple employees working on reviewing the apps, and they may apply the rules differently. For instance, even for different versions of the same app, you might get a rejection suddenly for some feature that was there since always, because the reviewer at that time decided to apply rules more strictly than previous reviewers.
The App Store guidelines in my perspective are written assuming that apps follow a pattern: are services provided by startups who manage servers and host user content. This catches a wide variety of apps out there, but it poorly describes what an SSB app is: it's not a service provided by a startup, the developers do not manage servers nor host user content. So it doesn't easily fit the narrative implicit in the App Store guidelines. Manyverse is such case: the developers of the app are not providing a service, are not managing servers, and are not hosting user content. This is made clear on our privacy policy, which is another artifact that Apple requires when you submit an app.
On the other hand, Planetary is a startup that provides a service through servers that they manage (more than 5 servers, as far as I've seen) and host content. Thus, they probably fit into the traditional App Store guidelines, and reviewers may treat that app consistently as they do with other startups that host user content as a service.
The Apple App Store guidelines would direly need a reform, in my opinion, because they make such strong assumptions about companies providing services through the apps, and make it complicated for new decentralized protocols to flourish and help reform the internet at large. The Web is such a decentralized protocol and it has a somewhat special treatment in Apple's and Google's policies: if you make a browser app, as a developer you will not be held accountable for content browsable on fringe websites. If you make a generic email app, as a developer you will not be held accountable for illegal emails. The same should be true for other protocols that are in spirit similar to the WWW, and there are many nowadays: IPFS, Hyper, SSB, Gun, Matrix, ActivityPub. I think we need Apple and Google to acknowledge these protocols and give them equal status as the WWW protocol has.
I was going to ask you about BlockStack after getting pinged back on twitter (I didn't know this AMA existed!), but I see that you've already answered that question.
In the same vein (mesh network type stuff) I was wondering if you had any insights with respect to hardware for local mesh networks. A lot of what I can find doesn't seem to be general purpose enough. For example, it is limited to something like instant messaging.
I'm interested in setting up a local wireless network with some friends in my community (distances max around 700 meters). It would be a cool pilot project to get something started - just to see if its possible.
I've read you mentoring some engineers and would love to hear from your experience.
If you have to share 1 thing only for "wannabe mentors" and 1 thing only for "wannabe mentored by you", what that would be?
In the sense that callbag and CSP have this concept of synchronous message passing, while the process is abstracted away by the event-loop nature of JS engines.
Would be possible to have two callbag "threads" communicating?
I feel for any open source library to become really popular more than just the idea its the documentation that plays an important role. Generally its the last thing the developers tend to focus on. In your opinion, what are the key points that one should consider while writing documentation for an open source library.
Hey, btw: I hope we will meet again at CycleConf ;)
You recently talked about tracking services like Google Analytics (here). I wonder what do you think about error logging services like Sentry or Rollback? Do you use one of them. If not, do you have an alternative. If yes, which one and why?
Svelte project produces JavaScript code, so is more a compiler of components than a library, as it does not need to be included at runtime.
What do you think of Svelte, and of this approach?
My family are also immigrants (from Russia) living in Sweden, I was just curious about your story :)
Hi Andre,
Firstly, thanks for having this space to share some of ur knowledge and point of view about stuff not always related to coding.
I'm soon graduating in Information Systems and lately I have been working as Android Developer in Sao Paulo. In few months I will be moving to Finland for a new chapter of my life and sincerely I'm a bit apprehensive about what the labor market there would expect from me as a recent graduated student in the near future.
Could you share a bit of ur story of what obstacles did you have to fight against since you have moved there?
Thank u very much! =)
E.g, in manyverse, you seem to have a key-value system for labels, with keys being priority
, scope
, and type
. But you also seem to have other labels like ~testing
.
Is it indeed a key-value system? If so, what all are the keys & their values' meaning? (e.g., type: dx
). Or, in general, what's your current process/best practice for labeling and organizing issues?
Thanks in advance! :)
Considering TensorFlow, each "tensor" seems to be a simple operation that propagates changes to another tensors, which seems similar (at least from my very superficial perception) to observables.
What do you think about it and how do you think that functional and reactive programming could help in this field?
In this talk (great one btw) you're using vim inside an IDE, which one?
Thanks.
My friend and I have a hard time finding somewhere to go for lunch almost every day. Do you know of a good place to go around Kamppi, Helsinki?
Having predicted Kotlin's rise on Android, what do you think of Flutter? Do you think it lends itself to writing cycle™ style views on top of Kotlin/Swift for platform specific stuff?
One of the main properties I lack when not using Observables, is the capability of combining substreams into a larger stream that holds the same set of behaviour.
In React components, we can do render callbacks to propagate state, but you will probably need to reinvent the combineLatest as a component to get it to be fractal on the state-level.
Looking at microservices and Kafka, you usually start with a global event bus, and then you break out rivers that you can subscribe to instead of the main event bus to avoid overloading the main bus. This feels like how Redux does it with a global mindset, where it can be partially fractal, but some properties always stay on the global level.
Have you seen any trends on where we are headed in the future across the programming domain? Are we getting closer to doing Observable streams everywhere, or maybe fractal systems?
Why aren't we discussing system properties more holistically? It seems like cycle.js and other streams-based systems solve lots of pains when it comes to message passing. Why is that not a part of a microservice architecture debate?
To me, it seems like we are ignoring the next big paradigm of fractal systems, still holding on to monolithic systems when we do frontend components and backend microservices, and get bad results.
To me, it seems like React will unavoidably reinvent observable streams in the near future. Microservices have a higher threshold for combining services, but also a larger need for coordinating. My guess is that we need a micro-event bus with fractal properties.
Kinda complex question here, so if anyone is following this AMA, feel free to pitch in. The floor is open :-)
Do you like GIT? Or do you think it is just "good enough for the time" tool?
For instance, some things are really cumbersome in GIT, like merging new commits from the branch if you have already comitted your owns (or other similar problems).
Do you think that it should be improved, or good visual tools are enough for that?
Thanks!
Let's assume that "the other framework" is something with similar feature set, e.g. React or Vue.js.
Hi! So glad to see you doing an AMA. I've promised myself not to write too often ;-)
I've been inspired by cycle.js, and also by FP via Brian Lonsdorf.
You also wrote that Haskell is the only language to write real backends in, so I've tried to write Haskell-ish code in JS.
The trouble is that currying/partially applying and typescript doesn't seem to match well.
Then again, the need for something like ramda to curry or compose reactive code might not arise as much.
Given a reactive tool, what mix of functional tools and types-enabling tools would give the most bang for the buck for a typical large admin-GUI based on cycle.js? Is there some combination too quirky right now that it's worth skipping?
And big thanks for the awesome coding philosophies!
I Frankensteined Cycle onionify & Redux to build Mirror, a fractal state tree that any node can query. Mirror makes some really cool dev tools possible, which I'll start working on within a few weeks (graph/performance visualizations & test generators). The library uses React bindings by default, but there's undocumented APIs that let you use Mirror either on its own or with other bindings.
Mirror excels when orchestrating hundreds of nodes together. It'd be really awesome if you had thoughts on the general direction, or could see any specific missteps I should consider dialing back on. Or any questions of your own.
PS: When Google met Wikileaks is on my reading list, I just haven't gotten around to it yet.
e: My implementation of TodosMVC demonstrates idiomatic usage.
I have probably watched your talk here https://www.youtube.com/watch?v=Tkjg179M-Nc over 10 times already and shared it with a lot of people. Its too cool!
I wanted to understand more about why haskell chose monadic over stream IO. One of the reasons I could think of is sometimes when we have multiple side effects there is a lot of to and fro of messages which is not only very inefficient, it also pollutes the message space causing collisions eventually. Its also really tough to find a suitable name for each message type.
Here when I say Stream I mean the conventional message based IO and not wrapping a monad inside a stream
I am really seduced into using a message based architecture because its awfully easier to test but honestly I have never been able to sell it to my colleagues because of the above mentioned issues.
Hi there!
Occasionally, I google something and add andrestaltz
to see your opinion on it. However, I've noticed that some of the links Google gives me for your tweets seem to be broken. Did you delete them on purpose or can I have access to them?
Example: Googling 'andrestaltz json schema' gives me this tweet but it seems to be broken :(. The result on google is:
André Staltz on Twitter: "For describing JSON schemas, #TypeScript is ...
https://twitter.com/andrestaltz/status/788743214404661248
Oct 19, 2016 - For describing JSON schemas, #TypeScript is actually a compelling and readable alternative to ... André Staltz @andrestaltz 19 Oct 2016.
Hi,
I've found myself using a pattern where I do the model layer first for a component and then send it in as an argument to a viewable component that then extends the model object with a view. I've found myself liking that pattern, but still feel like I'm missing out on a great community that cycle.js have.
Is there some way to structure your application in an idiomatic way in cycle.js so that I can have a model that doesn't know about the view, or what kind of transport system (http or websockets) that is being used, but still setup the logic?
Reference component: https://github.com/marcusnielsen/reactive-tournament/tree/development/src/components/button
Good luck with the scuttlebutt stuff! I'm counting on you :-)
Is it making money or fame? How much have you accomplished so far?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.