r/javascript • • Jul 28 '19

ScriptUI: Write React without JSX

https://github.com/anater/ScriptUI
1 Upvotes

22 comments sorted by

8

u/Renive Jul 28 '19

Lets throw away what everyone knows and learn my syntax. React succeeded because you could use HTML knowledge.

0

u/[deleted] Jul 28 '19

This isn’t so much about the syntax as it is about eliminating the cruft required to use JSX. That’s the goal at least. You need node npm and babel at least. That’s a lot to learn before you try building something. You shouldn’t need a terminal to build a modern web app. It can be easier, this is just one attempt to get there.

3

u/Renive Jul 29 '19

Terminal is used to build and run everything, I dont see your point.

1

u/[deleted] Jul 29 '19

Exactly. You need to build and run your app just to see what you’ve built. This step comes with it a lot of knowledge beyond browser technologies. This makes web development more intimidating to learn for beginners in my experience.

1

u/Renive Jul 29 '19

No its typing webpack into terminal. Bundlers nowadays have zero config mode, it just cant be easier now. If someone is that basic, it shouldnt touch React and focus on fundamentals first.

1

u/[deleted] Jul 29 '19

Whatever man. You’ve missed the point that all of that is extra stuff that isn’t actually required to build a website. Or, if you truly believe it is, then you prefer an overcomplicated work environment.

iOS developers, for comparison, need to know one tool to start building: Xcode. I’d love to see similar simplicity for web development environments.

node, npm, webpack, and Babel only truly are required for a narrow set of projects. We just use them because it’s “easy” now that we’ve done it over and over. But that’s 4 technologies you have to understand when they fail you: whether by bugs or by limitation. I’m not saying what I built fixes all that. I’m saying it’s my motivation to build something with vanilla JS. It’s dishonest to act like all of that is so easy. Ask your youngest family member how easy it is...

2

u/[deleted] Jul 30 '19

so, I just wanted to say sorry that everyone in /r/javascript is dismissing/attacking you. it sucks to have people be callous about your creation.

however, one thing I wanted to say over in /r/reactjs and didn't, was that I wholly disagree with the anti-tooling motivation. static analysis, type checking, linting, minification/uglification are all amazing things to have. sure, I can build a website without them, but I would never do that because the benefits outweigh the cost of learning them.

1

u/[deleted] Jul 30 '19 edited Jul 30 '19

Haha thanks 😅. I do agree with you. These tools are useful. Itd be absurd to propose they aren’t. They impede my process so Im trying something different to help myself. I thought sharing it might be useful for others. I need to work on the presentation. The headline really triggers people here.

2

u/Renive Jul 29 '19

Xcode is far more complicated than 4 of those combined. You talk about npm like its something more than npm install in command line. Same with node, you dont even interact with it, just need to have it installed. All you need is webpack which is medium sized script, compared to multi gigabyte IDE.

4

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

u/[deleted] 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

u/[deleted] 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 is npm start until 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

u/[deleted] 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

u/[deleted] 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

u/[deleted] 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.

0

u/Skaryon Jul 28 '19

I, too, have seen swiftUI