Programming thread

People react to it like this and then wonder why I like Javascript.
it's cool in a sick perverted way but the ideal language should only have smaller languages in it after you tell the smaller languages to be there
you shouldn't ever have to figure out that your type system with 6 different nulls can be used to make brainfuck but worse
 
How can we make a holy-C like interpreted language called javaScripture?
holyc is already jit compiled so all you need to do is rename it
I really wish that instead of coming out with WASM, W3 came up with a sensible alternative to Javascript.

:optimistic:
the web was already turning into a weird application platform so they added a weird version of the jvm
 
  • Like
Reactions: Wright
people chastise c++ for having extensive, complicated, and weird turing complete macros bolted on over c's barely-enough-to-work text substitution macros, but javascript wins the fucked language competition yet again by accidentally having a turing-complete esoteric language erupting out of its heavily retarded type system

nobody had to make this horror it was simply discovered within the treacherous insanity of javascript
What's interesting is that it works more as a transpiled language, since it abuses a bunch of type interoperability and truthiness "features" of JS to execute JS code underneath. Ones such as:
  • You can turn primitives like booleans and ints into strings by adding an empty array to them. For example: true+[] === "true". You could then index these strings with square brackets to pick out individual letters.
  • Negating an empty array evaluates as false. So ![] === false and, by extension, !![] === true. You can do !+[] === true too.
  • +true === 1, so +!![] === 1. Conversely, +false === 0, but this isn't nearly as useful.
  • You can access array functions and properties by indexing them with square brackets and a string key like any other object. For example: [1, 2, 3]["concat"]([2, 1]) === [1, 2, 3, 2, 1]. Consequently, you can repurpose the existing function constructors to execute your own code from a string.
The last one is most interesting because if you can create any string using this type system trickery, you can painstakingly build a string of JS code out of these symbols and have that code executed.

Edit: some dishonorable mentions:
  • [1] + [2] + [3] === "123" -> [+!![]] + [!+[]+!![]] + [!+[]+!![]+!![]] === "123"
  • +("123") === 123 -> +([+!![]] + [!+[]+!![]] + [!+[]+!![]+!![]]) === 123. This also works if you use square brackets to encapsulate the value instead.
 
Last edited:
What's interesting is that it works more as a transpiled language, since it abuses a bunch of type interoperability and truthiness "features" of JS to execute JS code underneath. Ones such as:
  • You can turn primitives like booleans and ints into strings by adding an empty array to them. For example: true+[] === "true". You could then index these strings with square brackets to pick out individual letters.
  • Negating an empty array evaluates as false. So ![] === false and, by extension, !![] === true.
  • +true === 1, so +!![] === 1. Conversely, +false === 0, but this isn't nearly as useful.
  • You can access array functions by indexing them with square brackets and a string key like any other object. For example: [1, 2, 3]["length"] === 3. Consequently, you can repurpose the existing function constructors to execute your own code from a string.
The last one is most interesting because if you can create any string using this type system trickery, you can painstakingly build a string of JS code out of these symbols and have that code executed.
Neat!
and with the power of randomly converting numbers to strings by adding [], i can make "100" with +!![]+[]+(+![])+(+![]). positive false being 0 can be useful in this demented world, at least for golfing. i don't know which integrated type names like "Infinity" i can grab random letters from to make it a real number (i'm a lazy nigger)

anyway if you still think js is a particularly sane programming language, i don't know what to say
see kids? this is what happens when weak typing and polymorphism go way too far
 
Neat!
and with the power of randomly converting numbers to strings by adding [], i can make "100" with +!![]+[]+(+![])+(+![]). positive false being 0 can be useful in this demented world, at least for golfing. i don't know which integrated type names like "Infinity" i can grab random letters from to make it a real number (i'm a lazy nigger)
An important thing to note is the leading + is an implicit add to 0. So you can combine ways of evaluating true to save a few characters. For example:
Code:
+!![]+!![] === 2
!+[]+!![] === 2

Edit:
Code:
+(1e1000) === Infinity -> +([1]+(true+[])[3]+[1000]) === Infinity -> +(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]) === Infinity
+[false] === NaN -> +[![]] === NaN // this works with +[true] too.
[][[]] === undefined, [][+[]] === undefined // there are a lot of ways to do this one.
 
Last edited:
I am slowly growing to love Lisp in my head, but I haven't taken the plunge and programmed in it yet, just reading a lot of samples.

What's the best way to dive in?
Scheme is nice. There are all sorts of variants, but the one that Racket is derived from is solid.

How to Design Programs, Second Edition

Once you get the hang of one dialect, the skills transfer very well to other ones. So common lisp won't be completely foreign after learning scheme or racket.
 
Last edited:
  • Agree
Reactions: Marvin
I am slowly growing to love Lisp in my head, but I haven't taken the plunge and programmed in it yet, just reading a lot of samples.
congratulations on wanting to learn the only programming language which has fanboys more obnoxious than rust niggers. these spergs have been extremely elitist since before most rust fans were born, and will continue to be obnoxious for long after the rustlets 41%. welcome to (((the eternal (((lisp))))))
What's the best way to dive in?
step 1 is to set up emacs because i've never seen a lisp faggot who doesn't love emacs
step 2 is to write some programs (just like every other language)
you don't have to be super familiar with macros right away, you can write programs the normal way if you want. the power of macros is when you keep repeating some pattern so you write a macro and make it a new part of the language
Scheme is nice. There are all sorts of variants, but the one that Racket is derived from is solid.

How to Design Programs, Second Edition
scheme is a very simple lisp that leaves out things like the controversial loop macro and retarded separate namespaces for functions and variables. it also helpfully leaves out most of the libraries too because it's hard to fit random shit like xml into a <100 page report. fortunately it's just a myth that you can't do real work in scheme, you just end up locking yourself into one of the half-dozen different implementations with different libraries included. there are also srfis which are very nice
 
An important thing to note is the leading + is an implicit add to 0. So you can combine ways of evaluating true to save a few characters. For example:
Code:
+!![]+!![] === 2
!+[]+!![] === 2

Edit:
Code:
+(1e1000) === Infinity -> +([1]+(true+[])[3]+[1000]) === Infinity -> +(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]) === Infinity
+[false] === NaN -> +[![]] === NaN // this works with +[true] too.
[][[]] === undefined, [][+[]] === undefined // there are a lot of ways to do this one.
Neat!
and with the power of randomly converting numbers to strings by adding [], i can make "100" with +!![]+[]+(+![])+(+![]). positive false being 0 can be useful in this demented world, at least for golfing. i don't know which integrated type names like "Infinity" i can grab random letters from to make it a real number (i'm a lazy nigger)
This is the most succinct reason of why even after three tries with JS for Frontend and Backend lectures, I fucking dropped my CompSci Technical degree.

JavaScript is the unholy child of Brainfuck and Java, dear Turing.
 
named let in Scheme and Racket works close enough imo
they are not the same though because loop is a massive insane gigamacro that does 73 different things and named let is a small syntax sugar macro that helps you make recursive functions and not much else
This is the most succinct reason of why even after three tries with JS for Frontend and Backend lectures, I fucking dropped my CompSci Technical degree.

JavaScript is the unholy child of Brainfuck and Java, dear Turing.
js is like if somebody took scheme and did srs (syntax reassignment surgery) to troon it out to look like java and then added some shit from random other languages to try and patch up the holes made by the butchery
and somewhere along the way they decided to make it weakly typed and overload the operators really hard so it can have weird and counterintuitive behaviors like jsfuck
 
they are not the same though because loop is a massive insane gigamacro that does 73 different things and named let is a small syntax sugar macro that helps you make recursive functions and not much else
Yeah, to rephrase: named let works close enough practically for anything you should be doing with it. My biggest problem with the CL loop is its syntax is gross and unwieldy, and I feel there are much more LISPy ways of achieving its goals. Like sure, you can still insist on having a big disgusting macro that'll also change the oil in your car and make you a cheese sandwich, but make it less butt ugly.
 
Yeah, to rephrase: named let works close enough practically for anything you should be doing with it. My biggest problem with the CL loop is its syntax is gross and unwieldy, and I feel there are much more LISPy ways of achieving its goals. Like sure, you can still insist on having a big disgusting macro that'll also change the oil in your car and make you a cheese sandwich, but make it less butt ugly.
the worst thing about loop is that it does half a dozen things that HOFs can do and another half a dozen things that other functions could do and also provides iteration facilities as what feels like an afterthought to all that
 
  • Agree
Reactions: y a t s
step 1 is to set up emacs because i've never seen a lisp faggot who doesn't love emacs
I use emacs, but pretty much solely as a text editor with syntax highlighting.

The thing is, emacs lisp is fucking horrible and I don't know how anyone ever writes anything in it.

If there was an emacs-like editor with a good lisp, like a scheme or something, that'd be baller as fuck. Except you'd lose all the years of extensions and other crap people have written in emacs lisp. So you'd have an even smaller audience of people willing to contribute.
 
If there was an emacs-like editor with a good lisp, like a scheme or something, that'd be baller as fuck.
There is this fennel language which is basically lua lisp. It compiles to lua and has full interop with it.
Some use it to configure neovim.

IDK how close it is to "emacs-like editor with a good lisp" though.
 
Back