HNHacker News
TopNewBestAskShowJobs

zoomerang

201 karma · joined February 4, 2014

submissionscomments
zoomerang··on The Case for React.js and ClojureScript
I'd agree, except that I consider the level of granularity to be too fine the way React does it, resulting in too much boilerplate to do simple things.
zoomerang··on The Case for React.js and ClojureScript
Yep - JSX solves many of those complaints. (My post was more of a reaction to the 'templates are bad' tone than React itself). I'm not a fan of JSX as a templating language, but it's good enough.

I still feel that React encourages a style of development that pushes small snippets of HTML rather than full-page templates. Depending on your development style and the type of application your building, this may or may not be desirable. (If you're building something that's inherently component based, then it's good. If you're building something that's not, then it just adds boilerplate).

I'm working on a pretty large Angular project at the moment - it's been utterly fantastic, although it does have its warts. (Primarily around maintaining state ). React.JS claims to solve many of these issues, although I'm not entirely sure it solves them in the right way. (I'd prefer to aim for a more FRP approach personally).

zoomerang··on The Case for React.js and ClojureScript
I agree very strongly, but I can understand the opposite viewpoint.

For me, I like to write HTML in HTML. While I'm primarily a backend programmer these days, I've spend a considerable portion of my career writing HTML, so I'm very familiar and fluent in it.

As such, to me, writing HTML as HTML with annotations for data bindings and loop is a much better approach. Anything else just gets in the way of my workflow. AngularJS is the only tool I've used so far that really nails this properly. (At least since Zope)

However a lot of developers aren't HTML guys. They think in code, and to them HTML == DOM == a Tree structure. So it makes sense for them to be returning a tree.

I quite religiously think the latter is the wrong approach and results in less maintainable code. Instead of having a single template with the entire page clearly laid out, you end up with small snippets of HTML rendered all over the place.

This becomes even more jarring when you're working with designers that aren't coders. I manage a team of 7, and Using HTML-based templates means that my designer can write fluent AngularJS templates without developers having to do a thing. The alternative is for the designer to mock something up, and then for developers to cut it up into tiny little pieces and rewrite it in whatever DOM abstraction is the flavour of the month. Try reskinning a site made up of hundreds of small snippets of DOM vs a few complete HTML templates - the latter is far easier.

Some developers like to write Dom in Javascript because they know Javascript and don't want to learn another language.

To me, the idea that templates are bad because somebody doesn't want to learn another language just reeks of anti intellectual bullshit. Angular template aren't difficult.

I'll finish off this post by adding that I much prefer reactive code over imperative observables or dirty-checking, but Angular templates work so ridiculously well it'd feel like a step backwards moving to another framework that didn't have them. My dream toolchain would use something similar to Angular templates, with FRP code behind the scenes.

tl;dr To somebody used to writing HTML, building a page by emitting snippets of DOM inside Javascript is about as annoying as trying to write Javascript by emitting snippets of code in XML.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
Sure, but that's not idiomatic Angular. I'd wager the majority of Angular projects don't even use custom directives.
zoomerang··on AngularJS: Factory vs. Service vs. Provider
Angular does mix HTML and presentation logic. That's the point, and this is desirable.

Angular does not mix Presentation and Business logic. React doesn't inherently mix the two, but it doesn't dissuade it either.

> This does not make sense. React.js whole point is writing components that do emit HTML and re-render themselves (and children).

Yes, but it's writing code in Javascript that emits snippets of HTML or DOM. I'm generally not a fan of this approach. Even just just iteration requires jumping between the two, and often breaks up the page into multiple smaller segments in cases where it really doesn't need to me.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
You can cheat in any framework. The difference is that angular strongly encourages you towards one design, whereas React.js does not. (Directives are also not part of your normal daily workflow. Many projects wouldn't even use them).

Yes, angular templates are templates, not pure HTML. That's the idea. I'm not sure what your point is there.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
More a distaste with the design pattern of mixing HTML and Logic in one monolithic codebase. (i.e. lack of proper separation of concerns)

Forcing a clear separation leads Junior developers towards a better design, which is one of the reasons I like Angular - I can put a junior dev on a project and have them productive within about 10 minutes while feeling fairly confident they will do things the right way. It's a very easy framework to get started with, leads you towards a good overall architecture, and is deep/powerful enough that it doesn't fall over when things get hairy 85,000 lines of code later.

Obviously good React code will keep proper separation of concerns (whether using standalone templates or not), but I do worry a lot of developers will cheat and start emitting snippets of HTML in areas of the codebase that shouldn't be doing that.

Mind you React.js is a great framework, I just personally prefer Angular based on experience working with both.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
If you can solve something in jQuery, why are you using Angular? Wrong tool for the job.

If you have an application that otherwise uses Angular, and you have a snippet of jQuery code that you want to use, wrapping it in a directive takes about 30 seconds. Alternatively, if you don't want to write a directive, you can just run the jQuery code directly as if Angular didn't even exist.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
The Angular guys aren't missing the point. I think it's the other way around.

People see the word "Factory" and for some reason assume that it's somehow a Java enterprise bloatware feature. Nevermind that "Factories" Angular are

a) Nothing at all like Factories in Java

b) Something you don't need to use, and most Angular apps likely don't

c) Really useful when you do need them

If AngularJS is too heavyweight for what you're trying to achieve, it's not he right tool for your task. It's like complaining that a forklift isn't a very good hammer.

Angular is used to build thick heavyweight client applications. The sort of thing you might use to build a complete desktop-style application in the browser running in offline mode.

Mind you it's still surprisingly good at smaller applications as well. But if your solution can be solved with a few lines of jQuery, then you don't need Angular.

zoomerang··on AngularJS: Factory vs. Service vs. Provider
I love Angular for exactly that reason. My HTML template should be a HTML file. I cannot stand codebases that mix code and markup together.
zoomerang··on SanDisk announces 4TB SSD, hopes for 8TB next year.
I've been running a 256gb SSD in my Macbook and haven't come remotely close to hitting that limit.

In my case it's my secondary computer, so I don't see a need to store much in the way of media (Movie, Music) etc on it, which is about the only way I imagine I would use that much space.

The OS and Applications takes up a decent chunk, as does VirtualBox, but other than that it's just documents and source code.

zoomerang··on Porting 600k Map Views to OpenStreetMap/MapBox
I think you misunderstood my post. By 'app', I mean the app built by a third party company that makes use of OSM.

Being a contributor is nice and fuzzy, but not a commercially viable option. If my customer says "I can't find this town on the map", I'm hardly going to tell them to drive out and map it themselves.

zoomerang··on Porting 600k Map Views to OpenStreetMap/MapBox
And therein lies the problem. For some areas of the world OSM data is excellent.

But the internet is global. It might work correctly for you when testing, but somebody in another country finds your app utterly useless.

Even if Google Maps has worse data for some areas than OSM, globally it's far more consistent.

Given that there's far, far cheaper options for mapping than Google while still providing excellent data (ArcGIS comes to mind), if you're building a commercial product with an international market in mind you're still better off using a commercial GIS solution

zoomerang··on JavaScript Promises in Wicked Detail
Callbacks seem simpler in a lot of these examples because they aren't really showing the power of promises.

Promises allow you to chain much more complex flows of information together in a way that would result in a mess of spaghetticode if attempted using callbacks.

zoomerang··on Porting 600k Map Views to OpenStreetMap/MapBox
Outside of the US, OSM is almost completely useless. I live in a major Australian capital city, and there's vast areas of the city without any geocoding information at all.

If you just want to display a vague map of a major metropolitan area it's ok. But as soon as you need to actually find an address, you're out of luck.

zoomerang··on Porting 600k Map Views to OpenStreetMap/MapBox
Google Maps has no free tier for commercial use.

I've been involved in negotiations with Google for their mapping service. I can't give specifics, but will say we settled on another commercial service that was two orders of magnitude cheaper for our use case.

(In our case OSM wasn't a viable option, as mapping data in my country is very poor).

zoomerang··on Exec($_GET
It's pretty easy to implement such a feature in any strongly typed language, but sadly few framework/libraries/stacks actually do it.
zoomerang··on Ask HN: Reasons behind renaissance of functional programming languages
Not to mention Python and Ruby.
zoomerang··on Classy: Cleaner class-based controllers for AngularJS
Look a little closer - It's not about saving bytes. I ended up coming up something very similar for my projects and it made a notable difference in defect rate.

- Removes the need for positional arguments for constructor injection, so you only have to list your dependencies once. This one seems minor but can be a major frustration and a source of bugs when working with lots of services.

- Moves actions out of the scope and onto the controller itself, where they belong.

- Provides a clean template structure for other project members to work off that guides you to nicely structured and properly separated code (i.e. Watches in one section). This seems minor, but when you're working with multiple junior developers it starts to become a big deal very quickly.

You can do all this without using a third party project, but if you're new to Angular this is a nice bootstrap and helps guide you towards a solution that avoids a lot of warts in the framework.

zoomerang··on The JavaScript Problem
It's just another annoying thing on the list of warts with Javascript that make maintain a large codebase a pain in the arse.

Plenty of third party implementations is half the problem. Want to import a module by somebody using a different module format? More pain in the arse!

zoomerang··on You have ruined JavaScript
> Also, a large codebase can be very easily maintainable with tightly coupled components

Agreed, but having worked on large codebases it's usually easier to plan ahead and decouple from the start - it can be hard to decouple components later when you didn't plan for it. It's also much easier to properly unit test when you can trivially inject a mock.

Of course this is only relevant if you're building a large project. The typical web app just doesn't need it.

zoomerang··on You have ruined JavaScript
> functional programming.

That's not functional programming.

zoomerang··on You have ruined JavaScript
I agree with you for the most part - what you're describing is rampant abuse by cargo-code programmers that don't know better.

This doesn't mean GoF design patterns are specifically wrong. It's just that they are misused and applied in places they don't belong. When done properly, they should emerge organically as you code without you even realising it (That is to say good design patterns are emergent phenomena in good code, not the other way around).

It also doesn't help that the entire software industry is fixated on single-inheritance OO languages, which tend to encourage ridiculously bad designs.

> It's cheaper and more reliable to chop your product up and write each chunk in whatever separately with no official architectural pattern usage system-wide.

This nails good software design on the head. Don't write large software, write small independent reusable components and combine them together.

This is what dependency injection solves well - When done properly. (If it involves XML or config files it's not done properly).

zoomerang··on You have ruined JavaScript
You've never found the need to decouple components?
zoomerang··on You have ruined JavaScript
You're completely missing the point and solving the wrong problem. Function or class, its a minor semantic difference for the same thing.

The issue is not how you define your factories, it's how you pass them around and use them in a component that has no knowledge of the outside world.

zoomerang··on You have ruined JavaScript
Saying "OO is Evil" is the flavour of the month. Functional Programming is the new cool kid on the block. This would, in theory, be a good thing.

Unfortunately legions of Javascript fanboys have recently noticed that they don't have the keyword 'class' in the language, but they do have functions and have decided this means that it's a functional programming language, and they knew better than everyone all along.

They'll then follow it up with some perfectly nice procedural code and tell themselves it's functional with a nice little pat on the back.

zoomerang··on You have ruined JavaScript
Whether you use OO, Procedural, of Functional programming, you're still going to end up with some variant of IoC in order to keep your abstractions clean.
zoomerang··on You have ruined JavaScript
Thank you! I came here to say this, but you said it a lot more politely than I would have.

There's a lot of hate for certain design patterns because they are seen to introduce too much complexity or boilerplate in small projects - but are absolutely essential for large projects.

zoomerang··on You have ruined JavaScript
What does your example have to do with functional programming?

You've written two factories, pretty much exactly how AngularJS uses them, in an imperative style.

Regardless of which, this doesn't in any way solve the issue Angular Services are designed to solve (IoC).

zoomerang··on You have ruined JavaScript
Another case of "I don't understand something so I'm going to just say it's too complex and stupid". The author completely misses the point of service injection in Angular, and then goes on to offer a simpler "solution" that doesn't even remotely do what service injection is trying to do.

Here's the thing - Inversion of Control exists for a reason. Once your codebase gets to a certain size it becomes far, far more manageable to work with loosely coupled components that have no direct knowledge of each other.

These abstractions are a good thing. Lord knows how many projects I've had to fix because some idiot decided that "Architecture" was just some silly crusty of enterprise thing, and "Frameworks" are too opinionated - so instead they decide to ignore 50 years of industry conventions and write a spaghetti code pile of shit (But at least there are no factories!)

Whether you're using procedural, functional, or object-orientated style - A large codebase is still going to be unmaintainable if you don't understand how to write loosely coupled components. (More specifically, don't write a large program - write lots of small ones and compose them together).

← PreviousPage 2 of 3Next →