Wikipedia Chooses Lua As Its New Template Language
bonch writes "In an attempt to tackle the inefficient complexity of its current template system, Wikipedia will be adopting the Lua scripting language. Known most for its use in videogame scripting, particularly World of Warcraft, Lua is lightweight and designed for easy integration into existing applications. The transition is expected to begin after the release of MediaWiki 1.19, possibly in May."
Basically, the template system started turning into an ugly programming language. There was debate over using Javascript or Lua; Lua ultimately won due to implementation concerns. The mailing list threads announcing the decision and discussing the change have further details.
As opposed to Javascript?
"the template system started turning into an ugly programming language" - ah, any sufficiently complex system eventually evolves to contain a limited, broken version of Common Lisp.
Stop delaying the inevitable!
Lua has some notable differences from more prominent languages like Java, but as a World of Warcraft addon developer, I find it a surprisingly robust and fun language to program in. I look forward to this change to Wikipedia and hope it works well for all of their contributors.
This seems to be at least partial evidence that that's not really the case: it was discussed for a while, a decision was made, and implementation rather than further discussion is now happening.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
I'll be interested to see if they go for WoW-style "raw", imperative Lua (gobs of functions) or a more OOP-style Lua (NB: my site).
In designing the Lua interface for an old Game UI authoring product I originally went with OOP-style Lua. It was (IMHO) a rather elegant wrapper on our DOM. However, we soon found that the memory thrash of using Lua's lightweight userdata to go back and forth between C++ and Lua resulted in poor performance on consoles, and I ultimately had to redesign the interface to be more WoW-like for our next release.
It was a shame, putting more onus on the scripter to manage objects (tables of properties in Lua) based on a 'pointer' passed around to uniquely identify each element in the DOM, and passing that pointer to all relevant functions. But the performance increase was dramatic.
Javascript is web scale. Lua is not web scale. Also: Lua comes from Brazil. You know what else comes from Brazil? Waxed balls. I wouldn't trust a programmer that waxes his balls. If he can't make good decisions involving his nutsack, can he make godo decisions involving language design? (Just look at PHP!)
That's a really valid argument. Im inclined to agree.
You don't generally need to be an administrator to edit the scripts, with the exception of a few scripts that are used on so many pages that they're vandalism magnets. And even for those, you can propose changes on the talk page, which are usually made if they're reasonable. There is not really a whole lot of politicking around the content of scripts, although admittedly that's partly because the home-rolled language sucks so much that very few people care to figure out how to edit pages that look more like line-noise than classic Perl did.
There's sometimes politicking about whether a particular one should exist or be used at all; some people find the proliferation of infoboxes, footer boxes, succession boxes, portal boxes, etc. too much clutter and not very useful. But the internals, afaik, aren't one of the hotbeds of debate.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
The author specifically modeled it on MVP to maintaining a strict separation of concerns. Presentation and model don't co-mingle. Might seem a bit unusual at first since the language will seem limited at first. But, it'll keep you from running into the "bloating script" problem.
I swear to God...I swear to God! That is NOT how you treat your human!
Wikipedia could stick to PHP or switch to any other language. But that's not their problem. Their problem is the messy markup language they slowly created. I know cause once I tried to render their markup inside another app. Basically, they have all sorts of tags that reference obscure server-side behaviour and everything is so entangled that creating a new renderer is basically impossible. This is sad because they are wasting the work of volunteers.
Check out my cross-platform apps
FTFY (see WP:NPOV)
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
Embedding Lua for configuration or building templates is it's real strength. I've used it many times in programs that require pretty extensive configuration and it's a joy in that environment. I think it's a great choice for this.
I've never been able to get into Lua, whereas Python and Javascript I have. I prefer C/C++, Java, C# however. Though, if I had to pick a scripting language to use I'd use Python. Ruby is unbearable for me, I've tried to like it just can't. Lua isn't unbearable so much as I'm generally too bored with it to try it.
Things I generally don't like about Lua: := or something if you absolutely must avoid ==, I'd complain a lot less. At least it's a clever and convenient way of addressing the problem. Let's face it, == only makes sense to a programmer, a mathematician would look at you weird. Then again they'd look sideways at := too, whereas Let in math has a meaning. Really I think math should teach := and drop the let, it'll save room on whiteboards. .. to concatenate strings either. "a".."bc" looks godawful goofy. I much prefer "a" + "bc". I get that it can cause problems when you need to mix in math, but that's what parenthesis are for. I see why they didn't use + though, they support "coercion", like 100 + "7" becomes a 107 integer. Which is a pretty cool concept I guess. But, it forces you do something weird like .. for concatenation which is a minus against it. Maybe they could have done just "a" "bc" becomes "abc". Then it'd be as simple as two strings like str1, str2 just being placed like... str1 str2 in order to concatenate them. Then they could still use + for coercion.
1) Lua replaced the ! symbol with ~ for Not. This doesn't make any sense. Not that ! made much sense either. I do like that they added a "not" keyword. That at least makes sense.
2) It feels very BASIC with its do, end, then, end etc. That's not a good thing. We should be moving away from that garbage.
3) I'm not a particular fan of any language that wants me to type one of; local, let, or var. The parser should be able to figure out when I'm assigning at all times. And, they still use == in this language which is silly since the whole point of using local, let, or var is so you can distinguish = from assignment or condition. It's annoying when languages that do this. Having said that, you could just pull a Pascal instead
4) Why should you have to prepend = to evaluate something? Like: = 2+3, or even = 3 == 3. Why can't I just type 2+3, or even 3 == 3? It's weird.
5) They went so different with everything, but they kept % for modulo? Doesn't make sense, why not just type mod? The symbol never made much sense. If they were being really adventurous they would have tried harder IMHO. Having said that, I respect that they switched ^ to power instead of xor.
6) I'm not a fan of using
7) I don't mind nil for NULL. It's better than Python's Nothing IMO because it's shorter. Though, I see where Python was going, they were trying to make it obvious when read by a user who doesn't know programming. However, the rest of Python isn't obvious to a non-programmer anyways, so that defeats the purpose. Whereas, nil is at least is less typing, doesn't require an uppercase, and it has an English and Latin definition so as far as being a real word it's wins against Nothing in at least simplicity. I give them props for using this.
8) tonumber("10") is goofy, they're going for English I guess. Python's int("10") is less typing so I'd prefer that. I think when it comes to English vs typing less, as long as it isn't a weird symbol that makes no sense, I lean towards typing less. However, I could live with tonumber, it's not one of the worst things in this language.
9) Having to type function or def in a language to declare a method is annoying. If I was forced at gunpoint to choose, I'd probably go with function because at least it's obvious, less typing didn't win out here, def is weird looking and doesn't make sense at all. The def keyword reminds me of Sub from BASIC, in a bad way. I realize it's a bastardization of defmethod from Lisp. If we absolutely have to have some way of parsing methods (I think there should be a way around it IMO) startin
Exactly what I was thinking. We have a problem: not enough people understand how to edit Wikipedia because of it's complexity. Rather than analyze what makes it complex and how it could be simplified (which is boring), we'll focus on implementing something technically whizzy in some language that's cool, and that will solve the problem.
Wiki syntax did always strike me as stunningly stupid. It has essentially become just another markup language. Except that it's much more unclear, shitty and limited than original XML. Which is a textbook example of the inner-platform anti-pattern.
Another horrible example is TypoScript. Which is a template language, written in another template language (PHP)!! Again becoming a shitty clone of PHP. Which itself already is a shitty clone of a proper scripting language. (I've had to use it in my day job, every day, for five years. I know. [And yes, I still keep up-to-date. And if anything, with the new tacked-on over-blown object system it has only gotten worse.])
XHTML already IS a n00b markup language that your grandma can use.
PHP already IS a n00b template language that every "web designer" (read: wannabe amateur) can use.
And for that purpose, they are perfectly fine!
Seriously, Wikipedia's #1 fault and the reason I ceased actively contributing is that it requires humans to use a mark-up language for what is essentially a simple text based document.
And all such edits would be handled much easier via a WYSWIG editor. Yes, elitist monkeys with far too much time on their hands love that feel of doing something complicated for the sake of it.
Those more intelligent and or beings who have furthered the race through reproduction tend not to want to waste time.
Implement a simple editor that facilitates editing. And let computers do what they do best, process. And humans do what they do best collate ideas and knowledge.
First rule of computers. Don't waste time doing what a computer can do better than you.
Sorry, your comment is NPOV. I marked it for speedy deletion. Also see WP:Shit_that_no_one_cares_about
-- SparklyRainbowLetters
the only language that would use more words to describe the article than what's in the article
As opposed to whatever scripting language(s) MediaWiki was already using for the rest of it's code.
Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
This is probably the stupidest rant I have read in a long time.
AccountKiller
1) In standard logic, ~ means NOT. Since LUA uses functions for it's bit-wise operations, I see no issue with using this.
2) Why? People don't consider C to be BASIC and it allows pre and post-test WHILE loops.
3,4) I got nothing
5) You should really make up your mind here. They use the normal % for modulo and you complain? Come on now.
6) PHP uses . to concatenate strings, seems like you're splitting hairs here for no particular reason other than to complain.
7) Wow, you found something good?
8) LUA is dynamically typed, why would they have an int()?
9,10) You really shouldn't be using LUA... go with a language that you like. It sounds like you prefer Python anyways.
Just as a note, I haven't programmed anything in LUA before but I've looked at the code and looked over the reference manual. Looks like a fine language; I just have no use for it as of yet.
The nmap guys seem to have considered a few scripting languages too for a while, and stuck to Lua because of a couple of reasons addressed in this conference (and probably in some other place in the NSE docs). While I know nothing of the people behind the scenes of Wikipedia, I do kind of trust the decisions made by the nmap team, so my guess is it's not a clueless decision.
That's because it's the devs. They tend to solve stuff in relatively short order.
(The reason a visual editor has taken so long is that it involved not merely an impossibly difficult problem - analysing wikitext - but politics as well - ten years' existing data and a requirement to keep the shitty, shitty format. Wikimedia has lots of sheer brilliance on tap, but this problem also required money and politics.)
http://rocknerd.co.uk
I don't have the bookmark here, but I followed the discussion ( I am on that mail list, and I am a huge fan of javascript ) is that with Lua, is possible to have "quotas". You can limit what LUA do in cpu and ram useage, while a javascript vm maybe will end stressing the server. This was the ultimate motive. This and that some features we easy to implement (where already implemented in the discussion). I think this mean that Javascript must add these things, and make easy for "language embeders" to control how much memory javascript take. I don't know how feasible is that.
-Woof woof woof!
Disclaimer: I mostly like Lua, though I wouldn't say I love it. Like all languages, it has advantages and disadvantages. Lua's strength is embedding, though, and that's where it shines--the only other language that comes close is Tcl, and Lua is cleaner, IMO.
1. I mostly agree with you that ~= for not equals was a mistake. As another poster pointed out, it's a somewhat justifiable mistake, but we had nearly managed to standardize !=. Lua is the first recent language to ignore this near-standard. After 11, below, this is probably my biggest complaint about Lua. :) :) Oh, and "def" doesn't come from Lisp--it's simply short for "define". P.s. if you really want to use just one delimiter everywhere, try Tcl. It's not a bad alternative to Lua if you're looking for an embedded language, and it uses curly braces for everything--even function arguments. P.p.s. those aren't methods, because Lua's not an OO language. Those are functions. (Or procedures, though Lua, like most modern languages, doesn't distinguish between the two.) :)
2. BASIC? Really? Dude! Those keywords don't come from BASIC! (In fact, I've never used a version of BASIC that supported any of them--oh, and get off my lawn!) Those come from Algol, probably by way of Pascal or Modula, and they're great, which is why BASIC ripped them off--they're probably the only good part of any flavor of BASIC, because they're not BASIC features.
3. I'm not sure what you're on about with "local, let and var" (though I think I disagree), but the rest of your rant (about "==") is inconsistent with your earlier complaint about "~=". Like "!=", "==" has become more-or-less standard, and I'm glad Lua didn't decide to innovate here.
4. What are you on about? "print(2+3)" works just fine, as does "a = {1, 2+3}".
5. Man you're stretching! And again, inconsistent with your point 1.
6. Matter of taste. I think I actually prefer "..", but it's not something I feel strongly about either way. Using "+" for concatenation tends to work better in an OO language with operator overriding. Lua's more of a low-level embedded language.
7. Like, whatever. Is this really worth even discussing? 47 different languages do this 47 different ways, and all of them are fine.
8. tonumber() is consistent with the other coercion functions, and if you really hate typing that much, you should probably find another line of work. I certainly wouldn't want to hire you. People who complain about extra typing are generally the ones who write opaque, cryptic, incomprehensible code with no comments.
9. Oh. My. God! If you ever design a language, I will pray that I am never, ever forced to use it!
10. I don't think I've ever encountered this quirk, so I won't comment, except to say, if you don't like that, don't do it!
11. You only had 10 points on your list, and I'm truly amazed you left out the one biggest issue most people (especially those familiar with C, C++, Java, Perl, Python, Ruby, etc.) will trip over--one-based arrays! If you're going to rant about Lua, how can you possibly ignore the exasperating one-based arrays? Are you even a programmer?
Anyway, Lua's not really competing directly with perl/python/ruby. Its strength is that it's small, fast, and easily embeddable. The ease with which you can call back and forth between Lua and C is what really makes it shine. Some of its quirks seem to be choices made for performance reasons, and I'm willing to live with that. Overall, I like its style and flavor better than tcl, which seems to be its main competition.
3) I'm not a particular fan of any language that wants me to type one of; local, let, or var. The parser should be able to figure out when I'm assigning at all times. And, they still use == in this language which is silly since the whole point of using local, let, or var is so you can distinguish = from assignment or condition.
No, the point of local, let or var is to establish a new lexical scope in a clean manner, so that the implementation does not have to guess the actual scope from the place of the first assignment. Lua assigns with =, but it does not establish new lexical bindings with it.
Ezekiel 23:20
MongoDB is web scale. It's got what plants crave.
For example, the lua table object is used by the standard library (table functions) to represent C arrays with integer indexes or more accurately C++ vectors. However, in general you should not attempt to use the resulting table object in any other way than provided for by the table functions. It would have been more user-friendly to have an own vector type for this.
Although it isn't a problem most of the time, sometimes you want to preserve the order in an associative array with non-numerical indexes like you are used to for example in PHP. As far as I know this can only be achieved by having a second table defining the order.
I really like using "or" to express default initialization anywhere though, this will assign "die" if funny is null (or false): ..
function be(funny)
funny = funny or "die"
end
Hey don't blame me, IANAB
Using Lua instead of the current template syntax will not mean much for editors of articles and nobody claimed it would. It will only make (huge) difference for those who currently write templates.
On the other hand, there is also some work going on to make editing of articles easier using a WYSIWYG editor.
User-generated anything (code, data, content, etc) is best supported when you allow many modes of expression, and freedom to change without a standards committee getting in the way.
On the other hand, machines require a fixed standard, or something that changes relatively infrequently.
For this reason, I think the choice of any scripting language here is as ill-conceived as the web itself being standardized on HTML/JavaScript.
I wouldn't trust a programmer that waxes his balls. If he can't make good decisions involving his nutsack, can he make godo decisions involving language design?
Seems like a perfectly good decision to me. There really is nothing like a shorn scrotum, it's breathtaking; I suggest you try it.
sic transit gloria mundi
For some strange reason, so am I...
Random Thoughts From A Diseased Mind (Not For Dummies)
Great. Now if they actually handle the problem of people tapping the proverbial delete button like it dispenses morphine, then myself and a lot of editors will actually have a reason to return to that hellhole.
There is no justification (outside of highly illegal content) for articles being deleted as rapidly as they are. Not in the era of cheap bandwidth, cheap disk space, and crowdsourcing.
Random Thoughts From A Diseased Mind (Not For Dummies)
I wax my balls too and I'm not from Brazil... (I wonder if maybe that's the reason I'm not a programmer nut a marketing analyst instead)
I see what you did there...
I know it's not a big problem but... Not all keyboard layouts have a "~".
"I'm selling these fine leather jackets"
I'm a mathematical modeller, and I like 1-based arrays. I program in both C and GNU Octave (a Matlab clone), and I find Octave considerably easier to use (although to be fair, that's because it's designed to be easy to do maths with). Stuff like "for i=1:50", or "X = rande(2,3,4)", "any(A==[1 2 3])" are things that are so trivial (or the wonder that is eval(), allowing me to generate code with my code). Sadly Octave is not fast enough to do all my work, but I can get things working in much less time (so it's excellent for short jobs).
Generally there are two things I'm going to want to do with arrays: order things, and count things. When counting integers, great, start from 0. When counting decimals (e.g. times), well the array numbering is of no help to me (except that 0 tends to line up with 0). I do a lot more ordering though, choosing the nth item from an array, or the (i,j,k)th item from a 3 dimensional array (which C doesn't like if you don't know the dimensions at compile time, which I usually don't). For ordering, I really struggle with how when selecting the nth thing, I have to pick the n-1th array slot. If I want to pick elements 5 through 10, then it's indices 4 through 9, and that just feels wrong. I get why it was done, but should we really be troubling ourselves over pointer arithmetic in this day and age?
You could say "if you're a modeller, and you like 1-based indexing and multidimensional variable length arrays, why don't you use Fortran?" Well... my supervisor uses it, I suppose I could learn it, and it would probably be worth while, but it's certainly got a steep learning curve, and there don't seem to be the tutorials out there that there are for C. For the moment I've stuck with C, but once you get used to 1-based indexing, it's hard to go back to 0-based.
Python uses 'None'.
-- Lattyware (www.lattyware.co.uk)
This is true. But also remember, the Brazilian wax can also be applied to females. Those other kind of people without nutsacks. This is a good thing.
Python uses 'None'.
Typical for slashdot. A whole thread arguing about nothing.
The problem you are seeing is with the editor you are using ....not with MediaWiki..
Try dragging a URL into a text editor and it will fail ...what a surprise ?
Puteulanus fenestra mortis
Profoundly clueless rant. Most of it superficial nonsense about cosmetics, not even worth responding to. In the few places you discuss something semantically meaningful, you get it utterly wrong. For instance, #4, you're apparently unaware that local denotes *scope*, and has nothing whatsoever to do with helping the parser distinguish comparison from assignment.
The bottom line is that Lua is a much better language than JavaScript. It has proper lexical scoping, proper tail calls, a powerful metaprogramming facility, coroutines, and much more.
That you didn't get this from your 10-minute evaluation in the interactive interpreter is no surprise. Nor, I guess, is your resulting overconfidence in your understanding (see: Dunning-Kruger).
Since when is the indexing offset important? You should be using "zip", "map" (or even "parallel-prefix") and the like.
That's the thing that irks me most about Lua. It pretends to be "high-level", but it isn't really. (Well, that and weak typing. There really is not excuse for that -- other than ignorance.)
HAND.