I regularly read source. And one of my pet peeves with TypeScript is that I will click on a type and have to walk half a dozen types deep to understand what it is. Because the library has sensibly abstracted types to be DRY and whatnot.
What I want is a type flattener that I can point at a type and it basically links it all so I see a raw type in all its verbose but complete glory.
Example - HttpServletRequest
getAsyncContext, getAttribute, getAttributeNames,
getCharacterEncoding, getContentLength,
getContentType, getDispatcherType, getInputStream,
getLocalAddr, getLocale, getLocales, getLocalName,
getLocalPort, getParameter, getParameterMap,
getParameterNames, getParameterValues, getProtocol,
getReader, getRealPath, getRemoteAddr, getRemoteHost,
getRemotePort, getRequestDispatcher, getScheme,
getServerName, getServerPort, getServletContext,
isAsyncStarted, isAsyncSupported, isSecure,
removeAttribute, setAttribute, setCharacterEncoding,
startAsync, startAsync...
getHeader, getHeaderNames, getHeaders, getIntHeader...
"How many maps?" Vs. In Clojure, Just Use Maps
{:remote-addr "127.0.0.1",
:scheme :http,
:query-params {"somekey" "somevalue"},
:form-params {},
:request-method :get,
:query-string "somekey=somevalue",
:content-type nil,
:uri "/foobaz",
:server-name "localhost",
:params {"somekey" "somevalue"},
:headers
{"accept-encoding" "gzip, deflate",
"connection" "close",
"user-agent" "Apache-HttpClient/4.1.2 (java 1.5)",
"content-length" "0",
"host" "localhost:8383"},
:content-length 0,
:server-port 8383,
:character-encoding nil}
"In Clojure, we just use maps. This stuff came over a wire in HTTP, as
text. How did we turn it into this [the Java]?"JS is a little more complicated than that, but (sorry to tell you) so is ClojureScript, where a “map” can become a bunch of different actual data types through the course of a normal runtime.
In all cases, sending plain maps/pojos is nice but receiving them is fraught. Again TypeScript helps here by providing type guards where your parse/validation code can be statically analyzed.
Edit: and in terms of serialization, all of these languages struggle with fidelity loss. Clojure has EDN or Transit if you’re willing to incur one cost or another. But by default you’re sending out a smaller subset of types than your runtime is using, and receiving the same.
Clojure/Script of course approaches validation and parsing using schema systems (malli or spec) that has its advantages compared to static type based approaches.
> Clojure/Script of course approaches validation and parsing using schema systems (malli or spec) that has its advantages compared to static type based approaches.
So does TypeScript. It has to, because the type system doesn’t have a runtime. The benefit in TS is that you also get static analysis.
My (vaporware, but I’ve built something similar before on top of io-ts) project would provide a similar API, but with base types built from JSON Schema definitions, and automatically generate docs.
There are also opportunities to significantly improve runtime performance (at the expense of build time) by avoiding unnecessary parsing where statically checked code paths are already valid, eg naive multiple parse steps.
type Merge<T> = { [K in keyof T]: T[K] }
Typical usage is with intersection types like: Merge<A & B>
Where the resulting type is not aliased, at least at the top level, and you just see the structure of both A and B. But it should also work for inheritance, interface extensions, and object type overloads.I think as of either 4.4 or 4.5 you can also safely make it recursive.
Some codebases don't have source available, e.g. Windows, so there I guess one would use the docs.
Maybe my second point is the reason for the first.
In fact, I think that's the default now. Google may have associated you with Python 2, but I'm getting almost all Python 3 results for any search Python related.
You can also filter by time, but that's less useful because Python 2.7 pushed the end of life date so far back.
Google does this because a team wants to make a name so they do a retool or redesign, it is a line item on a budget sheet and a metric for bonuses or whatever.
Users be damned.
I've taken to freezing certain servers and never updating them just to fight back against this. I'm tired of breaking changes every few weeks. I'm tired of learning where an option was hid in this update, only to have it moved in the next one, and the next.
As an industry, shame should be wielded to prevent this. Microsoft was never held accountable for their transgressions with excel and Word. It really opened the gates for every other development house to do the same thing, and now, a decade and a half later...
But I also have to say - better no examples than misleading, outdated ones. And please for dog's sake don't link to a site that requires registering an account to read nothing more than "further example" code snippets that turn out to be the same outdated examples with different variable names.
Yes, search engine results are for amateurs (except for finding the source, spec, base documentation, etc.). If you are serious, hold yourself and your learning to higher standards.
It's also faster to read the serious sources: They are much more dense and complete, requiring less searching around and accumulation of stuff, much more to the point, more authoritative and accurate, and IME more clear (I think because clear writing requires deep understanding and clear thinking, which is much more likely to be had by the dev who wrote the code or the experts writing the spec, than blogs, reddit, or even HN commenters).
You'll find that most of the online forum/blog authors don't actually know what they are talking about (and that many of your peers have big holes or misunderstandings).
I don't think that's accurate. Like the gp, I find myself relying more and more on reading the source and reading specs (WhatWG, RFCs, etc). However, search engine results are still incredibly valuable.
This is exceptionally gatekeepy and predicated on the assumption that everyone learns or consumes knowledge in the same way you do, which is just not true. We already work in a profession that has issues with gatekeeping - I think we should avoid exacerbating that.
> We already work in a profession that has issues with gatekeeping - I think we should avoid exacerbating that.
Why? Law and Medicine are gatekept fields, the minimum bar is essential for providing such sensitive services. With all the security issues - never mind accessibility - I think that professional software development should be gatekept.Hobbist software development - where many of us started - should of course have welcoming arms to new members. I wonder how the Law and Medicine fields would cope with hobbist communities.