Live data from Hacker News

Ask HN: What made you change your mind about a programming language/paradigm?

news.ycombinator.com

21–30 of 401 posts

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#22
post #10

I used to hate C and thought it was primitive, ugly, dangerous, tedious to write in and annoying to read. While writing a big project in it ( https://github.com/RedisLabsModules/RediSearch/ ) , I've discovered the zen of C I guess. Instead of primitive I started seeing it as minimalist; I've found beauty in it; and of course the great power that comes with the great responsibility of managing your own memory. And wor…

Same, except I realized this after starting my first (and current) job as a C developer.

I now get way more annoyed by the in-house build system than the huge C codebase.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#23
post #16

Every once in a while I search for something I need in Python and find that it only exists in Python 3, but I'm not quite convinced it's worth the effort to transition from 2. However... I've just learned about Python 3's f-strings and they gave me a big smile, and probably the final push I needed :) (Yes, I do know that sounds silly and there are probably much better reasons to transition to Python 3 ¯\_(ツ)_/¯ )

f-strings really are great. As someone who has to do a lot of string manipulation, they're both easier to maintain and easier to read than any other Python alternative.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#24
I the early Nineties, I had a good idea of what an ideal programming language would be. Then I encountered Perl, which was diametrically opposite to everything I thought I wanted. Perl enabled me to do in a morning what would have taken a week in C. I was blown away. I was converted. I became a Perl evangelist. I used Perl everywhere I could.

20-odd years later, writing Perl for fun and C++ for money, I had a Perl program which, over ten years, had gradually grown to about 5,000 lines and 25 classes. It needed more testing than anything else I maintained. I missed the help I would have got from a C++ compiler -- what some Perl people disparagingly call BDSM. In C++, if I need to add a Widget argument to a leaf method, the compiler will find all the call sites that need updating. If they in turn need updating to accept a Widget, the compiler will find their call sites, and so on. By the time the program compiles again, it's much of the way towards working. But Perl doesn't do that for me. I can't even specify the number of arguments a method should take, let alone their types.

I eventually rewrote the whole thing in D. It came out at almost exactly the same length, which was a surprise, but I got native speed, much-reduced memory consumption, and proper type-safety. My hunch is that a translation to modern C++ would have been longer and taken more work than doing it in D, but not that much more, and the performance would have been better still.

This is not so much a story about Perl, C, C++ and D as about weakly- and strongly-typed languages. (Perl 6, in particular, remedies some of the deficiencies in Perl 5's type system, and some of the bolt-on object systems for Perl 5 take steps in that direction as well. These are heroic and ingenious efforts to give users the best of all possible worlds, to the extent that that's possible, and I wish them well.) Languages that are too weakly typed, too dynamic, too flexible, are fine for short programs that are maintained over a short period of time, but they just don't scale -- maintenance becomes too difficult, too time-consuming and too error-prone. At some point, it's best to rewrite in a well-chosen language that imposes more structure and provides more type-safety, and work with that structure (not against it) to make your program rigid enough to stand up under its own weight.

As a result of that experience, I no longer use Perl, or any other very dynamic language, for anything but the smallest throwaway programs. For everything else, I anticipate the need to grow by using C++ or D, and the next language I learn is more likely to be Rust than, say, Python.

A more general point: if you only know one composer, one band or one style of music and you think the rest aren't worth knowing, you don't know music. Even though I don't use dynamic languages much nowadays, I'm a stronger engineer for having done so. Do take the time to learn several different languages that differ widely from each other and from what you already know -- preferably including some assembler -- and don't assume that the language of the month is best suited to your unique temperament or to the job in front of you. Having an abundance of tools and choosing between them wisely is better than having one and using it for everything. It doesn't matter how dexterously you can use a soldering iron when what you need is a chainsaw.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#25
I avoided having to learn Javascript in-depth because I thought its type system was like coding in the dark.

Your IDE would either return all possible methods of all possible objects in your whole project, or wouldn't return anything at all.

You need to either memorize the API of whatever object you're currently working with, or have its API open in a separate window to always see what's what.

Wait, no, I still think this is true. I discovered Typescript a while ago and it is a joy to work with. I don't understand why developers would subject themselves to the modern equivalent of coding in notepad.exe when they could use a language that actively helps them.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#27
post #10

I used to hate C and thought it was primitive, ugly, dangerous, tedious to write in and annoying to read. While writing a big project in it ( https://github.com/RedisLabsModules/RediSearch/ ) , I've discovered the zen of C I guess. Instead of primitive I started seeing it as minimalist; I've found beauty in it; and of course the great power that comes with the great responsibility of managing your own memory. And wor…

[deleted]

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#28
post #11

Using TypeScript for about 2 hours made me wonder why anyone would write JavaScript ever again. This was several years ago, when TypeScript wasn't nearly as good as it is now.

What's the correct way to use typescript when you're directly working with the Dom, and using minimal jQuery? It seems to really not like it if you're explicitly asking for things you know you have in your document, but it reports an error.

> What's the correct way to use typescript...

You write TypeScript the same way you write JavaScript. It just enforces a lot of the proper discipline and practices that JavaScript doesn't, and it doesn't let you incorrectly use APIs.

> you're explicitly asking for things you know you have in your document, but it reports an error

I'm not 100% sure what you're talking about, but I bet you'd get a great answer on StackOverflow by posting example code and the error message.

First of all, TypeScript doesn't know what's in your document unless you built the document with TypeScript objects. If it's HTML, TypeScript can't read or understand it.

My guess is that you're using something like "getElementBy..." and then TypeScript complains that you're using a value that might be null. You just need to check if the value is null and (for example) throw an error. Once you do that, any line after the null check will assume there's a value.

There are other workarounds when you're 100% sure you don't need TypeScript's error checks (like // @ts-ignore flags), but I strongly recommend against using them.

> using minimal jQuery

Why are you using jQuery at all? It's a solution for a problem that doesn't exist anymore. Just use vanilla JS.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#29
I realized just how useful shell scripting is (bash) when it occurred to me a simple five line script I wrote to erase and reclone my main work repo is the single most useful piece of code I’ve written in my first year as a web developer. God that’s a time saver.

Re: Ask HN: What made you change your mind about a programming language/paradigm?

#30
As someone who appreciated C and C-style languages I hated on python for a long time.

I disliked python because of syntactical annoyances,mistakes I would notmally iron out at compile time now happen at run time and version fragmentation with no backward compatibility at times. On that last point,new java versions for example would deprecate features over time allowing the programmer the option of enabling these features. I still think the simple things like mixing tabs and spaces shouldn't have caused a hard failure,warnings or ability to override the deprecation would have been nice. Not only that,I hated how I would ship a python program having tested it in one python version and five years from now the default python version on linux distros (or default installer for windows) would install an incompatible version,I hated how users of my program would have to figure out the correct version.

But I no longer hate python mostly as a result of having seen how easily it has helped me solve different types problems that are otherwise difficult or time consuming to solve. At the end of the day,it gets the job done well,is easy to learn,harder to screw up in and has saved me a ton of time.

Post reply on HN