keean / zenscript

A trait based language that compiles to JavaScript
MIT License
42 stars 7 forks source link

Why ZenScript? #24

Open shelby3 opened 7 years ago

shelby3 commented 7 years ago

@shelby3 wrote:

@skaller some where you wrote that you don't know why anyone would run JavaScript on the server instead of something more performant or better designed (presumably with static checking). Some reasons that come to mind (@keean may have others?):

  • Node.JS and npm are an ecosystem
  • Reuse of the same code on the server and the browser
  • C++ is a pita (1500 page manual), Haskell is too obtuse, Python is slower, Scala too many corner issues, Java too verbose no damn unsigned int any way. Some of them don't have GC by default nor typeclasses.
  • JavaScript's asynchronous concurrency model is a better first step than multi-threading
  • Compiling to JavaScript from most other languages carries of load of other crap with it. Bucklescript and Purescript maybe exceptions, but we didn't feel those languages give us what we or the mainstream want.

In short, there really isn't a great general purpose language for modern programming. That is probably why we are doing this, even though both of us probably didn't want to take time away from other important work we also need to do.

shelby3 commented 7 years ago

Before y'all get too attached to the name ZenScript, please note I want to change it to Type-fu.

Seems I better do something about this soon, before this ZenScript name gets adopted into everyone's consciousness by default.

shelby3 commented 7 years ago

@skaller replied:

There is a great language for modern programming: Felix. Of course it won't run in a browser which is a big negative.

And frankly I would expect even otherwise Felix would still get very low adoption by the JavaScript/Java/Python mainstream because of Felix's syntax choices and making the language too powerful. I don't know about competing with C++, as I last coded in C++ in 2002.

I could be wrong about that though. I am getting old (51) so I may be out-of-touch.

Felix may be a great powerful language though. I don't know it well yet.

But JS is useless for anything serious. I don't know node.js but I know people that have used it to do servers and they say it is utter crap once you go past a really simple "canned" application. Google agrees, that's why they invented Go, to write servers. Go is crap too of course :)

The best language I've seen recently that is popular is actually Apple's Swift.

Swift doesn't have typeclasses. I read it facilitates a design pattern which can sort of give some of the benefits of typeclasses, but afaik the compiler isn't doing the heavy lifting.

Also I remember something about Swift using the upper bits of a 64-bit value for something on Android (something about memory addressing afair). I forgot the details. Seemed really hokey when I was reading about it.

Any way, we should expect Swift to be pretty good since its primary designer is apparently the creator of LLVM.

I think we need to move reasonably quickly on something like ZenScript, because Swift is for example gaining momentum and it doesn't have typeclasses in earnest.

I should probably expend some more time studying Swift and relay my findings.

Given that it has to wrap Objective C, it is pretty cool: variants, pattern matching, HOFs, closures, etc. They say it will be open sourced eventually.

In any case, I have no problem with a language that targets javascript. Zen is certain to be useful. I'm all in favour!

Please continue that discussion here. It doesn't apply to Compiler Implementation. That is why I made this thread.

skaller commented 7 years ago

Haha .. you're a spring chicken. I'm 61 :)

Actually, Swift DOES have type classes. It doesn't call them that but it does have them. I don't know quite how powerful they are but Swift is not static, they're upgrading it. It's not perfect by any means, but at least the developers knew some dang computer science!

SimonMeskens commented 7 years ago

JS is useless for anything serious

I would seriously fight you on that. Unless you can show me a useful language (as in, not some esoteric language no one uses) that has prototypal inheritance, JavaScript is actually one of the most useful languages out there. Also, it's the most used language in the world and it used by massive servers all the time.

Optional typing through TypeScript massively improves the language of course (which is why Google is probably going to make a superset of JavaScript that is somewhat compatible with TypeScript, called SoundScript).

JavaScript is based on Scheme and Self, two of my favorite languages. I wish it had some more features of Scheme of course, but overall, JavaScript is fast, powerful, available on all platforms (there's embedded systems running JS for christ's sake) and it has the best ecosystem by a long shot.

SimonMeskens commented 7 years ago

JavaScript's asynchronous concurrency model is a better first step than multi-threading

I think this is important too, I talked about it before, but JavaScript's setTimeout model is pure genius. I'm not even sure which other language even has it? It's a very good concurrency model. It's simple, powerful and as you said @shelby3, a really good first step to build more useful abstractions on top of.

It's basically a simple even queuing system. Most infinite loops in JS are written by: running the loop once, queuing it to run again. You yield priority to other processes by requeuing it (timeout of 0 works really well here).

shelby3 commented 7 years ago

So Swift can do typeclasses. The part I missed before when I linked to this:

There is also another way of expressing the same idea: see this article on how to do it using Swift 1.2 (spoiler alert: <C: Ceasarable where C.T == C>)

So you could do multiple associated type parameter typeclasses with the linked method.

So I would say let's transpile to Swift (or just use Swift!), except:

Other reasons to create ZenScript instead of hoping to advance with Swift over time, is that syntax of Swift isn't ideal from my (and probably @keean's) perspective such as lacking a data type syntax.

keean commented 7 years ago

@shelby3 I can't see any evidence Swift can do multi-parameter type classes from following the link.

shelby3 commented 7 years ago

@keean I think we'd write that instead <A, B, C: Ceasarable where C.A == A, C.B == B> assuming Swift supports that intersection syntax on a where clause.

shelby3 commented 6 years ago

Re: Why Zenscript?

I wrote:

And @evancz the creator of Elm realizes that it’s not designed for all those use cases. I agree with his point that “alternatives make each community stronger”.

The Organizational Structure of Programming Languages.