DEV Community

Discussion on: Why the JS ecosystem is awesome !

Collapse
 
travismix1980 profile image
Travis A Mix

Wow that is so much work but that is probably because of all the garbage we have forced into the pile of garbage JavaScript already was. I am glad you have found something you like but JavaScript isn't the solution to everything infact it's really only good in a small group of use case scenarios. Why do we keep overengineering simple things?

Collapse
 
gmartigny profile image
Guillaume Martigny

You seems to have a conflicting relation with Javascript and that's alright. Of course, JS is not meant for everything, that would be bad.
The fact that JS is able to do CLI, web API and front-end scripting, all of that with the same code-base is still awesome in my opinion.
I don't know where do you see so much work. This article is quite long because it was aimed at medium to low level devs. The code is somewhere around 100 line of code, this is far from a lot of work.
What solution would you have recommended that is less over-engineering ?

Collapse
 
travismix1980 profile image
Travis A Mix • Edited

First off just want to point out that you mention that JS was created to work on the back end but unless I am mistaken it was created to make buttons work on the front end and it wasn't until node that we could use it on the backend.

Javascript is being presented as the solution to everything these days, and not only that, but it changes so much that what is new and what you need to know at this moment is outdated and not cool anymore in about 5 minutes it seems. What this leads to is people chasing after every new thing that comes out or getting frustrated and giving up. We need to help the new people instead of scaring them off which is what all this pushing JavaScript leads to. JavaScript, language we used to say was for people who couldn't figure out programming has turned into a huge complicated mess that tries to do everything and its getting harder to the point where it rivals C++ in difficulty if it hasn't already surpassed it.

How many different languages and tools and npm packages did this require, and yet your trying to convince people this is easy and aiming at new devs, and it's no wonder we scare people off.

As far as an example of an easier way of doing things here is some c# code that I found in a quick google search on how to create an png file in unity and export it. This code has 6 lines to it. I know its a different situation but still if your looking to make a png file and export it this is easier than what you did. It used only one language, no need to find and install a bunch of packages, no config files no scripts to let your operating system work with it or anything.

//create the bitmap
Bitmap bmp = new Bitmap(50,50);
Graphics g = Graphics.FromImage(bmp);

 //paint the bitmap here with g. …
 //I just fill a recctangle here
 g.FillRectangle(Brushes.Green, 0, 0, 50, 50);

 //dispose and save the file
 g.Dispose();
 bmp.Save(@"filepath", System.Drawing.Imaging.ImageFormat.Png);
 bmp.Dispose();

if we want to help more people become developers instead of scaring people away we need to find and show simple solutions that serve a real need not scary looking things that don't really help anyone out. We need to stop promoting JavaScript for everything because learning php for example is not hard at all infact it is super easy and most anyone can pick up the majority of it in an afternoon.

Here is a python example using the Pycairo library to create a png drawing it using vector math and then exporting it which can be found at pycairo.readthedocs.io/en/latest/t...

import math
import cairo

WIDTH, HEIGHT = 256, 256

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)

ctx.scale(WIDTH, HEIGHT) # Normalizing the canvas

pat = cairo.LinearGradient(0.0, 0.0, 0.0, 1.0)
pat.add_color_stop_rgba(1, 0.7, 0, 0, 0.5) # First stop, 50% opacity
pat.add_color_stop_rgba(0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity

ctx.rectangle(0, 0, 1, 1) # Rectangle(x0, y0, x1, y1)
ctx.set_source(pat)
ctx.fill()

ctx.translate(0.1, 0.1) # Changing the current transformation matrix

ctx.move_to(0, 0)

Arc(cx, cy, radius, start_angle, stop_angle)

ctx.arc(0.2, 0.1, 0.1, -math.pi / 2, 0)
ctx.line_to(0.5, 0.1) # Line to (x,y)

Curve(x1, y1, x2, y2, x3, y3)

ctx.curve_to(0.5, 0.2, 0.5, 0.4, 0.2, 0.8)
ctx.close_path()

ctx.set_source_rgb(0.3, 0.2, 0.5) # Solid color
ctx.set_line_width(0.02)
ctx.stroke()

surface.write_to_png("example.png")

There is just a couple of quick examples. JavaScript sucks when you look at the alternatives.

Thread Thread
 
nielsbom profile image
Niels Bom • Edited

Technically JavaScript has been a server side language since 1995 (source). Although I don't think it was used a lot up until we got node.js.

Thread Thread
 
nielsbom profile image
Niels Bom

I disagree with a lot you're saying.

JavaScript, language we used to say was for people who couldn't figure out programming has turned into a huge complicated mess that tries to do everything and its getting harder to the point where it rivals C++ in difficulty if it hasn't already surpassed it.

OK, where do I begin?

JavaScript is a language with a lot of good features. It also has some ugly warts, definitely, and most JavaScript devs really know that this is the case. The reason why JS wasn't taken seriously is not because of the language. This had more to do with browsers not running JS fast enough, computers were slower and a couple more reasons.

JavaScript, the language, has not gotten that much new features in the last few years. The features that were added are actually quite good and very useful.

As far as an example of an easier way of doing things here is some c# code that I found in a quick google search on how to create an png file in unity and export it.
no need to find and install a bunch of packages

So your counter example uses Unity which is a video game engine. That's sort of like saying "welding a bicycle yourself is more work than buying a car". Well duh.
😄

Here is a python example using the Pycairo library...

Ah and now we come to your Python example, yum. Don't misunderstand me, I like big parts of Python.

Now please show us how, with very little work, you can make this Python script into a CLI, a package and a deployed web app.

(hint: this is quite a bit of work actually)

because learning php for example is not hard at all infact it is super easy and most anyone can pick up the majority of it in an afternoon

OK, and by now I get the feeling you're trolling. I can't take you seriously anymore.

Well played.

Thread Thread
 
gmartigny profile image
Guillaume Martigny

All languages have a reason to exists. Monopoly has never been any good anywhere. We couldn't have Javascript without the syntaxe breakthrough of Java, without the C++ V8 engine, without the Erlang CouchDB Database of NPM ...

JS maybe's not perfect, but for newcomers I'll recommend it without hesitation (I know, I'm biased).

Thread Thread
 
mjesuele profile image
Matt Jesuele

The complaint is that JS requires libraries and configuration and your counter-example is in a compiled language that requires an SDK and uses Unity? Wow.