5 ms·
Stream of consciousness programming?
by getcrunk 3y ago
Stream of consciousness programming?
- bane 3y agoPerl has a weird way of letting you go from thought to code, and disappearing in between, unlike any other language I've ever used. You really can go from idea to functioning system as fast as you type without a lot of pre-planning. It's hard to describe, and the style has fallen out of fashion for more formal, easier to share between humans languages like Java or python, which feel like they introduce an inherent friction in that transition layer as a tradeoff for scalable teams and readability. I miss it, but understand why it fell out of favor. It's the closest I've ever gotten to singing whalesong with a machine.
- alfiedotwtf 3y agoExactly this. As fast as you type you're coding. Even though I've now spent years in other languages compared to Perl, it's still stop-start in every other language. I've said it many times, but Perl really moulds to your brain rather than the other way around. You bend Perl how YOU want it.
- eperoumal 3y agoI so much feel the same. At the time I was writing Perl, each line made so much sense, as if I was speaking my mother tongue. It was clearly an extension of my brain. Never had that feeling with any other programming language, and it took me years to eventually let Perl go and try to wrap my head around Python.
- arp242 3y agoI wonder how much Larry Wall's background as a linguist has to do with that, which perhaps also explain some of Perl's "messier" features, just like natural language is kind of messy. I once had a long conversation about this with a linguist and Perl programmer that I randomly met in a pub. However, I was quite drunk and don't really recall too much, and we never saw each other again.
- singingfish 3y agoThis is quite an interesting phenomenon, and kind of explains why perl is disliked so much. Computer programming theory has large swathes of inspiration from theoretical linguistics - think lisp. That's nice for theoreticians because it makes things like parsing easier to think about rigorously. Perl on the other hand, to my knowledge is the only significant programming language to be inspired by practical linguistics, and therefore appeals to concepts like context and ambiguity way more than other languages. This means that a lot of computer scientists academics absolutely hate it, and so it was very much neglected in the education space. The other side effect of this is you still get a good number of talented programmers with backgrounds in the humanities and social sciences who do very well on perl.
- masto 3y agoI love this subthread; I've tried to explain this for years and I've concluded it's simply impossible to convey to someone who never experienced it. It's sad, and really frustrating, to just hear the same clueless comments and memes repeated. So I'm glad to see there are still people around who know what it was like to work with a truly expressive language. About 15 years ago I was put on a Java project that ran for a year with half a dozen developers toiling away (along with an outsourced team that management eventually added to write unit tests). I spent half that time fighting with Eclipse and the other half divided between tearing my hair out trying to wade through the AbstractSpringFactoryInterfaceAbstractFrameworkInjectorAbstractionBuilder nightmare, being lectured at by people who learned everything they know about computers from in-flight magazines that this is the way professional software development is done, waiting for the one person who could actually build the application (which he did partly by unzipping the jar files and manually tweaking their contents), and actually coding. To my complete lack of surprise, the project never achieved a working milestone and was cancelled. What did surprise me was that a coworker who was sympathetic to my grumbling persuaded the CTO who was trying to rescue the project to let me try it my way. On my own (using Perl and PostgreSQL), in a couple of weeks, I had a fully working prototype. We got the green light to proceed and built the company's flagship product on that stack. It was not my brilliant engineering as much as Perl's extraordinary ability to connect mind and machine (coupled of course with my brilliant engineering) that made it possible. I owe Larry Wall for a huge career boost.
- runlaszlorun 3y agoLarge teams themselves become boat anchors towards progress. But you’ve inspired me to spend a little time with Perl.
- alfiedotwtf 3y agoLOL are you me? This is exactly what happened to me! Same situation, Java with an external team, project over budget and over time, gets canned and then a few weeks with Perl and it’s done
- bitwize 3y ago> Perl has a weird way of letting you go from thought to code, and disappearing in between, unlike any other language I've ever used. Funny, a lot of people say that about Lisp...
- singingfish 3y agoAs a medium long time perl guy who's been dragged kicking and screaming to do a bit of python recently I'm going to repeat this here: Python and perl are actually pretty much exactly the same - analogous to the Judean People's Liberation front versus the People's Liberation front of Judea. However the languages are optimised for a slightly different purpose. Python helps you to think more like the computer does, whereas perl helps the computer to think more like you do.
- __s 3y agoThis can be nice in Python. The `dis` module makes execution pretty transparent, & it's easy enough to know what bytecode a given line will compile to (granted, comprehensions creating closures does make that a bit harder) CPython's implementation is also straightforward enough that you can look up ceval.c to get a gist of what an opcode is doing
- gonzus 3y agoI associate this with what we used to call "one-liner programming": I would write a single line of Perl code (in bash, prefixed with `perl -Mwarnings -MDebug -E'<code here>'`, convince myself the code did what we needed, and then share it around as a paste in irc / chat / whatever. It was amazing what you could achieve with the right modules, and Perl's flexibility allowed your mind to roam freely. Incidentally, the fact that you cannot write this type of one-liner in any meaningful way with Python is one reason I do dislike that language.
- fulafel 3y agoAbout Python, are there practical situations outside IRC where you can't include a newline in there? This .. python -c ' import re, sys for line in sys.stdin: print(line.lower().count("foo")) ' works in shell interactively (both bash and zsh support multiline history entries well), or in shell scripts, and also in slack/mattermost/matrix/email.
- teddyh 3y agoYou can do that as a one-liner (I have kept the unused “re” module import, to keep it as close to your code as possible): python -c 'import re, sys; print("\n".join(str(line.lower().count("foo")) for line in sys.stdin))' or if you want to avoid building one large output string: python -c 'import re, sys; print(*(line.lower().count("foo") for line in sys.stdin), sep="\n")' if memory consumption is still an issue: python -c 'import re, sys; set(print(line.lower().count("foo")) for line in sys.stdin)' (This creates a useless Set object and throws it away as a side effect.)
- deleted 3y ago[deleted]
- hnfong 3y agoIt's sad that Perl is dying a slow death. Between Python and Perl, both styles of coding are possible. While Python is my preferred language for most tasks, I still use perl as an ad hoc stream processor with `perl -pe` and nothing really beats it at the task. Anything more than 10 lines and I find python easier to deal with (or at least it's my comfort zone).