HNHacker News
TopNewBestAskShowJobs

mambodog

4,836 karma · joined February 6, 2010

submissionscomments
mambodog··on Show HN: An Isomorphic JavaScript Framework Faster Than React
It's not hard to be faster than React, React's performance benefit comes from the fact it makes performance easy to understand and optimise rather than just being magically (but opaquely) fast.

However, the real reason React is a good choice is not performance, but rather how it encourages developers to think about, isolate and better manage mutable state in their applications.

mambodog··on Kore: a fast web server for writing web apps in C
It does seem like if your goal was security than perhaps Rust would be a better choice.
mambodog··on Bringing Asm.js to Chakra and Microsoft Edge
Some examples of non-standard extensions which have fallen by the wayside (or failed outright):

    ActiveX
    Java Applets
    Flash
    Silverlight
    VBScript (and other non-JS scripting langs)
    NaCL
    Dart (via a native VM)
mambodog··on Show HN: PHPunctional, a PHP Functional Programming Library
You could improve the usability of this library (or FP in PHP in general), by implementing 'string lambdas' such as those found in Oliver Steele's Functional.js[0], which was a clever, if controversial, workaround for Javascript's lack of a concise anonymous function syntax at the time.

For example

    function($n) use ($partial) { return $partial($n - 1) + $partial($n - 2); 
could become

   'partial(n - 1) + partial(n - 2)'
Compiling the string lambda to a function can be memoized with the string itself as the key (as many regex implementations do with the regex text) so each is only ever compiled once.

[0] http://osteele.com/sources/javascript/functional/

mambodog··on Hacker News written with Angular 2.0
If you google 'isomorphic Javascript' you'll get a bunch of hits explaining this particular (ab)use of the word, here's a good one: http://nerds.airbnb.com/isomorphic-javascript-future-web-app...
mambodog··on Hacker News written with Angular 2.0
An 'isomorphic' approach would really help with that first page load time. Here's one I built with isomorphic React: http://hackernewsmobile.com/

(source: https://github.com/jsdf/hacker-news-mobile)

mambodog··on How to Center in CSS
Flexbox can be a bit low level, but with it you can build abstractions (eg. classes or preprocessor mixins) for common use cases, which I think is preferable to having only a high-level tool which can't cover all use cases.
mambodog··on How to Center in CSS
This should also have an option for 'what browsers do you need to support' and just provide flexbox output instead if you don't need to support legacy IE.
mambodog··on Unit tests fail when run in Australia
Border Village, a roadhouse on the other side of the WA/SA border, also observes Central Western Time Zone. However, the next stop on the Eyre Highway does not.
mambodog··on Learn AngularJS
The combination of React with a data/state management pattern such as Flux (https://facebook.github.io/flux/) is fairly analogous. You can also just use something like Backbone models (for example) with React if you want to use a more 'traditional' JS MVC pattern.
mambodog··on Ask HN: JavaScript developer – what do I need to know?
You should usually be doing 'data handling' wherever results in the best user experience. Persistence and calculations which are essential to the integrity of your application's data obviously need to be done (or at least validated) on the server, but if the application has any kind of complex workflow then constantly going back to the server to generate new application states is likely to severely bog down that workflow.
mambodog··on Nuclide: An open-source IDE for React Native
I would argue that React set them on the path to doing DOM manipulation right. After all, when they started using React as a replacement for (less optimal) manual DOM manipulation, it brought performance improvements, and when they replaced React with (more optimal) manual DOM manipulation they achieved further performance improvements.
mambodog··on Efficient Nested React Components
I recommend reading swannodette's The Future of JavaScript MVC Frameworks[1], which was the article which first got me to try React, after earlier passing it by. This meant I was coming to React via good examples of how to use it in an optimisable way, already thinking about reference equality of the props I was passing, and whether changes within state object structures were observable in my application (mutation vs copying etc).

Now that React has had a large recent influx of new users, hopefully these key concepts are not lost in the deluge of new blog posts and demo applications. Those who are championing React within groups and organisations should try to make sure developers who are more passively following are made aware of such useful ideas. Javascript (and software engineering in general) has a long history of collectively forgetting important ideas only to rediscover them later, but it would be better to be proactive than to leave it up to the archeologists.

[1] http://swannodette.github.io/2013/12/17/the-future-of-javasc...

mambodog··on Show HN: JavaScript Acid Techno Machine
Quick tutorial for anyone who isn't familiar with the music gear being emulated:

The top two items are two instances of an imitation of a Roland TB-303 bassline synth. The bottom item is an imitation of a Roland TR-909 drum machine (a drum synthesizer).

Press 'Play' in the top left to start all three instruments playing. Each is now running through 4 bars of 4 beats, or 16 steps in total. By default the first bass synth is playing a low 'C' on every step, the second bass synth is playing nothing, and the drum machine is playing a bass drum on the first step of each bar (steps 1, 5, 9, and 13).

Laying out a pattern on the drum machine is a little more intuitive, so start with that. The row of 16 buttons represents the steps on which a hit will be played for the currently selected drum type. Buttons for switching modes to edit the pattern for each drum type are listed horizontally (BD, SD etc). Switch to a different drum and add some hits to the pattern by clicking on those steps in the row of 16 buttons.

The bassline synths are programmed in basically the opposite way. The 16 steps become the modes you switch between (by clicking the UP and DN buttons under 'Current Step') and clicking on any of the the 13 musical note buttons (coloured like piano keys) will select the note which plays on that step. The highlighted note can also be deselected so that no note will be played for that step. Try stepping through and changing the notes which are played on each step or deselecting notes to create a more interesting rhythmic pattern.

mambodog··on Boiling React Down to Few Lines in JQuery
It's sad that your colleagues' lack of open-mindedness about adopting a framework is forcing you to create a less-well-specified, less-documented, implicit framework.
mambodog··on Replace CoffeeScript with ES6
Yeah but then we'll just be compiling our ES8 code with 8to6.
mambodog··on Morpheus – Isomorphic web publishing platform, built with React and Flux
Basically, they can leverage the same code on the server and in the browser. Google 'isomorphic javascript'.
mambodog··on Morpheus – Isomorphic web publishing platform, built with React and Flux
I had a similar idea a while ago[1], the main ideas being:

- to use Postgres JSON columns for storing documents (rather than the typical CMS approach of a complex EAV/table-per-field structure), and

- to use React components for rendering the public-facing content views, which could then also be used for inline editing or a live split preview/editor – like a markdown editor, but capable of turning arbitrary fields of input into arbitrary output

- embeddable content types/entities which know how to render themselves

- live collaborative editing

1. https://github.com/jsdf/cosmos

mambodog··on “This” in JavaScript
Another way of thinking about it is that it's kinda like Function.prototype.call is being used implicitly at the call site to set the 'context' (the 'this' value):

    // assuming in each case
    var o = {}
    var o2 = {}
    var fn = function(){}
    
    // 1. bare function call
    fn() // this == undefined in strict mode, global in non strict mode.
    
    // 2. calling with Function.prototype.call
    fn.call(o) // this == o
    
    // 3. 'method' call (calling an object's function property)
    o2.fn = fn
    o2.fn() // this == o2
    // equivalent to
    fn.call(o2)

    // 4. calling object's function property with Function.prototype.call
    o2.fn = fn
    o2.fn.call(o) // this == o

    // 5. new
    var o3 = new fn() // this = o3
    // equivalent to
    var o3 = Object.create(fn.prototype)
    fn.call(o3)

    // 6. calling function bound with Function.prototype.bind
    var fn2 = fn.bind(o)
    fn2() // this == o
    // equivalent to
    var fn2 = function(){ fn.call(o) }
    fn2()

    // 7. calling object function property which is a bound function
    o2.fn = fn.bind(o)
    o2.fn() // this == o
    // equivalent to
    o2.fn = function(){ fn.call(o) }
    o2.fn()
    
  
Basically you should think of functions (and 'methods') as not being intrinsically bound (as in binding-of-'this' bound) to anything.

If you think of a 'method' (function property) as being bound an object purely by being 'attached' to it then you are gonna have a bad time. Instead, think of binding of 'this' as usually only happening at call time, to the thing you are 'calling the function off of'.

In reference to case 1 (bare function call), this is the same behaviour which occurs when as defining an anonymous function inside a function which has 'this' set. Just don't use 'this' in this case, it doesn't make sense. Defining a _this or self variable in the parent function is the standard practice to deal with this case, or in ES6, Coffeescript etc. you have the => fat arrow to implicitly do that for you.

mambodog··on The JavaScript Trap
Not exactly, it's more like LLVM IR with a weird syntax[0]

[0] http://llvm.org/devmtg/2013-11/slides/Zakai-Emscripten.pdf

mambodog··on iPhone 6 Plus bending in pockets
It's almost like they'd be better off making the glass less flexible so it would just crack when people bend it too much, and then they'd know they did the wrong thing. The fact that the phone can bend like this without breaking might mean they don't realise that they've subjected it to an unreasonable amount of force.
mambodog··on Show HN: Paths.js – Generate SVG paths for geometric shapes
Consider, why do people use SQL query builders when you could just use a string?
mambodog··on LIVE NOW: Glenn Greenwald, Assange, and Kim Dot Com in NZ
Nope it's $20 if you pay the fine when you get it, or $170 if you let it go to court

http://www.aec.gov.au/faqs/voting_australia.htm#not-vote

mambodog··on Mini vMac: Early Macintosh Emulator
If you want to play around with classic Mac OS without downloading and installing anything, I made a browser port of PCE (a similar emulator): http://jamesfriend.com.au/pce-js/
mambodog··on React Components
Typically you would render a single root element and then use the 'after' lifecycle methods (componentDidMount, componentDidUpdate) to grab the root element (with getDOMNode) and make your changes (eg. call a jQuery plugin method on the dom node)

Here's a jsfiddle for the specific lib you're talking about (Odometer): http://jsfiddle.net/p1h7rn3q/

mambodog··on React Components
As someone who is using react-router, there are some good reasons for it: it provides a nice way for the current state of the router (eg. the active route and the state that represents) to fit into React's re-rendering on updates. Existing off-the-shelf routers don't tend to cover this case (re-rendering from state without re-executing the route), so I wrote a layer on top of Backbone.Router to integrate the two, but react-router means one less thing to maintain, and it also has handy transition hooks (modelled on Ember.Router).

As for the use of JSX specifically, it's handy because it allows expressing ordered associative data, for which in javascript the other choices are both kind of messy: either an array of objects (verbose) or an object (not guaranteed to be ordered).

mambodog··on JSX: XML-like syntax extension to ECMAScript – Draft specification
It's not an exhaustive list of JSX implementations.
mambodog··on X to close
If you want to see the UI of GEM for yourself, here's an in browser emulator of an Atari ST with GEM:

http://jamesfriend.com.au/pce-js/atari-st/

mambodog··on BuzzFeed Raises $50M from Andreessen Horowitz
[ads that pretend to be news stories]

John Oliver recently commented on this stuff (so called "Native Advertising") on Last Week Tonight: https://www.youtube.com/watch?v=E_F5GxCwizc

mambodog··on MacBasic
If you want to try it out for yourself, I tracked down a copy of MacBasic .335 and wrapped it up in an in-browser emulator here: http://jamesfriend.com.au/pce-js/macbasic/
← PreviousPage 5 of 23Next →