9 ms·
Speed& Simplicity LuaJIT speeds can rival code written in C. And if you are still not getting the speed you want, see my 1st point above (Integration with C an
by gregholmberg 15y ago
Speed& Simplicity
LuaJIT speeds can rival code written in C. And if you are still not getting the speed you want, see my 1st point above (Integration with C and C++ for that matter).
The simplicity of Lua is, I think, really underrated.
It is a good learning exercise to write some small benchmark / utility / tool in Lua so you can get an idea of how quickly you can develop, and how fast the resulting code will be.
Then read through the Lua source [0] to see just how little code is required to give you that platform for your ideas.
[0] http://www.lua.org/source/5.1/lua.c.html http://www.lua.org/source/5.1/lua.c.html
- loup-vaillant 15y agoThe simplicity of any code is really underrated. Like 4 orders of magnitude underrated: http://www.vpri.org/html/work/ifnct.htm http://www.vpri.org/html/work/ifnct.htm (Long story short: a typical mainstream desktop weights more than 200 millions lines of code. The guys at the Viewpoint Research Institute can simplify it down to 20.000 lines.)
- groby_b 15y ago"We have a technique to reduce the complexity by four orders of magnitude, but unfortunately can't even give a summary of that technique here". I reserve judgment till I see an actual proof of that.
- loup-vaillant 15y agoThe proof is not far. See their last report here: http://www.vpri.org/pdf/tr2011004_steps11.pdf http://www.vpri.org/pdf/tr2011004_steps11.pdf Also, a good deal of their code is accessible here: http://vpri.org/fonc_wiki/index.php/Installation_Guide http://vpri.org/fonc_wiki/index.php/Installation_Guide As far as I can tell, several things can explain how they fit a whole library in a single book (assuming 50 lines per page, 400 page books, 10.000 books in a library). First, the use of dedicated languages instead of C and C++ seems to explain 2 orders of magnitude. The 2 remaining ones are explained by feature creep and plain lack of reuse (in the Franck system for instance, they use a single library to draw everything, from characters in a word processor to the frames of the windows.) They also claim specific achievements: a full self-implementing compilation stack in less than 2Kloc, on top of which implementing something like Javascript or Prolog takes less than 200 lines (see http://piumarta.com/software/maru http://piumarta.com/software/maru for actual code). A Lex/Yacc equivalent in 400 lines or so (see http://www.tinlizzie.org/ometa/ http://www.tinlizzie.org/ometa/ for actual code). A Cairo equivalent that run with acceptable performance in about 500 lines. A TCP-IP stack in 160 lines, stable enough to run a web site. If half of that is true, we can effectively talk about a silver bullet. That bullet won't kill the complexity werewolf of course, but it will seriously cripple it.
- groby_b 15y agoLooking at OMeta, it seems to use libcairo and X11. It's hardly fair to _not_ count those lines. Same goes for dedicated languages. If I don't have to count my toolchain, and I'm allowed specialized languages, I can do everything in one line... DoAwesomeStuffJustLikeILikeIt(); Don't get me wrong, there's some cool stuff there - but the claims of 4 orders of magnitude seem exaggerated to me.
- loup-vaillant 15y agoWait, what? OMeta uses libcairo and X11?! Where did you see that? The only thing I saw it use is a host programming language (Javascript or Python or Ruby…). You may want to count those lines instead. Anyway, remember that they also claim a full language stack in less than 2000 lines. Including a variant of OMeta. Even Lua is 5 times as big. Not counting GCC. I know it's unbelievable. But other personal experiences make me think they're probably right. I have written equivalent OCaml and C++ code where the C++ version were 5 times larger (both where optimized for clarity). In my day job, I routinely divide substantial portions of C++ code by 2 through light refactoring. VPRI's miracle doesn't only come from the awesomeness of their ideas. It also comes from the awfulness of current systems. A full desktop in 20.000 lines may not be so small, if you consider that current ones are way too big. Addendum: I omitted a rather important detail: while the STEPS project aims to build a full desktop system, along with networking, publishing, messaging, and programming capabilities, it makes no attempt be compatible with anything (except the hardware on which it has to run). It doesn't do HTTP nor HTML, for instance.
- groby_b 15y agoBased on a cursory glance at the sources. Maybe I'm misreading things, or maybe it's an intermediate version - certainly possible. And, to be clear, I _do_ believe there are substantial savings in program size to be had. (Especially over C++. Chatty little monster ;) It's the 4 orders of magnitude that make me doubtful. The good thing, AFAIK VPRI is a year or so from completion, so we'll see soon. And even if it's not 4 orders of magnitude, I'm sure there's a lot to learn from it.