October 30, 2014
I know that there is way to write all on JS. But I can't understand what the reason that there are no single language that can work on web and as native language.
October 30, 2014
On Thursday, 30 October 2014 at 08:39:15 UTC, Suliman wrote:
> I know that there is way to write all on JS. But I can't understand what the reason that there are no single language that can work on web and as native language.

It is possible, but you need to design the language within the constraints of javascript:

1. single threaded (or worker threads)

2. 53 bits integers, 26 bits for multiplies.

4. "weird" fixed size heaps (ArrayView)

5. if garbage collection then it has to be javascript style

6. no tricks: forget coroutines
October 30, 2014
> It is possible, but you need to design the language within the constraints of javascript:
>
> 1. single threaded (or worker threads)
>
> 2. 53 bits integers, 26 bits for multiplies.
>
> 4. "weird" fixed size heaps (ArrayView)
>
> 5. if garbage collection then it has to be javascript style
>
> 6. no tricks: forget coroutines

I can't understand why this restructions?  Could you explain them?
October 30, 2014
On Thursday, 30 October 2014 at 09:35:04 UTC, Suliman wrote:
>> It is possible, but you need to design the language within the constraints of javascript:
>>
>> 1. single threaded (or worker threads)

Javascript is single threaded by nature. Parallel execution is done in isolation. No shared memory.

>> 2. 53 bits integers, 26 bits for multiplies.

Javascript only support double. Double has 53 bits precision. So without emulation javascript support:

53 bit division /
52 bit addition +, -
32 bit masking &, |
26 bit fast multiply *

>> 4. "weird" fixed size heaps (ArrayView)

You can allocate a fixed size byte array and put aligned typed views on it in modern browsers. This is used in asm.js

>> 5. if garbage collection then it has to be javascript style

You have no notion of a stack in javascript. You are therefore stuck with what javascript provides.

>> 6. no tricks: forget coroutines

You cannot implement your own coroutines without an emulation layer which will be heavy.

> I can't understand why this restructions?  Could you explain them?

The restrictions come from what javascript can do efficiently (execution time, code size and memory use).
October 30, 2014
No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!
October 30, 2014
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote:
> No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!

It's already created - C++! http://www.chromium.org/nativeclient
October 30, 2014
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote:
> No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!

Yes, you can create a new programming language that can work everywhere if you restrict the semantics to the least common denominator of platforms or take a speed/space penalty.

But the key to speed in browser apps is to leverage the browser engine or OpenGL,  and in the future OpenCL and worker threads. So… portability is limited unless you bundle the browser with the app.
October 30, 2014
On Thursday, 30 October 2014 at 10:28:06 UTC, Kagamin wrote:
> On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote:
>> No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!
>
> It's already created - C++! http://www.chromium.org/nativeclient

PNACL is using the Pepper API, which is kind of limited: you still need javascript for a HTML5 web app.

And PNACL is limited to Chrome and result in large binaries (and asm.js does too).
October 30, 2014
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote:
> No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where!

The problem is getting new features into the browsers that people use.

You could also just write native programs and use the web as nothing more than a delivery system. You might have a harder time getting people to install it though.
October 30, 2014
On Thursday, 30 October 2014 at 06:14:18 UTC, Suliman wrote:
> Is it's possible to create single language that cover desktop and web? Like D+Dart?

You can also run D code on the web server and do very little on the web client itself for a lot of programs.