5 ms·
Yes, but IMO JavaScript, again, is not as easy to read (especially for a person who's just learning it) as Java. (And why the downvote?)
by mayanksinghal 15y ago
Yes, but IMO JavaScript, again, is not as easy to read (especially for a person who's just learning it) as Java.
(And why the downvote?)
- amouat 15y agoI haven't downvoted, but you've not given any reasoning behind why you think OO code is more readable than functional. I suspect most people think readability is more affected by style rather than choice of programming language.
- mayanksinghal 15y agoAgreed, may be I have seen only bad code. I am still a student and the only industry code that I have seen was in Java. Much of the rest of code, that I saw in academia, was functional in nature and written in C. I have observed that (may be due to the lack of a review system in academia) the code was much harder to read. With C, the problem was even worse due to extensive use of global variables and poor structuring of code. Java, on the other hand, has two benefits: firstly, it's really strict and verbose. So even if a person is practicing bad coding, it is still harder to make truly unreadable code. Secondly, the IDE are more powerful, makes coding as well as code browsing easier. My prejudice might be against C and in favor of Java. And i just related it to functional and OO respectively. But I would like to add that modifying objects still somehow seem more intuitive to me - probably because I had a better Java teacher than a C teacher. :)
- vogon_poet 15y agoI think you might be misunderstanding what "functional" means. C is typically considered a procedural and not functional language, even though you do define everything in functions. Functional programming refers to languages (like scheme and Haskell, and also Ruby and Python) where a function is no different than any other object in memory (like int, char, etc.). It can be returned as a value and passed as a parameter. A function can take functions as arguments and return another function as a result, kind of like taking the derivative or integral in math. (Something like this can be done in C with function pointers, but it's ugly.) Moreover, it's possible to define an "anonymous function", or "lambda". This is essentially an expression that evaluates to a function without a name, the same way you can type (x * y * z) and have it evaluate to a number without having to store it in a named variable first. Also, you ideally want to define "pure functions", which means functions that return the same value for the same inputs no matter when you call them. These are much easier to debug than code that depends on outside conditions. When you wrap your head around functional programming, it is actually a lot easier and more sensible in many cases than OOP. Of course, OO is still ideal in a lot of situations, which is why many languages (Python, Ruby most notably) combine the two. (if you've been in academia, Mathematica is an example of a functional language.)
- scott_s 15y agoNot worth saying: "I like pizza. It tastes good." Worth saying: "I like pizza. Its combination of bread, cheese and tomato sauce is unique."
- wisty 15y agoI didn't downvote. Don't sweat the downvotes. Sometime people just hit the wrong button. Sometimes they don't agree. If you worry about being popular on HN ... Anyway. It might be harder to read because you already know Java. Javascript has some horrible warts (IMO), and CoffeeScript fixes. Also, Javascript is usually targeting the DOM, which is often ugly, especially if you are trying to include compatibility stuff. The DOM is basically a GUI, and GUI code can be rank ugly. Yes, it is hard to read (and learn) HTML, CSS, DOM, HTTP, and Javascript all at once, which is what real Javascript often involves.
- mayanksinghal 15y agoYes, and to add on that, I think for JS there is a lot of ugly code out there on the web. I have actually used them a lot before watching Crockford video's and I found them quite late! BTW, are there any other resources similar to these videos? (Or, to put it differently, is Douglas Crockford the authority for JS?)