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

Pages: 1-4041-

J-expressions make Javascript the acceptable Lisp

Name: Anonymous 2016-11-25 13:12

The consistent implementation of key enumeration order of objects in Javascript engines allows us to write specifications of composeable computations using generic JSON-serializable notation that we can call “J-expressions”.

{opname: main_parameter,
keyword1: value1,
keyword2: value2,
...}


J-expressions, in combination with functions that implement what the operation named opname is supposed to do, are then a systematic way to approach DSL construction within Javascript. The notation is as expressive as s-expressions.

Name: Anonymous 2016-11-25 13:16

I'm probably going to be writing a small declarative JSON-based (I'd rather have sexp-based one but FIOC sexp libs suck) DSL soon, but it's not going to be executed from JS. and it won't be an acceptable Lisp

Name: Anonymous 2016-11-25 13:21

It is pretty much the same, except a bit more verbose. (opname data) is much better than {"opname": "data"}.

Name: Anonymous 2016-11-25 14:03

J-expressions

lol

Name: Anonymous 2016-11-25 16:11

Uncommon Lisp - Irregular Expressions

Name: Anonymous 2016-11-25 18:35

Hello, I'm beginner singer.
I recorded a couple of songs live, I would like to hear your opinion.
Thank you in advance.
https://www.youtube.com/watch?v=FFkh_FeParE

Name: Anonymous 2016-11-25 18:54

>>6
Лол, какой же ты псих если даже до этой борды добрался.

Name: Anonymous 2016-11-25 21:03

Check em

Name: Anonymous 2016-11-25 21:48

>>1

My other car is an Object.getOwnPropertyNames(obj)[0]

Name: Anonymous 2016-11-25 23:30

>>9
SEXY

ELEGANT

SCALABLE

Name: Anonymous 2016-11-26 1:11

>>10
Also check'em

Name: Anonymous 2016-11-26 7:20

>>1
what's the point of using dictionaries? why not just use arrays?

[opname, arg1, arg2, ...]

var named_functions = {
'add': function(a) {
return a.reduce((x, y) => x + y, 0)
},
'mul': function(a) {
return a.reduce((x, y) => x * y, 1)
},
'car': function(a) {
return a[0]
}
}
var interpret = function(jexpr) {
if (jexpr.length < 2) {
throw `Bad jexpr: ${JSON.stringify(jexpr)}`
}
var [ car, ...cdr ] = jexpr
if (Array.isArray(car)) {
car = interpret(car)
}
if (typeof car === "string" && named_functions.hasOwnProperty(car)) {
var op = named_functions[car]
} else {
var op = car
}
console.log(`op: ${op}`)
return op(interpret_params(cdr))
}
var interpret_params = function(params) {
if (params.length === 0) {
return []
}
var [ car, ...cdr ] = params
if (Array.isArray(car)) {
return [interpret(car), ...interpret_params(cdr)]
}
return [ car, ...interpret_params(cdr) ]
}


Examples:

interpret(['car', ['mul', 4, ['add', 6, 1]]])
;; => 28
interpret([(x) => Math.floor(x / 2), ['mul', 4, ['add', 6, 1]]])
;; => 14


fuck javashit tho tbh fam

Name: Anonymous 2016-11-27 0:02

>>12
Arrays are anti-Lispitic. Nazis were lined up in arrays when they listened to Hitler speeches and gassed the future-Lispniks.

Name: Anonymous 2016-11-27 0:14

>>12
return a.reduce((x, y) => x + y, 0)
throw `Bad jexpr: ${JSON.stringify(jexpr)}`
var [ car, ...cdr ] = params
What the fuck is this garbage?

Name: Anonymous 2016-11-27 3:46

>>12

-1, not using let and const

Name: Anonymous 2016-11-27 12:14

>>14
Those are lambda functions, template literals, and array comprehensions, respectively. Why would you call these garbage? Ecmascript 6 added a lot of neat features and is actually fun to program in. I just wish there were an integral primitive type.

Name: Anonymous 2016-11-27 18:06

car[br]cdr
lol, nobody uses that shit.

Name: Anonymous 2016-11-27 18:11

>>17
[br]
lol, nobody uses that shit

Name: Anonymous 2016-11-27 19:56

>>16
Because it's pointless syntactic sugar that bloats up every JavaScript parser, interpreter, and compiler that supports it.

What's the point in adding a totally different syntax for already existing things to an existing language?

JavaScript already has a lambda syntax (function). It already has a way to include the result of an expression in strings (the + operator). It has array indexing and a slice method.

They should have deprecated and froze JavaScript, and put the new features and syntax into a new language.

Name: Anonymous 2016-11-27 20:45

This type of superfluous syntactic sugar is introduced to pander to stupid people who don't see the forest for the trees. They think that making one thing easier is always good for the language as a whole, not understanding that making one thing easier may make other things harder.

Name: Anonymous 2016-11-27 23:42

>>20
They think that making one thing easier is always good for the language as a whole, not understanding that making one thing easier may make other things harder.
I don't understand. Can you give an example?

Name: Anonymous 2016-11-27 23:58

CHECKEM BITCH

Name: Anonymous 2016-11-28 0:05

>>19-20
Yeah I agree that's why I said javashit is shit. I think the ES6 Ruby-esque lambda syntax, for example, is better than function() lambda syntax so should just have replaced the function() lambda syntax entirely.

>>22
sweet dubs bro

Name: Anonymous 2016-11-28 3:03

>>23

this in lambda syntax is lexically bound
this in function syntax is dynamically bound

Array comprehensions let you do in 1 line what could have taken many lines.

I don't think they should have added the class syntax, however. It's misleading and it doesn't really save any typing compared to writing Object.prototype.method = ...

Name: Anonymous 2016-11-28 11:12

Good thread.

Name: Anonymous 2016-11-30 3:01

>>24
Classes were unnecessary, but I can understand why they added them. The language has gotten criticized for decades for not making OOP easy enough for retards. The masses want classes. The one place where do is calling a superclass method: now you can write super.whatever() rather than pig disgusting SuperClassConstructor.prototype.whatever().

IMO they've already gone too far. Readability is starting to suffer. Some jackass posted a thread on Reddit showing a bunch of truly perverted uses of destructuring applied to objects, which now I'll have to read and understand when they appear in other people's code.

Generators, function*, and yield had some uses, but added a bunch of complexity to the language, and were limited and shitty and didn't really fix the async problem, so now they're adding more complexity (async/await) to deal with that.

Not only must the programmer evaluate whether each of these features is worth using but (this being JS) you need to consider what environments they'll actually work in, and until every feature is universally supported, rely on fifty zillion polyfill plugins for a code generation framework that complicates your build process.

Meanwhile, no old features can ever be removed because ancient web pages would be broken.

It's a fuckin mess and if the committee isn't careful they'll have another C++ on their hands.

Name: Anonymous 2016-11-30 3:02

>>26
The one place where do is calling
Ah fuck, I mean The one place where classes do help is calling a superclass method.

Name: Anonymous 2016-12-02 8:12

Name: Anonymous 2016-12-02 8:39

>>28
there was a better one on that site where someone made a programming language in XML. it was as horrible as it sounds

Name: Anonymous 2016-12-03 1:29

>>29
XSLT is turing complete and is written in XML.

Name: Anonymous 2016-12-03 2:02

Anyone care to explain what TRUE OOP is about? All I ever see are faggots complaining about classes not being TRUE enough but the only counterexample they give are fucking Javashit prototypes.

Name: Anonymous 2016-12-03 2:20

>>31
It means stop passing notes in class and be indoctrinated like a good little object!

Name: Anonymous 2016-12-03 2:51

>>29
Any LISP program can be trivially represented using XML syntax, so I don't see how XML necessarily means a ``horrible'' programming language.

Name: Anonymous 2016-12-03 3:14

Name: Anonymous 2016-12-03 12:23

>>31
True OOP is about objects. Simple, huh? Even your peabrain could feasibly get this without asking stupid questions.
Try redefining an object at runtime in C++/Java/C#, like add new methods to it. Class tyranny is exactly why these languages are COP and not OOP. In Javascript, you are free of class tyranny as classes don't exist, and objects roam and mutate freely, which is why it is closer to Smalltalk and the actual OOP paradigm.

Name: Anonymous 2016-12-03 21:33

>>31
Classes are irrelevant to OOP, as is inheritance. Polymorphism is the critical component needed to actually be OO. Most people think of OOP as needing a bunch of accessor and mutator functions though. That just means they are retarded though.

Name: Anonymous 2016-12-04 9:17

>>35
I don't understand why you need to redefine an object behavior (object methods) at runtime. OOP is all about self-contained objects that communicate to one another by passing messages to one another. I've never needed to design OO systems where the behavior needed to change (by adding, removing or overriding functions) during runtime. I've always designed them as independent objects that work in their own self-contained worlds and communicate through "messages" as soon as they need to read or send information to other self-contained worlds (other objects).

Name: Anonymous 2016-12-04 11:52

>>37
You don't understand it because your mind has been conditioned and formed by the statically-typed COP languages.

self-contained objects that communicate to one another by passing messages
What if you need to add functionality to existing objects, what do you do? Stop the runtime, edit code, recompile and run it again? That's not the OOP way. The OOP way is to never stop the runtime (save it to an image if you need), adding new message handlers or modifying old ones on live objects. This makes for rapid prototyping and fast code evolution. COP on the other hand is a poor man's OOP because defining object blueprints (aka classes) statically supposedly allows the compiler to optimize calls better.

Name: Anonymous 2016-12-04 12:18

>>38
What if you need to add functionality to existing objects, what do you do? Stop the runtime, edit code, recompile and run it again? That's not the OOP way. The OOP way is to never stop the runtime (save it to an image if you need), adding new message handlers or modifying old ones on live objects.
I've never heard this in any textbook I've read about OOP. Are you sure this is OOP because what I described about OOP is the lesson that I've learned about it.

Name: Anonymous 2016-12-04 13:09

>>39
Because what has been marketed to you as OOP was actually COP. Because back in those days languages like Smalltalk were deemed too unperformant compared to the speed of C++/Java. But the real OOP lives on in languages like Javascript or Io.

Name: Anonymous 2016-12-04 13:11

>>39
And if you haven't heard that Smalltalk or Common Lisp are image-based, if the only concept of OOP you have is the statically-compiled crap, well.. then you have no idea of OOP, congratulations!

Name: Anonymous 2016-12-04 15:17

If the supposedly true OOP is about adding methods and members to objects during runtime for no fucking reason, I'd rather stay with COP and actually know what each object has.

Name: Anonymous 2016-12-04 15:36

>>42
That's because you're a static bitch who can't handle dynamicity.

Name: Anonymous 2016-12-04 21:36

>>42
That's fine today, but what about when you want to send similar, but different, objects through your old programs?

Name: Anonymous 2016-12-04 23:41

>>40
You're an authority on OOP based on what qualification? Have you written a textbook or otherwise taught a lecture about this in an accredited course?

Name: Anonymous 2016-12-05 0:07

You're an authority on OOP based on what qualification? Have you written a textbook or otherwise taught a lecture about this in an accredited course?
authority
kek
Authority is a useless concept.

Name: Anonymous 2016-12-05 1:16

>>46
Authority is earned based on either pioneering work that advances the state of art.

Name: Anonymous 2016-12-05 9:32

The Nazis gassed the jews in parallel.

Name: Anonymous 2016-12-05 11:26

authority is a spook

Name: Anonymous 2016-12-05 11:38

there's nothing in the definition of OOP that necessitates it being either static or dynamic. classes and prototypes are different interpretations of the same paradigm which in turn makes class-based languages different from prototype-based ones but at a higher level of abstraction, the underlying concepts and goals are similar.

Name: Anonymous 2016-12-05 13:41

>>50
Who chose you to define OOP?

Name: Anonymous 2016-12-05 13:53

>>51
I chose myself recursively

Name: Anonymous 2016-12-05 15:33

>>51
A call to cddaddar was associated with me.

Name: Anonymous 2016-12-05 16:30

JavaScript won't be an acceptable Lisp until it gets TCO and bignums.

Name: Anonymous 2016-12-05 18:32

>>54
Check my dubblers, Lisp weenie.

Name: Anonymous 2016-12-05 18:54

>>54
TCO
But this is an implementation detail.

Name: Anonymous 2016-12-05 19:32

>>56
Bounded vs unbounded recursion depth is not an ``implementation detail".

Name: Anonymous 2016-12-05 22:04

unbound my anus

Name: Anonymous 2016-12-06 1:57

>>58
e/prog/in ANUS meme, /prog/ro!

Name: Anonymous 2016-12-06 8:52

>>33
XML can represent any tree structure so obviously it can represent any Lisp program. this doesn't mean XML makes Java the acceptable Lisp. with some creative thinking, you can also use it to represent programs in other languages:

<preprocessor>
<include>stdio.h</include>
<define name="ANUS">10</define>
</preprocessor>

<function name="enterprise" ret="void">
<declare type="int">i</declare>
<for>
<init>i = 0</init>
<condition>i &lt; ANUS</condition>
<increment>i++</increment>
<loop-body>
<function-call name="printf" arg1="XML makes Java the acceptable C \n" />
</loop-body>
</for>
</function>

<function name="main" ret="int" arg1="argc" arg1-type="int" arg2="argv" arg2-type="char**">
<function-call name="enterprise" />
<return>0</return>
</function>


or maybe this:

<class name="Main">
<public>
<constructor>
<var class = "ConcreteEnterpriseFactory">
<name>x</name>
<assign>new /org/progrider/bbs/ConcreteEnterpriseFactory</assign>
</var>
<call-method>
x/build/haxMyAnus
</call-method>
</constructor>
</public>
</class>

<class name="AbstractEnterpriseFactory">
<public>
<method name="build" ret="EnterpriseInterface">
<return>/org/progrider/bbs/AbstractEnterpriseFactory/build_internal</return>
</method>
</public>
<private>
<method name="build_internal">
<return />
</method>
</private>
</class>

<class name="ConcreteEnterpriseFactory" extends="AsbtractEnterpriseFactory">
<private>
<method name="build_internal" ret="EnterpriseInterface">
<return>
<new>/org/progrider/bbs/EnterpriseClass</new>
</return>
</method>
</private>
</class>

<class name="EnterpriseInterface">
<public>
<static>
<method name="haxMyAnus" ret="void" />
</static>
</public>
</class>

<class name="EnterpriseClass" implements="EnterpriseInterface">
<public>
<constructor>
<assign value="XML makes Java the acceptable Java">enterprise-variable</assign>
</constructor>
<static>
<method name="haxMyAnus" ret="void" />
<call-method arg1=etnerprise-variable>/System/out/println</call-method>
</method>
</static>
</public>
<private>
<slot class="String">
<name>enterprise-variable</name>
</slot>
</private>
</class>


this doesn't make it any less horrible though. just because you can doesn't mean you should

Name: Anonymous 2016-12-07 0:21

>>60 proves it. XML is more powerful than LISP

Name: Anonymous 2016-12-07 7:49

>>61
you could write the same thing with s-expressions.

IHBT

Name: Anonymous 2016-12-07 12:53

>>62
Sexpressions do not support tags.

Name: Anonymous 2016-12-07 12:55

>>63
tags are syntactic sugar

Name: Anonymous 2016-12-07 23:00

*grabs anus*

Name: Anonymous 2016-12-08 1:15

(check 'dubs)

Name: Anonymous 2016-12-08 7:47

>>66
nice!

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