Better HN
topnewbestaskshowjobs
Log inSign up

pathsjs

472 karma · joined Sep 17, 2014 (12y ago) · 223 submissions

Submissions

comment 9y ago · link · parent

100 IQ is the norm, sure, but why obesity?

comment 9y ago · link · parent

That is obviously not the home page. It is not even the first page when a user opens the documentation.

Also, you make it sound like disabling automatic updates is something that requires work, hence needs to be prioritized on a task board. In fact it is quite the opposite: work was needed to enable automatic updates in the first place!

comment 9y ago · link · parent

I read the book and found all the characters extremely simplified and shallow. I guess the audience was not ready for sophisticated personalities - there are the evil Thenardier, the saint Myriel, the disgraced Cosette... Most books written today are better written than that

comment 9y ago · link · parent

Too many negations, I can't parse. Do you want an OS written in C++ or not? :-)

comment 9y ago · link · parent

I am italian as well and have been hearing this joke since the times of Craxi

comment 9y ago · link · parent

Well, the example you are looking at is very complex, but also you are very unlikely to run into it early! For better examples, look at the homepage: you will see something much more approachable.

The reason this snippet is complex is that:

1. It deals with the Foreign Function Interface

2. It deals with the FFI with respect to C++, which is much more complex than the one towards C, essentially because C++ itself is complex

3. It uses a particular construct (emit) that is only needed when the standard FFI is not enough

So the example is really a showcase of a particularly complex case that you will likely not encounter, unless you start wrapping C++ libraries (which is not an easy task, unlike the C ones)

comment 9y ago · link · parent

There is a (very minimal) HTTP server in the stdlib. It can be used for very quick prototyping.

It can easily be wrapped in a more usable API, for instance I have made mine: https://github.com/andreaferretti/rosencrantz

comment 9y ago · link · parent

In Nim, each thread has its own heap :-)

comment 10y ago · link · parent

Well, I am actually a mathematician. I knew cateogry theory well before I was even able to hack a web page with php and jquery. :-)

And still, I find that most of the abstractions that appear, say, in Haskell have little mathematical content. Even less so their imitation in Javascript. ¯\_(ツ)_/¯

comment 10y ago · link · parent

That has really little to do with mathematics...

comment 10y ago · link · parent

Did you really create an account just to say this?

comment 10y ago · link · parent

Nim is statically typed, very similar to python syntax-wise, fast and with trivial c interop. This makes it a good target for scientific programming, although unfortunately there are not many libraries yet http://rnduja.github.io/2015/10/21/scientific-nim/

As for being functional, strictly speaking it is not, but still has some features like closures and higher order functions, immutable variables, the usual suspects (map, filter, ...) can be inlined with zero overhead, side effect tracking and so on (in addition to a very good macro system)

comment 10y ago · link · parent

The worst way to end a chapter is "in this chapter we have seen...". Unfortunately that seems to common in programming texts, for whatever reason

comment 10y ago · link · parent

The experiments were conducted by invoking spark with flags --master local[1]

This means running on a single core. Not really a fair comparison with the Julia multithreaded or multiprocess version

comment 10y ago · link · parent

If the solution to packaging is "I'll use docker", i.e. I will need essentially an entire OS as a dependency of my application, this shows that Python packaging is broken. More sane packaging system allow to define dependencies per project, and only install packages globally when required

comment 10y ago · link · parent

A union type in Nim can only be used in funciton arguments, and it does the obvious thing: when you actually call the function, it specializes to the type you are calling with. Think about templates in C++, where the type parameter can only assume one of two (or more) values. Hence it would generate exactly what you would write by hand, but the syntax is much less messy than C++ templates

comment 10y ago · link · parent

Nim fits everything you ask, except for "can target GPUs via LLVM or SPIR-V". Even that may eventually be fixed by having OpenCL C as a compilation target.

Also, I am not sure what you mean by "first class SIMD structures", but you can definitely have a single definition for sin4f and sin8f if they are line by line equal except types, by using union types.

comment 10y ago · link · parent

Shameless plug: I have been proposing this approach for long. I found that the missing piece is how to generate the actual geometric information starting from data, hence I wrote a library to this effect https://github.com/andreaferretti/paths-js

For the animations, it is often just a matter of continuosly updating the state of some component, something that I did in this mixin https://github.com/andreaferretti/paths-js-react-demo/blob/m...

comment 10y ago · link · parent

How does one actually... well, display the presentation? (without the markdown on the side)

comment 10y ago · link · parent

In Scala and in Factor too! ;-)

comment 10y ago · link · parent

In any case, I do not want to sound too critical. I would be happy to see a lighter syntax for Rosencrantz - I just do not know how to do it while preserving the composability of handlers.

If you have any proof of concept of how it might work, I would be glad to get a PR! :-) Ideally, it would be something that can be layered on top of the existing core, so that one could import "syntax helpers" from a separate module

comment 10y ago · link · parent

Hi jboy, thank you! :-)

The problem with the syntax you propose is that it does not compose well.

For instance, in the example you give, `path`, `get` and `ok` are all handlers, but they appear in very different roles syntax-wise. It is not clear to me how one would add one more level, say to parse handlers.

I agree that the [] syntax is not the best-looking in the world, but I need something where I can do the equivalent of `h1[h2]`, where `h1` and `h2` are both handlers.

Templates and blocks would sort of work, but not in the case where both `h1` and `h2` are, say, stored in a variable. I am all for trying to obtain a better syntax, but I would not like to lose composability for that

comment 10y ago · link · parent

Of course template can return values.

The problem is that they need to be given the AST. What if one constructs a handler somewhere in another module (say an authentication handler) and you import it? How can you reuse it, considering that it needs to surround other handlers (that is, if auth fails, you do not go inside inner handlers)?

With Rosencrantz it is easy: if `auth` is our authentication handler, and in your module you define a handler `h`, you can use `auth -> h`, or `auth[h]` if you want to spell `h` inline.

Now, what you could in fact do is write a template `authTemplate` that takes a handler `h` and returns `auth -> h`, so that you can still write in template style. But you have to do this for all handlers.

It could make sense to provide such templates for builtin handlers, though... want to chime in? :-)

comment 10y ago · link · parent

The problem with this approach is that it would be difficult to make handlers first-class. What if your post routes are a handler imported from another module?

Templates would allow for the syntax you present, but do not combine.

comment 10y ago · link · parent

I wrote Rosencrantz because I do not like the Jester API very much.

Jester, like many other frameworks, hardcodes exactly what to do with a Request - say parsing the headers, parsing the form if the content type suggests so, always return a date, and so on.

This is not bad per se, but I prefer to have something I can compose. Say, I have a working route `r`. If I want to add CORS support, for instance, I can just make a handler `h` that adds CORS headers and then use the route `h -> r`.

This is more flexible and leaves fine grained control over which headers to require, or return, how to do content negotiation, and so on. You can separate your routes for `POST` from those for `GET` in different modules and then combine them, or maybe separate your authentication routes from the business logic ones. You can easily create handlers that work as middleware, and so on.

In short, the thing I like about this approach is that handlers become first class objects that you can manipulate and create freely

comment 10y ago · link · parent

What would you suggest instead? Routes are naturally nested, and overloading [] seemed the best choice

comment 10y ago · link · parent

> If it's divisible by a number, the number must appear in its factorization and vice versa.

By writing "its" factorization, you are already assuming that there is only one

comment 10y ago · link · parent

Videogame engine developers do not need advanced mathematics

comment 10y ago · link · parent

Yes, I also wanted to add your library, but I was not sure how it works and to what degree it uses metaprogramming. But I am glad that you mentioned it! :-)

comment 10y ago · link · parent

Other examples of things one can do with metaprogramming: async/await http://nim-lang.org/docs/asyncdispatch.html#async , pattern matching http://andreaferretti.github.io/patty/ , for/do comprehensions https://github.com/vegansk/nimfp/blob/master/tests/fp/test_f...
1
45678