Better HN
topnewbestaskshowjobs
Log inSign up

pansa

39 karma · joined Jan 7, 2020 (6y ago) · 13 submissions

Submissions

comment 6y ago · link · parent

Julia is built around multiple dispatch - when making a call, the method to execute is chosen based on the run-time types of all of the arguments.

Once this choice has been made, Julia compiles the method, specialised for the exact types of the arguments.

So, the dispatch process and the JIT compiler are linked - both are reliant on type information every time a function is called.

This specialisation is the only way the Julia JIT uses runtime type information. Unlike JavaScript JITs, Julia does not track things like the types of local variables during execution (although it may do some static inference). Therefore type annotations for local variables can improve performance.

comment 6y ago · link · parent

I was sure your link to a British comedian was going to be:

https://en.wikipedia.org/wiki/Tommy_Cooper

comment 6y ago · link · parent

Doesn’t Python’s `import` evaluate code in the same way as Ruby’s `require`?

comment 6y ago · link · parent

There is some convention in Python - for example `reverse` and `sort` are mutating, whereas `reversed` and `sorted` are not.

However, I don’t know if there is a good reason why the mutating versions are methods and the non-mutating ones are standalone functions.

comment 6y ago · link · parent

[deleted]

comment 6y ago · link · parent

Wouldn’t reddish organic matter just be “red meat”? Or do you consider, for example, lamb to be a type of beef?

comment 6y ago · link · parent

> Genuinely curious, what makes Python look more like pseudocode? The use of colons?

I used to think it was significant indentation, but if you look at the pseudocode on e.g. Wikipedia, there is no significant preference for either whitespace or begin/end.

Therefore, it’s probably things like `if value in my_map` vs `if my_map.contains(value)` and `[x * 2 for x in my_list]` vs `my_list.map(x -> x * 2)`.

comment 6y ago · link · parent

> I am sure method_missing could be implemented in python using various tricks but nobody, afaik, is doing that.

You could probably implement method_missing in Python using either __getattribute__ or __getattr__.

I think this is a small example of why nobody is doing so. It’s not just culture - Python’s object model is so complex that it would be hard to get right.

> why don't people just write clear, explicit, maintainable code instead of trying to be clever

But that’s boring. Seriously, it always amazes me how many programmers allow their decisions to be guided by what’s best for their personal enjoyment rather than what’s best for the project.

comment 6y ago · link · parent

IIRC Guido himself is planning on adding a `match` statement to Python.

comment 6y ago · link · parent

> how would you showcase an experimental feature to the community?

How do other languages do it? Python has the PEP process for discussing design on paper, but I don’t know how they handle experimental implementations.

comment 6y ago · link · parent

> I’ll never understand how Python became the more widely appreciated language

IMO syntax is a major factor. Python looks like pseudocode, while Ruby looks like Perl.

comment 6y ago · link · parent

Did tech “barely exist” when Zuckerberg started Facebook in 2004?

comment 6y ago · link · parent

> A guy who [...] wants to be known as the creator of something.

I have this problem. I’m frequently distracted from doing what I want to do by ideas for things that I want to have done (and wouldn’t enjoy actually doing day-to-day).

The search for prestige is about the only reason to switch paths and start working on any of these ideas, but it’s hard to ignore.