Live data from Hacker News

Fengari – Lua for the Browser

fengari.io

111–120 of 145 posts

Re: Fengari – Lua for the Browser

#111

Earlier quoted context omitted.

57k post Brotli. Measuring the decompressed size of your page's static text content is like measuring your static image content by the size of the decompressed bitmap the browser generates instead of the size of the PNG (or whatever format). Server side both examples should be precompressed as they are static assets.

Uncompressed size matters for parse time. Although you are correct about network latency.

220kb is fine for a parse time alone, you'd ship Fengari in a separate bundle, probably in a worker.

Speaking of bundles, the webpack loader is pretty cool, it allows you to import .lua files: https://github.com/fengari-lua/fengari-loader

Re: Fengari – Lua for the Browser

#112

Earlier quoted context omitted.

It has all the power of something like Python, but is much faster and with far less cruft and basically no confusing elements. You’re given a small set of tools and it’s incredibly easy to build off them.

Lua definitely does not have the power of something like Python. That's usually what people like about Lua: it's barebone, yet high level and clean. If one likes Python, then the chance of liking Lua are low. E.G: Both python and lua can open something (a file, a socket, a transaction...) in one line. But only Python has the `with` construct that means it's easy to guaranty you close it in case of an error. Lua is th…

Lua 5.4 has to-be-closed variables that are similar in functions to with blocks in python.

Unkike the __gc hook which provides no guarantee as to when it will be called, if ever, the __close hook is called when a value goes out of scope.

http://www.lua.org/manual/5.4/manual.html#3.3.8

Re: Fengari – Lua for the Browser

#113

Earlier quoted context omitted.

I’ve used JavaScript for about 25 years, sometimes more seriously, and always hated it. I’ve always found it unpredictable, I don’t like the turtles-all-the-way-down thing going on with its objects. I’d like to leverage my experience with regular class definitions and instantiation from Java workalikes. I’m sure many people love JS’s take on OO but I find it annoying. A perfect example: I read hey there’s a cool simp…

> I’d like to leverage my experience with regular class definitions and instantiation from Java workalikes. I’m sure many people love JS’s take on OO but I find it annoying. That's a bit like complaining about a language without types not having interfaces. I mean, sure, but it's also clearly not what that language is trying to do. Prototype-based programming is object-oriented programming without defining classes, t…

> That's a bit like complaining about a language without types not having interfaces

Totally agree. I wouldn't make the mistake I see often of saying "for this reason JavaScript is objectively bad" -- but it's bad for me.

> you're not really embracing the paradigm of the language you're using

That's true, and related to the problem. I don't want to learn another paradigm, I want to get my work done. JavaScript's paradigm isn't intuitive to me, and at this point I assume will never click since I've been using it fairly consistently for 25 years and it still makes me uncomfortable.

> Not sure what this has to do with OOP vs prototypes, or even Objects

It doesn't. It's an example where JS often doesn't behave the way I expect it to. Some examples of this unpredictability have been fixed with newer versions over the last 25 years but this just illustrates the problem I often have where I make what I feel are reasonable assumptions about how its scoping or execution model works and have to trial-and-error my way into getting it to work right. This is after countless time spent reading JS books and posts over the years.

I accept that this may just be a personal issue, but I also don't think I'm the only one.

Re: Fengari – Lua for the Browser

#114

Earlier quoted context omitted.

At 5.3 the behaviour of the basic arithmetic operations were changed in a fundamental and non-backwards compatible way to bring in those integers. That certainly counts as a language fork, as opposed to the other two examples.

It definitely is the mainstream continuation of that language by the original authors. Changing the API, or the implementation, or making other breaking changes does not automatically (or otherwise exclusively) make it a "language fork". Lua has the luxury of making breaking changes, and most Lua users both accept and appreciate that. Lua is continuously refined while languages like JavaScript and PHP are stuck with…

This is not breaking an API or the implementation. It is not a refinement. This is a change to the language itself. If you had a published standard it would be a change and not an addition.

Re: Fengari – Lua for the Browser

#115

Earlier quoted context omitted.

It definitely is the mainstream continuation of that language by the original authors. Changing the API, or the implementation, or making other breaking changes does not automatically (or otherwise exclusively) make it a "language fork". Lua has the luxury of making breaking changes, and most Lua users both accept and appreciate that. Lua is continuously refined while languages like JavaScript and PHP are stuck with…

This is not breaking an API or the implementation. It is not a refinement. This is a change to the language itself. If you had a published standard it would be a change and not an addition.

Was the release of C11 a fork of the C language, since they removed the gets() function?

Re: Fengari – Lua for the Browser

#116
post #49

Earlier quoted context omitted.

I'm not entirely sure what you mean by "language fork", but all versions of Lua have incompatibilities. 5.1, 5.2, 5.3, and 5.4 are all major versions, with features that aren't completely compatible with any of the others. For example, 5.2 brought in major changes for how environments were handled, and 5.3 brought in integers, and 5.4 brought in changes to how number overflow is handled.

At 5.3 the behaviour of the basic arithmetic operations were changed in a fundamental and non-backwards compatible way to bring in those integers. That certainly counts as a language fork, as opposed to the other two examples.

is every OS version a fork, is every new parliament a new country? there are markers other than backwards compatibility for continuity.

Re: Fengari – Lua for the Browser

#117

This is at the JavaScript level but I would love to see someone release a browser with a side-by-side JS VM and Lua VM, just as an experiment to what the web could be like with a better language.

IIRC Google made a version of Chrome with a Dart VM quite a while ago

https://www.cnet.com/news/googles-dart-language-arrives-in-c...

and they cancelled it ... my interpretation of their reasons are unless all browsers ship it it's a problem.

https://news.dartlang.org/2015/03/dart-for-entire-web.html

Re: Fengari – Lua for the Browser

#118

This is at the JavaScript level but I would love to see someone release a browser with a side-by-side JS VM and Lua VM, just as an experiment to what the web could be like with a better language.

IIRC Google made a version of Chrome with a Dart VM quite a while ago https://www.cnet.com/news/googles-dart-language-arrives-in-c... and they cancelled it ... my interpretation of their reasons are unless all browsers ship it it's a problem. https://news.dartlang.org/2015/03/dart-for-entire-web.html

Foe anyone interested, there was a port of Webkit/Blink where the web objects retained by javascript are garbage collected outside of V8, using blink GC to destroy those objects.

The way it works its through smart pointers, where for instance you say how the reference to that object is retained according to the object that it references.

The good side of this is that other programming languages besides Javascript can deal with blink objects the same way Javascript does (This feature was called 'oilpan').

It's this feature that makes possible for my project to have web-based applications in Swift, for instance, and would allow to plugin the Lua VM or Jit in the same way and still be able to be a first-class citizen of the webkit API as Javascript is.

Re: Fengari – Lua for the Browser

#119

For those looking for powerful async coroutines in the browser: The combination of typescript+redux+redux-saga is also quite powerful. Redux-saga uses generator coroutines to handle all sorts of asynchronous tasks.

Well, you're completely OT, but I started hating frontend development exactly when redux + sagas started becoming popular.

Don't get me wrong, Elm has a very similar architecture but it's pleasant to use. The idea is cool, the implementation of redux and sagas is a terrible boilerplate mess.

More recently, with react hooks + async you can model something similar without having to use redux or sagas.

Redux hook syntax is also a step forward, albeit not very useful now that we have context and reducers.

Post reply on HN