News for hackers. Stuff that matters.
Re:Ask HN: Is web programming a series of hacks on hacks? by lobster_johnson on Monday September 12, 2016 @02:00AM (#12477505)
React is, in my opinion, a big step forward in reclaiming the front end as a mature UI environment.

I have also found that CSS becomes a lot more tolerable with CSS Modules, in combination with React, which allows you to write CSS that targets one component and only that component. By eschewing cascading, you can finally write modular, reusable CSS that avoids side effects and still allows fine-tuning (overriding) by the component user.

Re:Ask HN: Is web programming a series of hacks on hacks? by reitanqild on Monday September 12, 2016 @06:07AM (#12478403)
Maybe for web applications.

There should be something in the license of JavaScript frameworks & libraries to prevent them from being used in blogs, newspapers, trade publications etc :-/

For now all innovations in JS just seems to provide us with even heavier web sites for no real benefits. I feel I'm starting to dislike JS the way I disliked Flash which would be quite a feat.

Re:Ask HN: Is web programming a series of hacks on hacks? by RussianCow on Monday September 12, 2016 @11:23AM (#12480483)
I think it's completely fine to write a website/blog/newspaper in React, provided you make it isomorphic and keep it as light as possible. Then you get all of the advantages of using React with almost none of the disadvantages.

Of course, nobody does this in practice.

Re:Ask HN: Is web programming a series of hacks on hacks? by douche on Monday September 12, 2016 @12:16PM (#12480958)
If your blog/newspaper/text+images website requires JS or it is not readable, you failed.
Re:Ask HN: Is web programming a series of hacks on hacks? by asolove on Monday September 12, 2016 @12:44PM (#12481252)
The two of you are agreeing: "isomorphic" in this context means "the server can render it to html and serve it like a normal webpage".
Re:Ask HN: Is web programming a series of hacks on hacks? by reitanqild on Monday September 12, 2016 @12:51PM (#12481323)
For those who like videos(unlike me) and Java (like me), this was a topic for one of the talks at JavaZone in Oslo last week and I watched that one on my way home today: https://vimeo.com/181925279

(Oh, BTW, JavaZone 2016 was Oracle-free and all talks seems to have been uploaded to vimeo with no restrictions on downloading.)

Re:Ask HN: Is web programming a series of hacks on hacks? by niccaluim on Monday September 12, 2016 @02:14AM (#12477572)
I agree—I loathe frontend development, but React made it tolerable to do for limited periods—but it's still a hack on a teetering Jenga tower of hacks.
Re:Ask HN: Is web programming a series of hacks on hacks? by dcposch on Monday September 12, 2016 @06:39AM (#12478546)
The really funny thing is that the OS runs a simple event + render loop, then the browser implements a wildly complex stateful/declarative structure on top of that (the DOM), then React apps create a simple event + render loop again, this time with special diffing logic to update the underlying DOM as little as possible
Re:Ask HN: Is web programming a series of hacks on hacks? by Bartweiss on Monday September 12, 2016 @11:21AM (#12480464)
This is a great insight. I'd never noticed this about browser stuff, but it's definitely a major issue in video game development.

Like, most game dev frameworks (especially for mobile) leave you with device-level looping, under language-level looping, under framework-level looping, under code-level looping. This, obviously, is hell.

The result is that something as simple as "play this sound file, looping when finished" ranges from awkward to literally impossible. Memory access, garbage collection, and framework timing all collide and leave you with mysterious multi-second gaps while everything tries to sync up. And so everyone building something serious has to dive down past LibGDX into awful, ground-level things like Hammer or un-frameworked C++/Java/etc.

I'm not sure what the cure is - unlike a AAA game, there's room for a tiny bit of inefficiency in a webpage. 0.1-0.5 second loads are reasonable, instead of 0.01 second frame renders. But right now the endless layers are spitting out far too many 10 second load times, and no one even seems to notice the redundancy.

Re:Ask HN: Is web programming a series of hacks on hacks? by jacobush on Monday September 12, 2016 @06:57AM (#12478632)
And no doubt this layering will continue... "Look how I easily render this document decription into react primitives".
Re:Ask HN: Is web programming a series of hacks on hacks? by sotojuan on Monday September 12, 2016 @09:20AM (#12479397)
https://news.ycombinator.com/item?id=12473549

I made this comment in another thread, but it fits right into this one too.

Re:Ask HN: Is web programming a series of hacks on hacks? by tempodox on Monday September 12, 2016 @09:32AM (#12479484)
Yes, we write web browsers in JS, simply because our browsers let us write nested browsers in JS. I'm only waiting for an OS written in JS so we can use its editor to write an OS in JS.
Re:Ask HN: Is web programming a series of hacks on hacks? by marxidad on Monday September 12, 2016 @11:44AM (#12480674)
Gary Bernhardt mentions an OS written in JS in his video: https://www.destroyallsoftware.com/talks/the-birth-and-death...
Re:Ask HN: Is web programming a series of hacks on hacks? by dcposch on Monday September 12, 2016 @06:47PM (#12484300)
Re:Ask HN: Is web programming a series of hacks on hacks? by jakobloekke on Monday September 12, 2016 @08:26AM (#12479074)
Brilliant observation. That actually never occured to me.
Re:Ask HN: Is web programming a series of hacks on hacks? by webXL on Monday September 12, 2016 @11:38AM (#12480621)
loathe? I loathe public speaking and flossing, but these things are good for me, and I'm sure you wouldn't be doing frontend dev if there wasn't a big upside that it made possible.

> teetering Jenga tower of hacks?

How is any programming language not capable of being brittle?

Re:Ask HN: Is web programming a series of hacks on hacks? by niccaluim on Monday September 12, 2016 @01:12PM (#12481545)
This isn't about a language. It's about the whole stack.

I've been programming since before the web was invented. The web, as a development platform, is the worst layer-cake of kludges I've ever seen.

Re:Ask HN: Is web programming a series of hacks on hacks? by webXL on Monday September 12, 2016 @03:26PM (#12482849)
Fine. Name a better stack then and suggest ways this one can improve.
Re:Ask HN: Is web programming a series of hacks on hacks? by breatheoften on Monday September 12, 2016 @02:15AM (#12477576)
I echo -- this is good advice. Pick the minimal set of tools you need to use react and css modules (this probably means banging your head against something like webpack for more time than you can possibly enjoy) - but with those pieces alone as starting point, you don't really need a lot of additional library support to build applications that run in browsers ... and your code should start to seem understandable/predictable -- in a manner reminiscent of using better native frameworks of the past.

Unlike many other web programming approaches -- this stack should help avoid the need to invent new hacks for every new feature or slightly different situation ...

Re:Ask HN: Is web programming a series of hacks on hacks? by aclsid on Monday September 12, 2016 @09:40AM (#12479565)
From a javascript point of view, React is great, but I wholeheartedly disagree on the CSS modules. What React did here breaks the whole purpose of CSS, even if it is messy, not to mention that now designers need to have help from programmers to do their job. IMHO, it is much better to user Sass to make CSS sane, and just do whatever makes life easier on the frontend. I feel something light like Backbone.Native with a Shadow/Virtual DOM system is a superior system in this sense.
Re:Ask HN: Is web programming a series of hacks on hacks? by atombender on Monday September 12, 2016 @11:41AM (#12480654)
I'm not very impressed with "the whole purpose of CSS". CSS made a ton of design mistakes which we're still living with today.

A big design mistake was the global cascading/inheritance system. It's a huge pain to write CSS that doesn't leak into nooks and crannies where it shouldn't. CSS is supposed to be modular, but you can't just import someone's stylesheet (e.g. for embedding something in your page, like a video player) and trust that it won't override everything around you, intentionally or accidentally.

More than that, CSS was designed for "styling documents" — the idea being that you could display the same document with different stylesheets, sort of like themes, and so the stylesheet obviously had to be separate from the document. But almost nobody who uses CSS these days do it to "style" anything, let alone "documents". One particularly egregious issue coming from this design is the attempt to separate layout from content, when in truth layout is content, and for pretty much any application today, the style is also content. We're well beyond the point where an HTML document can be "semantic".

Shadow DOM may be the way forward in the future, but CSS Modules is a nice stopgap solution, at least, and you can use them with React + PostCSS (+ SASS) + Webpack in a nicely seamless way, without requiring any browser support.

Re:Ask HN: Is web programming a series of hacks on hacks? by goatlover on Monday September 12, 2016 @12:40PM (#12481204)
What about full on web components? Then the designers can just target components, and leave the programming to the component makers.
Re:Ask HN: Is web programming a series of hacks on hacks? by lobster_johnson on Monday September 12, 2016 @12:55PM (#12481360)
I don't know enough about them to say for sure, but they do sound like a good solution. Haven't they been just over the horizon for a number of years now?
Re:Ask HN: Is web programming a series of hacks on hacks? by goatlover on Monday September 12, 2016 @01:41PM (#12481841)
Flying cars, cold fusion, and web components?
Re:Ask HN: Is web programming a series of hacks on hacks? by flukus on Monday September 12, 2016 @02:49AM (#12477696)
IMO react is a big step backwards. Adding an abstraction layer almost never produces a better result, it just makes things more complicated.
Re:Ask HN: Is web programming a series of hacks on hacks? by axlprose on Monday September 12, 2016 @03:34AM (#12477846)
abstraction isn't inherently a bad thing, it's what gives us the tools to reason at a higher level. It's leaky abstractions that are the problem.

Proper abstractions are supposed to compress large bundles of information into a smaller set of [broad] concepts, which then imply all the large sets of details they're abstracting away. High level languages are pretty good abstractions on top of raw assembly code for example, because you don't have to think about what the assembly for your java code is going to look like, it's already implied that it's going to work.

As for react, I'm also not a huge fan, but that's because it's still a relatively leaky abstraction that comes with a lot of the same baggage as plain js+html+css. Especially when compared to a fuller abstraction like Elm[0]. But even that's still lacking a complete abstraction of html/css stuff. And that's not even taking the leaky abstractions on the backend side of the equation into account:

http://haskell-web.blogspot.com/2014/04/towards-deeper-integ...

[0] http://elm-lang.org/

Re:Ask HN: Is web programming a series of hacks on hacks? by evolve2k on Monday September 12, 2016 @05:12AM (#12478197)
I think where a key abstraction was lost was when JavaScript became the language you had to compile to if you wanted to do web development. Biggest hope I see on the horizon is WebAssembly, which has support of many big players but I've heard very little on it recently.

Ref: https://medium.com/javascript-scene/what-is-webassembly-the-...

Re:Ask HN: Is web programming a series of hacks on hacks? by tezza on Monday September 12, 2016 @06:32AM (#12478514)
But then you still have the following hack offenders:

* DOM,

* HTML Layout,

* CSS,

* A small variety of crappy events ( onDomLoaded ),

* a fairly rubbish heavyweight communication layer ( AJAX )

* Keyboard bindings that never work cross app, never cross platform

* Accessibility ??

* No idea of the energy impact of your code

* No ability to do queries on important device metrics ( energy consumption, clipboard, user presence, login / logoff, single sign on )

* History management and back button mess

Re:Ask HN: Is web programming a series of hacks on hacks? by philplckthun on Monday September 12, 2016 @05:51AM (#12478346)
Abstractions make things more complicated? I think you're missing the basic definition and purpose of abstractions. So how do you define "almost"?
Re:Ask HN: Is web programming a series of hacks on hacks? by calgoo on Monday September 12, 2016 @06:11AM (#12478420)
I think the correct term is complex. Abstractions make things more complex, as there are more moving parts. This normally leads to complications when trying to debug some obscure error that you will get when the project gets bigger. At that point you feel for calling on some ancient deity to spite the developer who decided to use this framework 6 months, until you remember that you proposed it as replacement for the last pile of abstractions to hide the failings of the platform. (Yes there is plenty of sarcasm in here :P )
Re:Ask HN: Is web programming a series of hacks on hacks? by afarrell on Monday September 12, 2016 @06:49AM (#12478585)
Which is more complex - an apple or an internal combustion engine?

Tis a trick question. The actual complexity experienced by humans depends on the job they are trying to do with the object. If you are a botanist/arborist driving to work, then clearly it is the apple. If you are a mechanic on your lunch break, then clearly it is the engine.

Re:Ask HN: Is web programming a series of hacks on hacks? by Retric on Monday September 12, 2016 @08:20AM (#12479040)
Inherent complexity is often ignorable, but bugs can and will sit anywhere. So, yea the fact an apple is vastly more complex than an engine is not always relevant, but when it is relevant you have real issues.
Re:Ask HN: Is web programming a series of hacks on hacks? by dllthomas on Wednesday September 14, 2016 @09:42PM (#12502738)
Bugs are much more likely to be in the apple.
Re:Ask HN: Is web programming a series of hacks on hacks? by philplckthun on Monday September 12, 2016 @08:20AM (#12479043)
A good abstraction hides complexity without adding major tradeoffs. Presumably an abstraction makes it easier for a developer to reason about what is going on.

It's true that abstractions can lead to a lot of trouble when they are failing to work correctly. But when they are good they add a lot of good value. When did you last have to debug a system call, because you couldn't open a file? There are really good, old abstractions that no one thinks about anymore, since they're just really good.

A framework in web development is of course another matter, where complexity can sometimes be staggering. I believe that the lifecycle of React components is really nice. Instead of initialising X things you can think about how a single component will change over time.

There are endless examples of good and bad abstractions, I guess. But at the end of the day, we have to choose abstractions when we need them to reason about what we're doing, despite adding more points of failures.

After all, if an abstraction just enables us to think faster and more clearly about a problem, AND allows us to write less code, that means that less bugs will be in the final product, assuming that the density of bugs is constant. ;)

Re:Ask HN: Is web programming a series of hacks on hacks? by Pitarou on Monday September 12, 2016 @04:20AM (#12478001)
I'm glad you added the qualifier "almost" because, even in low-level C, you're typically sitting on about 4 layers of abstraction:

C -> ASM / byte code -> machine code -> primitive CPU operations

Re:Ask HN: Is web programming a series of hacks on hacks? by flukus on Monday September 12, 2016 @07:34PM (#12484552)
That's what I'd call a good abstraction. You can write in c, debug in c and very rarely (if ever) be forced to know what the lower layers are doing.

All these javascript and css transpilers however, they force you to know the higher level, the lower level and many of the intricacies of how one translates to the other.

Re:Ask HN: Is web programming a series of hacks on hacks? by zyngaro on Monday September 12, 2016 @06:53AM (#12478604)
Abstraction is the foundation of modern modern computer science. I mean would you prefer writing in assembler rather the a higher level programming language ?
Re:Ask HN: Is web programming a series of hacks on hacks? by jacobush on Monday September 12, 2016 @06:57AM (#12478636)
Maybe?
Re:Ask HN: Is web programming a series of hacks on hacks? by terminalcommand on Monday September 12, 2016 @07:15AM (#12478723)
The dillema is that you need to understand the low-level aspects in order to understand the abstractions.

The problem that haunts me -and a lot of other hackers I presume- is that we have this urge to understand every little detail of the systems we design. Nothing is good enough.

The other problem is that by using arcane and primitive tools we limit ourselves in the ability of producing real work. As with everything in life, we need to make the distinction between tinkering and doing real work.

If all we do is tinker, very little gets done :).

PS: I just read the satire Real Programmers Don't Use Pascal [1], my comment could be highly biased from that.

[1]: http://www.pbm.com/~lindahl/real.programmers.html Bonus: Here is a little bookmarklet I wrote for styling unstyled html pages for easier reading.

  javascript:(function() { document.body.style.maxWidth='700px'; document.body.style.margin='0 auto'; document.body.style.lineHeight='1.5'; document.body.style.fontSize='20px';} )();
Re:Ask HN: Is web programming a series of hacks on hacks? by emodendroket on Monday September 12, 2016 @09:25AM (#12479433)
So I assume you write all your programs without the benefit of an operating system then.
Re:Ask HN: Is web programming a series of hacks on hacks? by goatlover on Monday September 12, 2016 @01:43PM (#12481859)
Didn't HN have a thread where someone wrote a CMS site in assembly? It sounds crazy, but if it can be done, someone will do it.
Re:Ask HN: Is web programming a series of hacks on hacks? by emodendroket on Monday September 12, 2016 @01:47PM (#12481893)
Yes, you can do it, but the drawbacks are huge and obvious.