Hacker News new | ask | show | jobs
by bigdataanswers 3416 days ago
why python???? ... any language with functions will do. I mean just create a java class with all public static functions if you want it to work like python (global functions). Its really language agnostic. Your answer will be a number a string or a list of things. All languages can do that.

Im making an explicit opinion that python is no better than any other language for implementing algorithms. HN please prove me wrong in an objective way so we may all learn?

9 comments

We detached this subthread from https://news.ycombinator.com/item?id=13654240 and marked it off-topic.
> why python???? ... any language with functions will do.

it will. and this person chose python.

> HN please prove me wrong in an objective way so we may all learn?

no one cares about the choice of language. This is about learning algorithms.

Significant whitespace is great for technical interviews - you don't need to worry about matching brackets and whatnot. No brackets also means you have some more vertical space to work with on the whiteboard.

Beyond that, if your interviewer is fluent in python, list comprehensions can greatly shorten the amount of boilerplate you have to write.

Amusingly, significant whitespace is the one reason I don't like using Python in whiteboard interviews - my handwriting is far from excellent on a board, and I don't want any ambiguity when reading my control flow.

I'll definitely second the list comprehension point, though. Between that and pleasant string support, a lot of standard interview answers are maybe 50% as long in python as Java. Not easier, necessarily, but faster to write and cleaner to read.

Indentation is a pretty good thing to practice for whiteboards. A lot of people have a tendency to waste more and more space on the left as they go. It's a pretty easy thing to fix, just do some questions and have someone there to correct you whenever you start doing it.

Even if you aren't using python, it will give you more room to work (the other part of this is divide the board before you start).

Yeah, I definitely suffer from that rightward drift, which I suppose I should work on. Somehow I never thought to divide the board, that's an easy improvement!
I'm not making a claim about Python being "best" for algorithms.

The course uses JavaScript. I recommend re-implementing the algorithms covered in the course in another language that you know well. It helped me really understand what's going on.

In my case, I'm most familiar with Python.

One thing that I like about Python implementations of algorithms is less thinking about types. When I implement my sort algorithm, I just need to say > or < and assume the caller has given those terms meaning.

Not a Java expert, can you do something similar with Java? Maybe with generics?

I'm no expert but due to the language I think you need to specify types somewhere. It just offloads it to your test code as opposed to the algorithms.

With python, your algorithm will work with the primitives without specifying either in the algorithm or test code. You only need to specify type, i.e maybe a new class and definitely instantiation, if you want to use something more abstract.

This would be true of Ruby and other dynamically typed languages. For beginner algorithms courses at least, a dynamically typed languages makes more sense since the algorithms taught are only clouded by typing. Complexity theory still applies and what not.

Maybe if learning algorithms that do heavy crunching, a lower level language, probably with static types, may be used but by that point you're not going to mind type info.

Yes, generics in Java or templates in C++ is how any algorithms library would handle this. Any type passed into such a function needs to possess the required operators and functions or it will fail to compile/run.
You might be complaining about students being taught Python and it becoming their "blub" language. We all start somewhere, and you can indeed go far with Python in some fields. It's popular with scientists for instance.

Recommended reading: https://www.reddit.com/r/programming/comments/9nipa/joel_on_... ( https://www.joelonsoftware.com/items/2009/09/23.html )

http://www.paulgraham.com/avg.html

http://www.lessonsoffailure.com/tag/paul-graham/ <-- note "flamewar" in the title!

I agree with this. For me, I'm using the language I'm currently using at work (C#) to learn them better. If I'm going to be tested (in tech interviews) in the language I know my bet is that it'd be better to know the C# way of doing it and knowing how to implement it using C# conventions. I haven't interviewed yet, but this is just the hunch I have if the goal is to do well in a tech interview
I don't like Python either but it's out there and a fact of life. You use whatever a client requires.

Dictionaries, sets and lists can be nice though.

Go here( https://www.thecodingforums.com/threads/performance-sets-vs-... ) and search-find "Terry Reedy".

"HN please prove me wrong in an objective way so we may all learn?"

Your issue isn't so much being wrong as lacking a coherent and relevant point in the first place.