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

Pages: 1-4041-

JavaScript alternative

Name: Anonymous 2008-12-24 12:26

Is there any language similar to javascript but which can compile to binary?

Name: Anonymous 2008-12-24 12:46

How similar?

Name: Anonymous 2008-12-24 12:47

Scheme

Name: Anonymous 2008-12-24 13:10

>>2
Prototypes,type inference/no type declarations,C-like syntax,flexible functions with ability to return (functions)}.

Name: Anonymous 2008-12-24 13:18

(copied from wiki)
JavaScript supports all the structured programming syntax in C (e.g., if statements, while loops, switch statements, etc.). One partial exception is scoping: C-style block-level scoping is not supported. JavaScript 1.7, however, supports block-level scoping with the let keyword. Like C, JavaScript makes a distinction between expressions and statements.

[edit] Dynamic

dynamic typing
    As in most scripting languages, types are associated with values, not variables. For example, a variable x could be bound to a number, then later rebound to a string. JavaScript supports various ways to test the type of an object, including duck typing.[10]
objects as associative arrays
    JavaScript is almost entirely object-based. Objects are associative arrays, augmented with prototypes (see below). Object property names are associative array keys: obj.x = 10 and obj["x"] = 10 are equivalent, the dot notation being merely syntactic sugar. Properties and their values can be added, changed, or deleted at run-time. The properties of an object can also be enumerated via a for...in loop
Also String[index] as array elements

run-time evaluation(NOT REQUIRED)
    JavaScript includes an eval function that can execute statements provided as strings at run-time.

[edit] Functional

first-class functions
    Functions are first-class; they are objects themselves. As such, they have properties and can be passed around and interacted with like any other object.
inner functions and closures
    Inner functions (functions defined within other functions) are created each time the outer function is invoked, and variables of the outer functions for that invocation continue to exist as long as the inner functions still exist, even after that invocation is finished (e.g. if the inner function was returned, it still has access to the outer function's variables) — this is the mechanism behind closures within JavaScript.

[edit] Prototype-based

prototypes
    JavaScript uses prototypes instead of classes for defining object properties, including methods, and inheritance. It is possible to simulate many class-based features with prototypes in JavaScript.
functions as object constructors
    Functions double as object constructors along with their typical role. Prefixing a function call with new creates a new object and calls that function with its local this keyword bound to that object for that invocation. The function's prototype property determines the new object's prototype.
functions as methods
    Unlike many object-oriented languages, there is no distinction between a function definition and a method definition. Rather, the distinction occurs during function calling; a function can be called as a method. When a function is invoked as a method of an object, the function's local this keyword is bound to that object for that invocation.

[edit] Miscellaneous

run-time environment(A COMPILER IS REQUIRED)
    JavaScript typically relies on a run-time environment (e.g. in a web browser) to provide objects and methods by which scripts can interact with "the outside world". (This is not a language feature per se, but it is common in most JavaScript implementations.)
variadic functions
    An indefinite number of parameters can be passed to a function. The function can both access them through formal parameters and the local arguments object.
array and object literals
    Like many scripting languages, arrays and objects (associative arrays in other languages) can each be created with a succinct shortcut syntax. In fact, these literals form the basis of the JSON data format.
regular expressions
    JavaScript also supports regular expressions in a manner similar to Perl, which provide a concise and powerful syntax for text manipulation that is more sophisticated than the built-in string functions.

Name: Anonymous 2008-12-24 13:25

>>4
I don't know why C-like syntax would be important, but Lua does all the rest (and does it better).

Name: Anonymous 2008-12-24 13:30

>>6
C-Syntax is this:
 abc(x,y,z){
if(x>0){y=do(x);if(!x){return y};
switch(y){
case 'what':;do_something();break;
default:
}}}

Name: Anonymous 2008-12-24 13:33

do
  local oldprint = print           -- Store current print function as oldprint
  print = function(s)              -- Redefine print function
    if s == "foo" then
      oldprint("bar")
    else
      oldprint(s)
    end
  end
end

can this be bracketised and run in lua or its FIOC?

Name: Anonymous 2008-12-24 13:35

this syntax sucks.Its mix of python and scheme

Name: Anonymous 2008-12-24 13:36

Lua:
do
end

what i want:
 oldprint = print         
 print = function(s)           
 if(s == "foo"){oldprint("bar")}else{oldprint(s)}

Name: Anonymous 2008-12-24 13:40

do
  local oldprint = print           -- Store current print function as oldprint
  print = function(s)              -- Redefine print function
    if s == "foo" then
      oldprint("bar")
    else
      oldprint(s)
    end
  end
end

OPTIMIZED :
oldprint=print;print=function(s);(s=="foo")?oldprint("bar"):oldprint(s);

Name: Anonymous 2008-12-24 13:48

FURTHER OPTIMIZED:
print(s=='foo'?'bar':s)

Name: Anonymous 2008-12-24 13:55

Lua:
function factorial(n)
  if n == 0 then
    return 1
  else
    return n * factorial(n - 1)
  end
end         

//notice the difference
Javascript:
function factorial(x){for(var i=x;i>0;i--){x=x*i};return x}

Name: Anonymous 2008-12-24 14:09

Lua:

fibs = { 1, 1 }                                -- Initial values for fibs[1] and fibs[2].
setmetatable(fibs, {                           -- Give fibs some magic behavior.
  __index = function(name, n)                  -- Call this function if fibs[n] does not exist.
    name[n] = name[n - 1] + name[n - 2]        -- Calculate and memoize fibs[n].
    return name[n]
  end
})

Javascript:
function fibs(x){a=0;b=1;c=0;for(i=x;i>1;i--){c=a+b;a=b;b=c}return b}

Name: Anonymous 2008-12-24 14:19

>>13
FIXED:
function factorial(x){for(i=x-1;i>0;i--){x=x*i}return x}

Name: Anonymous 2008-12-24 14:22

JavaScript could be more concise:like instead of:
function factorial(x){for(i=x-1;i>0;i--){x=x*i}return x}
i'd like to:
factorial(x){for(i=x--;i>0;i--){x*=i};x}

Name: Anonymous 2008-12-24 14:26

or even more concise:
fact(x)={loop(x--){x*=i};x}

Name: Anonymous 2008-12-24 14:31

fact(x)={loop(x--){x*=i};x}
----explained
function fact(x){
loop x-1 times
 multiply x by i(implicit loop counter) and save as x
return last expression;x
}

Name: Anonymous 2008-12-24 14:33

>>17
should be:
fact(x)={loop(x-1){x*=i}x}

Name: Anonymous 2008-12-24 14:42

Jvascript(shortest function to return absolute value)
function abs(x){return (x>0)?x:-x}

Could be twice as short:
abs(x){x>0?x:-x}

Name: Anonymous 2008-12-24 14:55

For every wasted character i could write more code.
Shorter code is more productive:thats why Lua,Python and other "Explicit declarational" languages suck.
They waste the space with empty syntax.

Name: Anonymous 2008-12-24 14:59

>>21
Bullshit.

Name: Anonymous 2008-12-24 15:01

The following expression finds all prime numbers from 1 to R. In both time and space, the calculation is O(R²).

(∼R∈R°.×R)/R←1↓ιR

Name: Anonymous 2008-12-24 15:02

>>23
Wtf is this language?

Name: Anonymous 2008-12-24 15:03

Name: Anonymous 2008-12-24 15:06

>>21
Enjoy your write-only, unmaintainable code.

Name: Anonymous 2008-12-24 15:07

: fact 1+ 1 tuck +do i * loop ;

Name: Anonymous 2008-12-24 15:53

>>13
Javascript:
function factorial(n)
{
    if (n == 0)
        return 1;
    else
        return n * factorial(n - 1);
}

--notice the difference
Lua:
function factorial(x)for i=1,x-1 do x=x*i end return x end

Name: Anonymous 2008-12-24 15:59

Uhh... isn't Javascript compiled these days?

Name: Anonymous 2008-12-24 16:00

>>28
end's and do's ruin the syntax
still the above recursive crap is never used in OPTIMIZED code.

Name: Anonymous 2008-12-24 16:01

>>29
the ngs compiler is linux only.
Java compilers make Javascripts into crappy java applets which load slower then original code and JVM to run.

Name: Anonymous 2008-12-24 16:03

>>28
Invisible block separators.Imagine such function 10 times larger.

Name: Anonymous 2008-12-24 16:05

function factorial(x)for i=1,x-1 do x=x*i end return x end
with separators.
//notice the difference
function factorial(x){for (i=1,x-1){ do x=x*i} end return x end}

Name: Anonymous 2008-12-24 16:09

>>32-33
What?  Why are you adding invalid characters?

Name: Anonymous 2008-12-24 16:21

>>34
They aren't invalid,they are what your crappy language should have
instead of end/do and.

Name: Anonymous 2008-12-24 16:27

to write code efficiently you need to utilize punctuation such as {(;)},not introducing code words you need to type each time you close the block of code.

Name: Anonymous 2008-12-24 16:32

>>36
Hello there, may I interest you in some APL?

Name: Anonymous 2008-12-24 16:34

>>35-36
do is faster to type than (){
end is faster to type than }

That other junk requires shift key combinations; with do and end you never leave the home row.

Name: Anonymous 2008-12-24 16:39

>>37
How does polar bear know what APLs is?

Name: Anonymous 2008-12-24 16:44

>>38
I have 2 hands.

Name: Anonymous 2008-12-24 16:48

>>40
Indeed.  And you can make effective use of both of them so long as you're not typing obscure garbage.

Name: Anonymous 2008-12-24 16:52

>>41
I can hold shift/ctrl/alt with one and type with both.
This is what you use to type your post isn't?
Or do you type "control words" which get auto-capitalized to literal Uppercase characters prefixing words?

Name: Anonymous 2008-12-24 16:55

This is how you type sentences the Lua way:

cap this is how you type sentences the cap lua way:

Name: Anonymous 2008-12-24 16:57

>>43
OPTIMIZED
do cap this is how type sentences the cap lua way end

Name: Anonymous 2008-12-24 17:01

>>44
FURTHER OPTIMIZED:
do cap this
  is how you
     type sentences
   end
  cap lua
 end
end

Name: Anonymous 2008-12-24 17:05

>>45
Emergency Patch from Microsoft:
do cap this
  is how you
     type sentences
   end
if patchlevel> 2
  cap lua +new "way"
 else  cap lua
 end
end

Name: Anonymous 2008-12-24 20:07

Smaller set of fast and easily pipelinable operations considered superior to richer set of more complex and expressive operations, even at the cost of needing slightly more instructions to accomplish any given task.

Name: Anonymous 2008-12-25 2:44

Fcuk this bullshit i'm learnign C++ and writing my own language.

Name: Anonymous 2008-12-25 4:07

>>48
Why would you learn Sepples when you'll soon have your own language?

Name: Anonymous 2008-12-25 4:14

>>49
because you can't write new languages in Scheme or Javascript.

Name: Anonymous 2008-12-25 4:21

Actually i could write the compiler in some http://en.wikipedia.org/wiki/Compiler_compiler
but i'll doubt it will work.

Name: Anonymous 2008-12-25 4:49

Hmm there are several which compile to x86 assembly.
This has potential.

Name: Anonymous 2008-12-25 5:17

>>50
My sarcasm detector may be broken.

Languages like scheme and ml's are actually quite suitable for compiler creation.

Name: Anonymous 2008-12-25 6:11

1. JavaScript is a pretty cool guy.
2. Write a JavaScript I/O library and compiler.
3. ???
4. Profit

Name: Anonymous 2008-12-25 6:38

>>53
Yes,i can generate even raw binary files using plain javascript.
That doesn't mean it a great compiler generator.Its fucking slow.

Name: Anonymous 2008-12-25 6:46

Wikipedia:
The ideal compiler compiler takes a description of a programming language and a target instruction set architecture, and automatically generates a usable compiler from them. In practice, the state of the art has yet to reach this degree of sophistication and most compiler generators are not capable of handling semantic or target architecture information.

Just as i thought...

Name: Anonymous 2008-12-25 6:58

<JavaScript-like language><--Compiler for this(compile to .exe,not VM/runtime/interpreter) <--Compiler for compiler(must be already a compiled program,not intrepreter)

Name: Anonymous 2008-12-25 7:35

i'll probably need to interface it(the interpreter version of the Jcompiler) with Firefox.But this is insignificant compared to writing compiler.

Name: Anonymous 2008-12-25 8:57

>>55
I think i have a better idea,i juts need to test how fast JavaScript handles regex calls.

Name: Anonymous 2008-12-25 23:59

>>59
Compilers are basically regex parsers

Name: Anonymous 2008-12-26 3:27

>>60
I tested this yesterday and apparently its quite fast for interpreted language.Using array.push() to build compiled strings and simple regex would allow easily to parse even 100Kb programs(this would take awhile,but i never wrote things larger then 5KB).
i think arrays+regex are more powerful then BNF grammars.
The compiler-compiler builds parse trees,introduce multiple meanings comprehension and other object-oriented crap.
Here a compiler in 3 lines:
regexarray=[];regexarray['compiledword']=/sometriggercode/gi;
codestring=codestring.replace(/\n/gi,";").split(";");
for(i in codestring){for(m in regexarray){codestring[i]=codestring.replace(regexarray[m],m)}}

Name: Anonymous 2008-12-26 3:49

Nothing but niggers.

First off, you don't need another language, you can use fucking JavaScript. So there is not "but which can compiler". JavaScript can already.

JavaScript has nothing to do with Java. It was only so named because of a lame and failed marketing deal.

However some fag decided to make a tool that compiles JavaScript to Java Bytecode. It sucks like all of Java.

What you want to do is compiler your JavaScript to a native binary using the .Net DLR.

The rest of you niggers, learn your shit.

Name: Anonymous 2008-12-26 3:55

>>62
It would not compile my IMPROVED version of javascript which
first needs to be compiled into .Net compatible JavaScript.(it more concise to write it my way).(and my regex converter would easily make assembly or C code blocks with some changes);
I will try .Net though.

Name: Anonymous 2008-12-26 4:15

Name: Anonymous 2008-12-26 4:29

Compilers are basically regex parsers
You are talking about the parser, which is the most simple part of a compiler.

Name: Anonymous 2008-12-26 5:00

>>65
wikipedia:
A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language). The original sequence is usually called the source code and the output called object code. Commonly the output has a form suitable for processing by other programs (e.g., a linker), but it may be a human-readable text file.

http://en.wikipedia.org/wiki/Linker
In computer science, a linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

Name: Anonymous 2008-12-26 5:03

>>66
??/10/WTF

Name: Anonymous 2008-12-26 5:08

>>67
http://en.wikipedia.org/wiki/Compiler#Compiled_versus_interpreted_languages
In a sense, all languages are interpreted, with "execution" being merely a special case of interpretation performed by transistors switching on a CPU. Modern trends toward just-in-time compilation and bytecode interpretation also blur the traditional categorizations.

Name: Anonymous 2008-12-26 5:15

"This article is about the computing term. For the anime, see Compiler (anime)." ...oh my.

Compiler (as in a computer compiler) is an anime based on the manga by Kia Asamiya which features two girls, Compiler and Assembler, who arrived on earth from 2-D cyberspace to play a "game" in which they will delete the real world and reform it. However, they move in with two young men called Toshi and Nachi and lose interest in the game. After Toshi is injured and the game is cancelled, two beings called Plasma and Compiler 2 are sent in to erase the girls. The opening theme is called, "I Was Born to fall in Love" and the end theme is called, "Full Up Mind", both by Masami Okui. As well as the soundtrack, a single of the opening theme and three image albums - Compiler, Assembler and Interpreter - were released.

Name: Anonymous 2008-12-26 5:18

Name: Anonymous 2008-12-26 5:18

O
ne day, two women, named Compiler and Assembler, drop down in front of brothers Toshi and Nachi. These two women have come from a cyberspace in order to play a game of destruction and creation. They begin their game, which consists of destroying the 3D world (The Earth) and reshaping it, but Toshi who they designated as their stand-alone (spectator), gets injured. Because they broke a rule stipulating that they aren't allowed to injure spectators, the game is canceled. Having failed at their mission, the ruling council of the cyberspace sends two beings to eliminate the two. However, the two girls have since moved in with Toshi and Nachi; as a result, they have lost their desire to continue the game. The animated version of the popular comic by Kia Asamiya. The OVA series consists of two distinctly different chapters, Yin and Yang.
  One evening, Compiler is wandering the streets alone when she unexpectedly comes across Nachi together with a girl. Compiler exchanges pleasantries as she always does and leaves, but for some reason her mood is different today. She never used to care... What is this feeling? From that night,        
Assembler and Toshi start to be concerned about Compiler, who has become depressed. After Assembler and Toshi leave, Compiler goes out again and once again spies Nachi trying to pick up a girl. Nachi sees Compiler and promptly invites her to go drinking with him. While drinking, Nachi flirts playfully with Compiler. However, Compiler, offended, slaps Nachi, gets up and leaves.
  Nachi, however, is unflustered, and gets up and boldly joins a group of girls who have witnessed the scene and again begins making smooth talk. The next day Compiler is still wearing a long face. Asked what's wrong by Assembler, she replies that Nachi made advances on her, but can't come up with an answer for why she is in such a gloomy mood. Just then, a girl comes to visit Nachi. It's the girl he was making passes at the night before.


Main Staff
Original Concept : Kia Asamiya
Director / Script / Storyboards : Yasushi Murayama (Yin chapter), Takao Kato (Yang chapter)
Character Design : Yuji Moriyama
Animation Direction : Yasuhiro Oshima (Yin chapter), Toru Yoshida (Yang chapter)
Animation Production : animate film, Studio Fantasia

Name: Anonymous 2008-12-26 6:13

>>69-71
Damnit, this one is going to be hard to find...

But it'll probably be the "so bad it's good" type of anime. Sort of like SICP.

Name: Anonymous 2009-03-06 8:24

with Zope at a   sixliner in Haskell   and come back   Excuse the lack   of capitalization of?

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