8 ms·
JavaScript is the new Perl
- buster 14y agoMh... "those who hate Perl hate it because it’s “too hard to maintain” and too “strange.”"... No.. i hate perl because it's too easy to write really, really bad code and non-obvious how to write good code.
- mutation 14y agoThere's one obvious way to write good Perl code: read the documentation. Perl has tonnes of it. There are bugs in there of course, but most of it is very good. Also try to visit perlmonks.org once in a while - they're good there. Everything else is just a reason to be lazy and not care about the code you write.
- smonff 14y agoThere's another obvious way to write good Perl thanks to the CPAN: don't write it because others already made the work better than you. @mutation: i agree with doc quality.
- aduitsis 14y agoAnd, Perl has an awesome community, let's not forget that. They do love clean code and all (modern Perl is very easy to read and understand IMHO), but are aware that in the end you want to get the job done. Time and again, the question "are there any useful ideas or features in language X that we can borrow and implement in Perl?" has been posed by prominent people in the Perl community. Which is the opposite of the "not invented here" syndrome.
- buster 14y agoWell, the documentation system on CPAN is ancient and awful to use. I have often enough found missing documentation. Particularly perl programmers seem to give a f*ck about documenting return values. And even when there is a good documented function, often enough i am not smarter after reading. Just picking a random method of a random module here: http://search.cpan.org/~grichter/HTTP-Webdav-0.1.18-0.17.1/Webdav.pod#$session_->_cookie_register_(cache) http://search.cpan.org/~grichter/HTTP-Webdav-0.1.18-0.17.1/W... What's the return value? Is there really no result? And what is cache? I can't even click that variable and see it's structure. As a reminder, i just picked some random module. It's 2013 and not 1980. I'd like to know that kind of stuff quickly when i check for arguments and how to call stuff. I like that stuff in my editor/ide as well. Clickable. Call me lazy, but i do want to work efficiently and not trying to google all day for a simple usage example. I like to get the work done. You're partially right about perlmonks. It's a great resource for perl! Sometimes it seems like it's the last stronghold of the perl community but it has great answers. What is not so great is that i find multiple solution (like more then 10) for a very simple problem, but that's subjective..
- webreac 14y agoI love Perl because it is really easy to structure your code to match your way of thinking. And it is so fast to get the job done. I am a javascript beginner. For me, it is a lot more difficult to read than Perl. I very much agree with the article, but I think that javascript is more than a new Perl, it is also a new BASIC. Like BASIC 30 year ago, it is present on every computer, almost every developer will encounter the need to learn javascript and almost anything can be coded in javascript.
- smonff 14y agoAgree with the opinion that modern Perl5 is much more simplier to read than JS. Especially with stuff like jQuery.
- peteretep 14y agoAny time people hate on Perl but like Javascript, I get confused. Perl has some weaknesses vs Javascript (doesn't run in the browser, can't be parsed by anything other than perl so you don't get interesting new interpreters) but also some considerable strengths (uninsane OO, considerably better tooling, string handling, runs on every server by default). But the nice things about JS - the effortless ability to go all higher-order, the flexibility, the power, the /fun/ - and much of the bad parts - the difficulty with writing clear and maintainable code, no support for strong types; if you like Javascript, you will love Perl when you get to know it.
- eksith 14y agoUsing any technology in hopelessly idiotic ways when better tools (and more importantly, appropriate tools) exist will turn it to the new [previous-tech-used-in-hopelessly-idiotic-ways]. This dilemma is as old as programming itself and will only go away when we introduce public flogging as punishment* for wrongly applying the "laziness is a virtue" dogma. * Developers are people too (mostly) and I don't condone public violence against them. Private violence is OK.
- hayksaakian 14y agoPlease recommend a better option for running code in a web browser. ... ... ... There is no php, or rails, or asp alternative here as there is with perl. Correct me if I'm wrong, but the closest thing I've found is 1. NaCl 2...?
- eksith 14y agoThis isn't about running code in the web browser. This is a greater problem of offloading what is better off as being server-side processing on the browser.
- mercurial 14y agoThis comes off as very dogmatic. There are good use cases for single-page or few-pages webapps. I'm likewise more comfortable server-side, but I can understand why you would want this sort of thing.
- DrinkWater 14y agoso much hate in the developer culture. i rather get shit done.
- spoiler 14y ago> JavaScript just waiting for the next technology to come around and make it look like Perl does today: pervasive, but lacking enterprise adoption on large applications. How about CoffeeScript? Also, I worked on some pretty "big" JS projects (in terms of scale, not popularity) and I found Javascript really easy to maintain, you just have to plan ahead a little, but I do agree that the syntax is a slightly bit not to my liking, but it is not horrible. Also, what type inconstancy is he referring to?
- rcfox 14y agoSomebody hasn't seen "wat". https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- 1_player 14y agoGod, that was fun
- Hupo 14y agoThe fun thing about JavaScript's type coercion and concatenation is that you can use it to create fun brain benders like this: +[[+!+[[]]]+[![]][+[[]+[]]]++] === 10 This evaluates to true. Cookie for anyone who can explain why!
- spoiler 14y agoI gues it could be because + infront of an empty array returns 0. So, when you do !+[] you get 1. What you pasted it a bit of a labyrinth, but if someone bothered to keep track of it, they could definitely find ten 1s in there. It's not why, it's a how. I hope someone figures out the rest and gets a cookie! :D
- spoiler 14y agoOh, I've seen it, but it didn't cross my mind. However, I knew before that Array + <something> will give you a String (with the members of that array delimited by a comma) followed by <something> cast into a String. I don't find that wat. Also, the reason why String+Number works is because + is overridden on strings to concatenate, while - isn't. That's why you get a NaN, but you probably know that. How would you expect it to work anyway? I don't think it's that watty. The only thing that I find wat-worthy is Object + <something>, because that truly makes little sense. There might be some ambiguous logic behind it, though.
- reissbaker 14y agoPerl never had a monopoly on a runtime environment with an install base of pretty much everyone who owns a computer, tablet, or smartphone. Sometimes it's not about engineering principles. If native mobile apps end up de facto replacing the open internet, that could change, of course. But I hope the internet remains, warts and all. And as ARM chips improve, and DOM APIs are expanded, and JS engines become more efficient, and the HTTP spec is ever more optimized for web applications, I think in the end the browser will survive.
- grendel 14y agoI would argue that before JavaScript Perl is the only one that came close, part of why it was so popular.
- marrs 14y ago>> Perl never had a monopoly on a runtime environment with an install base of pretty much everyone who owns a computer, tablet, or smartphone. Sometimes it's not about engineering principles. This.
- visualR 14y ago> If native mobile apps end up de facto replacing the open internet Mobile is just hyped. Once companies realize that people who access to the internet solely through their phone can hardly be monteized, well be back pre-iphone in the hype department.
- oscilloscope 14y ago> we still haven’t seen our “Java of the browser” Haven't we? http://en.wikipedia.org/wiki/Java_applet http://en.wikipedia.org/wiki/Java_applet
- arocks 14y ago> Still, you don’t see that many big Python and Ruby shops either... But we keep seeing a lot of PHP shops. Does this mean that PHP is better suited for "large scale projects?" I'd very much doubt that. The ease of learning a language and it's availability are very important factors in the popularity of a language. Javascript scores well in this regard. Really, I am not too worried about Javascript's impending doom. Unlike Perl, it continues to remain a favorite "target language" making it further entrenched in most ecosystems.
- dschiptsov 14y agoNope. It is new Java.) Haskell is today's Perl, if you wish.
- fuzzix 14y agoModern Perl is today's Perl. http://www.onyxneon.com/books/modern_perl/index.html http://www.onyxneon.com/books/modern_perl/index.html
- smonff 14y agoAlso check out the excellent 2012 Ovid's Beginning (modern ) Perl - http://ofps.oreilly.com/titles/9781118013847/ http://ofps.oreilly.com/titles/9781118013847/
- tikhonj 14y agoHaskell is today's Lisp, it seems.
- dipthegeezer 14y agoJavascript is fairly new, Perl hass been around for ages. So there is a lot of old code knocking about that was written quickly and by people who quite frankly did not know what they were doing. Perl5 is actually extremely readable and if you are any where near a decent developer you will understand it. I have worked in loads of companies and bad code is bad code no matter the language. I have have seen some Java code that made me want to give up development for good, and don't get me started on legacy browser javascript code.
- mercurial 14y ago> Javascript is fairly new On a geological scale, maybe. It appeared in the mid-nineties, which is positively ancient in computer terms.
- edtechdev 14y ago"Perl5 is actually extremely readable" @!&?
- smonff 14y agoAbsolutely, it is when following readability guidelines and write documentation. Using obfuscation style is a mess and will never help anybody but the developer ego who believes he is smarter than everybody. But that's a pitty to act like that cause it create pain for maintainers and even for yourself.
- hippich 14y agoPer wikipedia, Javascript was appeared in 1994 versus Perl in 1987 - not that big of a difference. Now, both Perl and Javascript today - are totally different beasts they been back then. They both evolved a lot, but due no real competition in browsers Javascript have monopoly. Perl on the other hand, even having all this awesome stuff in it today, have to compete with many other platforms.
- draegtun 14y agoAlready posted 3 times before to HN this year: - http://news.ycombinator.com/item?id=5016848 http://news.ycombinator.com/item?id=5016848 - http://news.ycombinator.com/item?id=5014218 http://news.ycombinator.com/item?id=5014218 - http://news.ycombinator.com/item?id=5020893 http://news.ycombinator.com/item?id=5020893 NB. Only the first post has comments.
- jaequery 14y agodon't take it lightly of the fact that javascript could theoretically become the most popular language for decades, mainly due to browser support.
- smonff 14y agoHope they could create a kind of huge centralized 'CJSAN' repository as CPAN [1] is. I've checked some existing projets [2] but it can hardly list some hundred modules. NPM [3] is great, but it should himself be integrated into a larger JS repository in the same way Cpanminus [4] is integrated inside CPAN. [1] - https://metacpan.org/ https://metacpan.org/ [2] - http://plugins.jquery.com/ http://plugins.jquery.com/ - http://jamjs.org/ http://jamjs.org/ - http://jsfromhell.com/ http://jsfromhell.com/ [3] - https://npmjs.org/ https://npmjs.org/ [4] - https://metacpan.org/module/App::cpanminus https://metacpan.org/module/App::cpanminus
- smonff 14y agoAnd check out how CPAN is an active modules repository :D http://stats.cpantesters.org/statscpan.html http://stats.cpantesters.org/statscpan.html
- lucian1900 14y agoI don't see how Java's idea of type safety is particularly useful for anything, its type system is almost entirely useless. I've yet to see compelling arguments for why it might be better in "large" projects.
- PommeDeTerre 14y agoIt may not be the greatest, but at least it's better than JavaScript's broken type system. It does catch at least some problems prior to runtime. The most compelling arguments regarding this matter are often in the form of personal experience working with large applications. JavaScript code bases don't scale well past around 10,000 lines of code and 2 or 3 developers at most. Languages like Java, C, C++, C# and Ada, on the other hand, can relatively easily handle software systems with millions of lines of code, worked on by hundreds or even thousands of developers spread globally.
- mercurial 14y agoIts type system is not particularly complex, but it is robust - it doesn't, for instance, coerce strings-with-numbers-in-it into numbers. Sure, you don't have sum types, etc, but at least it behaves in predictable ways.
- marrs 14y agoC++ is notoriously bad at scaling. I'm told that Ada is both very safe and painfully slow to code. JS certainly has its problems. I don't think its type system features all that high. Newcomers trying to make it behave like their favourite language is a much bigger problem.
- keeperofdakeys 14y agoCompared to javascript, Java is quite "rigid". There is always a right way to do things, and doing something else usually leads to hard times. This means that it fits quite well together, and allows complex systems to be more easily created. Javascript's relativity 'loose' type system means that developers have to spend a lot more time ensuring parts will work well. It isn't like good code can't be written in javascript, it's just that it takes a lot more effort.
- lsiebert 14y agoI'm actually taking a Perl class at the moment, and enjoying the heck out of it. CPAN is awesome.
- tferris 14y agoThese subtle JS rants every other day are kind of annoying. Comparing JS to Perl gives a new but still wrong angel on an old tedious discussion. JS weaknesses are overrated: anybody can grasp all quirks within an hour and after few days you get used to them (besides there just a few and great standard libs like underscore making JS a rock-solid base) and JS' bad parts won't stand in your way anymore. Those who aim for perfection won't get shit done anyway. They look for the academically structured Rails apps (or replace with any other bloated framework) with half a second respond times and breaking after every 0.0.1 update of Rails. In my view JS is damn perfect and I can think of anything better right now. JS and its ecosystem (especially the awesome npm) gives you anything to write elegant, well maintainable code bases ten leagues higher than any script language like PHP and on the same level like Ruby or Python. JS is not a hack written in ten days. JS is a wonderful and modern language, more innovative than most other language out there, it's a masterpiece of a language. People complain because it's different: it doesn't follow the traditional OO, there're no strict monolithic frameworks which teach them how to structure code and most are just overwhelmed with functional programming and event loops/call backs/asynchrony because they were just used to something different. This is not being arrogant it's just that people don't like change or hoping all the time for something better instead of being happy with what they have now. You can create and maintain very large code bases in JS without any Coffee or other layers of abstraction (there enough examples out there). Most people are just not used anymore to think theirself about structuring code since there was always somebody who did the job for them (Rails, Django, etc.). You don't need to compile to JS -- JS is also not the new assembly of the net because hundreds are building weird languages on top providing useless syntactic sugar and again old-age OO, it's already a very high level language allowing you to do ANYTHING and structuring you code exactly as want. Nothing will stand in your way. And Javascript is so fast, you get C class performance with a dynamically typed language. No need to compile after every single change or deploys are fast and easy without sending huge binaries to the servers. There's no other language providing this speed for such little cost, no other. To understand JS' beauty and to get the "flow" you have with other languages and you do not get with JS you have to do two things: invest time and try to forget what you learned. And if you still don't get there spend more time with JS. It's not JS which failed. JS haters and other downvoters: not agreeing != downvoting
- 14y ago
- giusc 14y agoSounds to me like the classic apples and oranges comparison. In my opinion Javascript's evolution has become a requirement more than just a story of success. It was the de facto standard language for browsers but with big lacks of performances. Browsers vendors worked to improve it and everything was only a natural consequence of the evolution of the World Wide Web. Perl's history is completely different. Perl has always worked behind the scenes, and still does it greatly. It has a stable, rock solid, very performant and widely spread runtime. Let's just call things with their names and use them for the purpose they are born and everything will look less confusing. More than else, always remember: You can write FORTRAN in any Language.