Better HN
topnewbestaskshowjobs
Log inSign up

crazypython

4,542 karma · joined Jul 18, 2019 (7y ago) · 1,228 submissions

Submissions

comment 5y ago · link · parent

Automatic return type inference is a joy, compared to TypeScript and Flow: https://tour.dlang.org/tour/en/basics/functions

A zero-overhead foreach loop is great compared to JavaScript and C#: https://tour.dlang.org/tour/en/basics/loops

Uniform function call syntax: https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...

Sophisticated reflection, without any of the runtime overhead, since it occurs at compile-time: https://tour.dlang.org/tour/en/gems/traits

662.

Interactive tour of the D Programming Language(tour.dlang.org ↗)

6 points · by crazypython · 5y ago · 1 comment

comment 5y ago · link · parent

I wonder if it's common in other industries e.g. dance. And how many victims there are, and how many of them are those most easily exploited: the poor, weak, and underage.

comment 5y ago · link · parent

Markdown is like C and XML: Popular not because it's very easy to write a single-pass parser for, giving it widespread and universal use.

comment 5y ago · link · parent

> But it doesn't work like this in practice! There is a limit to the number of concurrent connections a browser will make, Chrome for example is <=10 IIRC. You can see this in the waterfall:

In HTTP/2, which our site will switch to soon, the concurrent limit is 100. The world's changed, change with it, and throw away those bundlers.

Either way, you can compare to our direct competitors: https://diep.io https://arras.io

> Finally, why on earth are you redirecting to HTTP after serving an HTTPS response?

This isn't really related to the argument at hand. My app is currently on HTTP for reasons downstream.

comment 5y ago · link · parent

> It's the same with the builtin documentation generator.

The syntax of the documentation generator is also far more convenient than JSDoc or JavaDoc.

comment 5y ago · link · parent

Symmetry Investments hires D programmers every year and is continuously adding new developers.

comment 5y ago · link · parent

Sorry, I meant to say use snowpack.

comment 5y ago · link · parent

Mixed Content: HTTPS sites cannot connect to HTTP resources. The game needs to dynamically scale without expensive load balancers in front. Until I get dynamic DNS and HTTPS working, the site will not have HTTPS.

670.

Organizations Using the D Language(dlang.org ↗)

144 points · by crazypython · 5y ago · 127 comments

671.

With the D Programming Language, write fast, read fast, and run fast(dlang.org ↗)

1 points · by crazypython · 5y ago · discuss

comment 5y ago · link · parent

You probably have HTTPS Everywhere with EASE mode on.

comment 5y ago · link · parent

For Vega, I would use the pre-built minified ES5 version: https://github.com/vega/vega#es5-support

Add a <script src=> tag.

Access it by object destructuring a global variable. You can access ES5 stuff from ES6, just let ES5 run first.

674.

I use the D programming language for scripting(opensource.com ↗)

1 points · by crazypython · 5y ago · 1 comment

comment 5y ago · link · parent

> I would say the primary motivators at this point have shifted from browser compatibility to syntaxes like TypeScript and JSX that will (likely) never be supported natively

I suggest using a single-pass transpiler like Surcase[0] that doesn't translate to IE11-compatible syntax, and just loops through the string once, avoiding generating an AST– making it much faster– removing TypeScript annotations and desugaring JSX.

If you additionally need to support IE11, you can use a development build with Surcase and a production build with a bundler like Snowpack. C/C++ developers have been doing things like this for ages: compiling files as objects during development, and compiling them into one big binary for production.

[0]: https://github.com/alangpierce/sucrase

comment 5y ago · link · parent

I don't have any third-party dependencies. We all agree the JS ecosystem sucks.

When I do, I use a script tag, and put it before my ESM modules:

    <script src="/scripts/data/contractor.js"></script>
Use them via global variables.

I generally avoid third-party JavaScript modules for performance and maintainability reasons. When I do use them, I'll frequently vendorize them (put them in my source tree) and make ESM modules for them.

comment 5y ago · link · parent

> 1. How do you handle npm dependencies that don't expose ES modules?

See my comment above.

> 2. How do you handle the performance impact of your browser doing multiple sequantial requests because it doesn't know your whole dependecy tree?

Put all your dependencies in the HTML file, so it fetches them all in parallel. So instead of just loading the root application file and forcing the browser to resolve dependencies:

    <script type="module" src="/scripts/app.js" defer></script>
Load the dependencies like this:

    <script type="module" src="/scripts/lib/gui.js" defer></script>
    <script type="module" src="/scripts/lib/guielements.js" defer></script>
    <script type="module" src="/scripts/lib/network.js" defer></script>
    <script type="module" src="/scripts/lib/input.js" defer></script>
    <script type="module" src="/scripts/lib/rendering.js" defer></script>
    <script type="module" src="/scripts/lib/sockets.js" defer></script>
    <script type="module" src="/scripts/lib/world.js" defer></script>
    <script type="module" src="/scripts/lib/ui/classupgrades.js" defer></script>
    <script type="module" src="/scripts/lib/ui/toasts.js" defer></script>
    <script type="module" src="/scripts/lib/netstore/minimap.js" defer></script>

    <script type="module" src="/scripts/data/configuration.js" defer></script>
    <script type="module" src="/scripts/app.js" defer></script>
You can see a demonstration of this technique on my production site, a complex JavaScript SPA that loads everything (including dynamic content) in less than one second: http://vnav.io

For a small performance boost, you can load smaller files first via <link rel=preload>.

678.

Hegel: A static type-checker for JavaScript(hegel.js.org ↗)

2 points · by crazypython · 5y ago · discuss

comment 5y ago · link · parent

Here's my suggestion if you want faster builds:

In development, use an index.html that loads it directly from the filesystem, using a single-pass annotation remover such as https://github.com/alangpierce/sucrase A single-pass transpiler doesn't build an AST, instead just looping over everything once, which will surely make it faster than esbuild.

In production, use a bundler like snowpack.

comment 5y ago · link · parent

> Can we talk about Ruby’s laissez faire approach to syntax. Ignoring all the purely technical stuff every ruby project I’ve seen that has at least a small team behind it looks like a kitchen sink. Bob does it X way, Tina does it Y way, Joe does it X way. Every person does it their own way and readability becomes an eyesore as the project grows.

This is why Python has deliberately chosen to not add Ruby's blocks. To make any code readable by everyone. (And to prevent bad coding patterns that blocks promote, but that's besides the point.)

comment 5y ago · link · parent

I just serve my ESM modules directly from the filesystem. It works well, builds in literally 0 seconds.

You also don't need a transpiler like Babel if you drop support for IE11. Almost all ES6 features– such as classes, proxies, arrow functions, and async are supported by modern browsers and their older versions. As long as you avoid features like static, private, and ??=, you get instant compile times.

It's not 2015. You don't need a transpiler to write modern JavaScript. As of writing, the latest version of Safari is 14 and the latest version of Chrome is 88. These features fully work in Safari 13 and Chrome 70, which have less than 1% of marketshare.

comment 5y ago · link · parent

> "This object will only ever have these properties; it will never have properties created or deleted"

Already in JavaScript: Object.seal(object)

> "This prototype will never be modified at runtime"

Already in JavaScript: Object.freeze(myPrototype)

comment 5y ago · link · parent

> Esbuild is like 20x faster than webpack.

Just serve your ESM modules directly from the filesystem. You don't need webpack or snowpack. Build in 0 seconds.

You also don't need a transpiler like Babel if you drop support for IE11. Almost all ES6 features– such as classes, proxies, arrow functions, and async are supported by modern browsers and their older versions. As long as you avoid features like static, private, and ??=, you get instant compile times.

It's not 2015. You don't need a transpiler to write modern JavaScript. As of writing, the latest version of Safari is 14 and the latest version of Chrome is 88. These features fully work in Safari 13 and Chrome 70, which have less than 1% of marketshare.

> The JS ecosystem is so complicated nowadays. It just seems we’re patching shit on top of each other without reasoning from first principles.

I agree. I don't use any third-party JavaScript dependencies, except for the occasional framework. You can rewrite many third-party libraries yourself and more specialized to your usecase quickly. Third-party JS libraries tend to have poor performance.

comment 5y ago · link · parent

> HTML gets little respect as a programming language because it's not one. The programming/behavior part of this is using javascript.

Open a typical modern website– you'll see a horrible mess of divs. People using very large amounts of HTML to do what should be very simple tasks. People writing complex JavaScript and React and SPAs instead of simply writing HTML. This is a case of people doing what should be done in HTML, in JavaScript.

> That said, I'm interesting in that DSL, care to link it/talk more about it?

view-source:https://wwwperiodictable.surge.sh/

comment 5y ago · link · parent

HTML gets little respect as a programming language because it's easy. But used properly, it's extremely powerful. Used improperly, as it almost invariably is due to the very little curriculum focus on it, it is slow and stupid. I used CSS Grid to create a mini-Domain Specific Language for Periodic Table of Web APIs.

HTML is a document format. It defines the CONTENT of a webpage. That it has an API or is usually styled is secondary. The semantic tags– as used here, as used to STORE DATA here– are what make it possible to build a kanban solution so easily.

HTML is also a data format. It can be styled through the use of CSS.

comment 5y ago · link · parent

Sellers already pay people to write reviews– and compensate for the product. How is this system any different?

> If a seller wanted to keep farming reviews, they would now have to buy up the vast majority of their own inventory in the hopes of being selected.

They already have 100 people buy their product and fully pay for it for a review.

comment 5y ago · link · parent

> Not sure I'm so keen on Python driving my car.

It uses CPython, which is reference counted, letting them ensure predictable timing/hard real-time system.

688.

The third result for “AI” on Google is Google AI(google.com ↗)

1 points · by crazypython · 5y ago · 1 comment

1
222324
41