Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

my attempt at magic

Name: Anonymous 2013-03-27 18:00

lua interpreter: http://bpaste.net/show/kidIoH7vfJlDUvEXPzdd/
still missing features like skip and parenthesis for composing operations

example code:

bindself fact conjure empty
enchant fact set cond = n 0
enchant fact if cond unsummon self with acc
enchant fact set acc * n acc
enchant fact set n - n 1
print summonhold fact with n 10 and acc 1

Name: Anonymous 2013-03-27 18:33

I am far from an expert at Lua, but I have done a couple of semi-serious projects in the language and will try to recall specifically what I didn't like:
- Broken lexical scoping: assignment acts as declaration, in effect clobbering global variables. Bad scoping is the single biggest source of bugs and confusion (http://lua-users.org/lists/lua-l/2008-11/msg00008.html). Even simple variable access goes through table system, producing several L2 cache misses in process just to get to value. That makes Lua slower than comparable alternatives, like Lisp.
- Hash-Table as a primary data structure has overwhelming issues. There is no simple and safe way to implement Lisp-like FIRST and REST functions: either you have to copy whole Table or modify it, and sequential access is somewhat slow. There is no easy way to remove an element from a list. Even worse, the size of a list may not be what you expect: "b={};b[666]="a";print(#b)" will print 1. Table indexing starts from 1, instead of 0, like everything in computing. That acts as a source of errors and confusion, when interfacing with external APIs or converting algorithm from Lua to C/C++, while 0 still acts as a dangling pointer. Lua Tables don't provide advantages of immutable catenable queues - a silver bullet data structure, you'll find in modern Lisps and Haskell; Lua Tables are mutable and encourage modification, instead of creation, meaning there is no easy way to do functional programming with Lua. Lua's REPL wont pretty-print tables, instead it'll print something like "table: 0x807e978".
- Lua uses floating point values instead of integers, so 9999999999999999999==10000000000000000000. In general, Lua's logic seems odd: "nil+1" produces error, while "(not nil)+1" gives 2. Things could be unequal to itself: `t={[{1,2,3}]="abc"}; print(t[{1,2,3}])` wont print "abc", meaning that `{1,2,3} != {1,2,3}`.
- Lua' syntax is inconsistent and full of quirkness: underscores for special variables and cryptic symbols for simple functions, like `#xs` for `length(xs)` and `x = start,end,step` instead of range(start,end,step), while logical connectives (`and`, `or` in place of `&&`, `||`) are hard to notice between other symbols. do/then/end everywhere could be annoying. Moreover, `t = {"a","b","c"}; print(t[2])` works, but `print({"a","b","c"}[2])` fails. `print 'hello';` works, but `print 123;` fails.
- Lua is unstable: API changes frequently, functions are being added and deleted continuously, `table.foreach` being a good example of to be deleted function, and then there is `table.unpack`, which present only in some versions of Lua.
- Lua's GC is a naive mark-and-sweep implementation, which stores the mark bit directly inside objects, a GC cycle will thus result in all objects being written to, making their memory pages `dirty` and Lua's speed proportional to the number of allocated objects. Lua simply was not designed to support hundred thousand objects allocation per second.
- Lua was built as a glue language, and it shows. Much of Lua hype comes from it's usage as a simple integrated scripting language in video games industry. That makes typical Lua user a teenage gamer with little expectations or taste for computation features and productivity.

Name: Anonymous 2013-03-27 19:20

>>2
I used lua cuz I find it very easy to write code in
but if I ever decide to be serious about it I can translate it to C or some other faster language
btw print(({"a","b","c"})[2]) works

Name: Anonymous 2013-03-27 19:34

>>3
That makes typical Lua user a teenage gamer with little expectations or taste for computation features and productivity.

Name: Anonymous 2013-03-27 20:48

>>3
>2013
>no luajit

Name: Anonymous 2013-03-27 21:05

http://luajit.org/dynasm_features.html

have they heard about CPUs beside x86?

Name: Anonymous 2013-03-28 22:48

>>2
Lua deserves a better anti lua kopie. Most of this is either out of date, or just "lua isn't lisp."

good points:
unstable API
limited API
no builtin pretty printing
weird numbers
weird/verbose syntax

Name: Anonymous 2013-03-28 23:24

>>7
Broken lexical scope is the single unfixable flaw, making Lua a freak for live. You can fix GC, API or even type system, but you can't fix scoping, just because it defines whole language.

Any natural and computer language serve to name and manipulate physical phenomena, while broken scoping makes naming hard, because you can't isolate named objects from each other. The only thing Lua does good is simulating schizophasia of schizophrenic mind, where thoughts can clobber each other.

Name: Anonymous 2013-03-28 23:27

Name: Anonymous 2013-03-28 23:38

>>8
You get normal lexical scoping using local. I was about to say maybe local could be implicit and a global keyboard could make global variable references explicit, but that has it's own problems.

Name: Anonymous 2013-03-29 0:05

>>10
You get normal lexical scoping using local.
1. nobody uses `local`, because nothing forces
2. forget `local` and you have a bug
3. mistype variable and you have a bug
4. forget to declare a variable and you have a bug
5. use 3rd party code and you have a bug.

Name: Anonymous 2013-03-29 1:32

>>11
Yes, it's a bug waiting to happen, and all those points are valid. They should be added to the pasta. But with the nature of lua, local variable and global variables with no global declaration need to mix. Maybe this is better.


function f(n)
  local a = n*2
  b = a*4
  return a
end



function f(n)
  global b
  a = n*2
  b = a*4
  return a
end

Name: Anonymous 2013-03-29 2:57

My first attempt at magic was a magic sigil I made to allow me to program with easy. Since witchcraft is the work of Satan, I became a web developer.

Name: Anonymous 2013-03-29 4:05

>>12
Dichotomy between "global" and "local" is retarded, because all variables are local to some context, but Ierusalimsky, being a fucking kike, decided to transform his sophomore C++ calculator project into a full-blown language, so he implemented variables as simple hashtable and called it a feature.

Name: Anonymous 2013-03-29 4:45

>>14
I suppose the issue isn't really global versus local, but what constitutes a variable declaration and what is a reference to a variable in an outer scope. With local, you declare a new variable that exists in the current scope. If you don't use local, you are referring to a variable defined in an outer scope. If no such variable exists, then you are creating a new global variable. I suppose one way to formulate this, is to say that every variable of every possible name is always defined in the global scope with an initial value of nil.

Name: Anonymous 2013-03-29 5:11

>>15
It is, because all variables are global by default. Early Lua implementation likely had only global scope. Moreover, without explicit declaration, you either have to do hoisting (which is bug-prone) or introduce variables on assignment, with is utterly inefficient and buggy. Lua is just broken and cant be fixed.

Name: Anonymous 2013-03-29 5:50

>>16
I don't think you read what is in >>15. If every variable is declared with local, the global scope is never touched.

Name: Anonymous 2013-03-29 6:57

>>17
If God ever existed, then goyim would be never created.

Name: Anonymous 2013-03-29 9:27

guys, talk about my lang, not about lua >.<
>>11
dude I always use local, it's already automatic
just browse through the interpreter and you'll see

Name: Anonymous 2013-04-08 21:00

I've changed it a bit, summon will halt the summoner, but not the other spirits, but to return something you'll have to use bind summoner

here's a search for creature
http://pastebin.com/UzKjsgPd

Don't change these.
Name: Email:
Entire Thread Thread List