r/javascript • u/[deleted] • Jul 28 '19
ScriptUI: Write React without JSX
https://github.com/anater/ScriptUI4
u/Delioth Jul 28 '19
But... why? You can write React without JSX by default if you like it that way. It's just that JSX is a syntax that makes intuitive sense for composing things that are roughly equivalent to HTML with attached JS.
0
Jul 28 '19
I wanted to see how I could achieve something as expressive as JSX but less verbose than using React.createElement. Using JSX requires at a minimum: node, npm, and Babel. Webpack if you’re handling other assets that Babel won’t handle for you.
From a beginners standpoint, it’s intimidating to take on so much knowledge before getting to Hello World. It’s not perfect, it’s just an attempt at something different with a specific set of constraints. It’d be great to have a single dependency that got you to the starting point right away. You could just us a link tag. Web development should be easier to get started with.
1
u/Delioth Jul 29 '19
That's... the whole point of many, many projects like Create React App, React Boilerplate, et al. You use a script to get you to "Hello World" with all the stuff you'll actually use in the real world, rather than dinking around with things that you'll never use as they exist in production. It's better for beginners to learn in an environment that's solid and sustainable, rather than hoping to roll their own and learning in an environment with major issues.
1
Jul 29 '19
Yes but they still require knowledge of command line node and npm. This may be necessary as projects swell and involve many devs. But for learning it all gets in the way to building something. It’s easy to forget how weird it was to learn all of this coming for websites built with jQuery or Vanilla JS.
1
u/Delioth Jul 29 '19
No matter what you're doing, at some point you'll need to learn the command line and NPM to some extent anyways. It doesn't get easier than a tutorial of "install node by googling it and installing it from their website, then run
npx create-react-app [app name]". They're arguably going to need to do vastly more to have a local server that's actually serving the html document that contains the javascript you need. After that initial "gimme an app", all you need on the command line isnpm startuntil you want to get fancy.I just don't get the point of a library that's not any easier than actual production stuff, with the only possible advantage being the ability to not have webpack or babel running, which prebuilt boilerplates handle for you anyways.
0
Jul 29 '19
You’re right that, as of today, all that is necessary. My opinion is it shouldn’t be necessary.
I think the status quo is a burden and wastes mental cycles better spent creating something.
<script>should be all that’s needed to get up and running.And so I figure I try to see what it might look like if you start without it and this is where I ended up. You don’t have to use it or like it. It’s an experiment.
1
u/Delioth Jul 29 '19
The biggest reason that more than a
<script>is necessary... is that you first need to set something up to serve that<script>. You have to start up a server at some point, and a webpack-dev-server configured by CRA running with Node is one of the most painless servers to get going... ever. And it happens to also give you all the tools real work is going to use (or at least approximations of them).0
Jul 29 '19
You literally don’t need a server to use a
<script>tag. You just need a raw JS file and a raw HTML file. Then open the HTML in a browser and: there’s your webpage! No server required.Netflix, Amazon S3, or Github Pages offer (cheap or free) static file hosting that removes the need to think about a server.
Seriously, not every project needs all the tools you’re defending to get started, maintain, or host online. My argument is it’s possible to improve the dev experience without them. I find they are harmful to new devs and slightly annoying for more experienced devs: especially when they break.
1
u/Delioth Jul 29 '19
Well, those are servers, so...
And it's not like I'm advocating for a ton of tools. Just Node (which is useful for many things), Babel (which every site should use anyways so that people with browsers you didn't bother to check can still use your site), and webpack (which is immensely useful to know, and almost trivial to set up for simple projects anymore).
I think it's harmful to try and expose React with a weird API for the sole purpose of eliminating the need for supporting software. There's a reason we have the supporting software in most all projects, and why it's trivial to setup anymore.
3
u/PM_ME_GAY_STUF Jul 30 '19 edited Jul 30 '19
Man, reading through these comments, I just feel so bad for OP right now. This is a neat idea with some good work put into it, and new tools are always fun, but I have to agree with the others here, I'm still not really seeing the why. JSX is nice, it let's you use normal html syntax. And the terminal isn't some scary thing to be avoided, it's your friend who lets you do stuff. I do agree in principle that people should probably stop using npm the moment a usable competitor becomes popular enough, but I only think that because npm is a hot mess right now, not because it's too hard or something.
1
Jul 30 '19
Thanks for the feedback. Haha I wont rehash my other arguments because I think it’s not coming across properly. I need to think more about how to position this tool for this crowd. I just want something I can start building with ASAP. There’s nothing inherently wrong with tooling. It’s just so in the way of actually doing anything. I don’t find boilerplates or scaffolding CLIs (like Yeoman) to be useful - I now have to remember where the repo is or what I called it.
I just want a powerful expressive dev environment that I can whip up with just HTML in my text editor and my browser. So I made this to make that possible. I thought others might appreciate something different and easy to start with. Railing against everyone’s beloved tool chest was probably the wrong angle.
11
0
8
u/Renive Jul 28 '19
Lets throw away what everyone knows and learn my syntax. React succeeded because you could use HTML knowledge.