These are chat archives for jdubray/sam

14th
Jun 2017
Zach Dahl
@schtauffen
Jun 14 2017 02:12
fp is about pushing mutations to the edge. pure functions are easier to reason about, easier to test, and easier to replace. mutations still have to occur or you could never get anything done, but I have a hard time understanding why you wouldn't want to make as many functions pure as you can. It is a far better experience
Victor Noël
@victornoel
Jun 14 2017 07:52
I think there is a big mixup between types and classes : they are two different things (and classes are in ES6 by the way): types are not about datastructure (but they are good to define datastructure yes). You can do many things with types that are strongly related to execution and not structure. You can enforce certain actions at certain moments with types (with typed structure that are not used to hold data, but to hold state, as in state machines), you can constrain the architecture of your application with types, etc. Maybe OOP sucks, but it has nothing to do with typing (even though I understand it is the mix of typing + oop that gets you a focus on datastructure).
Antanas A.
@antanas-arvasevicius
Jun 14 2017 08:33
It's good fundamental questions, but they are important in any language let it be Java, JavaScript or TypeScript.
FP, OOP, Dataflow logic, Actor model, Automata-based, Metaprogramming is programming paradigms within its concepts.
The type system in itself I see as a some kind of formalism which helps to define a structure/relationships between parts.
Whether you choose to write it down explicitly or not the "relationships" be in your code in either way. So I think when we are talking about typing we are talking about two possibilities: a) express it in a code, b) leave it in a mind
Main problems with type systems is that they are more constrained than our minds and languages (especially nominal typing systems), but I think structural type system which was chosen in TypeScript is really very flexible and I think you can express a lot of concepts in it. It doesn't contains any "OO hierarchical" (nominal subtyping) feeling because type identities are not type "names", but structures.
Antanas A.
@antanas-arvasevicius
Jun 14 2017 08:39
And in TypeScript the types cannot affect a run time code, they do not exists in a run time so in the run time it's just JavaScript and there is no way to somehow get information about types. That's why if we want to simulate OO subtyping in JavaScript we need to add additional property in an object, like "kind" which gives us an additional information about its type in code.
type Circle = {kind: "circle"; radius:number;};
type Square = {kind: "square"; w:number; h:number;};
type Shape = Circle | Square;

function draw(o:Shape) {
   if (o.kind === "circle") {
         // .... autocompletes/compiles,  o as Circle type
        o.radius;
   }
}
Antanas A.
@antanas-arvasevicius
Jun 14 2017 08:44
So actually types in TypeScript is only for human, IDE's and auto linting. For run time it's useless, it doesn't give anything for JavaScript, if there is a need for type on object you'll need explicitly mark objects, same as in JavaScript.
But the benefit from this is that you can omit any type checking / type assertion code in run time.
When there is a big team of developers I think this formalism of type information is a win. Sure you can achieve it by team policies, conventions, extra tooling etc. (nothing is new here), but it's easier to say just, we are using TypeScript with --strict flag on. That's it. Do anything you want, but don't forget to write "extra type information" that all team can clearly understand what is needed for your APIs and how to combine that code to others code.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 12:56
@antanas-arvasevicius I certainly like the approach where a particular construct solves a problem (say communication between team members), but in the end it cannot supersede the foundation of programming. In essence you cannot adopt a solution that will create more problems that will require solutions that will create more problems and so on.

Let's take @schtauffen response:

1/FP is about pushing mutations to the edge.
2/ Pure functions are easier to reason about, easier to test, and easier to replace.
3/ Mutations still have to occur or you could never get anything done, but I have a hard time understanding why you wouldn't want to make as many functions pure as you can. It is a far better experience

Jean-Jacques Dubray
@jdubray
Jun 14 2017 13:09
1/ FP is pushing side effects to the edge not mutation. Side effects are in essence inter-process communications (console, database, api calls...). Even a timeout is an inter-process call to self. The problem we need to solve is that the "response" to that inter-process communication is an event to your system/application and that event needs a hook in your application state to get a sense of what to do with it.
2/ Maybe, if you don't understand how to manipulate state, for sure not manipulating it will appear to be easier, but aren't you just kicking the can down the mutation loop? Isn't that a solution that eventually creates more problems? By adopting pure functions we had to introduce and manage immutability and ultimately the right size for the pure function became exactly one, that then we had to learn how to modularize. uh? So follow me because the science is complicated here, we started with a stateful code, we said FP is better for all the reasons you enumerate, we ended up discovering that the best approach to FP was to use exactly one function which internally contains all the state. uh? Don't you get a sense that we didn't move the problem by one nanometer?? Ok maybe a micron, we separated inter-process communication from application state. But in doing so we introduced a good chunk of boiler plate code, simply because we didn't understand mutation and how inter-process communication is articulated with respect to mutation. Yu-oo!
3/ I have nothing against pure functions, SAM has as many as it can possibly have and I fully encourage people to use pure function where it makes sense as long as they can make a distinction between purity and wiring, but no more than that, as I say, the paradox in FP is that as you approach perfect purity, the more dis-functional your system becomes.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 13:15

@victornoel again, from the perspective of the foundation of computer science (whatever it is), how can we evaluate that statement:

You can enforce certain actions at certain moments with types (with typed structure that are not used to hold data, but to hold state, as in state machines)

I hope everyone realizes that when these questions are left to interpretation, our code will look very different. It will be more/or less maintainable, easier/harder to write. I am not trying to judge the proposition, I am just trying to point out that all the statements that are made here have merit, but I need something to gauge their validity, I can't just rely on experience, cargo cults or Channel 9. We have done that for decades, written billions of lines of code under fallacious principles. I am just suggesting to move forward with purpose, with a real foundation that we can all reason about, not he said/I said.

I am not here to sell anything. If TLA+ is not that foundation, so be it, give me a better one, I'll use it in a split second. If my interpretation of TLA+ is not correct, let's change it, I have no problem with that whatsoever.
Johan Alkstål
@johanalkstal
Jun 14 2017 13:23
@jdubray To sum up what you say, you want scientific evidence to drive what solutions we use to solve our problems. And in relation to the SAM pattern (which is why we all are here :) ) you feel that it's basis in Paxos and TLA+ gives it the scientific merit you are looking for?
Is that a correct understanding? :)
Jean-Jacques Dubray
@jdubray
Jun 14 2017 13:25
Yes, exactly. Up until now, the foundation of computing was Lambda-Calculus and Petri-Nets. There was also Pi-Calculus, but that's different (inter-process communication).
TLA+ offers a unified view based on Mathematics (not just pure function).
Again how simplistic is the view that pure functions are the foundation of programming? because 99% of people understand what a pure function is? that's it?
Vincent Jo
@chiwoojo
Jun 14 2017 13:43
My gripe about pure functions is that it made no effort to handle interprocess communication from the start. When I learned Redux for the first time and Abramov (creator of Redux) showed what pure functions are, even as a beginner I knew something was off. The whole javascript ecosystem is based on interprocess communication (SPAs, NodeJS). I understand that people love organic, pure, clean things without BPA in their plastic but my honest opinion is that functional programming it's just a fad because from the start because it put side effects and interprocess communication to the side lines.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 13:47
I agree, but we should be able to go back to a foundation that can guide us, we can't really continue with the approach that Erik said, and Dan said, but Michel said, and Evan said, and Andre said... right there you should get a signal that if there no foundation we can go to to evaluate what all these bright people are claiming then something is missing and we are all wasting our time.
Clearly the litmus test is how do you weave an interprocess communication (e.g Paxos) into your programming model. If a programming model does not have any provision for that (OOP, FP, RFP, ...) you should be extremely suspicious about it.
Now we have also tried to create a programming model from an inter-process communication protocol (REST, ...) but does not work either.
OOP has tried to pretend there is no interprocess communication, a remote call is like a local call, even in 2017 that's not possible. Maybe one day.
Antanas A.
@antanas-arvasevicius
Jun 14 2017 14:08
It remembers me a Einstein's searches of Unified Field Theory.
Actually look at what's in the world, programmers are now in a very high demand, programmers quality are getting lower and lower due that. Entry level is almost zero.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 14:13
Well, Dr. Lamport is clearly of that caliber, but we should be honest that we should have a point of reference from which we can evaluate proposals to structure our code. I am sure from there, there would be optimizations that would lead to stream-based programming or functional programming, or OOP, but we would all know what OOP is better here than FP, not because someone said so.
Antanas A.
@antanas-arvasevicius
Jun 14 2017 14:13
Businesses want results, no one cares about theories, if you can ship a product using mutable OO nightmare it's ok for them
For example, I've really was dived in Scala language it's FP concepts etc. even thought to start a project with Scala, but when you look closer and see that all programmers in a company understands (and wrongly) only OOP.. you just had no options, but just use OOP language :)
Jean-Jacques Dubray
@jdubray
Jun 14 2017 14:17
Well I have to admit that learn how to code in 1980 on a TRS-80 and there was absolutely no one to tell me anything. I taught my High School Math teacher how to program. Even in my engineering school a few years later, the TA knew nothing about programming. It's not until mid to late 80s that Software Engineering became wide-spread. So it's no surprise that people can learn on their own, that's how it used to be (say unlike mechanical and civil engineering which are based on "real" science).
Fred Daoud
@foxdonut
Jun 14 2017 14:20
My first programming was also on a TRS-80 -- BASIC in all its GOTO line number glory.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 14:20
I wrote my first commercial software for a bank that summer on an Apple ][, again because no one knew how to program them
Antanas A.
@antanas-arvasevicius
Jun 14 2017 14:20
hehe, my was QBASIC v1 on 80086
remember that line counting times :D
Jean-Jacques Dubray
@jdubray
Jun 14 2017 14:21
@foxdonut ah ah
That Goto for instance... there was nothing wrong with it, it's a state transition! what was wrong was if-then-else that was the problem and yet we burned it to the ground.
Antanas A.
@antanas-arvasevicius
Jun 14 2017 14:24
I still have some code in basic: http://www.plog.lt/personal/myGames/caves1/src/CAVES.BAS there are some GOTOs
Antanas A.
@antanas-arvasevicius
Jun 14 2017 14:35
I think it's better to concentrate on programs validity, reason about how to prove it's correctness from the beginning, using unit testing, functional testing, manual testing if needed. Some problems fits much better in FP others in OOP or even in FSM (which can be described with some external / graphical language). I think languages like JetBrains MPS ( https://www.jetbrains.com/mps/ ) which can unify every paradigm all in one language could be a future.
When problem space fits perfectly with a selected approach the testing and reasoning becomes simpler.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 14:56
I beg to disagree, it is not until coding practices develop on a sound foundation that we will find what we are all looking for, and only a guy the caliber of Dr. Lamport can figure it out, not your average YouTuber or social follower addict.
Zach Dahl
@schtauffen
Jun 14 2017 16:24
I think you severely underestimate people. You don't need a million years of education to have a good thought
mutations are side effects
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:33
Maybe, so far after 20 years of Web app development this tweet summarizes best where we are https://twitter.com/jaredcobb/status/872192437350957056
Vincent Jo
@chiwoojo
Jun 14 2017 16:37
I feel so young, my first language was Java in school. I did try this game called "human corporation" (or something like that) on Steam that was a game using assembly language GOTO statements. It was very difficult for me. I constantly think about how Google and Microsoft having written billions of lines of code that works without such foundation in programming or just MVC. It amazes me. They probably take forever to debug.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:39
Believe, you didn't miss much ...
Zach Dahl
@schtauffen
Jun 14 2017 16:40

front end web development has changed greatly over the last decade. javascript was previously only for tiny toy features on a website.
it makes sense there is an explosion of frameworks as we move into the new era of actual apps-in-js.

I for one think it makes it an exciting field to be in: I get to learn new things constantly, and the good frameworks teach you not only the framework, but new ways to think about coding in general. Do I think React will be king in 10 years? Maybe not, but some of its methodologies are guaranteed to be.

Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:45
but there is no conceptual difference between React and Server side rendering! What react solved is arbitrary DOM manipulations in sprawling event handlers. React is nothing more than a "server" emulator running in the browser. SPA give a better UX so that's the right model, but architecturally React is no different than JSP/ASP. The virtual-DOM is an optimization, not an architectural feature, it actually makes it even clearer that it's no different than JSP/ASP models.
Slađan Ristić
@sladiri
Jun 14 2017 16:46
It is exciting, and the browser democratized programming. I was a bit lucky maybe that I took a brief look at an interesting (to me) language, Erlang, before I started studying, where they showed us the usual C, C++, Java (and JS was a regarded as a joke) path.
So JS was never very foreign to me, oh and in school we had Pascal briefly.
But still, I keep this quote in mind today: https://softwareengineering.stackexchange.com/questions/191738/why-did-alan-kay-say-the-internet-was-so-well-done-but-the-web-was-by-amateur :)
Zach Dahl
@schtauffen
Jun 14 2017 16:47
the important part of react is how they promoted unidirectional data flow, not virtual dom.
the date is your truth, not the dom
data*
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:48
Again, let's go through the flow of a JSP architecture.
Let's add VDOM to it, what do you see?
Zach Dahl
@schtauffen
Jun 14 2017 16:49
i'm not saying its a novel concept. but it is new to front end
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:49
It's new to SPA, not to Front-End
Zach Dahl
@schtauffen
Jun 14 2017 16:49
previously you had jquery programs which flipped flags and added and removed classes
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:50
yes, as I mentioned it prevented the mess in the making of arbitrary DOM manipulations in sprawling event handlers.
@sladiri Alan is a bit outdated, he pushed OOP on us then when it was clear it was not working it was "guys you didn't understand what I was saying", whatever. The Web is actually quite a remarkable architecture, HTTP, HTML, CSS, and JavaScript too are really remarkable technologies. REST as the Web architecture (not as a programming model) is spectacular, at least on par with the Internet.
He probably can't stand the idea that the Web democratized programming, it's kind of a Steve Jobs experience who spent his life democratizing computing (allow as many people to use a computer as possible).
What did Alan Key did on that scale? Through some OOP crap at us? then when it was not working, walked away?
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:56
It's impossible to have a discussion with the OOP gang (Alan, Grady, Ivar...). Ivar is the most approachable.
Slađan Ristić
@sladiri
Jun 14 2017 16:56
@jdubray Hm, I just applied his quote to recent times then. :) Didn't Apple's first GUIs use his "true" OO concept? He seems to encourage people to think outside of the box or current trend in his talks.
Zach Dahl
@schtauffen
Jun 14 2017 16:56
It is weird that apple started with concepts to get computers in front of everyone and now they are a luxury good
Jean-Jacques Dubray
@jdubray
Jun 14 2017 16:57
Yes, Apple is deep in OO and MVC for sure, but I am talking about the ultimate goals:
1/ To allow anyone to use a computer
2/ To allow as many people as possible to program a computer
Obviously 1 >> 2
But you can't have 1 without 2
Steve Jobs was an Alien, he articulated his vision very clearly in the late 70s and delivered it consistently until his death. Us developer we come up with some crap like everything is an object, function, stream, whatever, without any vision and we expect followers will just ... well just follow. Do you see the difference?
Slađan Ristić
@sladiri
Jun 14 2017 17:00
I like how Alan encouraged young children to use computers as a tool, visualizing physics for example. The OO, I never tried to completely adhere to it, sounded like a nice concept at first, like FP does.
@jdubray Well Alan seemed disappointed by a lack of vision of web-developers. But I am not that familiar with both him and Mr. Jobs. :)
Jean-Jacques Dubray
@jdubray
Jun 14 2017 17:01
To quote Dr. Lamport "I believe that the best way to get better programs is to teach programmers how to think better." That's a vision on the scale of Steve Jobs.
It's a bit like human language grammar. There are two extremes (though I don't speak any of these languages so please take what I am going to say with a grain of salt). Sanskrit's grammar was invented several thousand years ago and to this day it is one of the best grammar ever produced. On the other hand, take a language like Thai, it looks like one of the worst grammar you can think off (the way you express past tense, connect actions...). Would you think that expressing, communicating and understand ideas is independent of the grammar you use?
Slađan Ristić
@sladiri
Jun 14 2017 17:11

OOP has tried to pretend there is no interprocess communication, a remote call is like a local call, even in 2017 that's not possible. Maybe one day.

@jdubray Don't you yearn for OOP too then? :) I am just trying to be pragmatic, if a concept helps, an experienced programmer will recognize it early and use the right tool.
Trying to evolve your thinking as Mr. Lamport says should be a pre-condition. :)

Jean-Jacques Dubray
@jdubray
Jun 14 2017 17:22
I am a service-oriented / message guy. I never see the need for objects whatsoever. I can't think the last time I felt I needed a class. Of course a closure is nothing but a class in disguise, so if you count that as a class, I do use OOP, but not in an OOP sense (type, encapsulation, inheritance, polymorphism...).
#1 Vue 2.0 comes with a faster and lighter Virtual DOM implementation than React,

#2 Vue offers both template-based syntax and programmatic rendering with JSX or hyperscript.

#3 Vue is much easier to learn than React

#4 Vue’s two way data binding is simpler than React’s.
Johan Alkstål
@johanalkstal
Jun 14 2017 18:31
Okay?
Feels like some context is missing here. :)
Why the sudden comparison?
Fred Daoud
@foxdonut
Jun 14 2017 19:16
I disagree with #3, and #4 is a non-issue because I don't want two-way data binding... #1 is also a non-issue because there are plenty of lighter, faster vdom libraries.
Wow I disagree with most of that article. Lots of arguable opinions.
Antanas A.
@antanas-arvasevicius
Jun 14 2017 19:18
Fred Daoud
@foxdonut
Jun 14 2017 19:19
reinvention of HTML and CSS within JavaScript a painstaking task
Antanas A.
@antanas-arvasevicius
Jun 14 2017 19:19
They promote that it binds directly everything to DOM, there is no observable pattern
Fred Daoud
@foxdonut
Jun 14 2017 19:19
I think it's the complete opposite, template-based frameworks make the reinvention of JavaScript within HTML a painstaking task.
Slađan Ristić
@sladiri
Jun 14 2017 19:24

I am a service-oriented / message guy. I never see the need for objects whatsoever. I can't think the last time I felt I needed a class. Of course a closure is nothing but a class in disguise, so if you count that as a class, I do use OOP, but not in an OOP sense (type, encapsulation, inheritance, polymorphism...).

@jdubray I think we agree, I do not have that much experience, so take my comments with a grain of salt too :)

Antanas A.
@antanas-arvasevicius
Jun 14 2017 19:27
It looks like react, but with functions and works without virtual dom: https://scalafiddle.io/sf/9f4Tp47/1
devin ivy
@devinivy
Jun 14 2017 19:31
@foxdonut maybe everyone can agree that CSS is hard :P
Johan Alkstål
@johanalkstal
Jun 14 2017 19:31
Nah :P
devin ivy
@devinivy
Jun 14 2017 19:31
especially in the componentized world. that's one thing web components seem to do a lot better.
Fred Daoud
@foxdonut
Jun 14 2017 19:44
@devinivy lol I'm with you on that one!
Jean-Jacques Dubray
@jdubray
Jun 14 2017 22:17
@antanas-arvasevicius yes, the power of V = f(M) there is no turning back from there. I wondering why people are still talking about 2-way data binding
@sladiri in essence an event invokes a service (passing a message), service processes, persists in the database/model and returns response. Why would you need an object anywhere? ORM does not work, message structures need to be flexible (forward compatibility), validation rules are much more complex that what any type could give you.
@johanalkstal that was just a random excavation from my twitter feed :-)
@foxdonut yes, I agree, but that's interesting how someone can spin arguments and when you have no point of reference you can take them for face value.
Jean-Jacques Dubray
@jdubray
Jun 14 2017 22:22
CSS is the most mind bending technology invented after XSLT and APL, but I used to like APL a lot.
Zach Dahl
@schtauffen
Jun 14 2017 23:01
xslt is sort of fun in a way :P
Jean-Jacques Dubray
@jdubray
Jun 14 2017 23:02
Yes, I think that's the best way to describe it...
Zach Dahl
@schtauffen
Jun 14 2017 23:40
oh dang it looks like the links are out of date, but you ever see this? http://ajaxian.com/archives/jslt-a-javascript-alternative-to-xslt
bringing all that xslt goodness to json :P
If you almost liked XSLT, and like JavaScript, maybe JSLT is for you.