Ask HN: What is your favorite programming language and why?

15 points by fath0m ↗ HN

44 comments

[ 2.7 ms ] story [ 100 ms ] thread
I haven't found one yet that doesn't suck in some way.
One could generalize this quite widely :) I think humans can always find a pain point...
Bash. There is no actually used language that can do as much with as few keystrokes, not even perl. Who needs quotes for strings anyways.
I agree it's very quick and easy to just get shit done in Bash. When I go back to my code after a few weeks I can't stand looking at it.
I can’t ever remember how to write loops in bash or the command line flags of xargs so I sometimes indulge in guilty metaprogramming pleasures like

   ls -l | awk … | bash
even though it is notoriously unsafe. I guess a lot of younger folks know xargs but not awk.
Well ... awk is great, but only up to a certain level of complexity. The standard language has only global variables. It's got no real support for functional style. There's no standardized library system. Oh, and it can't reliably distinguish STDERR from STDOUT. So there are a bunch of kludges to get around all the deficiencies, which results in awk programs which look like a retarded dialect of C.

IMHO the best parts of awk are regex literals, natural pipeline participation, and familiar/simple syntax. Sitting down to write a complete program in awk start to finish though ... no thanks.

Ruby because I feel productive using it and it allows you to write pretty elegant code. I also think bundler is the single greatest dependency management tool that's bundled with a language.
Python, readability counts more than anything else.
Go

Simple in a good way, fast, excellent toolchain, great libraries, great Documentation and easy to learn, read and explain. A pragmatic language that I can simply get sh* done with.

Python. Readability, extensive libraries and developer community
Recent versions of Java, say JDK17.

With sealed types, pattern matching, var, records, it is fun to write compilers. Java is on track, as it has been for a long time, to become ‘ML the good parts.’

No favorite but here’s some things I like about a few:

- TypeScript: the type system is incredibly powerful and expressive. You can guarantee wild things at compile time without a single runtime test.

- Clojure: very simple and elegant way to learn/introduce FP.

- Rust: I’m learning it now, and while I definitely understand why it’s considered difficult to learn… it’s certainly much less intimidating (in my experience) than other systems programming languages, in particular because of the borrow checker.

I'm surprised to see Typescript as a favorite language. I use it every day, and I kind of see it as a necessary evil, but not something I particularly enjoy. I guess I'm saying this to ask, am I doing something wrong?

I feel like there's essentially no useful type inference, writing custom types is a nightmare because everything has its own special keyword rather than a simple core set of composable types, error messages feel intentionally vague, and having to write constructors and custom "isType" checks for every type you define is a massive chore.

In Haskell I could write:

  data Tree a = Leaf | Branch (Tree a) a (Tree a)
  tree = Branch (Branch Leaf 1 Leaf) 3 (Branch Leaf 2 Leaf)
whereas in typescript it would be something like:

  type Leaf = { 
    type: 'leaf' 
  }
  type Branch<a> = {
    type: 'branch'
    v: a
    l: Tree<a>
    r: Tree<a>
  }
  type Tree<a> = Leaf | Branch<a>
  const isLeaf = (l: any): l is Leaf => l?.type === 'leaf'
  const isBranch = <a,>(b: any): b is Branch<a> => b?.type === 'branch'
  const isTree = <a,>(t: any): t is Tree<a> => isLeaf(t) || isBranch<a>(t)
  const Leaf = (): Leaf => ({ type: 'leaf' })
  const Branch = <a,>(v: a, l: Tree<a> = Leaf(), r: Tree<a> = Leaf()): Branch<a> => ({ type: 'branch', v, l, r })
  const tree = Branch(2, Branch(1), Branch(3))
How does this not feel like a major pain in the ass? Is there a simpler way to get typescript to do all the boilerplate for you?
Don’t focus so hard on guaranteed type safety, and write more code.

For real engineering I think it’s a wonderful compromise between formality and practicality.

Nim.

My current job is more focused on business processes and advising on cybersec, this means that coding for me is only for fun and side projects.

I love the syntax and the sufficient standard library. I would pick python every time, but Nim's performance and compilation to a single binary file makes everything so much simpler so I can focus on the features instead of having to optimize and manage dependencies.

I have completed Advent of Code in Nim this year and it has been a joy.

How do you deal with the lack of community packages that Python has. I wanna try Nim but that is the only thing stopping me right now.
It is a big lack if you want to start a complex project, I cannot deny it.

But at the scope I code, it presents itself as a way for me to solve the problem by myself.

I like languages for different things:

- C++ : Mostly what I work in, for raw speed and control.

- Ada : Most of the C++ feature set (RAII, custom alloc) with straightforward syntax. It's very underrated (aspects and built-in concurrency are amazing) easy to call C from, and has its own package manager.

- Python : cross-platform automation

Tie between Julia and Haskell, for different reasons.

Julia has an intuitive and expressive syntax, while having good flexibility and the ability to work in multiple paradigms. Also, being a scientific programming language, it lends itself well to much of my work.

Haskell is rigid enough to force good design; this "higher barrier" generally results in better mental models by front-loading the understanding of a problem.

Honorable mention to a non-language, the Makefile. Especially with things like help targets[1], it's a very good accelerator for picking projects back up after they have sat on the shelf a while.

[1] https://marmelab.com/blog/2016/02/29/auto-documented-makefil...

PHP, unironically. I started in WordPress and have since moved to Laravel.

Although, I've started toying with Elixir and I'm considering moving to an Elixir shop when I get back from a big trip next year. If anyone is interested in hiring a senior software dev that actively wants to learn Elixir, hit me up!

I like quite a few languages and don't actively hate any, but my favorite has to be Go. It is just such a pleasure to write, and the excellent test tooling makes it almost feel like a crime to not write tests during development. I've also never felt "stuck" with Go: it makes problem solving and implementing what's in my head flow very smoothly (which I suspect is mostly an individual thing - I bet different languages do that for others).
How do you write your tests? I love go, but when it comes to testing I'm torn between having a more standardized setup with BDD tests (but worse ergonomics), or completely free-form tests with just a simple assertion library (but better ergonomics).
There isn't really any set testing methodology I am married to, other than writing tests for behaviour I want to ensure (both at function and public API level). Go makes that really intuitive. I usually write a test right after implementing the first version of a struct. I make use of both private unit tests in the same package alongside the implementation and public API integration tests in a separate test package. I don't make it a rule to test every single function or anything, but Go seems to make it easy to end up with pretty high coverage and fairly low maintenance overhead.

I make pretty heavy use of mocks and like how easy it is to mock external API calls in Go by either wrapping an external call in a mockable interface or spinning up a local server with `httptest`. I also love how quick it is to write a couple of benchmark tests to get a rough idea of perf tradeoffs between approaches.

I usually try to keep tests small, but I do like testing more end to end and inter-package flows as well. At some point large tests do get brittle and reliability on CI is key so I try to stay away from convoluted test paths, but it's been pleasantly doable to write reliable tests even for larger flows with Go. When I worked on an auth service we had tests going through full oauth failure and success flows and those got pretty big (eg imagine an end to end PKCE auth code grant test that also has to communicate with an additional external provider). For these we had separate tests at the storage level, and mocked storage (or used a test memstore where relevant) at the auth handler level.

I like `testify` for assertions, `gomock` for mocking, `spannertest` for spanner, and `miniredis` for redis testing.

Thanks, that's very insightful. I feel like especially in larger projects, going for a monorepo approach where the integration tests are just another package that runs on the entire repo makes what you're doing very powerful.
I don't really dislike any language i've worked with, but I find myself looking forward to writing some Elixir at work and Common lisp in non-work situations.

Ruby is pretty great too.

I am fairly new to programming (beside dabbling in it when I was a teenager). So far I enjoy C the most. I find it way easier to reason about than a more complex language like say Java (both in regards to language-features as well as the respective libraries). Also it seems to me every time C lacks something I'd rather like to have/use, having to figure out how to do it brings me closer to understanding advanced features in more complex languages. All this obviously assuming I correctly understand the problem I try to solve. Edit: This does not mean that I dislike other languages as a whole. I am getting into Lua for scripting and am obviously using Java at university.
Coming from a Java background, I've found Kotlin to be everything I've ever wanted. Taking cues from Effective Java and functional programming language paradigms, it strikes a balance between succinct and expressive. I wouldn't be upset with doing primarily Kotlin for the rest of my career.
I enjoy learning new programming languages. My favorite that I've played around with is Elixir. But I don't see that ever being used at my current job.

The language I reach for the most is C#. LINQ is great and the base libraries are solid. Plus, the industry I'm in (building controls) is largely Windows based, so that obviously influences that choice.

I really enjoy the concepts and syntax of OCaml, but I've repeatedly lost of the battle of making it work on Windows.

The JVM has become much more popular in the building controls industry in the last decade. So I've been thinking of picking up a JVM language this year. Trying to decide between Clojure and Kotlin.

Clojure it's runtime is fast and lively enough that I can iterate my feedback loop for great developer ergonomics

Then all I need to do is focus on how to pace my thinking and taking regular breaks

My treadmill desk is helping with that and hyperfiddle/rcf is great for TDD practice to ensure I'm moving forwards with small stable increments

Lazarus / Free Pascal - It's easy to understand, fast to compile, handles strings nicely, and matches the way I think pretty well. The component library is modeled on Delphi, which makes very solid use of the object oriented model of programming. It is also multi-platform, you can compile to quite a few targets, including WASM.
Scala

* a mainstream language with an upscale type system

* can look as lightweight as Python if you prefer that style

* .. while still retaining the power of the JVM with little Java-esque ceremony

* as multi-paradigm as C++

* Akka, Spark/Flink/Kafka, plentiful jobs in Data Engineering/Big Data Analytics/ML

Just * don't touch SBT (especially just starting with the language)

* ignore anything that rhymes with scalaz/cats for work purposes

* consider Kotlin if Scala is out of the question in your company/team

I used Scala over Python for lots of Spark work. The only thing I didn’t like is that I really struggled with the functional syntax for working with lists and maps. I felt the learning curve was steep in that specific area. Aside from that, really nice, elegant language.

Is Kotlin still that relevant after the latest releases of Java?

What should be used in place of sbt ?
Rust - Embedded or executables. Outstanding official tooling and docs, package management etc. Elegant language. Not much competition in this field, so doesn't need to be a standout to win.

Python - Experimenting with numbers - eg a fancy calculator, plotter, DSP prototyper etc. Robust set of mathematical, scientific, and statistical libraries. Frictionless syntax. Nice REPL (ipython) Doesn't have the licensing issue of Matlab. Julia has better mathematical syntax, but has too much overhead to compete. (ie it's slow for this use, despite being advertised as a fast language)

HTML, CSS, and Typescript - Web; keep it simple, universal, and fast.

(comment deleted)
Python - been using it for more than 10 years and every time I get the change, I teach it to my students (Python, flask, Django..). I started recently a website to share some articles, micro-courses and ebooks on Python programming [0]. That's how much it is my favorite programming language! :)

[0] https://pylearners.com/

Edit: There's a why in the question! Basically, I like the explicitness of the language core, the fact that is very high level (and easy to teach), and it's easy (and fast to get feeback) while testing things in the REPL..