6
votes
Angular with PureScript
I have to do an assignment for university soon-ish, and it requires Angular. I'm not very fond of that framework specifically, but I would be interested in making it more interesting as a learning project. I've also recently discovered PureScript, which I have no experience with right now.
Searching online, I've purescript-angular, which hasn't been updated in years. I also couldn't find much else. Of course, I may be missing something simple (for instance, it's actually supported by default in Angular these days), so I wanted to ask if any of you know if this is possible, and if so, how?
I'm going with the assumption that you talk about Angular.
I work with frontend technologies since quite some time at this point and I've had experience with AngularJS, Angular, Vue.js and something in React. If you read carefully, you'll understand why I've only had "something with React".
If you allow me I want to spend a couple of lines explaining to you why you should reconsider your viewpoint on Angular / React.
Consider first of all, that the framework you use are tools. If your project don't require a deep and complex structure, you shouldn't use something like Angular. React with its component-first approach is more that fine for that.
But always remember that you shouldn't identify yourself with a framework. It's like a mechanic going to an interview saying that he's a "screwdriver mechanic". You can imagine that he's gonna be kicked out quite fast from that interview.
Having said that, drop that PureScript thing please. Angular move quite fast (using a canary approach for new versions) and it's already at Angular 6.x that is terribly different from the very first version of Angular (called just Angular2). On top of that, try and become accustomed with the official CLI tool. If you used the react-cli, think about that, but ten years in the future.
Every project can nearly be "done" entirely just by using the CLI and writing a couple of lines of logic.
The CLI will take care of organising your components, pipes, providers and whatever else so that you don't have to worry about injection and library loading optimization. Also use Typescript for the love of gods. Not because it's "so much better" but because if you'll need help, it's much more easy to find articles and stackoverflow answers that use that. Also, it's basically the same as using ES7 so there isn't really much of a difference.
Angular helps you keep your code clean, organized and that is invaluable when you'll be working because it will be rare that you're working alone on a project. The latest version also include all the tools you need to scale a project easily in contrast with React that needs additional libraries to take care of things like state management. Your university is doing you a big favour in having you write a project with it.
I see lots of developers hating on it but the only reasons they give me at the end is that "it force them work on hard rails" and that usually means that they cannot write the code with the bad habits that they have developed over time. Which of course, it's a damn good thing.
In summary:
+1 for TypeScript. Using a niche language while attempting to write your own bindings for little gain doesn't seem very appealing.
I think an important lesson for a software developer is being able to choose the right tool for the job, and this might be a good example.
Not to mention having more angular experience in it's recommend language under your belt is never a bad thing, especially if you're considering going into web development.
I've already done a project in Angular before, and I didn't really like it. The project after that I did in React, which I liked much more. I'm also not particularly fond of TypeScript (I'm not fond of JavaScript at all, to be honest), hence I want to give PureScript a try.
Using the right tool for the job is certainly important, but to make this decision you need to be aware of multiple tools, and know how they work in practice.
If your assignment is in Angular, you almost certainly want to be using TypeScript. Almost every resource available is going to be geared towards people using TypeScript; it's the right tool for this job.
While I wholeheartedly agree with this, I don't think that this means that you need to create a Purescript Angular project to know that it's not the right fit for the job. It's important to set yourself up for success in projects and not put roadblocks in your own path if you don't need to. I can't speak for your prof, but if I told someone who worked for me to build something in angular, and they built it in purescript, I wouldn't be impressed; that's almost certainly not what is intended, and it's probably not something your prof wants to mark or look at. If they gave you an angular project, they are probably looking for TypeScript.
In that context I'd agree with you, but this is university. I'm here to learn. University doesn't seem too interested in teaching me multiple tools, so I try to incorporate new ideas into the assignments I'm given myself.
I urge you to talk to your instructor before writing something in an unexpected language. At the very least, there's a chance that you'll be using up your instructor's good will, which is a valuable asset.
There's no need to teach yourself PureScript by doing something that's arcane. Write something in React with PureScript for yourself - that would be more palatable than Angular - or write something purely in PureScript.
But diving in a bit more - what is it about PureScript that you expect to like versus TypeScript? It's certainly okay to have a preference that doesn't match mine (or the general consensus on the matter) but TypeScript is pretty great once you get into it, and to me PureScript is just not quite as good at TypeScript while trying to solve things in the same way that TypeScript does.
The syntax.
But breaking convention (in this case, using PureScript instead of TypeScript with Angular) just for the sake of learning a new technology isn't valuable. If you want to learn PureScript, then I highly suggest doing that without the added complexity of a framework that doesn't support it. I can guarantee you will never work on a project an Angular PureScript project, so what knowledge are you gaining by trying to mix the two yourself?
You'll come to find that a programmer's abilities aren't about how many tools they know, they're about their ability to adapt to tools they're unfamiliar with, or create new tools when necessary. There's no need to reinvent the wheel if you don't have to, so you should stick with Angular convention.
It's great that you want to broaden your horizons and learn things outside your standard cirriculum, but adding an extra complexity like this to your project will be nothing more than a nusisane to yourself and to your professor.
If you want to go above and beyond, you can expand the scope of your project in other ways, like adding additional features. Bringing PureScript into the mix is needlessly complex.
I made this thread because I wasn't sure if it could support it. I ask it first because I'm not dead set on using it no matter what, which seems what everyone is thinking I said now.
That's fair. I interpreted your last couple comments as an intention to use PureScript anyway, but perhaps I was wrong. My mistake.
In short, the purescript-angular plugin you linked to appears to be for a very old version of Angular (1.2), so will not be compatible with more recent versions. Any sort of PureScript Angular project would probably require you to write your own extensive plugin in the same vein as purescript-angular, which would probably not be worth the effort in the long run, as there does not seem to be any way for Angular to currently support PureScript. It is probably possible with a lot of hard work and duct tape, but I would not recommend pursing it.
Almost anything is possible given enough time and effort.
If there is one piece of advice I can give you about Angular (been developing in it for almost 7 years now), fighting it's design and best practices will only lead to more tears. Every single time I've been absolutely frustrated with this framework it was because I was trying to do something in a way that worked against their recommended methods. Angular is a take or leave it framework they have an opinionated way of doing things, and while it's possible to do it ways they don't officially sanction, it's likely to be more pain than it is worth and not likely sustainable.
Knowing your single constraint is that the project must be in Angular, you will have a greater chance of success if you stop worrying and embrace it. You don't have to like it, but you gotta do what you gotta do. If you want to learn Purescript I would suggest doing it in your own time or on a school project that doesn't require a monolithic framework like Angular.