Discussion:
A rant about backward-incompatible changes
Simon Cozens
2015-07-14 14:17:34 UTC
Permalink
Hello!

I maintain SILE, which is quite a large, complex application written in
Lua. Because it's an application, I can't control which versions of Lua
its end-users will be using, so we have to support a range of
environments. At the moment we have support for 5.1, 5.2 and I have
recently added support for 5.3.

If I was starting again, though, I would probably not use Lua.

When 5.3 came out, SILE stopped working for users who had upgraded. Not
only SILE's code directly, but code that SILE was using indirectly
through libraries and luarocks simply stopped working and started giving
errors. I don't think this is a great state of affairs.

In particular, one of the changes in 5.3 was that the core "unpack()"
function for handling variable arguments was removed. You might argue
that it was moved to table.unpack, but that's irrelevant: the end result
from a user's perspective was "attempt to call a nil value (global
'unpack')".

A backwards-incompatible change that breaks end-user code is the sort of
thing that probably should be documented, perhaps in the changelog. The
changelog says that "the reference manual lists the incompatibilities
that had to be introduced". Perhaps it was an oversight, but there's no
mention in chapter 8 of the reference manual that a core function was
incompatibly removed. In the changelog, it lists "functions for packing
and unpacking values" under "main changes", but that's as much detail as
you get.

I had to hunt around to find out what was going on, because I didn't
expect built-in functions to silently disappear, and passing variable
arguments to a function is a pretty key thing to suddenly vanish without
trace or documentation.

One more thing: from an application writer's perspective, having
backward-compatibility options available in luaconf.h makes things a
whole lot worse, not better. Because now you have to write code for two
possible platforms, both calling themselves Lua 5.3, but actually with
different and incompatible functionality. What could possibly go wrong?

I know that Lua is an evolving language and I don't think you should
never be able to make any core changes ever. But at the least, could we
please have a deprecation cycle with warnings that code needs to be
updated, rather than unceremoniously breaking end-user code?

Could we also please have a commitment to full documentation of
incompatible changes, with explanation of what needs to be done to older
code to make it work?

And please, can we think about the impact on third-party code of
shifting things around in the core? To make a Lua application
compatible across Lua versions, I have to stuff my code with lines like

unpack = unpack or table.unpack

That's not a hard thing. Lua could actually do that for me, but now I
have to do it. In other words, making code backwards-compatible in Lua
is a burden, and the burden is being placed on the developer, not on the
language. I don't think that's not a good state of affairs either.

Knowing that, when 5.4 comes out, my code is probably going to stop
working again, through no fault of my own, does not really fill me with
confidence or joy.

Simon
Luiz Henrique de Figueiredo
2015-07-14 14:32:12 UTC
Permalink
Post by Simon Cozens
I maintain SILE, which is quite a large, complex application written in
Lua. Because it's an application, I can't control which versions of Lua
its end-users will be using, so we have to support a range of
environments.
Why does a complex application depend on the version of Lua that end-users have?

If you control the application, why not embed a fixed version of Lua?

Many applications do, for instance VLC.
Simon Cozens
2015-07-14 14:35:07 UTC
Permalink
Post by Luiz Henrique de Figueiredo
Why does a complex application depend on the version of Lua that end-users have?
Because the application is written in Lua, and uses the Lua interpreter.
Rob Kendrick
2015-07-14 14:40:18 UTC
Permalink
Post by Simon Cozens
Post by Luiz Henrique de Figueiredo
Why does a complex application depend on the version of Lua that end-users have?
Because the application is written in Lua, and uses the Lua interpreter.
#!/usr/bin/env lua5.1

And then mock anyone who isn't using a Debian derivative.

To be honest, exactly the same thing happens with Python, Ruby, and
Perl. What does $(which python) expand to, Python 1, 2, or 3? Nobody
knows.

B.
Simon Cozens
2015-07-14 14:43:33 UTC
Permalink
Post by Rob Kendrick
To be honest, exactly the same thing happens with Python, Ruby, and
Perl.
No, it doesn't, because these other languages take backwards
compatibility seriously.
Rob Kendrick
2015-07-14 14:45:33 UTC
Permalink
Post by Simon Cozens
Post by Rob Kendrick
To be honest, exactly the same thing happens with Python, Ruby, and
Perl.
No, it doesn't, because these other languages take backwards
compatibility seriously.
Python 3 is not backwards compatible with Python 2. And Perl 5 is not
with 4. In fact, 5 has broken stuff in "point releases" for me in the
past.

B.
Simon Cozens
2015-07-14 14:50:44 UTC
Permalink
Post by Rob Kendrick
Python 3 is not backwards compatible with Python 2.
Right, but it has a deprecation/future process. ("from __future__
import...")
Post by Rob Kendrick
And Perl 5 is not with 4.
Actually, it is.
https://en.wikibooks.org/wiki/Perl_6_Programming/Perl_History says,
correctly, "Through all these developments, Perl has remained backwards
compatible with previous versions. The Perl 5 interpreter can read,
understand and execute (for the most part) programs that were written in
Perl 1, Perl 2, Perl 3 and Perl 4." And there is a test suite for this,
and a policy:
http://perldoc.perl.org/perlpolicy.html#BACKWARD-COMPATIBILITY-AND-DEPRECATION
Rob Kendrick
2015-07-14 14:53:03 UTC
Permalink
Post by Simon Cozens
Post by Rob Kendrick
Python 3 is not backwards compatible with Python 2.
Right, but it has a deprecation/future process. ("from __future__
import...")
That's forwards compatibility.

And Python 3 includes new keywords, so any Python 2 program that uses
them as variable names is shafted.
Post by Simon Cozens
Post by Rob Kendrick
And Perl 5 is not with 4.
Actually, it is.
https://en.wikibooks.org/wiki/Perl_6_Programming/Perl_History says,
correctly, "Through all these developments, Perl has remained backwards
compatible with previous versions. The Perl 5 interpreter can read,
understand and execute (for the most part) programs that were written in
Perl 1, Perl 2, Perl 3 and Perl 4." And there is a test suite for this,
http://perldoc.perl.org/perlpolicy.html#BACKWARD-COMPATIBILITY-AND-DEPRECATION
"for the most part".

B.
Coda Highland
2015-07-14 14:46:35 UTC
Permalink
Post by Simon Cozens
Post by Rob Kendrick
To be honest, exactly the same thing happens with Python, Ruby, and
Perl.
No, it doesn't, because these other languages take backwards
compatibility seriously.
Lua does, too. The feature in question spent the full duration of 5.2
clearly marked as "deprecated" and was accordingly removed from the
next major revision.

/s/ Adam
Luiz Henrique de Figueiredo
2015-07-14 14:51:29 UTC
Permalink
Post by Coda Highland
Lua does, too. The feature in question spent the full duration of 5.2
clearly marked as "deprecated" and was accordingly removed from the
next major revision.
And if you really need compatibilty with Lua 5.1, you can even build
Lua 5.3 with LUA_COMPAT_5_1 on or just LUA_COMPAT_UNPACK.

See luaconf.h for all compatibility options.
Search for the section "Compatibility with previous versions".
Simon Cozens
2015-07-14 14:59:22 UTC
Permalink
Post by Luiz Henrique de Figueiredo
And if you really need compatibilty with Lua 5.1, you can even build
Lua 5.3 with LUA_COMPAT_5_1 on or just LUA_COMPAT_UNPACK.
I don't know what end-users are going to build with. Having multiple
versions of a version doesn't help here.
Daniel Silverstone
2015-07-14 15:03:29 UTC
Permalink
Post by Simon Cozens
I don't know what end-users are going to build with. Having multiple
versions of a version doesn't help here.
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.

Operating systems which blithely jump forwards from 5.1 to 5.2 to 5.3 without
providing co-installability for those projects which have not been brought
forward should be larted until they behave properly.

D.
--
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 3CCE BABE 206C 3B69
Simon Cozens
2015-07-14 15:05:23 UTC
Permalink
Post by Daniel Silverstone
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.
I think the take-away here is that each minor revision of Lua should be
regarded as a different language. If that's the policy, then, fine, I'll
run with it.
Daniel Silverstone
2015-07-14 15:09:54 UTC
Permalink
Post by Simon Cozens
Post by Daniel Silverstone
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.
I think the take-away here is that each minor revision of Lua should be
regarded as a different language. If that's the policy, then, fine, I'll
run with it.
It's certainly how I run with it. Some of my work can be used in more than
one of these sub-languages, but not always.

D.
--
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 3CCE BABE 206C 3B69
Coda Highland
2015-07-14 15:09:44 UTC
Permalink
Post by Simon Cozens
Post by Daniel Silverstone
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.
I think the take-away here is that each minor revision of Lua should be
regarded as a different language. If that's the policy, then, fine, I'll
run with it.
As a different dialect of the language, at least, yes, akin to the
difference between Python 2 and Python 3. (LuaJIT is also a different
dialect of the language.) A good distro will install them as slotted
packages that can coexist.

As Lua's primary goal is to be embedded, applications that run from
the system-installed Lua interpreter are a fairly recent development.
For most deployments you're expected to roll your own Lua.

/s/ Adam
Simon Cozens
2015-07-14 15:32:43 UTC
Permalink
Post by Coda Highland
As Lua's primary goal is to be embedded, applications that run from
the system-installed Lua interpreter are a fairly recent development.
For most deployments you're expected to roll your own Lua.
Well, that's fine, I guess. But Hisham and the luarocks people are trying to build a module ecosystem, which is an extremely useful thing for developers to have. That's made a lot more complicated if the modules are either targeted for a particular dialect (which makes using them in arbitrary code a bit of a crap shoot) or have to be compatible across versions - leading to the original problem.
Coda Highland
2015-07-14 15:35:20 UTC
Permalink
Post by Simon Cozens
Post by Coda Highland
As Lua's primary goal is to be embedded, applications that run from
the system-installed Lua interpreter are a fairly recent development.
For most deployments you're expected to roll your own Lua.
Well, that's fine, I guess. But Hisham and the luarocks people are trying to build a module ecosystem, which is an extremely useful thing for developers to have. That's made a lot more complicated if the modules are either targeted for a particular dialect (which makes using them in arbitrary code a bit of a crap shoot) or have to be compatible across versions - leading to the original problem.
Yes, and LuaRocks exposes Lua versions as available dependencies. If
you don't work in 5.3, say so in your rockspec.

/s/ Adam
Rob Kendrick
2015-07-14 15:10:31 UTC
Permalink
Post by Simon Cozens
Post by Daniel Silverstone
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.
I think the take-away here is that each minor revision of Lua should be
regarded as a different language. If that's the policy, then, fine, I'll
run with it.
The thing to remember here is that in Lua's versioning scheme x.y.z, the
y is the major version, and the z the minor...

B.
Luiz Henrique de Figueiredo
2015-07-14 16:21:25 UTC
Permalink
Post by Rob Kendrick
The thing to remember here is that in Lua's versioning scheme x.y.z, the
y is the major version, and the z the minor...
Not quite:
The releases of Lua are numbered x.y.z,
where x.y is the version and z is the release.
http://www.lua.org/versions.html#numbering
Enrico Tassi
2015-07-14 16:20:08 UTC
Permalink
Post by Simon Cozens
Post by Daniel Silverstone
The one Lua-based project I have which really doesn't play nicely with multiple
lua versions simply refuses to work if the version is not the one it is written
for.
I think the take-away here is that each minor revision of Lua should be
regarded as a different language.
Exactly! In other words never start your scripts with #!lua, always
specify the Lua version.

BTW, a while ago I started a thread to make the point that standardizing
the Lua interpreter name would enable developers like you to just write
#!lua5.1 to select Lua 5.1 on all platforms.

Best,
--
Enrico Tassi
Andrew Starks
2015-07-14 15:21:11 UTC
Permalink
Post by Simon Cozens
Post by Luiz Henrique de Figueiredo
And if you really need compatibilty with Lua 5.1, you can even build
Lua 5.3 with LUA_COMPAT_5_1 on or just LUA_COMPAT_UNPACK.
I don't know what end-users are going to build with. Having multiple
versions of a version doesn't help here.
Simon,

I hear you. You're saying that things that seem like a minor thing end
up breaking in ways that are ugly, especially to new users.
Super-simple tire-kicking tests are marred with cryptic errors that
"should never be there." It makes everything look junky and unmanaged.
Also, there is nobody that stands up on a mountain top to say, "HELLO!
Lua 5.3 is coming soon! Have you updated your Libraries yet?" Instead,
those things are modestly posted on this list, written into the
appropriate place in the documentation, usually in exactly one spot
and using a terseness that only a mathematician can properly
appreciate.

Two examples that add to what you are stating, imho:

1) When 5.2 came out, it was more than a year before there was a
socket library that you could compile and run with it. 2) Recently,
the very sweet and well-done demo for LuaRocks failed out of the box,
again because of LuaSocket. Things are improving. LuaRocks is far
better than it has been and there has been a nice increase in activity
related to library ownership and maintenance.

I also think that it is simply a mistake to compare Lua to Ruby and
Perl. I think that it is better to accept that it's a C library that
you embed into your project and that while it *can* be used as a
stand-alone desktop language, that isn't its mission. Therefore,
backwards-compatibility is not as critical. In your case, you've
decided not to do embed Lua and as a consequence, your job is much,
much harder.

Lua doesn't have the same kind of culture. It is not promoted, changes
are not debated in the open, internal integrity/consistency trumps
most other wants. It might be possible to change those things, but I
doubt that it would be a "good thing" to do that.

-Andrew
Roberto Ierusalimschy
2015-07-14 15:35:45 UTC
Permalink
Post by Simon Cozens
Post by Luiz Henrique de Figueiredo
And if you really need compatibilty with Lua 5.1, you can even build
Lua 5.3 with LUA_COMPAT_5_1 on or just LUA_COMPAT_UNPACK.
I don't know what end-users are going to build with. Having multiple
versions of a version doesn't help here.
You cannot control what end-users are going to build, but you can
control how you build Lua for your tests. When you migrate to a
new version, you should test it against the new version with all
compatibilities off. (For instance, you would have immediately detected
the problem with 'unpack' when you adapted the code to 5.2.)

-- Roberto
Peter Aronoff
2015-07-14 15:38:40 UTC
Permalink
Post by Coda Highland
Lua does, too. The feature in question spent the full duration of 5.2
clearly marked as "deprecated" and was accordingly removed from the next
major revision.
This is true and fair enough.

Nevertheless, I would still suggest that the Lua 5.3 manual should add, in
section 8.1 Changes in the Language, the following:

* unpack was moved to table.unpack

It doesn't need to be any more complicated than that, but I think it would be
useful to list it explicitly in the manual for the simple reason that users may
be familiar with `unpack` from Lua 5.2 but not have followed or noted the
deprecation. In fact, I can list at least two users who were bit by this: Simon
and me. I only recently found out about the change after tests broke in CI. It
was easy to fix, but the first thing I did was look in section 8 of Lua's manual,
and I didn't find anything there. I was surprised. (I was actually going to
write the list about this today, separately from any of this.)


Thanks, Peter
--
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Coda Highland
2015-07-14 15:41:13 UTC
Permalink
Post by Peter Aronoff
Post by Coda Highland
Lua does, too. The feature in question spent the full duration of 5.2
clearly marked as "deprecated" and was accordingly removed from the next
major revision.
This is true and fair enough.
Nevertheless, I would still suggest that the Lua 5.3 manual should add, in
* unpack was moved to table.unpack
It doesn't need to be any more complicated than that, but I think it would be
useful to list it explicitly in the manual for the simple reason that users may
be familiar with `unpack` from Lua 5.2 but not have followed or noted the
deprecation.
It's already THERE -- just not in 5.3, but in 5.2 where that change
actually happened:

http://www.lua.org/manual/5.2/manual.html#8.2

/s/ Adam
Peter Aronoff
2015-07-14 15:44:10 UTC
Permalink
It's already THERE -- just not in 5.3, but in 5.2 where that change actually
http://www.lua.org/manual/5.2/manual.html#8.2
Then I'm even more confused. Why did my tests pass just fine under Lua 5.2
without warning? Was the deprecation only in Lua 5.2's documentation? I'm pretty
sure that I was running these tests using vanilla Lua 5.1 and 5.2 builds, and
everything remained fine.

I suppose I'm saying that the notice should go in the 5.3 manual (even if it's
redundant for some people), because 5.3 is when code actually began to break.
Does that make sense?

Thanks, Peter
--
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Coda Highland
2015-07-14 16:00:25 UTC
Permalink
Post by Peter Aronoff
It's already THERE -- just not in 5.3, but in 5.2 where that change actually
http://www.lua.org/manual/5.2/manual.html#8.2
Then I'm even more confused. Why did my tests pass just fine under Lua 5.2
without warning? Was the deprecation only in Lua 5.2's documentation? I'm pretty
sure that I was running these tests using vanilla Lua 5.1 and 5.2 builds, and
everything remained fine.
PUC-Rio made a decision to enable the 5.1 compatibility flags in 5.2
by default. It is exactly this kind of confusion that demonstrates
that their decision to change this default in all future versions was
indeed wise.
Post by Peter Aronoff
I suppose I'm saying that the notice should go in the 5.3 manual (even if it's
redundant for some people), because 5.3 is when code actually began to break.
Does that make sense?
I will point out the following excerpts:

5.2 section 8:

"You can avoid some incompatibilities by compiling Lua with
appropriate options (see file luaconf.h). However, all these
compatibility options will be removed in the next version of Lua.
Similarly, all features marked as deprecated in Lua 5.1 have been
removed in Lua 5.2."

5.3 section 8:

"Here we list the incompatibilities that you may find when moving a
program from Lua 5.2 to Lua 5.3. You can avoid some incompatibilities
by compiling Lua with appropriate options (see file luaconf.h).
However, all these compatibility options will be removed in the
future."

This seems pretty clear to me. I mean, maybe luaconf.h could be made a
link to the file in the source code and a link to the previous
version's deprecation notes could be included, but it tells you
exactly where to look as it is.

/s/ Adam
Roberto Ierusalimschy
2015-07-14 16:10:37 UTC
Permalink
Post by Peter Aronoff
Then I'm even more confused. Why did my tests pass just fine under Lua 5.2
without warning? Was the deprecation only in Lua 5.2's documentation? I'm pretty
sure that I was running these tests using vanilla Lua 5.1 and 5.2 builds, and
everything remained fine.
Run with compatibility on, but test with compatibility off. (Vanilla Lua
has compatibility on...)

-- Roberto
Peter Aronoff
2015-07-14 16:11:38 UTC
Permalink
Post by Coda Highland
This seems pretty clear to me. I mean, maybe luaconf.h could be made a
link to the file in the source code and a link to the previous version's
deprecation notes could be included, but it tells you exactly where to look
as it is.
My problem was not that it was hard to find. I found what I needed to know
quickly enough. My point is that I had to look. At the cost of adding a single
bullet point in 5.3's notes, I wouldn't have had to look at all.

That said, I understand what you're saying: the warning was there in 5.2. It's
my fault that I missed it.

Thanks, Peter
--
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Coda Highland
2015-07-14 16:13:51 UTC
Permalink
Post by Peter Aronoff
Post by Coda Highland
This seems pretty clear to me. I mean, maybe luaconf.h could be made a
link to the file in the source code and a link to the previous version's
deprecation notes could be included, but it tells you exactly where to look
as it is.
My problem was not that it was hard to find. I found what I needed to know
quickly enough. My point is that I had to look. At the cost of adding a single
bullet point in 5.3's notes, I wouldn't have had to look at all.
No, my point is that it IS documented in 5.3 -- in luaconf.h.

/s/ Adam
Peter Aronoff
2015-07-14 16:23:15 UTC
Permalink
Post by Coda Highland
No, my point is that it IS documented in 5.3 -- in luaconf.h.
Oh, I see. Then our disagreement is about whether simply saying "go read
luaconf.h" is ideal documentation. I didn't mean to quibble about whether or
not it "is documented".

I'll say again that I think a one-sentence addition to the 5.3 manual would be
helpful, given that 5.2 built by default with the compatability layer that you
mentioned.

To be clear, this isn't criticism of anything. I agree that there was
documentation earlier. I concede that I could read luaconf.h But clearly
some of us missed things—perhaps because of the compatibility layer, perhaps
because of our own mistakes. It just seems that section 5.8 of the manual
is meant to be a clear, brief, public version of changes. One more sentence
wouldn't hurt anything surely?

Thanks, Peter
--
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dirk Laurie
2015-07-14 20:21:24 UTC
Permalink
Post by Peter Aronoff
I'll say again that I think a one-sentence addition to the 5.3 manual would be
helpful, given that 5.2 built by default with the compatability layer that you
mentioned.
Personally I build with compatibility off, because of "ipairs".
Michael Welsh Duggan
2015-07-14 17:19:57 UTC
Permalink
Post by Peter Aronoff
Post by Coda Highland
This seems pretty clear to me. I mean, maybe luaconf.h could be made a
link to the file in the source code and a link to the previous version's
deprecation notes could be included, but it tells you exactly where to look
as it is.
My problem was not that it was hard to find. I found what I needed to know
quickly enough. My point is that I had to look. At the cost of adding a single
bullet point in 5.3's notes, I wouldn't have had to look at all.
That said, I understand what you're saying: the warning was there in 5.2. It's
my fault that I missed it.
I would recommend that functions are mentioned in the release notes both
when they are deprecated and when they are removed. This is simple
thing that could help with misunderstandings going into the future.

"Function foo deprecated in release N-1 is now removed/moved/changed."
--
Michael Welsh Duggan
(***@cert.org)
书呆彭, Peng Yi
2015-07-20 02:36:51 UTC
Permalink
Post by Coda Highland
Post by Peter Aronoff
It's already THERE -- just not in 5.3, but in 5.2 where that change actually
http://www.lua.org/manual/5.2/manual.html#8.2
Then I'm even more confused. Why did my tests pass just fine under Lua 5.2
without warning? Was the deprecation only in Lua 5.2's documentation? I'm pretty
sure that I was running these tests using vanilla Lua 5.1 and 5.2 builds, and
everything remained fine.
PUC-Rio made a decision to enable the 5.1 compatibility flags in 5.2
by default. It is exactly this kind of confusion that demonstrates
that their decision to change this default in all future versions was
indeed wise.
Post by Peter Aronoff
I suppose I'm saying that the notice should go in the 5.3 manual (even if it's
redundant for some people), because 5.3 is when code actually began to break.
Does that make sense?
"You can avoid some incompatibilities by compiling Lua with
appropriate options (see file luaconf.h). However, all these
compatibility options will be removed in the next version of Lua.
Similarly, all features marked as deprecated in Lua 5.1 have been
removed in Lua 5.2."
"Here we list the incompatibilities that you may find when moving a
program from Lua 5.2 to Lua 5.3. You can avoid some incompatibilities
by compiling Lua with appropriate options (see file luaconf.h).
However, all these compatibility options will be removed in the
future."
This seems pretty clear to me. I mean, maybe luaconf.h could be made a
link to the file in the source code and a link to the previous
version's deprecation notes could be included, but it tells you
exactly where to look as it is.
/s/ Adam
I suggest that section 8 list the deleted features (again!) besides the deprecated features.
--
the nerdy Peng / 书呆彭 / Sent from Thunderbird
Simon Cozens
2015-07-14 20:28:00 UTC
Permalink
Post by Coda Highland
It's already THERE -- just not in 5.3, but in 5.2 where that change
http://www.lua.org/manual/5.2/manual.html#8.2
You're right, and I take back what I said about the documentation.

The only reason I noticed it in the 5.2 -> 5.3 change was because all
the 5.2 interpreters in use were pretending to be 5.1.

(This, again, is why optional backward-compatibility flags break
backwards compatibility.)
Tim Hill
2015-07-14 22:58:07 UTC
Permalink
Post by Simon Cozens
Post by Coda Highland
It's already THERE -- just not in 5.3, but in 5.2 where that change
http://www.lua.org/manual/5.2/manual.html#8.2
You're right, and I take back what I said about the documentation.
The only reason I noticed it in the 5.2 -> 5.3 change was because all
the 5.2 interpreters in use were pretending to be 5.1.
(This, again, is why optional backward-compatibility flags break
backwards compatibility.)
The sub-text here, imho, is that using a “version number” to check for features is fraught with problems, in Lua and pretty much anything else. Windows for example, has an absurdly complex version number system of APIs because they have to “fake” version numbers for certain apps that make erroneous version number checks. Even the API that claims it gets the “real” version number actually gets a second-level faked one. And don’t get me started on apps that can’t even perform the correct version number compare logic.

What is really being checked is the presence/absence of a “feature” (in the abstract sense), and version numbers are being used to impute this indirectly. Since in Lua custom builds break the logic chain “version X.Y implies feature T” what’s really needed is a direct way to determine if a feature is present or not.

—Tim
Björn Kalkbrenner
2015-07-14 14:50:59 UTC
Permalink
Hi!
Post by Simon Cozens
Post by Luiz Henrique de Figueiredo
Why does a complex application depend on the version of Lua that end-users have?
Because the application is written in Lua, and uses the Lua interpreter.
Some things i have learned while using Lua is that i can:

- trust Lua's major-minor releases regarding revisions. If the revision
changes, nothing breaks. Not more or less (better than on other languages).

- find or create compatibility modules (compat-x.y.lua) to be compatible
to a major/minor jump if i REALLY need this

- can check the version number

- there are few versions as RC which i can try or test if i am
maintaining a software using Lua

- there are changelogs where such changes are documented

- distributions have slots for the different Lua versions (such as with
PHP4/PHP5/PHP6) or Python 2.7/3.0/3.2). Comparing, i thing that much
will break if you are using python2.7 and jumping higher (but i am not a
python coder). Same with PHP, i had that problem with PHP4 regarding
references to variables. You are not objective if you are saying "other
languages take backwards compatibilty seriously". I had that problems in
bigger scale with PHP really really often.

- write application/user documentation that makes supported versions clear

- it is really nice with Lua to implement dependency startup stuff (take
a look at prosody as example).

Bye
Björn
Staven
2015-07-14 15:13:37 UTC
Permalink
Post by Simon Cozens
Post by Luiz Henrique de Figueiredo
Why does a complex application depend on the version of Lua that end-users have?
Because the application is written in Lua, and uses the Lua interpreter.
So, don't do that.
Dirk Laurie
2015-07-14 15:14:06 UTC
Permalink
Post by Luiz Henrique de Figueiredo
Post by Simon Cozens
I maintain SILE, which is quite a large, complex application written in
Lua. Because it's an application, I can't control which versions of Lua
its end-users will be using, so we have to support a range of
environments.
If you control the application, why not embed a fixed version of Lua?
That was my first reaction too. You already embed over 1MB of libtexpdf
C source, so less than 0.4KB of Lua won't hurt.

LuaTeX, one of your main competitors in the typesetting world, does just
that.
Coda Highland
2015-07-14 15:16:07 UTC
Permalink
Post by Dirk Laurie
That was my first reaction too. You already embed over 1MB of libtexpdf
C source, so less than 0.4KB of Lua won't hurt.
Lua's not THAT small. ;)

/s/ Adam
Paul K
2015-07-14 20:38:02 UTC
Permalink
Hi Simon,

I'm largely in the same boat as I maintain several Lua modules that
need to work across Lua 5.1, 5.2, and 5.3 versions (including those
compiled with non-default options). Having said that, I have a
different perspective on Lua incompatibility as some of the breakage
is expected and given the slow pace of Lua releases is not too
difficult to handle.
Post by Simon Cozens
One more thing: from an application writer's perspective, having
backward-compatibility options available in luaconf.h makes things a
whole lot worse, not better. Because now you have to write code for two
possible platforms, both calling themselves Lua 5.3, but actually with
different and incompatible functionality. What could possibly go wrong?
Could we also please have a commitment to full documentation of
incompatible changes, with explanation of what needs to be done to older
code to make it work?
I agree with Simon here as the surprises with things breaking when the
new version is release are in my experience mostly caused by two
reasons:

(1) Lua is compiled with compatibility settings ON by default
(2) The documentation only lists deprecated, but not eliminated changes.

This means that when Lua 5.2 comes out, all the deprecated changes
still work (and they are documented in Lua 5.2). If you are slow to
update your code, by the time Lua 5.3 is out, things break and you
wouldn't see why from looking at Lua 5.3 documentation.

As discussed in the sister thread on documentation, I'd welcome two
changes to the documentation: (1) a subsection on removed features
(maybe with a link to the previous version where they were deprecated
to avoid duplication), and (2) a reference that a particular
deprecation/removal is controlled by a define. I realize that all this
information is in luaconf.h, but it would be very convenient to see it
in the documentation as well, especially given how short the
INCOMPATIBILITIES section usually is.

So, for Lua 5.2 I'd expect to see something like this:

* Function unpack was moved into the table library and therefore must
be called as table.unpack (controlled by LUA_COMPAT_UNPACK or
LUA_COMPAT_ALL).

for Lua 5.3, I'd expect to see something like this:

* Function unpack was moved into the table library and therefore must
be called as table.unpack (controlled by LUA_COMPAT_UNPACK or
LUA_COMPAT_5_1).

(having different defines is an argument for copying this information,
rather than linking to it).

In terms of practical approaches, I tend to make changes by sticking
to a subset of supported functions and adding compatibility functions
when appropriate; for example, I still use setfenv/getfenv, but they
are made to work for Lua 5.2 and Lua 5.3 (as much as possible). An
alternative would be to write code in a Lua-5.3-style and use
lua-compat-5.3 (or earlier lua-compat-5.2) to let it run on Lua 5.1
and Lua 5.2.

I think the Lua team took a sensible approach for deprecating/removing
functions (as they keep them available for one or even two versions),
but it may still seem like being not enough given that users can
compile Lua with different settings and still expect things to work.
To minimize the chance of this happening, I agree with Roberto's
suggestion to test things with Lua compiled without any compatibility,
as this will expose any issues with the code before the users see
them.

Paul.
Mason Bogue
2015-07-21 20:29:38 UTC
Permalink
If you want backwards compatibility I think it really makes more sense to
target LuaJIT. It runs on *most* of the devices where you'd want to use Lua
and Mike has been reluctant in the past to break backwards compatibility
regarding things he thought were unnecessary. If people want to build a Lua
module ecosystem, LuaJIT appears to be a more attractive/stable starting
point than any point-release of Lua, plus it's fast enough to compete with
Java and trounces V8.​

The Lua interpreter is really awesome in embedded applications -- for video
games, automobile HUD systems, NetBSD kernel "scripting", various Cisco
products, etc -- none of that would be inhibited in any way by the
standalone webapp and desktop people targeting their tangle of toolkits and
libraries to LuaJIT's dialect and header files. It worked well for
http://torch.ch/ after all.

Loading...