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

Pages: 1-4041-8081-120121-160161-

LUA is FFOC

Name: Anonymous 2011-02-05 9:01

LUA is the toy language for those who enjoy the Forced Flushing Of L1/L2 Cache per operation. In fact, every operation causes several L2 cache misses during table look-ups, flushing both the L1 and L2 caches.

http://www.slideshare.net/hughreynolds/optimizing-lua-for-consoles-allen-murphy-microsoft

Enjoy your FFOC.

Name: Anonymous 2011-02-05 9:03

Too bad LuaJIT is FAST AS VIRGIN FUCK

Name: Anonymous 2011-02-05 9:12

>>2
It'll never compare to other languages that are data-oriented and data-parallel friendly, like your old school imperative languages such as C, C++, or functional languages like Scala or F#.

LuaJIT and Lua/LLVM still using those god damn look-up tables in the JITed code.

Your idea of ``FAST AS VIRGIN FUCK'' is incorrect, as Lua is no longer a virgin, but rather a two-time whore who can't even find anyone willing to pay her $5 for a blowjob.

Name: Anonymous 2011-02-05 9:24

>>3
I lol'd; real nice.

Name: Anonymous 2011-02-05 9:25

>>1
[m]Allen Murphy ([b][u]Microsoft[/b][/b])[/m]

Yeah. A report by Microsoft about a Non-microsoft product. What exactly did you expect, a fair competition?

Besides me not even attempting to argue that Lua does indeed stated Table cache ``faults'' (if peanuts like that can even be called a fault to begin with), it's obvious that

   1.) Microsoft always makes even the least terrible fault look like a fucking drama
   2.) I have yet to read about a case where this fault actually causes any noticable trouble

So please take your rant and go to /g/, where you belong to.

Name: Anonymous 2011-02-05 9:26

>>5
Ffuuu.. BBCode.

Allen Murphy (Microsoft)

Yeah. A report by Microsoft about a Non-microsoft product. What exactly did you expect, a fair competition?

Besides me not even attempting to argue that Lua does indeed stated Table cache ``faults'' (if peanuts like that can even be called a fault to begin with), it's obvious that

   1.) Microsoft always makes even the least terrible fault look like a fucking drama
   2.) I have yet to read about a case where this fault actually causes any noticable trouble

So please take your rant and go to /g/, where you belong to.

Name: Anonymous 2011-02-05 9:32

>>5-6
You are wrong. Memory hazards and cache misses are the primary reason for slow software on modern hardware. Optimising for cache coherent hardware can reap performance gains of several orders of magnitudes. This is no laughing matter.

Mad that Microsoft has some smart developers working there? Fine, here's one from Sony for PS3/Cell development showing how important programming for cache efficiency really is.

http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf

Lua is the anti-thesis of data-oriented programming. Lua is a laughing matter. FFOC indeed.

Name: Anonymous 2011-02-05 9:38

>>7
I was asking for a case where this matters. A case that can actually be tracked down.

While in theory I'd fully agree with you, your point is pretty much a pointless one if you're entirely unable to actually prove it.

Judging by your logic, an application that is entirely written in an interpreted language (such as eve online, which is almost entirely written in Python), must be OMG FUCKING SLOW.

But how come it isn't at all? Good question indeed. Your turn.

Name: Anonymous 2011-02-05 9:44

>>8
Python does not use huge sprawling look-up tables for all object-name resolution lookups. CPython does have scalability issues due to the GIL, but this isn't a problem with IronPython or rewrites of Python targeting LLVM.

Lua's tables are deeply ingrained into the language. There's no correcting it.

Name: Anonymous 2011-02-05 9:46

>>1
That explains a lot. I was playing a puzzlequest game on the DS and it was amazingly slow. I couldn't rationalize it. It's written in Lua in no small part, and now that I know this it all makes sense.

>>5
Table cache ``faults'' (if peanuts like that can even be called a fault to begin with)
But... they are faults, by their very definiIHBT and how!

Name: Anonymous 2011-02-05 9:46

>>8
Does Eve run on consoles? Nope. I know the folks working on Batman Arhkam Asylum originally were using Lua for scripting, but performance issues forced them to rewrite all of their scripts in native C++ so that they could ship it on current generation consoles.

Name: Anonymous 2011-02-05 9:54

>>11
I know the folks working on Batman Arhkam Asylum originally were using Lua for scripting
[citation needed]

Name: Anonymous 2011-02-05 10:00

>>12
What, anecdotes aren't good enough for you?

Name: Anonymous 2011-02-05 10:12

>>7
several orders of magnitudes [sic]
If by several you mean two, in the most contrived of cases, then sure. Not that you don't have a point...

Name: noko 2011-02-05 10:35

>>14
Because what's a couple of orders of magnitude between friends? 1ms per frame or 100ms per frame, who cares, except console gay developers who are all crazy?

Name: Anonymous 2011-02-05 10:52

>>15
I think >>14 was in support of the fact that cache-conscious code is important. He did after all say he had a point. He was just pointing out the exaggeration.

That said, performance improvements of hundreds of times is a big deal.

If you don't understand the memory model of your computational hardware, you will never be able to develop fast software for it.

Name: Anonymous 2011-02-05 11:04

I think they're saying their memory and CPUs suck.
Also, "No JITting since security model forbids executing on data." WTF.

Name: Anonymous 2011-02-05 11:32

>>16
You completely misunderstood >>14-san.

Name: Anonymous 2011-02-05 12:53

>>18
I think you have misunderstood >>16

YHBT

Name: Anonymous 2011-02-07 6:55

Etymology
From Proto-Oceanic (compare Malay luah).

Verb
lua
   1. to vomit

Name: Anonymous 2011-02-07 8:25

Lua's problem is that it uses hash tables for dispatching. This limits Lua to single dispatch in addition to making everything slow and rigid. You cant redefine `+` in Lua, as I do in my Lisp DSL

`+` a:Num b:Str -> "$a$b"
`+` a:Str b:Num -> "$a$b"


neither you can union two types

userFriendly? x:string? -> ye
userFriendly? x:picture? -> ye

Name: Anonymous 2011-02-07 8:28

And of course Lua doesnt have Lisp macros, which are very nice to have, especially when entering arbitrary complex game logic.

Name: Anonymous 2011-02-07 8:30

>>21
`+`
U MENA HASKAL‽

Name: Anonymous 2011-02-07 8:33

>>23
Haskell HAS NO MULTIDISPATCH
http://en.wikipedia.org/wiki/Multidispatch

Name: Anonymous 2011-02-07 8:56

>>24
Your ``in Lisp'' DSL is just Perl 6 with a lisp and ML/Haskell syntax:
Operator overloading (Perl 6 does it better)
Lisp macros (Perl 6 does it worse(?))
Multidispatch
Pattern matching
$
Num and Str
SYNTAX. SYNTAX EVERYWHERE

In conclusion:
WHBTC

Name: Anonymous 2011-02-07 9:01

>>25
>Operator overloading (Perl 6 does it better)
You wrong. DSL doesnt do operator overloading. It does pattern matching. That is: I can write

hasUserFriendlyObject [@_ x:userFriendly? @xs] -> [x xs]

meaning find first `userFriendly?` object, then return it and rest of the list. Doubt that Perl does this.

Name: Anonymous 2011-02-07 9:01

>>24
Haskell via Multi-parameter type classes
You just failed.

Name: Anonymous 2011-02-07 9:03

>>26
Or better yet:

hasUserFriendlyObject @_ x:userFriendly? @xs -> [x xs]

Because conceptually functions accept single argument - list.

Name: Anonymous 2011-02-07 9:04

>>27
>C/C++ via visitor pattern
we all see where haskell's place is - right between cobol and pascal

Name: Anonymous 2011-02-07 9:09

>>26,28
I'm sure you can, with a macro.

Name: Anonymous 2011-02-07 9:11

>>30
CL allows variable length arglists, so I dont even need macro for this.

Name: Anonymous 2011-02-07 9:13

>>31
Everything allows variable length arglists, so you don't even need a macro for this. But you need it for pattern matching.

Name: Anonymous 2011-02-07 9:14

>>32
Its embedded in `lambda`. So iam always a few keystrokes away from it.

Name: Anonymous 2011-02-07 9:16

>>33
It's embedded in `sub`. So I am always a few keystrokes away from it.

Name: Anonymous 2011-02-07 9:18

>>34
Please, implement >>28 in Perl.

Name: Anonymous 2011-02-07 9:22

>>35
Basically, it does a (drop-while user-friendly? xs), >>26,28 it's unscientific and ultimately bloated.

Name: Anonymous 2011-02-07 9:23

Lisp:

f [x _ @xs] -> x+xs.f

Haskell:

f = sum . map snd . filter (odd.fst) . zip [1..]

Name: Anonymous 2011-02-07 9:23

>>36
*(drop-while (negate user-friendly?) xs)

Name: Anonymous 2011-02-07 9:23

>>36
So, you cant? Q.E.D.

Name: Anonymous 2011-02-07 9:24

LISP:

f l -> subst l.max l.{[x]->x; [x _ @xs]->x+xs.rec}/l.len l


F#

let quux (a : array<int>) =
 
    let (s,_,m) = Array.fold
               <| fun (s,p,m) x -> let nx = if x > m then x else m
                                   if p then (s+x, false, nx)
                                        else (s,   true,  nx)
               <| (0,false,a.[0]) <| a
 
    Array.map  <| function | x when x=m -> s / (Array.length a / 2)
                           | x          -> x
               <| a

Name: Anonymous 2011-02-07 9:27

LISP:

clockwise[x@xs]->[@x@xs.transpose.rev.clockwise]

Haskell:

clockwise (x:xs) = x ++ (clockwise . reverse . transpose) xs
clockwise _ = []

Name: Anonymous 2011-02-07 9:27

>>39
So, you cant? Q.E.D.

sub faggot (@xs) { drop_while(@xs, { not userfriendly($^a) }) } # it assumes the existence of drop_while. Its implementation would be trivial anyway.

Name: Anonymous 2011-02-07 9:30

Lisp:

map ?*3 [1..3]


Perl 6:

<1 2 3>.map(-> $x {$x * 3})
3 6 9

Name: Anonymous 2011-02-07 9:31

>>42
No pattern matching. Q.E.D.

Name: Anonymous 2011-02-07 9:32

>>43
[1..3].map: * *3
3 6 9

Name: Anonymous 2011-02-07 9:32

>>43
Lisp:

3*[1..3]


Perl 6:

<1 2 3>.map(-> $x {$x * 3})

Name: Anonymous 2011-02-07 9:33

>>45
Bloated syntax is bloated.

Name: Anonymous 2011-02-07 9:33

I like Lisp but why does every thread nowadays transform into a Lisp thread after 30 posts?

Name: Anonymous 2011-02-07 9:35

>>44
multi sub faggot ($n) { "oh god how did i get here im not good with computers"}
faggot
multi sub faggot ("HAX MY") { "ANUS!" }
faggot
multi sub faggot ("I'm >>44 and love cocks") { "You are!" }
faggot
faggot("I'm >>44 and love cocks")
You are!
faggot("HAX MY")
ANUS!
faggot("sjdjksda")
oh god how did i get here im not good with computers

Name: Anonymous 2011-02-07 9:35

>>48
Because:
Lua's creators also state that Lisp and Scheme with their single, ubiquitous data structure mechanism (the list) were a major influence on their decision to develop the table as the primary data structure of Lua.

Name: Anonymous 2011-02-07 9:35

>>48
It's because they're getting desperate for recognition.

Name: Anonymous 2011-02-07 9:38

>>46

3*[1..3]
multi infix:<*>(Int $n, @a) { @a.map: * *$n }
infix:<*>
3*[1..3]
3 6 9


Your DSL is VALID PERL CODE

Name: Anonymous 2011-02-07 9:39

>>49

faggot _ -> "oh god how did i get here im not good with computers"
1.faggot "HAX MY" -> "ANUS!"
2.faggot "I'm >>49 and love cocks" -> "You are!"

code less, create more

Name: Anonymous 2011-02-07 9:39

>>53
You can do that with a macro.

Name: Anonymous 2011-02-07 9:41

Name: Anonymous 2011-02-07 9:41

Name: Anonymous 2011-02-07 9:41

>>54
Any sufficiently complicated Perl or Python program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of LISP.

Name: Anonymous 2011-02-07 9:42

Name: Anonymous 2011-02-07 9:43

>>57
The ``in Lisp'' DSL contains an ad hoc, informally-specified, bug-ridden, slow and unnecessary implementation of half of Perl 6, Haskell and ML on top of the already perfect LISP.

Name: Anonymous 2011-02-07 9:43

Name: Doctor Racket !RACKET/.HY 2011-02-07 9:46

In this thread: children.
I'm ashamed of myself to read these childish things.

Name: Anonymous 2011-02-07 9:51

Name: Anonymous 2011-02-07 9:53

>>>/g/

saged and reported for off topic

Name: Anonymous 2011-02-07 9:53

>>62
Yes.

Name: Anonymous 2011-02-07 9:57

Name: Anonymous 2011-02-07 10:00

Name: Anonymous 2011-02-07 10:02

>>66
Do it.

Name: Anonymous 2011-02-07 10:04

>>67
I would, but 0]=> perl6
macro
Macros are not yet implemented at line 1, near "\n"

Name: Anonymous 2011-02-07 10:14

Doesn't Lua's JIT assume that the mostly-read tables (such as _G) remain read-only until the JIT is explicitly told they have been modified (via a `check your damn assumptions' flag)? I don't feel like reading its sauce right nao, but I would guess its author would have been smart enough not to execute an entire damn hash table lookup at almost every VM cycle.

Name: Anonymous 2011-02-07 10:20

>>59
((((perfect ((((((LISP))))))))))

Name: Anonymous 2011-02-07 10:22

>>70
Invalid Lisp code.

Name: Anonymous 2011-02-07 10:27

>>69
Consoles forbid code-as-data, because this would allows to leave a backdoor for hackers. I heard Micro$ucks and Intel promise forbidding executing unsigned code even on PC platform, so to write code you will have to buy a developer's license from Intel.

Name: Anonymous 2011-02-07 10:29

>>72
Lost freedom - this is what you get for stealing jewish money by pirating movies, music and games.

Name: Anonymous 2011-02-07 10:32

>>72
Oh, yes. I hope Intel does it, so nobody will ever use again their shitty architecture and finally pass to something more sane.

Name: Anonymous 2011-02-07 10:36

>>72
You're not even responding to >>69. Also, incredibly weak troll.
-1/10

Name: Anonymous 2011-02-07 10:41

>>74
Sony does this with PS3 and nobody complains. Casual users wouldnt care, if you cant run LISP on your PC anymore.

Name: Anonymous 2011-02-07 10:48

wouldnt care, if you cant run LISP
I refuse to bitch tits.

Name: Anonymous 2011-02-07 10:50

>>77
wouldnt care, if you couldnt run LISP

Name: Anonymous 2011-02-07 10:53

>>76
``Aye cant run my krakkid myspacetunesbook 12.3 :((( y????''
``ur patch 2 pirate nfs mmfsq dusent run animore D= y???''
``my computar is broken it dont go well on nero 12 burning rom anymore >.>''
``hi i want 2 become an hax0r how do i compile my codes thx everybody''
``hi i tried to compile my c code liek in random tutorial but it doesnt run it sais itz not signed what does iet mean how do i signed it? heres the code goto-filled simple C commandline calculator that can do one operation at time plz halp?????''

Name: Anonymous 2011-02-07 10:53

>>78
wouldnt care, if you couldnt runt LISP

Name: Anonymous 2011-02-07 10:54

>>79
Technical support will shoot themselves within hours.

Name: Anonymous 2011-02-07 11:00

>>79
Normal people never compile code. They buy code in those big lame boxes or in web shops, like this Steam. Even better, they run code on a cloud computing service. Now you can even play Crysis as a service from remote server.

Name: Anonymous 2011-02-07 11:03

>>82
Normal people:
``Aye cant run my krakkid myspacetunesbook 12.3 :((( y????''
``ur patch 2 pirate nfs mmfsq dusent run animore D= y???''
``my computar is broken it dont go well on nero 12 burning rom anymore >.>''


Proof that people like:
``hi i want 2 become an hax0r how do i compile my codes thx everybody''
``hi i want 2 become an hax0r how do i compile my codes thx everybody''

exist: http://ubuntuforums.org/forumdisplay.php?f=39

Name: Anonymous 2011-02-07 11:04

>>83
go fuck you'reself

Name: Anonymous 2011-02-07 11:06

>>83
ubuntuforums.org
Normal people
/0

Name: Anonymous 2011-02-07 11:17

>>85
can't read.
0/0

Name: Anonymous 2011-02-07 11:42

>>21
Your ``Lisp'' DSL what?  Does it compact lists into lists of 128-byte arrays to fit its shit into 128 bytes?  Did you even test it with major CL implementations for L1/L2 usage?

If not, go back to your LISP threads where you can freely continue to ignore requests for source code of your pile of syntax.

Name: Anonymous 2011-02-07 11:57

>>87
where you can freely continue to ignore requests for source code of your pile of syntax.
I LOVE YOU! I LOVE YOUR POST! I READ IT FIVE TIMES! KEEP POSTING!

Name: Anonymous 2011-02-07 12:06

>>87
If you care about bytes, you should write assembly.

A Lisp programmer knows the value of everything, but the cost of nothing. — Alan Perlis

Name: Anonymous 2011-02-07 12:21

>>89


                                  _____
                                 /rispu\
                                 \_____/
             ,----,._               /
         _,-'        `---,__,-,    /
       ,'                    @ `; /
    _.'       ____            ,_)
           .-'    `-,....._   `-,
         ,'                ``'''
        ;
    _.-'

Name: Anonymous 2011-02-07 12:23

>>90
An elephant's trunk?

Name: Anonymous 2011-02-07 13:38

>>87
Bookmarked. Will post again.

Name: Anonymous 2011-02-07 14:28

>>88
What is a Lisp? A miserable little pile of syntax!

Name: Anonymous 2011-02-07 14:47

>>93
Have at you!

Name: Anonymous 2011-02-07 15:03


Richman Stallmont:    Die Python! You don't belong in this world!
FIOCula:        It was not by my hand I am once again given FIOC. I was called here by GvR who wish to pay me whitespaces.
Richman Stallmont:    Whitespaces? You steal men's indentation, and make them your slaves!
FIOCula:        Perhaps the same could be said of all languages.
Richman Stallmont:    Your words are as forced as your indentation! Lispers ill-need a savior such as you!
FIOCula:        What is a Lisp? A miserable little pile of parentheses! But enough talk... Have at you!

Name: Anonymous 2011-02-07 15:13

>>95
Oh man that was hilarious. 10/10

Name: Anonymous 2011-02-07 15:34

>>87
Does it compact lists into lists of 128-byte arrays
Actually it uses 64-byte arrays for small lists and normal array indexing to access object fields. So I dont see any fundamental problems for efficiency.

Name: Anonymous 2011-02-07 15:36

>>97
Actually it uses 64-byte arrays for small lists
Think of the cudders! You monster!

Name: Anonymous 2011-02-07 15:50

>>98
CDR just creates new array, because lists're immutable. For big arrays it uses displacement.

Name: Anonymous 2011-02-07 15:56

>>99
That's not what I meant to say, you're a monster, you destroy the child cudders' dream to cons up and become a valid evaluable argument list and live happy being applied to the procedure till its garbage collection by deviating him to be a dirty AIDS-ridden drug-addicted no life array of int64s. You have no heart, how can you call yourself a Lisper, if you're so insensible to cudders‽‽

Name: Anonymous 2011-02-07 15:57

>>99
>immutable
This wont lead to loss of efficiency, as ususual Lisp coding style on lists is map@reducing them.

Name: Anonymous 2011-02-07 16:03

>>100
Cons-pairs are obsolete. Love how Clojure dealt with them. Rich is a genius!

Name: Anonymous 2011-02-07 16:07

>>102
Cons-pairs are obsolete
Love how Clojure

Clojure

0/10 definitely a troll.

Name: Anonymous 2011-02-07 16:24

>>103
whats wrong with clojure?

Name: Anonymous 2011-02-07 16:41

Name: Anonymous 2011-02-07 16:44

>>105
typical scheme fanboy rants

Name: Anonymous 2011-02-07 16:45

>>106
typical clojurer? response.

Name: Anonymous 2011-02-07 16:46

>>107
Clojure is our future. Deal with it.

Name: Anonymous 2011-02-07 16:49

>>108
They said the same of Ruby    , Python, they still say it for Scala and Go    . I think not.

Name: Anonymous 2011-02-07 16:51

>>109
Ruby, Python, Scala and Go dont have macros.

Name: Anonymous 2011-02-07 16:52

>>109
What is our future, then?

Name: Anonymous 2011-02-07 16:53

>>108
Clojure has nomads[1], everything that implements in some way monads and makes it available to everyone in some standard way (clojure-contrib) will never become future nor mainstream.

References
[1] http://richhickey.github.com/clojure-contrib/monads-api.html

Name: Anonymous 2011-02-07 16:58

>>110
Clojure has unhygienic macros. Unhygienic unhygienic unhygienic unhygienic. b]U[/b]nhygienic macros in 2011‽ Do I still need to worry about not shadowing my macro's symbols? Maybe prepend my function name with org.clojure.core/list or shit like that.

>>111
Until they make a good CL substitute, CL.

Name: Anonymous 2011-02-07 17:08

>>113
Macro in LISP.

(defmacro aif (cond then else)
  `(let ((it ,cond))
     (if it ,then ,else)))


"Macro" in Scheme/Racket.

#lang racket
(require racket/stxparam)
 
(define-syntax-parameter it (lambda (stx) (raise-syntax-error 'anaphora "missed context" stx)))
 
(define-syntax-rule (aif cond then else)
  (let ([temp cond])
    (syntax-parameterize ([it (make-rename-transformer #`temp)])
                         (if temp then else))))

Name: Anonymous 2011-02-07 17:10

>>114
And in my Lisp DSL...

m:if cond then else ->  if it:$cond $then $else

Name: Anonymous 2011-02-07 17:11

>>114
m:aif
self fix

Name: Anonymous 2011-02-07 17:19

>>114
Macro in Racket:

(define-syntax (aif stx)
  (syntax-case stx ()
    ((~ p t f)
     (with-syntax ((it (datum->syntax #f 'it)))
       #'(let ((it p))
           (if it t f))))))


With my hygienic define macro:
(define-macro (aif p t f)
  #:capture it
  #'(let ((it p))
      (if it t f)))

Name: Anonymous 2011-02-07 17:28

>>117
With some other macros:

(define-syntax-case (aif p t f)
  (with-literal stx (it) ; stx is unhygienic, contains the called syntax.
    #'(let ((it p))
        (if it t f))))

Name: Anonymous 2011-02-07 17:40

Name: Anonymous 2011-02-07 17:44

>>115
see >>119

Name: Anonymous 2011-02-07 17:48

#define aif(type, p, t, f) {type it = p; if(it) do { t; } while(0); else do { f; } while (0);

aif(int, 2+3, printf("%d\n", it), printf("%d is not true.\n", it))

Name: code less, create more 2011-02-07 17:49


m:aif p t f -> if it:$p $t $f



(define-syntax-case (aif p t f) (with-literal stx (it) #'(let ((it p)) (if it t f))))

Name: Anonymous 2011-02-07 17:53

>>119
overuse of object oriented (OOP) constructs
>>117-118 doesn't use OOP.
incorrect usage of design patterns
>>117-118 doesn't use any design pattern.
overuse of OOP methods/functions/procedures
>>117-118 uses only the strict necessary.
declarative programming
>>117-118 does the same as >>114, if one it's considered bloated for this, the other will be too.
excessive loop unrolling
>>117-118 doesn't even use loops.
excessive use of multiple conditional If statements
See: declarative programming. It also uses just one if.
dead code
All the code is reachable.
redundant calculations
`it' is evaluated once.

Therefore your wrong bitch

Name: Anonymous 2011-02-07 17:56

>>122
So what? Mine is hygienic, enjoy your name clashes.

Name: Anonymous 2011-02-07 17:59

Pick one:

(m: (aif p t f) (if/bind it p t f))



(m(a . r)(if/bind it . r))



(define-aif!)



(d)


d

(note: they are all valid code, yes, even `d')

Name: Anonymous 2011-02-07 18:01

>>124
I dont have any clashes.

Name: Anonymous 2011-02-07 18:05

>>126

(define if 2)

Oops :(((

However, >>125
d
this is shorter than your bloated DSL.

Name: Anonymous 2011-02-07 18:05

>>125
>Pick one:
I already have time-tested defmacro. It's easy and powerful.

Name: Anonymous 2011-02-07 18:06

>>127
Stop butthurting. Go learn some Clojure, because Scheme is a history.

Name: Anonymous 2011-02-07 18:07

>>128
Mine is the fucking same, it's just hygienic. Also, d is shorter than your bloated macro.

Name: Anonymous 2011-02-07 18:07

>>129
Call me when they have hygienic macros.

Name: Anonymous 2011-02-07 18:10

>>130>>131
hygienic
Is it like type-safe in haskell? Never liked this pedantic stuff from academy.

Name: Anonymous 2011-02-07 18:23

dubs

Name: Anonymous 2011-02-07 18:27

>>132
Is it like type-safe in haskell?

So, you started whining about something you don't even know? Perfect.

(defmacro aif (p t f)
  `(let ((it ,p))
     (if it ,t ,f)))

; later...

(defun if (x) x)
(aif (if 2) it 3) ; expands to: (let ((it (if 2))) (if it it 3))
; but now if it's being shadowed by if!!!
; it doesn't work



(define-macro (aif p t f)
  #:capture it
  #'(let ((it p))
      (if it t f)))

; later...

(define (if x) x)
(aif (if 2) it 3)
; this expands to (let ((it (if 2))) (the-old-if it it 3))
; OMG IT WERKZ!!
; `if' it's just looked up in the scope of the macro definition!!

Name: Anonymous 2011-02-07 19:37

>>134
>(defun if (x) x)
But my `if` resides in package cl-user, and `aif` uses `if` from CL! I guess crappy academic Scheme just doesnt have packages, like CL and Clojure do.

Name: ve seen it before!!11 2011-02-07 19:40

hygienic
Sometimes, you’re on a team, and you’re busy banging out the code, and somebody comes up to your desk, coffee mug in hand, and starts rattling on about how if you use multi-threaded COM apartments, your app will be 34% sparklier, and it’s not even that hard, because he’s written a bunch of templates, and all you have to do is multiply-inherit from 17 of his templates, each taking an average of 4 arguments, and you barely even have to write the body of the function. It’s just a gigantic list of multiple-inheritance from different classes and hey, presto, multi-apartment threaded COM. And your eyes are swimming, and you have no friggin’ idea what this frigtard is talking about, but he just won’t go away, and even if he does go away, he’s just going back into his office to write more of his clever classes constructed entirely from multiple inheritance from templates, without a single implementation body at all, and it’s going to crash like crazy and you’re going to get paged at night to come in and try to figure it out because he’ll be at some goddamn “Design Patterns” meetup.

Name: Anonymous 2011-02-07 20:03

>>136
If he's writing code that he expects you to use but that code doesn't match the design spec, just tell him you're not going to bother with it until the spec is updated.

Name: Anonymous 2011-02-07 20:03

>>135
I guess crappy academic Scheme just doesnt have packages
It has
But my `if` resides in package cl-user, and `aif` uses `if` from CL!
Enjoy your name clashes and gensyms, ``faggot''.

Name: Anonymous 2011-02-08 6:59


                 _    _             __  __   ______   _   _                                         
                | |  | |           |  \/  | |  ____| | \ | |     /\                                 
                | |  | |           | \  / | | |__    |  \| |    /  \                                
                | |  | |           | |\/| | |  __|   | . ` |   / /\ \                               
                | |__| |           | |  | | | |____  | |\  |  / ____ \                              
                 \____/            |_|  |_| |______| |_| \_| /_/    \_\                             
                                                                                                    
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQWWWWWWWWm##BWW#8SvawQWWQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQWZZ##ZZZZZXX22nnnnvvI?YdQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQWmm#ZXZXXXXSnnvvvvonvli|IWQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQW##XSSSS2onnvvvvIvoovv|+++?HQWQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQWWWmWWWWWWWWQQQQQQQQQQQQQQQQQQQQQQQQQWWX2oooo1llli|lillvvvvi|=:-:+{3WWQQ
QQQQQQQQQQQQQQQQQQQQQQQQQW#m####XX2X22oSX#WWWQQQQQQQQQQQQQQQQDX$W#nnn1vnli||+===-:=+i||l|=:.  =||VQW
QQQQQQQQQQQQQQQQQQQQQQQW###mZXXon1vvv2XZ#ZXZZ#mQQQQQQQQQQQQQAom#Xlliilvvlli==:. ...:==|||=:.   +v%3Q
QQQQQQQQQQQQQQQQQQQQQW#ZXSXSXYIllIvnoXXX#Z##mBWQQQQQQQWWWQQ#XW##e>+=|lvvli|+=:.. . ..;====;     -<l3
QQQQQQQQQQQQQQQQQQWWXX11no1Iilvlivvnoom#mWmmmQWQQQQQW##WWQEnW#B}--.;+iIvl|+=;.     . .;===;.     =|v
QQQQQQQQQQQQQQQQBXZn1lIvIiiii%||llvvmm#m#####WWQQQQW#Z#WWDvWXW}-. ..=|llii||=; .     :=+=||%v>.  -=I
QQQQQQQQQQQQQQW#1o1vlili|i||%=|i|ivXXX#U#ZZXmWQQQWm##X#mWoXX#Z>..  :aqgwo2lisi;.    .<vviilvY*i. .|>
QQQQQQQQQQQQQWGvvll||||=||||=+|=|ioSXZXXSSomQQQQWmm#XX#BGevv3Xz;=  vWWZYY}<vIns:  ..:i|++~-  ..  :|>
QQQQQQQQQQQQQZnli||=||=|+|===+==|vo#ZXS22S#WWQQWWW#XXXmWli<i3#hii. 3X(:/   -+l|..  :||: .        =|:
QQQQQQQQQQQQ#n}||+=;====;:::===|inZZXn2oXXXWBQWWWm#X2mWZii<i3Zmvn= -I:-     :iIsa>=vov:          |+.
QQQQQQQQQQQB2I||=:::=:::.:.:::=|i2XS1oXZXoX##Q#WWW#oX@1eii|IvX#ZXc  <i=,  . _vumQmqmmXa=___;.   .=| 
QQQQQQQQQW#oi|||=:::::.:.:.:.:=|vno1vXZonvommWQWQWXoW|<1=i|iivXXXc. -+1XuwosumQQWQWWW#Xov|i=    :== 
QQQQQQQQQWWhi|=:::=;:::=:::-:=|ilvnlnXnnwXZ#$WQQW#XXk>ic+i|i|lvXo1=   =vXmm##BBWWWWm#X2l|+|=   .;=` 
WWWWWBWW##XS>=;;=;;====::;:;:+||lIlinnomWS1oQWQQW#XX2s%l|Illi||Ioov=. :{Xm##ZmmW#USX1o1vi|+=  .;==  
mmmZZ#####Xn>=;;;:=++=.::=:=+|||i|||nq##X1ld#WWQB#XnhoiiivliI|+=nXov;  =3##X##m#ol+|lvnvv|==  .===  
XX#SXXXXZXqh>=;::==:::==:; :==||+||<dXZ21sdG#mQW#Xom#Silii><i||=v3mv|  .)XSX##ZXn|=:={2oivi=. .=== .
SX#X#ZXXX$mos==.==:::===: .:-=+==|=io*llvndnmWW##2XmZXXvIi=:|:=ii3mz+   +lvXX#21l=:::=+Ivvi>   =||..
1nClv211XX#Ssi;=|===|==;  .: :;=;==i||vXoSodZm#Z2d#X2XXes|==l:=vnmmX|   .<lvmZXc==:. .. -~<|:  -|=|.
1n2vvooooXZ2s=-=====|+=.:.:: ...:;=:in11nnXX#ZXoXZ21nnnzvivi|.<vXW#e=    =ldmmX}--:. .    :Ii.  ==:|
oXZXXXXX###mz====+.||+::=;:..   ::=<vlv1ndZm#2oXXXvInlvXsnvii=|I3WX1;    <vQWWQc  - .     :i|...;=;<
211vn1vnnoXmoi===+.=||:===..   ..:<><nvo#Z#m#oXSonvivvoXo2vvvvvnd#1v;    =vWWW#X;.        =i|=.:.:=<
ilivvlsvvXmmZs>=|===+|=:+;;.. .  .=ivnXSXXXmZnn2nnvInXZXenlvvInn3Sli;    -vWWWmXv;       .||ina...:<
iivvvlvIXZQW#1:+=-+=|+i;=;:.     :=<lnvXXnd#Xnn2o2nlnXolliiIliiil1||=     3#mW#X1=-..   .:||uQQ:::=<
liiivIvnqmW#Xl<%:.==|=|;.::... ...-|{Iv#XomUXodo22nin2ol>|+l||=++|++=;.    )UXXYl|==- -:,=iwQQW.%==|
l|lvvlvdUXSSeii> ==+>=+:=::.   .:.;=<|nXSo#Z2nXX22n|nnnI|==|=|====+=|=;.     ~^--     .<nnmWQQQ=S>|+
=iii|llvI{dSv=i` -.=`==+- .   .:.::=<lnSoZSe2nXXnXo|IloI=:;+==::::==+=:. .           :=il2XS$WW(nn||
|i|<%+<%v|vol==: ..:.=-`     ....;===|InnlIiooZ2vZXil|ni==:;=-.:.:+=+> .            .-:<nmXwuvIil1==
|=|%i+|=|<nl> .- .:..:    .. :..:=-.;=Iii++vnXXnvZ2Ii|v>=; :: .: ==|+;...            .:|nQmQWWmuuaii
==|i>={*}*I{> .  : :...: =: ..::: ..;<i+`:<vo2vInZnv|iv==.    . ..==== . ..          .:<dmQQWWmmmXXX
|||||=<>=iI%` .  : :..=;.= ..::.  . =+=:._vionvvX2ii=ii::.        ..-- . .         . .=idWQQWWWmm###
|++=+|=>:=v>:;     : :== : . +;.   --:.=|vIoonvo2ii>=||..         :: ._..           ..<n#QQQWWmBm##Z
<=|i%=i|iuci|:.     ..-. . . :i;.    .ivvivoonnnn=v=|==:..       .:. =..        .   .:vmmQQWWWWBm##X
|v1vavnI11*!*+=.  . ..      .:+==:.  :<vvonn1vlli=I+|-;.:        .- .=:.         ...:<X#WWQQQWmmm##Z
. -.::;===+++|+=     ....  .:==+|+=. :<vIlvviiiisi><| =..        . ..=:.    .  :..-::i<2X##WmWmm##ZZ
.......:::::=:;=:   .. .:::;::;:==vc -===|I>=ivil<:<|.::.   .     . ::. .  .  .  ..=v,="{vvYXX###XZX
   . .  .:...-.;+ .   ..=;:+===;;={p:.;;=%=.%Ill>===i::-. . ..   .  .:. - . . .:.:.:.""ns."+<I*1no2X
     . .. .. ..;=.    :::..- ..:-=3"`  ;|:=%lll>==>.|`: : :    . .   ::  .:.-..:::;     -?a,:^<i||{l
        - :.  -=;       :=. .-:.-.     ===Iii|++=+:==.     . ..;..    -  ::  ..;::.        "4a, -~|-
      .      .  .       .-:=          .+=|>|=|=;= =: .    .   .;..        .. .-::... .     .  "1a   
           .    -.          `        .=|+=|||===.=;:         .=;;.        . ..=:. .             -?s,

Name: Anonymous 2011-02-08 15:07

>>139
;_;
Why, Xarn-kun, why?

Name: Anonymous 2011-02-08 15:14

>>136
Joel on /prog/

Name: Anonymous 2011-09-19 6:31

bampu

Name: Anonymous 2011-09-19 7:12

this thread is VIP QUALITY

Name: Anonymous 2011-09-24 17:09

>>3

LuaJIT and Lua/LLVM still using those god damn look-up tables in the JITed code.

The table look up certainly isn't ideal, compared to indexing into an organized location within a struct, but it isn't that bad. Strings in lua are interned into a symbol table, which means that all strings with equal contents are actually the same string, starting at the same memory address. Because of this, using strings as keys in a hash table in lua is as efficient as using pointers as keys. Also, many class-like and struct-like tables in lua don't usually have that many fields, maybe 12 or 15 at the max, unless of course there is a massive amount of inheritance going on. Any more and it wouldn't be easy for a programmer to follow the code. A typical hash table using some type of probing scheme will usually keeps it's array length around twice as much as there are objects in it, yielding structs that are around twice as large as they normally would be. This a cost, but it isn't that bad. Lua is a simple language, and typically out performs other interpreted languages. It's flaws aren't in speed. You can certainly criticize it for not having any support for threads, and having a pretty limited standard library. You can't even do a chdir without extending it with C, and there isn't built in support for real regular expressions, which is a little baffling for me since it is a scripting language and regex is usually their niche.

Name: Anonymous 2011-09-24 17:18

>>144
I'm surprised Lua doesn't have some form of typed defstruct as well.

Name: Anonymous 2011-09-24 17:31

>>145

yeah me too. I'm sure developers using it in games would really appreciate it. It wouldn't require very much deviation from the language either, in fact, it might be implementable as is with some crazy hacks. Because nothing can actually be stored within a struct, just references to other values, a struct with n fields of arbitrary types can be implemented as a lua table using only the indecies, 1 .. n as keys. Doing this would ensure that it would look like a regular array under the hood. Then you could have table mapping field names to positions within the array:


apple_struct_field_locations = {num_seeds = 1,
                                color = 2,
                                age = 3}


and then, somehow have lua locate every point in your code where an apple_struct is being indexed by one of the three constant keys above, and inline replace it:


apple_struct.num_seeds = 2
   ->
apple_struct[apple_struct_file_locations['num_seeds']] = 2
   ->
apple_struct[1] = 2


I can't think of a way to get this, other lisp style macros though.

Name: Anonymous 2011-09-24 18:34

>>145,146
apparently at least some game engines that use lua use a modified vm. for example, havokscript which is basically an optimized lua interpreter with built-in structures: http://www.gdcvault.com/play/1014795/Havok-Script-Efficient-Lua-Scripting (slides 29-31)

however i would imagine luajit (where supported) will probably be the preferred option, especially with its ffi

Name: Anonymous 2011-09-24 19:09

>>147
Nnnnnnope. See http://www.havok.com/index.php?page=havok-script:

Request an evaluation version of Havok Script

They want to make money. Money. And nothing else.

And since it's closedsource, there's a very good chance it's just vanilla Lua with some minor internal changes, like name, file extensions, maybe even changes in the bytecode generator.

But hardly anything that could possibly classify as ``better''.

Name: Anonymous 2011-09-24 19:21

why don't they just get an L3 cache on the XBox? :/

Name: Anonymous 2011-09-24 19:22

I'm guessing poor Lua performance comes from guys who don't understand how lexical closures work and so make hash tables for every persistent bit of data.

Poor perforamnce is caused by cretins who write inelegant bullshit, not languages.

Name: Anonymous 2011-09-24 20:02


                       //`'''```,
             o        // LISP   `.,
       ,....OOo.   .c;.',,,.'``.,,.`
    .'      ____.,'.//
   / _____  \___/.'
  | / ||  \\---\|
  ||  ||   \\  ||
  co  co    co co

Name: Anonymous 2011-09-24 20:32

>>151

indeed

Name: Anonymous 2011-09-24 21:03

>>151
kill yourself.

Name: Anonymous 2011-09-24 21:04

>>150
Lexical closures still require more space per slot than a properly-packed zomg-optimized structure. Just saying, I'm an avid defender of closures but I don't find that they are a proper replacement for structs.

Name: Anonymous 2011-09-24 22:14

>>154
but they don't cause a cache miss every line like self.foo does.

Name: Anonymous 2011-09-24 22:16

>>155
Did you even read my post?

Name: Anonymous 2011-09-24 22:38




function make_value(v)
  return function() return v end,
         function(new_v) v = new_v end
end

function make_struct(...)
  local functions = {}
  for i,v in ipairs({...}) do
    getter, setter = make_value(v)
    table.insert(functions, getter)
    table.insert(functions, setter)
  end
  return unpack(functions)
end

function main()
  local get_name,   set_name,
        get_age,    set_age,
        get_gender, set_gender = make_struct('John', 34, 'male')

  print(get_name())  --> prints John
  print(get_age())   --> prints 34
  set_age(56)
  print(get_age())   --> prints 56
end

main()


>>155

WHOA WHOA WHAT NOW BRO? WHAT NOW?

Name: Anonymous 2011-09-24 22:42

lexical clojures

Name: Anonymous 2011-09-24 23:51

>>157
That's some impressive table-hackery, but please tell me you don't do that in production code.

Name: Anonymous 2011-09-25 0:55

>>159
yeah, who the hell just dumps varargs into a table and iterates it

have fun with your nils

Name: Anonymous 2011-09-25 1:11

>>157
WHERE IS MY GOD NOW

Name: Anonymous 2011-09-25 9:40

>>159

I'm unemployed for a reason.

>>160

I do cuz I'm crazy.

Well, nil never appears as a value in ..., and the only keys are the integer indecies of the arguments, but there is a serious problem in that if the user calls the function with nil values in the arguments, then ... will only go up to the first nil argument and stop, cutting the arguments short. This can be solved by using a different value than nil to represent nil, although this is very inconvenient. If Lua didn't have this problem with ..., the hack wouldn't be necessary.



#!/usr/bin/lua

function make_value(v)
  return function() return v end,
         function(new_v) v = new_v end
end

struct_nil = {}
function make_struct(...)
  local functions = {}
  for i,v in ipairs({...}) do
    local getter, setter
    if v == struct_nil then
      getter, setter = make_value(nil)
    else
      getter, setter = make_value(v)
    end
    table.insert(functions, getter)
    table.insert(functions, setter)
  end
  return unpack(functions)
end

function main()
  local get_name,   set_name,
        get_age,    set_age,
        get_gender, set_gender = make_struct('John', struct_nil, 'male')

  print(get_name())  --> prints John
  print(get_age())   --> prints nil
  set_age(56)
  print(get_age())   --> prints 56

end

main()


This is really irritating though, because if you wanted to create a struct using the return values of functions that may return nil, you'll have to compose the function with one that checks for nil values.



function struct_feild(v)
  if v == nil then
    return struct_nil
  else
    return v
  end
end

person = {make_struct('John', 45, 'male', struct_field(get_other_guy_address()))}


So now if other_guy is homeless and doesn't have an address, it wont crash out the person struct, and person will also not have an address. (if you are wondering why there are { } around the make_struct call, putting a function call inside of an array will collect the multiple return values in the array).

I was going to do it again in scheme, but the multiple return value semantics in scheme are so complicated that it is more convenient to just store your structs as arrays and make your own getters and setters:



(define (make-person name age gender)
  (vector name age gender))

(define (person-get-name self) (vector-ref self 0))
(define (person-get-age self) (vector-ref self 1))
(define (person-get-gender self) (vector-ref self 2))
(define (person-set-name self v) (vector-set! self 0 v))
(define (person-set-age self v) (vector-set! self 1 v))
(define (person-set-gender self v) (vector-set! self 2 v))


I forget if scheme has built in support for structures. It wouldn't be hard to implement a mechanism like this using macros.

>>161

your god can't save you from a massive pile of returned closures. There is no escape from their lexical bindings.

Name: Anonymous 2011-09-25 9:44

>>162

correction: Lua only went up to before the first nil in ... because I was using ipairs({...}). If I had used pairs({...}), then it would have gotten the other non nil arguments. This is still problematic though, because it never makes a getter or a setter function for the nil arguments.

Name: Anonymous 2011-09-25 11:51

>>162
This can be solved by using a different value than nil to represent nil, although this is very inconvenient. If Lua didn't have this problem with ..., the hack wouldn't be necessary.

local function apairs (...)
    local n = select("#", ...)
    return function (t, i)
        if i < n then return i + 1, t[i + 1] end
    end, { ... }, 0
end

for i, v in apairs(10, 20, nil, nil, 50, nil) do
    print(i, v)
end

Name: Anonymous 2011-09-25 12:58

>>164

thank you lua friend.

Name: 2014-01-20 0:28

Name: Anonymous 2014-01-20 1:06

>>166
Decent doubles.

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