News for hackers. Stuff that matters.

opensas

Re:Thoughts on Svelte on Monday March 27, 2023 @04:47PM (#35332322)
the inconsistency comes from the fact that this reactivity, triggered from inside a function, is not taken into account to build the dependency graph and ultimately decide in which order to process the statements
Re:Thoughts on Svelte on Monday March 27, 2023 @04:46PM (#35332292)
top level variables are reactive even when updated inside a function, just give it a try:

https://svelte.dev/repl/44e3aece18294ddb834bcdfb4394af48?ver...

` <script>

  let name = 'world';

  const flip = () => name = name === name.toUpperCase() ? name.toLowerCase() : name.toUpperCase()

  $: console.log({ name })
</script>

<h1>Hello {name}!</h1>

<button on:click={flip}>flip!</button> `

Re:Thoughts on Svelte on Monday March 27, 2023 @04:16PM (#35331835)
> The $ label is one technical reason why I would be hesitant to adopt Svelte for larger projects. It's a core part of Svelte that you can't always avoid, and I think the potential for introducing bugs through it is high to start and very high at scale.

The reactivity system in Svelte is really a joy to use, once you get used to it there's no turning back.

But the author did hit one of the ugliest pain points about it. Svelte can NOT correctly infer transitive dependencies when the variable being updated is inside a function. Meaning that the variable itself will be reactive (it will be invalidated every time it's assigned, even inside a function) but Svelte is not using that information to build the dependency graph, and falls back to the order in which the reactive blocks were defined, which may or may not be right.

I created this issue https://github.com/sveltejs/svelte/issues/5190 a couple years ago documenting it.

It's not so common, but when it bytes you it's pretty nasty.

The workarounds I found are the following

These are the workarounds I found:

- a repl with the issue: https://svelte.dev/repl/640736d3c91d40d3971afcc3eef8b25e?ver...

- workaround 1: manually reorder statements, need to figure out by yourself (and maintain!) the dependency graph: https://svelte.dev/repl/3ecd6aa918e045999db32d379270fc1c?ver...

- workaround 2 (my favorite): provide a redundant update as "hint" to tell the compiler that setY updates y: https://svelte.dev/repl/cbf98bb35f5e4dd4b037d13254853c90?ver...

(thanks to TylerRick for this: https://github.com/sveltejs/svelte/issues/5190#issuecomment-...)

in practice it means to do something like: `$: { setY(x); y = y };`

- workaround 3: put the update operations in order in a single block (it's just the workaround 1 with improved legibility, IMHO): https://svelte.dev/repl/074df362bb934312bbe6fd3aeccab771?ver...

I still think we could do better, at least explaining the issue and how avoid to fall into it (perhaps some linting warning?)

But I really hope svelte developers start considering this an issue to solve, it's inconsistent (meaning the variable is reactive but that reactivity is not taken into account to order the operation in "topological order" (Hey, I learnt about that from one of Rich's presentations, see https://rethinking-reactivity.surge.sh/#slide=19) and as I said before, in the rare occasions you stumble upon it is not so easy to understand what's going on.

A few ideas to foster Ubuntu edge founding

https://opensas.wordpress.com/2013/07/24/a-few-ideas-to-foster-ubuntu-edge-founding/

Canonical is trying to come out with it's own high-end Ubuntu Mobile, and to achieve it they expect to raise 32 million dollars (!) from crowd-founding. But, in my opinion, their offer is not tempting enough for us, the common mortals, unwilling to spend $ 800 on a mobile phone.Here's a couple of ideas to make foster ubuntu Edge founding.

( Read More... | no comments | 2 points | on HN )

Publish your own geocoded web services with CartoDB

https://opensas.wordpress.com/2013/07/06/publish-your-own-geocoded-web-services-with-cartodb/

This is the third part of a series of articles that shows how to use several really nice tools to play with open data. First we took our google contacts and used open refine to clean up and geocode our contacts. Now we will be using CartoDB to quickly upload them to the cloud and expose our data as a web service. We will also have a look at this terrific tool.

( Read More... | no comments | 2 points | on HN )

Using OpenRefine to geocode your data using Google and OpenStreetMap API

http://opensas.wordpress.com/2013/06/30/using-openrefine-to-geocode-your-data-using-google-and-openstreetmap-api/

In this article we will see how to use OpenRefine to enrich our datasets with data from any web service available on line. We will learn how to use Google and OpenStreetMaps web service to geocode the addresses of a dataset.In the previous article we saw how to take our comma-separated list of google contacts, and play with them using google refine. We learnt how to do things like filtering,...

( Read More... | no comments | on HN )

Journey to the open data jungle with OpenRefine, CartoDB, Leaflet and Javascript

http://opensas.wordpress.com/2013/06/27/journey-to-the-open-data-jungle-with-openrefine-cartodb-leaflet-and-javascript/

Playing around with data is not an easy task. There’s no secret formula for successfully finding your way through a bunch of pdf, csv, excel, APIs or whatever else you might have to deal with. There’s not even a single tool that could help you through the whole process, on the contrary, you’ll have to spend some time learning and trying out different techniques.In this series of articles we...

( Read More... | no comments | on HN )

Sharing you JavaScript Ninja secrets: Run your jasmine tests on jsFiddle

http://opensas.wordpress.com/2013/06/23/sharing-you-javascript-ninja-secrets-run-your-jasmine-tests-on-jsfiddle/

JsFiddle is a great tool to show bits of JavaScript code in action. And Jasmine is a test-driven-development for testing JavaScript code, that comes with a clean, obvious syntax so that you can easily write tests. Together they make a great learning tool, letting you share well documented pieces of js code online, without forcing your users to go thru the hassle of setting up libraries or...

( Read More... | no comments | on HN )

Live hot-code reloading with Chromium browser on Linux

http://opensas.wordpress.com/2013/06/12/live-hot-code-reloading-with-chromium-browser-on-linux/

Google Chrome Workspaces alows you to edit you javascript and css files right from your browser, and having them automatically updated on your file system and viceversa.Unfortunately, getting it to work on Chromium browsers on Linux is not as easy as it should.Here's a detailed step-by-step tutorial to start playing with this marvellous tools on your favourite operating system.

( Read More... | no comments | 2 points | on HN )

Troubleshooting Javascript & Backbone - part 1

http://opensas.wordpress.com/2013/06/09/troubleshooting-javascript-humble-homage-to-wat/

In this series of articles I try to tackle several of the most common and most annoying issues you might encounter working with JavaScript. I present a very simple Backbone application that starts to show some strange behaviour. To find out what&#39;s going on, and the best way to handle it, I&#39;ll have a look at the way JavaScript passes around variables, the prototypical inheritance, the...

( Read More... | no comments | 3 points | on HN )
Re:Writing Reactive Apps with ReactiveMongo and Play on Friday October 19, 2012 @10:01AM (#4673523)
great article...
Re:Play Framework 2.0 Final released on Tuesday March 13, 2012 @09:40AM (#3698324)
and a shiny new play framework site http://www.playframework.org/

Podcast en Java Hispano: Introducción a Play Framework

http://playlatam.wordpress.com/2012/02/23/podcast-en-java-hispano-introduccion-a-play-framework/

En el último podcast de Java Hispano han publicado una entrevista a Jorge Aliss (@jaliss) y Sebastián Scarano (@develsas), dos entusiastas miembros de la comunidad Play y asiduos colaboradores de este blog. Aquí tienen la nota de Java hispano, y desde aquí pueden escuchar la entrevista: http://www.javahispano.org/storage/podcasts/137_JavahispanoPodcast_PlayFramework.mp3

( Read More... | no comments | on HN )
Re:Playframework + Google Guice on Monday February 06, 2012 @10:40AM (#3557727)

Playframework + Google Guice

http://playlatam.wordpress.com/2012/02/06/playframework-google-guice/

In the last few years Dependency Injection has has evolved from being an obscure and little understood term, to become part of every programmer’s toolchest. In this article we'll see how easy is to integrate Guice, a very handy library from Google, into a Play framework application. Moreover, we will also cover how to customize it’s behavior for a better development experience.

( Read More... | 1 comment | 12 points | on HN )
Re:First steps with Scala, say goodbye to bash scripts… on Friday January 13, 2012 @02:38AM (#3459596)
I've found out that with the -savecompiled option the delay is not so pitiful... see http://playlatam.wordpress.com/2012/01/13/first-steps-with-s...
Re:First steps with Scala, say goodbye to bash scripts… on Friday January 13, 2012 @02:36AM (#3459593)
Why wouldn't it run on any unix, linux, or windows, or wherever a JVM can run? you should run it with "scala status.scala"

apart from that, I came to a similar conclusion: http://playlatam.wordpress.com/2012/01/13/first-steps-with-s...

Re:First steps with Scala, say goodbye to bash scripts… on Friday January 13, 2012 @02:32AM (#3459585)
thanks for the tip, here's my bash version http://playlatam.wordpress.com/2012/01/13/first-steps-with-s...
Re:First steps with Scala, say goodbye to bash scripts… on Friday January 13, 2012 @02:31AM (#3459579)
Thanks to everybody's feedback on this one... You encouraged me to write another article, mainly because I felt a little guilty for bashing (pun intented) bash and python ;-) Hope you like it http://playlatam.wordpress.com/2012/01/13/first-steps-with-s...

Older »