37
votes
What is your favourite programming language?
What is the programming language you enjoy the most, or otherwise define as your favourite? Why is that particular language your favourite?
Bonus: add just a little bit of code in it that you think exposes its beauty.
Go. Everything feels very concise while also being very fast. No other language I've seen has had such an easy concurrency model. Python there's all these modules and all this setup you have to do around them, to launch another thread in Go it's just a single extra word before your function call to make it non-blocking and maybe 2 changed lines of code.
Even just blindly launching 100,000 goroutines all at once, ends up being more than twice as fast (7.3 seconds vs 3.4).
It feels quick and easy to write, and honestly for simple scripts
go run file.go
feels like it rivalspython3 script.py
in startup speed, while the actual code runs insanely faster. Just as a super bad comparison, the single threaded python busy_work() function takes 50 seconds to finish.Not as fast as C, sure, but I still feel like I'm getting the ease of writing of Python while also not sacrificing speed.
I watched a computerphile video recently that had an interview with Brian Kernighan, and they asked him which languages he uses today and Go was among the list. I've been interested in trying it out since then - I've heard it described as "C for the 21st Century".
It's definitely very thoughtful in its design and doesn't go nuts with building absolutely everything into the language. Gives you the tools you need and no more. I've heard it said that Go tries to tackle new problems by writing new code, instead of writing new language features.
I really like Go, but have troubles with the way it wants code be organised,
GOPATH
&co is really off putting to me and I don't understand why they want to enforce something like that. Code is here, in this very$PWD
, why where it is matters, and why not just download dependencies in a vendor dir or some common place like~/.local/share
or~/.gopkgs
or~/.cache/golang
? Also the whole dependency management shenanigans were unnecessary IMHO.GOPATH
is effectively gone with the Go 1.11 module system.So this means I can put code wherever I want (except under
$GOPATH
up until 1.13) and expect go to work like any other package manager, right?Yeah, that's the plan. I have already used it in a project of mine, works pretty good.
I hated
$GOPATH
but with some recent updates, one can use their module system to write code anywhere. Pretty much sealed the deal for me.Golang is definitely my favorite language for a number of reasons:
go fmt
fixes every style issue that could arrive.go build
, and compiles into a static binary. Trying to build Python, or using CMake, is just not nearly as intuitive.It has it's oddities, like how removing an element from a slice is relatively non-trivial, but overall I find it to be very well thought-out and implemented. If I find something designed by the go team that isn't how I would've thought about the problem, then I see it as a learning opportunity because they certainly approached the solution better.
For me, it's most certainly Rust, and I'm not going to try to force anyone to like it, because it's not perfect, and also, that backfires.
I actually like Rust for several reasons, method chaining, an error story that actually lets you know what error states your program can enter into (looking at you Exceptions, not that I hate exceptions, they're better than some other options at least). and the whole "can't easily write a program that violates memory safety" thing. Going back to the states thing for a second, I like that I can move a lot of errors to compile time, where they might be runtime errors in other languages (Like guaranteeing that a UART controller doesn't accidentally set the wrong register, by using 2 different structs, that physically can't be created without the hardware being in the right state)
For some reason, the following function is my favorite function, it isn't perfect (actually, it isn't even that great), but I smile every time I see it:
This function copies the contents of the
src
"register" to thedest
"register" (except when they're both actually memory addresses, then it runs thehalt
instruction).For me, it is definitely Emacs Lisp, because it is at my fingertips all the time and I can use it to interactively build programs in Emacs that solve my immediate problems. Interactively building code makes it really easy. I tried and failed (bad API design, may retry) building an SSG recently, and the uninteractive way of building that I chose, namely TDD, was a big obstacle for me all the time. With Elisp, I can test parts of my function as I build the thing, so I generally don't need to test stuff afterwards. That's obviously bad for software that'll be collaboratively built or later distributed, but when it is your init.el, little programs just for you, this approach is way more productive.
I'll use an example session to demonstrate this: imagine you have a buffer, and you're editing a function that acts on it.
[]
is where the cursor is at.So, you want to test this with the buffer
test.txt
. You don't need the repl, and you don't need to copy stuff around. You also don't need tests and mock data. You just replacebuffer
on line 3 with(get-buffer "test.txt")
and move to the end of thewith-current-buffer
expressionand hit
C-x C-e
to see what it does. If it works as expected, just undo withC-/
and evaluate the command withC-M-x
: ready to go. And the effects of all this is immediately applied to your live environment, so you can immediately start using this stuff without restarting your program and/or losing any state. You can jump into core libraries or 3rd party code and just edit-eval-test until you have a working thing, then send a patch or save customisations to your init.el (i.e. override the functions). You can easily get help for functions, variables, etc. from the manual or the docstrings.This interactivity coupled with the Emacs platform makes for a great experience.
I'm still a beginner, but, in this order:
C for the small size, simplicity, terseness and for forcing me to think through certain things
Emacs Lisp because I can do a lot with it on Emacs without even really knowing it
You're a beginner but know elisp? That's pretty interesting! I've been coding for years and use emacs (doom flavour) everyday and still haven't got around to learning elisp. I mean I know some of the basics of the functional paradigm but to build an extension for emacs is something I've been thinking about.
How'd you go about learning elisp? Do you have any suggestions on resources that you found useful?
I'm less than a beginner. I'm just a master at googling and pattern recognition. I also found lots of help at /r/emacs, /r/orgmode and #emacs.
Basically, I look at how something works and I mess with it. After a year using Emacs, I gained enough knowledge to make a bunch of configurations and "hacks" amounting to 3000 lines that could probably only serve for my own use. I am not a lisp programmer by any means.
My suggestion: Emacs self-documenting nature is something you should definitely take advantage of. Master it, first of all. It should be second nature.
If you wanna learn Elisp for real, ask @cadadr! (but the eintr seems good enough).
Eintr (Emacs Lisp Intro, it is part of Emacs' Info docs) is great and I do suggest it, but I learned most of my Elisp skills through writing my config and hacking Emacs' core libraries or third party code. I'm a learn-as-you-go type, which is not efficient, but fun.
I guess Javascript can do the similar enough variable swapping as Python now because of array literals and destructuring.
Similar, but it doesn’t beat Python’s intuitiveness. Python was created for non-programmers, and it still shows!
People always use switching two variables as an example when discussing programming, but when would you ever need to switch two variables? I have literally never needed to do this.
Edit: I just had to do this for the first time! I was working on some user interface where the user can swap the position of two items.
IDK, it came up in algorithms class.
It's a very classic example for beginners, but hardly shows up in the real world. That being said, it's still a good example to demonstrate Python's power and simplicity!
Yeah, the class was actually in C, when I saw how to do it in Python it blew my mind because of how simple it was.
Python is my go to language when I need to solve a problem quickly.
Solving problems in python these days is often just
Which is nice. I do love python for lots of reasons, and it's my go-to language as well. But I've had more fun in other languages. Fun isn't always the goal, of course.
It's true. I really want to learn more C++ (or dive into Rust) but I haven't yet found a case where it leapt out at me as the right language.
Unless you want a job with C++ I'd recommend Rust over it any day for personal projects. I know Rust isn't the peak of static analysis, but coming from Ruby/Python/Javascript it's amazing.
PHP.
Fight me. :)
Not any more, really. But I spent a long time writing websites (back when they were web sites, not web apps) and php was great, in it's heyday. The days when if you wanted a framework you had to write it yourself. And I did, several times. I still use it here and there for the few small projects I'm involved with, because why do I need to mess about with Rails or Django or node or any of that stuff for my little brochure site? It feels a bit like driving a classic car - you have to be a bit careful otherwise something might explode or fall off if you go too fast, but it's all there, the foundations on which so much that came after was built on.
I work with PHP and have gone from "This isn't Classic ASP! I love it!" to "What is this inconsistent, patchy shit?" to "You know what, PHP is pretty good these days" and it is.
I totally agree. Most PHP dissenters are thinking of the 5.x era, not the 7.x era—PHP is extremely livable these days. It's not without its problems, but it feels pretty good to work in daily.
I agree. I've used lots of languages and I like PHP the best; maybe only because it's where I have the most experience. It has its oddities, like different ordered arguments in some functions, but it's a fairly fast language, easy to deploy, and I find it a joy to use.
I like the cgi execution style it uses where it just executes through your front end server. I don't love the extra complexity (however small) of other languages that run each program on its own port and then using a proxy to push traffic to those ports.
From this comment it's probably clear, but I do mostly backend web development such APIs.
You should check out Laravel.
I've never met a framework I didn't very strongly dislike. Except my own, of course.
They're all fun and games while you're doing stuff that the framework designers envisioned but every single time I've used one I've ended up running into problems because the things I want to do either aren't possible, or trip all sorts of problems that the designer didn't plan for. I once triggered a freakin' kernel bug from inside Django. On Debian STABLE. Cost me a fortnight of work of increasingly awful hacking, dicking about on LKML, in the end I ended up hiring one of Django's original devs and even he couldn't fix it. Had to rewrite a whole load of code to run in a different, and much, much slower, way. Awful.
I am not a frameworks guy. I get they save a lot of time for a lot of situations but for me they've been nothing but trouble.
Hi! PHP die-hard here.
I am not a Laravel person. I appreciate that it exists, but Laravel is very uncomfortably opinionated. I know that big frameworks are supposed to be better because more eyes have worked on and used the project, but it I can't help but feel that Laravel—the few times I've used it—forces me into design choices I'd never make myself. And, let me tell you, the core tenant of their project is not resist complexity.
If you want to change how you think about software development, give Erlang a try. It’s a really cool language that doesn’t get enough love. The syntax looks odd at first glance, but it’s actually pretty simple and pretty great. Give it a try!
Alternatively, Elixir.
I’ve liked using Elixir a lot. I think it really “meshes” with how my brain thinks about data flows and software in-general. As (primarily) a node/react web developer, phoenix framework has really gotten me out of a rut!
I work in C#/Net Core/JavaScript on a daily basis so I've come to like those languages but my favourite one for general dicking about on personal projects is Python. It just clicks with the way I think.
Same. I don't have much opportunity to use it these days but it does work how I think. I used to love that the quick reference manual was something like 30 pages.
Haskell! I understand it's not the most practical language, but it's certainly changed how I look at computations and problem solving in general (for the better, I hope at least).
In general I suspect the whole world would be better if we went back in time and built everything in functional languages from the start.
Some of the most enjoyable programming experiences I have ever had is in Golang. While the language is simple (no generics or fancy error handling), I haven't ran into a case where either are explicitly needed. Once I am done writing the code, the program feels robust. It has replaced any of my Python or Node.js development entirely. With that said, I think Rust takes the cake. Rust had a steep learning curve for me. For a long time, I was running into errors with the borrow checker left and right. But after enough time, I truly believe that Rust has forced me to be a more cognizant programmer.
In my experience, the lack of generics (+ no function overloading) hurts. You can even see it in the standard library.
There is no function in Go to take the max of two integers. Because max only takes in floats, they didn't want to clutter the std with max_int, and no generics.
You're actually supposed to write the max or min function yourself every time you need to use it. In fact, in the standard library's sorting implementation, it does. Whhhyyyyyyyyy
Generics are on their way.
Julia, for multiple dispatch, performance and generally elegant design. It just feels more fun to code with it. If only they could magically fix the loading/compilation times.
I always found the vectorised stuff from MATLAB and numpy to be really cool. Especially in a high level language.
What's great with Julia is the you are not forced to vectorize your code for performance, so when it makes sense or you feel like it you can just write for loops. You can also use a more functional style without penalties, so it's quite freeing.
I love the broadcast syntax too:
What do you use it for? I'm keen on learning some statistics in the coming months, and if you use it for stats, would you suggest it over R or Python?
I use it for scientific computing mostly, biology, statistics, machine learning, etc.
I think it's better than R for statistics, for example if you want to compute the density of a Poisson distribution at the value x you do:
At value 0 to 100:
If you want to take the quantile your do:
If you want to fit it to data you do:
Integrate it between 0 and 100:
You can probably guess how you draw random numbers from a Normal. In R you have your dpois (or ppois, I never remember which is which), qpois methods and a plethora of function with random names that don't compose into anything,
Scipy is nicer than R (being object oriented), but it's also pretty slow, so doing your own sampling, optimization or integration can be a pain.
You can check this too:
https://people.smp.uq.edu.au/YoniNazarathy/julia-stats/StatisticsWithJulia.pdf
Yeah you have to leave your session open, you can't reload things each time.
C, because I can keep its syntax in my head. Also, it just makes sense to use C in my most-used operating system, OpenBSD. I like the "close to the operating system" feel.
Probably C#, it just feels right. Every time I look at different languages I end up wishing the syntax and everything was more like C#. I used to like Dart, because it can be transpiled to JS, which means I can use it to replace JS and do some fun stuff like making games in the browser from scratch in the HTML5 canvas, but Dart feels a bit dead for this use now. Also Dart is really similar to C#, that's probably why I liked it in the first place.
I also don't like Google, which is definitely a good reason not to like a language... especially considering C# is Microsoft haha.
You might also like Vala https://wiki.gnome.org/Projects/Vala, A C# like language for GLib.
All of the ML languages. Though, in terms of viability F# takes the cake for having access to the .net ecosystem, as opposed to ocaml's fairy lackluster one.
Kotlin and typescript have good typing systems and the modern features you'd expect from a modern language. They solve some of the uglyness of their base platform's language (i.e you can free functions in Kotlin, no === in TS, sane scoping rules in TS, etc.)
Rust is nice for being an actual systems language with the taste of modernity (and without C++17+'s cruft, and a real module system)
My favourite is the HT one.
HTML
To be fair, when 90% of the web is a bloated mess of unnecessary, obtrusive and privacy invading JS... is it really all that surprising that people have projected their hatred of that aspect of it onto the language itself?
Clearly, CSharp is superior.
Hey we could all go back to allowing VBScript in webpages. Then maybe people will lay off on JavaScript.
There are some good things going on with Javascript. I've read through "The Good Parts" and learned to appreciate some of the language design - but there's a lot more to a language than just language-level features. Without a standard library you go from a neat little LISPy C-syntaxy language to the shitshow we have today.
I never said it was... but projection need not be (and rarely is) logical. I was simply explaining why it's not really surprising that people hate it, even though that hatred may be largely undeserved and misplaced.
I spent a year doing full-stack (mostly back-end) development in JS/node. I gotta say, I totally get the hate. It definitely has interesting parts, and it allows for some crazy tinkering, which can be cool. However, when you combine the dependency-happy ecosystem (so many packages!) with a remarkably flexible language, you get a whole lot of weirdness...
On top of that, there are some features of the language design that result in a lot of unpredictable, inconsistent behavior. Things like arrow functions,
==
, and||
come to mind (and don't get me started onthis
!).The fact that you can do stuff like this is cool...
...but I don't really want to be able to do things like that in "important" code; it's unclear, fragile, and will throw off every linter in existence AFAIK.
I don't want to pick on anyone for liking JS (I even enjoy using it sometimes), but it does have some issues that go beyond being inefficient.
Isn't the inverse the case today? I hear that V8 is one of the fastest VMs out there, and what I've encountered up until today makes me feel like good JS can easily be faster than Java. I haven't done/looked at any benchmarks or comparisons tho.
V8 is fast for an interpreted language, though LuaJIT still takes the cake for fastest JIT, but the JVM has the advantage of taking bytecode, and it is for the most part faster (https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/javascript.html).
I'm a big fan of java for collaborative stuff, and scala for non-collaborative stuff.
Java seems to make good designs easier to communicate and keep when you have multiple people working on a project. It also has a huge number of good libraries (and a huge number of bad ones, but...).
Scala lets me program in a functional world without losing access to those libraries. I wouldn't want to expose some of the horrors I've created in functional land to others, but you can make some really "clever" syntax with it...
Hey, if you like Java, you might also like Kotlin! Kotlin is similar to Java and also runs on the JVM. It's kind of similar to Java, but has learned from some of the pain points. It also has a whole bunch of nifty stuff in it as well that makes it quite the joy to program in. (I keep finding myself missing
when
in other languages)I think the main reason kotlin's come up on my radar in the past has been when looking at ways to write code once and release on iOS/android/web/other, but I wasn't in a position to make language decisions on that project. It does seem like a nice one though.
Ah, my job seems very keen to use the best tool for the job, even if that means I get to learn the tool on the job (thanks boss, not even joking, I'm very grateful for this). But I've learned both Kotlin and more recently Dart (for flutter). Flutter is pretty nice for building once for Android/iOS/web for the most part and has other OS' in the works. But it's fairly young and I've had bugs with both Flutter itself and libraries using it before (not on stable, but on the other hand, I've needed to use something other than flutter stable in production).
I was scanning this thread to find my two favourite languages. Kotlin in recent months has completely won me over.
I've been writing a lot of code in Kotlin and the following has really won me over:
.copy( innerVariableToChange = value )
to create a new object with just the value ofinnerVariableToChange
replacedwhen
is so gooddata class
are the best things that any business minded programming language has ever came up withtailrec
in the method so you can avoid all the obvious tail recursion pitfalls that exist in other languages.It really is such a nice little language, and I've recently bought the 'Kotlin In Action' book which has exposed me to some other clever little tips and tricks I could use in Kotlin as well as explaining how it was achieved in Java.
I mean, Java is cool and good and is really my first real grown up language that I've coded in over 8 years, but Kotlin is Java just smoothed out as well as some other stuff built into the language which I'd have to add some Apache/Guava library to achieve the same thing in Java. I cannot recommend it enough!
Lua. The main reason is that most of Tales of Maj'Eyal is written in it.
My favourite feature is Lua tables as the universal way to structure data.
Upvoting for patriotic reasons ;)
Racket for the sheer amount of thought and engineering that has gone into it. The community is wonderful and the standard library is feature-packed but consistent. Everything is well documented and cross-platform-ness is heavily emphasized (this is also a minus in certain cases, because to do platform-specific stuff (eg.
fork(2)
) you need to either use the ffi or use an external package). It's also consistently among the fastest dynamic programming languages out there.Two in fact.
First, LISP. Not elisp but classical (or Common) LISP. That language really moved the computing world ahead by decades, you can look it up; on LISP based computers people invented networking, GUI, laser printers, the computer mouse and much more. I believe that everyone should learn LISP. Not to program in it, but to understand it. There is always the moment when you really get LISP and learn a new way to think about programming in general.
Second is Rust. Although it's macros are not as powerful as LISP's, it has some other advantages. I really enjoy how it makes most of what I type an error so I can fix it before I deploy it! Though on the other hand, I also ran into compiler bugs, which put a project of mine on hold for almost half a year by now until they get a newer LLVM merged.
Classic ASP! I did about 7 years of that. Loved it for the first 3 or 4 years as it was the start of my career. Couldn't wait to do something entirely different after then. The last 3 or 4 years of working with ASP almost killed me.
I work with Fortran most frequently, so I guess my favourite is anything but that? I like C++ and OCaml quite a bit, and I'm a fan of Go because of its fairly simple (and well-enforced) syntax and tooling.
As far as languages I thought would be more of a favourite, I'd have to nominate the lisps. I like them in theory, but I've never managed to actually implement a real world project (other than some Advent of Code problems in Picolisp I guess)
Can i ask a kind of offtopic question?
I'm really surprized that nobody mentioned rust. I feel that if this thread would be a year or two ago it would have been mentioned more than once. Was it just a hype? Or is it just not as beloved as i percieved it was?
There are at least two posts which mention rust. In general, it's a somewhat niche language. Not everyone works in systems/embedded, and for those that do many still must work in C, whether that be for legacy reasons or just compatibility. For those that do not, oftentimes a GC just makes life easier.
Javascript, because it’s also the only programming language I know.
It's fairly unpopular these days, but I prefer perl5 for pretty much all of my home programming needs. This is in part because I've been using it professionally for the last fifteen years, but even in that span I haven't really seen terribly much of the 'write only coding' which it's famous for.
I've been taking some halfhearted efforts to switch to python or nodejs in order to stay in the mainstream of languages with available useful modules, but so far it hasn't seemed to be to an extreme benefit. I guess I'll have to switch someday, but so far it's been treating me quite well.
Perl 5 is beautiful. I have used it to write some essential scripts (e.g.) for my config, and it is the best tool for that. For larger programs, it is harder to use, tho. I'm not really fond of how OOP is done in Perl 5, writing classes looks hard and unnatural.
I certainly respect that as an opinion, though the code base I work with professionally is fairly large and object oriented. As far as I can tell the only real downside is that you can't have private members or data. That said, sometimes dipping into the object you're using has been pretty handy, even as I understand it to be not best practice.
Of course, I don't have a ton of experience with other languages, the largest codebase I'm otherwise familiar with is probably only ~5KLOC or so.
I write code in a lot of languages, but my favourite is definitely Python. Not because it's particularly beautiful, but because it's straightforward and it makes solving most problems easy, even when ignoring all the third-party libraries available for it. If it had a decent standard library, Lua would fill the same niche for me, "arrays start at 0" be damned.
If anything, I find shell - not full-fledged scripts, just one-liner pipelines - more elegant, more aesthetically appealing. But I don't really use languages for their aesthetic: I appreciate it more when they can make things simple. Python does that (but then, so do awk, shell, and make - in their own niches).
(bad/weird syntax, in any case, doesn't deter me much - writing boilerplate does, but not bad syntax)
This feels like a copout shitty answer.
My favorite programming language right now is Python 2.7. Why? Because it comes pre-installed on all CentOS servers which means I can finally stop writing scripts in bash for server monitoring. I fucking hate bash. There are no amount of tutorials that will get that language to click with me it seems. Which isn't to say bash is a bad language. It is to say it is a bad language for me and since 100% of my programming is for work, my favorite language is the one that makes work less frustrating for me. Once there is a CentOS version that comes with python3 natively and we move all our servers to that, then python 3 will probably become my favorite language.
I don't really care directly about the beauty of python or anything about python itself, just how it compares to my other options (bash). I use to work in C# and java and thought they were equally as good of languages as Python, but I don't have to work with those anymore so I don't care about them now.
Shell scripting is a horrible experience. I generally script in Posix Shell for my scripts, and while there are advantages to that (easily piping processes together), I'm not a fan of the experience of writing them.
If only there was a standard way to do it in a more proper programming language, nearly as ubiquitous as the (ba)sh...
PHP. For realz.
I've never understood why people give it so much hate. It's always felt unjustified to me.
There are so many good reasons to not love PHP. Most of them come back to this article: PHP: A fractal of bad design.
It's 2019 now, and this article is 7 years old. If we were to explore it in detail we would find that some of the specific examples have been fixed, but at the core, the article still has a lot of good points, and it comes down to this sentiment, which I've made as brief as possible:
It is important to note that for each of these five pillars of languages, PHP has made improvements in the last 7 years since this article was written, but because of these issues people had already begun to move away from PHP as their core language and considered other things. The big bonus of PHP was its ubiquity, and it no longer has that bonus over other languages; it's trivial to acquire whatever hosting you want, and it's just as cost effective to do things with a "good" language as it is to do things with PHP.
Long story short - PHP was a standard because it was available everywhere you wanted to host things, but that edge no longer exists, so now that we consider the other reasons we have to use a language, PHP is just generally not a particularly good choice. It's not necessarily a bad choice, though! It's certainly possible to do great things with it.
You sound like someone that hasn't tried PHP7.
Honestly, that response makes you sound like somebody who didn't read a thing I said, since I explicitly stated in my comment that PHP has made improvements in the last 7 years, and I even stipulated that most of the examples in the article linked have been fixed. How would I make that statement if I hadn't used PHP7? This doesn't make PHP7 good, by the way, it just makes it less shit than earlier PHP.
Other than Javascript (which is hands down the worst language) every other major popular language is at least as good, if not better, than PHP7.
Is there a good "fractal of bad design" article out there for JS? Wat is close, but it is not as detailed.
Not that I know of, unfortunately.
Hmm... maybe I should write one.
Would love to read if you do!
So hard to choose! But right now my favorite is a language I'm building. It is a scheme-like with unhygienic macros, smalltalk-like messaging facility, delimited continuations, built-in graphics via SDL, and (working on this part now) a PEG-like facility to extend the surface syntax, similar to OMeta. I'm certainly having a lot of fun working on it!