Commit 239c60a5 authored by Sameer Rahmani's avatar Sameer Rahmani

the target platform post has been improved

parent b357cac0
......@@ -14,17 +14,17 @@ As programmers, we have a tough life when it comes to making a decision that
has direct impact on our product. I'm pretty sure you went through this process
at least once. From choosing a semantically great name for a variable to choosing
a right technology for your next billion dollar startup. It is always hard to
pick a tech stack for a new project. Specially when the new product happens to be
pick a tech stack for a new project. Especially when the new product happens to be
a new programming language. If I get my hands dirty with a wrong tech stack for
a simple web application, no big deal. I still can rewrite the whole thing and
pay a penalty. But in case of programming languages that's not the case. Wrong
pay a penalty. But in the case of programming languages that's not the case. Wrong
platform can easily destroy you. From the dawn of computers, many smart people
created tons of languages. But only few of them made it to the top. While there
are so many reasons for their success, going with the right platform is one
the most important ones.
The obvious question that comes to mind when we're talking about "The platform"
is that should we build a platform from scratch or should we piggyback on others?
is, should we build a platform from scratch or should we piggyback on others?
Creating a programming language and a virtual machine from scratch is gigantic and
bone crushing task. It needs a crazy set of skills and knowledge. Even with such
wisdom and experience people who went through it has made many mistakes and had to
......@@ -39,7 +39,7 @@ abandon my goal. I should ride on the shoulders of the giants to gain benefit fr
their great work. I should choose a platform that helps me to move faster and iterate
through different ideas quicker.
From technical perspective, Starting from scratch means that I have to write a
From a technical perspective, Starting from scratch means that I have to write a
program that includes at least a parser and a compiler. Building a compiler
is no joke. Hypothetically let's say we have a working compiler and parser, What
about use libraries and ecosystem ?? It would be really hard to convince people
......@@ -56,9 +56,9 @@ the picture. We need to find a good platform for it. But what are the options ??
> already available.
[Racket](http://racket-lang.org) is a dialect of Lisp which allows us to build our own
language by extending it. While Racket is really cool and have long list of pros and
language by extending it. While Racket is really cool and have a long list of pros and
[many reasons why to use it](https://beautifulracket.com/appendix/why-racket-why-lisp.html)
(It's Lisp after all), it has a disadvantage that forced me to stop thinking about it
(It's Lisp after all), it has the disadvantage that forced me to stop thinking about it
for **Serene**. As I mentioned in the [rational](/programming/rational-and-a-name/)
I'm not trying to build a toy language or a domain specific one and Racket's ecosystem
isn't as great as a battle tested and well-known ecosystem like Java or Python (or other
......@@ -68,18 +68,18 @@ popular ecosystems).
We're living in the age of Web and one of the big players in this era is Javascript. The number
of the programming languages that compile to Javascript is increasing rapidly. Javascript
as a language [sucks](https://whydoesitsuck.com/why-does-javascript-suck/) but as platform
it is amazing. Lots of money and engineering afford has been spent on improving Javascript engines.
it is amazing. Lots of money and engineering effort has been spent on improving Javascript engines.
As a result Javascript is a crappy language with well engineered engines such as
[V8](https://v8.dev/).
Creating a language base on Javascript platform means that I have to be involved with the whole
Creating a language based on Javascript platform means that I have to be involved with the whole
transpiling scenario and deal with the fact that this new language can be used on different
browsers or on the backend. Or even on IE6 (Just kidding). I don't want to deal with all this.
I think Javascript platform can't be a good fit for what I need. So i won't go in details about
I think Javascript platform can't be a good fit for what I need. So I won't go into details about
it
## Python
Python is another famous platform form creating programming languages. Many people has built
Python is another famous platform form creating programming languages. Many people have built
programming languages on top of Python (Checkout [Lispy](http://norvig.com/lispy.html) if you're
a Python fan). Python is super popular these days and you'll see it everywhere. Creating a language
on top of Python (just like Javascript) gives me access to a rich ecosystem with huge number of
......@@ -87,15 +87,15 @@ libraries and a robust ecosystem.
But as I mentioned in the [rational](/programming/rational-and-a-name/) I want support for built-in
concurrency and parallelism. Python isn't even good when it comes to parallelism and concurrency.
I'm using python for more that 10 years now and I'm very familiar with it. I know about all the
I'm using python for more than 10 years now and I'm very familiar with it. I know about all the
effort to create useful concurrency and parallelism such as asyncIO. But the fact is Python
is not designed for this job. **GIL** is a huge problem in Python that literally prevents
us from Running two piece of code in parallel in two kernel space thread. It is a problem
us from Running two pieces of code in parallel in two kernel space thread. It is a problem
for me. If you can't do a decent concurrency and parallel execution you have no chance
against modern languages like Clojure, Go, Elixir and others. Python is fine now despite
of its problems because it is good at other stuff and people accepted it for what it is.
Python is out there for about 25 years now and it has established a big community. If
Guido van Rossum created Python a year ago, I'm pretty sure that it would've fail because
Guido van Rossum created Python a year ago, I'm pretty sure that it would've failed because
it can't compete with modern languages. Don't get me wrong, I'm not trying to trash Python.
It is great and it has many good qualities but a good Concurrency and parallel execution model
ain't one of them.
......@@ -120,17 +120,17 @@ Plenty of researches have been made to make it better and better.
The JVM has a mature ecosystem and a massive community of developers that resulted in an
unbelievable number of libraries (not the largest though, NPM is the largest artifact
repository. But it has huge amount of useless BS as well). By targeting the the JVM,
repository. But it has a huge amount of useless BS as well). By targeting the JVM,
users will have an easy time adopting the new languages because of the rich tools set
provided by the Java ecosystem and all the languages that targeted JVM as well. For example,
it will be possible to use libraries written in Scala or Clojure as well.
Long story short, I think the JVM is the right platform for me. The fact that many languages
have chosen it as their base platform shows that how useful it can be. But there is a problem.
have chosen it as their base platform shows how useful it can be. But there is a problem.
Targeting a higher level virtual machines like the JVM means that I'll have an easier job to
create a compiler. But I still have to write one. A compiler that takes the code and produces
JVM bytecode. As I mentioned earlier writing a compiler is an enormous task and the chance
of doing it wrong with some one like me who never has built a compiler before is very high.
JVM bytecode. As I mentioned earlier, writing a compiler is an enormous task and the chance
of doing it wrong with someone like me who has never built a compiler before is very high.
## One VM to rule them all
Luckily there is a solution. I can write an interpreter in a VM that is designed to optimize
......@@ -160,7 +160,7 @@ them all.
[Truffle](https://github.com/oracle/graal/tree/master/truffle) library is one the key
players in GraalVM. The initial results of Truffle are super exciting. Implementations
of Ruby in Truffle has a performances on the same order of magnitude as the much bigger
of Ruby in Truffle has a performance on the same order of magnitude as the much bigger
projects of JRuby. Just checkout [Truffle Ruby](https://chrisseaton.com/truffleruby/)'s
website to get amazed by it.
There is a [Javascript implementation](https://github.com/graalvm/graaljs)
......@@ -178,9 +178,9 @@ interpreter and Graal will handle the rest. It means that I can start by buildin
important and use a very well engineered toolkit in my advantage to get to my goal quicker
and then later on replace any part that I like with my own implementation. How cool is that???
But as an engineer and a wannabe scientist I'd like to see the proof with my own eye. Not
But as an engineer and a wannabe scientist I'd like to see the proof with my own eyes. Not
because I don't trust academic work, Just because it feels good to experience the proof.
So to begin with I'm going to create a dead simple Serene interpreter in Java and OpenJDK
and then build the same interpreter using Java on GraalVM using Truffle library and
compare the result and prove myself that choosing GraalVM is the right choice.
compare the results and prove myself that choosing GraalVM is the right choice.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment