News for hackers. Stuff that matters.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Thursday January 07, 2021 @03:50PM (#25677273)
Synergy is my attempt to create the thinnest possible layer of abstraction over the browsers built-in APIs in order to build UIs with Custom Elements. I wanted to be able to express UIs in simpler terms, and I feel like I've achieved what i was aiming for with this. It won't be suited to everybody's tastes, and that’s fine, but I’m having a lot of fun using it myself at the moment and I'm excited to share this for the first time and welcome any and all constructive feedback.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by h3rald on Thursday January 07, 2021 @09:07PM (#25680552)
That's the spirit! It doesn't really matter whether this will become the next (p)React, as ling as you learnt something from building it and you are enjoying using it.

And yes, I did create something like this but I wanted to include also a router (like Mithril) and a standardized way to handle state, both global and local... and I ended up with https://h3.js.org -- yep, probably not many people use it but I have been using it for months for personal projects and I keep tinkering to improve a little bit whenever I find I need to polish some rough edges or support additional use cases.

Like others said, I wonder how long it will take for bloat to creep in. For now though yes, I agree that you really don't need much code to build a fully functional SPA. And creating your own micro framework really helps you understand how things really work, without relying on someone else's abstraction.

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by fergie on Friday January 08, 2021 @01:08AM (#25682011)
"Synergy is my attempt to create the thinnest possible layer of abstraction over the browsers built-in APIs in order to build UIs with Custom Elements."

A noble goal. I like that you are avoiding compilation and tooling.

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @05:28AM (#25683308)
Thanks fergie, glad that you like the approach.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by NetOpWibby on Friday January 08, 2021 @02:06AM (#25682337)
Too bad the name "Svelte" is taken.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @04:19AM (#25682994)
lol
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by romwell on Friday January 08, 2021 @01:02AM (#25681982)
THANK YOU.

In this world of bloat, it is so refreshing to see someone doing The Right Thing.

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @04:35AM (#25683084)
thanks romwell, glad to hear that you like it!
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by forgotmypw17 on Thursday January 07, 2021 @04:26PM (#25677737)
Thank you for sharing your work. I learned from reading it.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Thursday January 07, 2021 @04:38PM (#25677899)
Thanks for the comment, I hope you get a chance to try it out!
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by forgotmypw17 on Friday January 08, 2021 @12:41AM (#25681870)
I find it interesting, but I'm biased against frameworks because I've yet to see one which claims to support every JS browser, which is one of my objectives.

For example, Opera 12 (Presto) has full modern DOM support with .createElement and such, but I doubt your framework would work with it?

There are hundreds of browsers and engines out there, and I want to support them all. Would your framework degrade gracefully in a browser you've never tested before?

Also, how do you deal no-JS users? I read through the documentation, but could not seem to find one?

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by nine_k on Friday January 08, 2021 @02:38AM (#25682510)
Supporting hundreds of different browsers?

This is a noble and audacious goal, but I suspect that it would either take enormous resources, or the least common denominator approach.

OTOH supporting, say, the 3 major browser engines that serve > 99% of the audience is sort of achievable, and also practical.

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by forgotmypw17 on Friday January 08, 2021 @02:43AM (#25682535)
a) I believe your 99% figure is way off.

b) I believe the remaining 1% matters, perhaps more than the others. (See wheelchair analogy.)

c) Yes, it does take a least common denominator approach at first, but you can build a lot on top of that, carefully, without upsetting even such classics as Netscape, Mosaic, and IE4.

Would you say that one developer working part time for a couple of years is "enormous resource"?

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by jlokier on Friday January 08, 2021 @04:33AM (#25683075)
You are going to have a hard time running JS Custom Elements or even the DOM on Mosaic!

IE4 had an early DOM but it was different from the current one, and JS syntax was different too.

Writing DOM-modifying code that does useful things on IE4 as well as on current browsers is possible, but requires a lot of extra code and testing for little gain, and will encounter browser bugs if you do anything complicated, so you can't just drop in a thoroughly-portable framework, you need to test as well.

If what you mean is you'd like graceful fallback to a decent non-JS page on ancient browsers, that's doable, but then it doesn't matter if the JS framework only supports 99% of browsers. Just make sure to disable the framework on browsers too old to use it. (You'll still have a hard time with CSS on Mosaic.)

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @04:56AM (#25683171)
RE "browser support". Synergy has support for "modern" browsers (e.g., https://caniuse.com/mdn-javascript_builtins_proxy_proxy). It would certainly be feasible to provide a legacy version to provide support for some older browsers. Thanks for asking the question though, I should call out "browser support" in the docs as well as the github page.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @04:41AM (#25683112)
Thanks for your questions. RE "no-JS", I have prioritised support for prerendering so that synergy can be used for progressive enhancement. Its early days so the docs are very minimal at the moment, but I will certainly be adding much more detail around this and I'm really happy to hear somebody raising this question as it's a valid concern that often get overlooked.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by Existenceblinks on Friday January 08, 2021 @12:35PM (#25687247)
Synergy looks like "uce" here https://gist.github.com/WebReflection/761052d6dae7c8207d2fcb... But I can see you use "Template Parts" syntax.

Can you explain, what technique you use to update DOM (I'm lazy to walk through code base), is it proxy object like Solidjs, or something like "uhtml". How do you manage to dispose event listener internally (is memory leak possible around that?)

---

Just read some docs it seems like using Proxy!

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @03:46PM (#25690242)
Thanks for your question. Yes, that's correct - Synergy uses Proxy to detect change on the object and then simply walks the tree and updates the nodes whose bindings have changed. Yes there is some commonality with µce API due to implementation of the Custom Element lifecycle methods.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by qwantim1 on Thursday January 07, 2021 @09:54PM (#25680950)
This is great!

But, what would you say to those that say, “Great- another year, another JS framework”?

Specifically, why would I want to use this instead of Vue? What does it buy the average developer?

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by onelovetwo on Thursday January 07, 2021 @11:00PM (#25681367)
its fun, he probably didnt make this for your company/corporation, He made it because he likes making stuff as a programmer.

I find it kinda interesting too so I might try it for my next project...thats how it goes.

Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @05:30AM (#25683325)
That's right, you really have to do this for the love of it when nobody is paying your bills in return. Would love to hear how you get on with it if you do get a chance to try it out.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by rk06 on Friday January 08, 2021 @10:56AM (#25685906)
you are not required to use it. And IIRC this is exactly how Vue, riot etc. started their life
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by mordechai9000 on Friday January 08, 2021 @04:11AM (#25682958)
I love that it has zero dependencies! Is there any chance that typescript definitions will be added, or would you be interested in seeing a pull request?
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Friday January 08, 2021 @04:19AM (#25682993)
Yes! That's definitely on the todo list and would be a welcome contribution.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by farynaio on Friday January 08, 2021 @06:52PM (#25692646)
Exactly. I just realized exactly the same. There is no external dependencies in runtime. I think author should add this is as a one of the biggest benefits/features. Congratulations on delivery.
Re:Show HN: I built a 4kb alternative to React, Vue, etc for... by defx on Sunday January 10, 2021 @06:36AM (#25713670)
Thanks farynaio, much appreciated.