Better HN
topnewbestaskshowjobs
Log inSign up

hellofunk

9,428 karma · joined Jul 10, 2015 (11y ago) · 3,276 submissions

John Bellick, Mexico City
Submissions

1261.

What Americans heard in Cuba attacks(abcnews.go.com ↗)

2 points · by hellofunk · 9y ago · discuss

comment 9y ago · link · parent

> I suppose you could wrap get, get-in with a nil check or something.

Indeed I suppose the solution would be write wrappers around common getters that allow you to pass a spec to the query and have them automatically assert that everything is what you expect.

comment 9y ago · link · parent

How much Spec do you sprinkle in your code? I'm often using a keyword to query a map. Should I always spec/assert the return of this simple and common task? Because if you type the wrong keyword, a typo or just because you confuse different keywords in your mind, then it doesn't matter how much spec you have applied to the top-level data structure, the function arguments or other things, you still end up with a very easy nil or just incorrect value floating through your data transformations.

The only way I see to have a lot of confidence is to add Spec to every new binding that is created, confirming that all named values are exactly what you think they are. Perhaps that is how most Spec users are working? That would mean asserting every item in a "let" for example.

comment 9y ago · link · parent

I suppose you'd have to use spec/assert for every instance of destructuring or "get" or "get-in" to avoid common mistakes. That's a lot of asserts everywhere.

comment 9y ago · link · parent

Clojure.spec is useful for a lot of things, but unless you are adding spec/assert to nearly every destructuring or "get" or "get-in" then it's still easy get nils running through your data transformations because you mistyped a keyword or something.

Also there is not a good answer for asserting the value of a function passed to another function; the return values of functions can be spec'd but they are not included in an assert test.

comment 9y ago · link · parent

Without a degree? I think that work experience in both dynamic and static languages is enough to offer a perspective. I don't have a degree in type systems but have done a lot of work in both Clojure and also C++ and Swift. I still can't decide if I prefer dynamic or static, they have nice tradeoffs.

comment 9y ago · link · parent

I agree that there is definitely added discipline needed to succeed well in large dynamically-typed projects. I also think that learning to build large projects in such languages is like running your marathon training high in the mountains, so when you get back to sea-level your body feels the joy. You are forced to write very clean code in Clojure if you want to easily maintain it later. That's a great skill that translates to any other language where less discipline might still get you far.

comment 9y ago · link · parent

If your typos are triggered by UI events, then you often won't see these problems until interacting with your UI (I work mainly in Clojurescript). Further, these typos may not get noticed at all for a long time if a code path is never taken. Of course, that's what unit tests are for. But writing tests takes time also. I'm not sure it's worth the trade off to spend the time writing those tests that I could spend writing in a more statically-typed language that would catch some things that tests wouldn't be needed for. (Besides, writing tests for UI stuff is pretty hard).

I am griping, really, because I cannot stress enough how nice it feels most of the time to write Clojurescript. But in complex projects, there is not doubt that a lot of time gets spent on things that wouldn't need to be spent if the language had even a very basic type system to back up the syntax for some things.

comment 9y ago · link · parent

I invite you to watch this talk.

Dynamic typing is about a lot more than having an "Any" type. It's about widespread lack of extra code and cognitive overhead associated with the imposed structure of adding static types to a project, as well as the verbosity that static typing typically adds (including in type-inferred languages).

You can't just turn off the static typing in a static-typed language; you can turn off the static type for a specific type, yes, but that doesn't give you the experience that dynamic languages offer.

comment 9y ago · link · parent

The new Conj talk is certainly an interesting look at one man's (or one community's) look at static typing. However, as much as I admire Rich, some of the points he made don't resonate with me, particularly the one about how compile-time checks to catch minor bugs in syntax are not a particularly useful feature of static typing. I certainly disagree. As someone who writes Clojure all day long right now for a living, I am constantly dealing with runtime errors that are due to minor typos in my code that I have to track down, and this time would be greatly saved by having a compiler tell me "on line 23 you looked for :foo keyword in a map but you meant to type :foobar, so that's why that was nil" and many other similar woes.

I love Clojure but I really miss static type checks.

The other item in his talk I do not agree with, he says (slightly paraphrasing) "in static typing, you can pattern match on something 500 times but if you add a case, you have to update those 500 matches to handle the new case, when really they don't care about this new case, only the new logic needs to consume this special case, it's better for the producer to speak directly to the consumer". Well, in languages like OCaml, Swift, Haskell, it is a feature that pattern matches much be exhaustive. This prevents bugs. In most cases, I'd expect that if I add a case to an enum, the chances are good my existing logic in pattern matches should know about that. Maybe not all, but a lot of them will. It's nice to have the compiler guide you to those places.

I certainly like how fast I can write programs in Clojure, and I like the minimal amount of code that makes refactoring and rewriting fairly straightforward since there is not a lot of time investment in the existing number of lines, and I like the incredible elegance of Clojure's approach to functional programming.

But I do miss having much greater compiler assitance with typos, mis-typed argument order to functions, mis-typed keyword names, etc. Would really save a lot of time.

comment 9y ago · link · parent

No one in this thread is yet talking about the content of this talk, which I think is interesting. Rich is doubling down on dynamic typing. As the world is gradually moving to more statically-typed languages (Rust, Swift, Go, Elm, Purescript, Typescript are all popular tools that come to mind), Clojure remains in the embrace of dynamic typing, and this talk is an interesting look at the perspective of why that is, and adds perhaps a little bit to the debate between static and dynamic typing.

I admire Rich a lot, but I also admire John Carmack, and it is apropos that yesterday another comment was shared on another post here [0] about his opinions on static typing, and how in just a few years (his talk was in 2013), the industry as a whole has made considerable changes in its opinions of static typing; according to his talk, in 2013 most of the industry was still not convinced of the benefits of static typing.

[0] https://news.ycombinator.com/item?id=15460604

comment 9y ago · link · parent

That is unfortunate. Whale hunting is illegal now in many countries, but the Japanese do like whale meat and continue to find ways to hunt them. I saw an interesting documentary maybe 4 years ago about how some hunting ships would find whales under the guise of science research, but really harvest them for food. Some countries stopped honoring the scientific licenses of the Japanese ships that allowed them to enter their waters. I'm not sure how much the affinity for whale meat has to do with tourism, though.

comment 9y ago · link · parent

Thanks very much for sharing this. Awesome.

comment 9y ago · link · parent

I don't understand; I have far more stored in Dropbox than on my computer's hard drives or even the sum of hard drive space among my household computers. The Selective Sync features allows me to do this pretty easily. Every once in a while, I plug in an external drive to ensure I have a physical backup of Dropbox -- that is the irony, the Cloud is my main storage, my external drive is the backup of that; not vice-versa.

comment 9y ago · link · parent

Marijuana acts as a hallucinogen for some people, so I think that's what's happening with you.

comment 9y ago · link · parent

Interesting. Let's discuss this further during your office hours?

comment 9y ago · link · parent

> I don't think you can compare software to other disciplines like medical, air transportation or architecture.

Why not? After all, the safety of a pacemaker is largely because of the software it runs. In many cases, medical safety and software safety are nearly the same. And throughout our world, this is true in many industries. Driving. Banking. Our software today is our safety for nearly everything. It will only continue to grow this way.

comment 9y ago · link · parent

I have no idea what your question has to do with my comment.

comment 9y ago · link · parent

Lots of tools and apps require knowing passwords; my password manager just lets me press "Copy" when I open it to a particular login, and then I paste it into the iTunes prompt or elsewhere. A little extra hassle but I don't need to remember the password.

comment 9y ago · link · parent

The reactions I have regarding the urgency of this are:

1) Have there in fact been any known phishing attacks in Apple's App Store using this method?

2) Wouldn't Apple's app review usually notice something like this before allowing it into the store?

comment 9y ago · link · parent

One solution would be for an OS to never have such a popup that requested credentials to be entered right there. Instead, the popup should just say "Visit System Settings to enter your account password to download whatever."

This would be similar to measures companies say in emails, "we never ask for your password, always visit our site directly," etc.

comment 9y ago · link · parent

Lots of talk here about better tools and better coding practices and better discipline, but what about better languages? Some languages make it impossible to make the kind of errors that other languages allow. And I think the languages will just keep getting safer and safer.

comment 9y ago · link · parent

> Which one do you think would win in a vote?

I don't know if this was a rhetorical question with an implied and obvious answer, but to me it actually is a curiosity, I have no idea which one would win a vote.

comment 9y ago · link · parent

I think you are conflating two different issues. Yes bad people are bad and should be punished. Does that mean that good people don't get what they think they are getting when buying services (if in fact that's what happened here)?

comment 9y ago · link · parent

Always wanted to try bucklescript. Even has built-in persistent data structures, which is a win over purescript.

comment 9y ago · link · parent

To be fair, in your example, the compiler does warn you:

      WARNING: cljs.core/+, all arguments must be numbers, got [number string] instead. at line 1 
Also, Clojure.spec would enforce it.

comment 9y ago · link · parent

Yes, you introduced the idea that HN's readers wouldn't be interested in this. Then, you went off on a tangent about whether or not HN is the right site or best site for lisp stuff. It's just filling the site with noise when people engage in those kinds of empty remarks.

comment 9y ago · link · parent

> the code-change-reload cycle is quite fast

I work on a 20K line enterprise CLJS app. Due to incremental compilation where only recent changes need to recompile during development, each code change (meaning, saving some source files) is on average 1 second of recompilation. With the Figwheel tool, there is no manual reload required, as it automatically refreshes the browser to reflect your most recent change.

comment 9y ago · link · parent

That's a strange comparison. Nearly every doctor in existence recommends exercise for a wide variety of reasons. How many recommend homeopathy? It's more than a little surprising to me to see several people in this thread who are explicitly skeptical about the value and potential effects of exercise.

I just think it would be unfair for someone to read these comments and then think, "ah, see, there is no reason I should try regularly exercising," and give up before they have started. Do you think that is a good outcome? Even you said you are a proponent of exercise.

comment 9y ago · link · parent

I have to agree that it is much more likely the code was not written well or idiomatically if there were performance problems. Still, I'd be very surprised that the problems actually were there.

And I actually test my clojurscript lines that I write in a JVM repl! Semantics between the two languages are virtually identical, I can test out my ideas for the JS target in a Java environment. Perhaps the OP has a different definition of "semantics".

1
424344
110