Live data from Hacker News

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

news.ycombinator.com

71–80 of 401 posts

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

#71

Testing. Unit testing to me seemed akin to drinking 8 glasses of water every day. A lot of people talk about how important it is for your health, but it really tends to get in the way, and it doesn't seem to really be necessary. Too frequently, code would change and mocks would need to change with it, removing a good chunk of the benefit of having the code under test. Then I started writing integration testing while…

My first job I wrote c++ for a win32 desktop app. I hated unit testing. My workflow was write the code, compile it, trigger the scenario, step through the code, write some unit tests after I knew it worked. It was the expectation on my team to write UTs so I did it. Fast forward to a different team I learned from a co-worker how UTs can help you influence your design. If you find yourself doing a ton of frustrating work to set up your UT scenarios there's probably a way of fixing the design to be less coupled that would allow you to test the code better. Now I think of UTs more as a way to help me understand how the design of my code is working and I get some extra validation out of it as well.

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

#72

Testing. Unit testing to me seemed akin to drinking 8 glasses of water every day. A lot of people talk about how important it is for your health, but it really tends to get in the way, and it doesn't seem to really be necessary. Too frequently, code would change and mocks would need to change with it, removing a good chunk of the benefit of having the code under test. Then I started writing integration testing while…

I almost only use mocks for external calls (usually external APIs). Very rarely, I use them for some internal code that is unusually time consuming or difficult to set up.

A few months ago, I did a contracting job and the team I worked with used the "mock everything" approach, without even one integration test, which to me seemed crazy (especially for a component which was calle "integration layer").

I tried hard to find the advantages in this approach, studying what the rationale and the best practices were, and questioned my previous assumptions. In the end, I had to confirm those assumptions: even if there were hundreds of tests and they all passed, many logical errors weren't caught.

Even worse, they gave a false sense of confidence to the team, and made refactoring super-slow. But the team leader was super-convinced it was the best idea since sliced bread.

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

#73

Testing. Unit testing to me seemed akin to drinking 8 glasses of water every day. A lot of people talk about how important it is for your health, but it really tends to get in the way, and it doesn't seem to really be necessary. Too frequently, code would change and mocks would need to change with it, removing a good chunk of the benefit of having the code under test. Then I started writing integration testing while…

I will probably be the lone voice here defending mock testing but probably not for the reasons you'd expect. Does mock testing end up being brittle? Yes. Do you have to refactor the tests immediately after making small changes? Yes. Is there a cost to this? Yes.

Mock based testing however is the only thing I've ever encountered that forces me to think very, very clearly about what my code is doing. It makes me inspect the code and think about what dependencies are being called, how they're being called, and why they're being called.

I have found that this process is extremely valuable for creating code that is more elegant and more correct. I value mock tests not for the tests that I end up with at the end, but for the better production code that I wrote because of them.

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

#74

Testing. Unit testing to me seemed akin to drinking 8 glasses of water every day. A lot of people talk about how important it is for your health, but it really tends to get in the way, and it doesn't seem to really be necessary. Too frequently, code would change and mocks would need to change with it, removing a good chunk of the benefit of having the code under test. Then I started writing integration testing while…

> Unit test suites would break all the time for silly reasons, like someone optimizing a function would mean a spy wouldn't get called with the same intermediary data, and you'd have to stop and go fix the test code that was now broken, even though the actual code worked as intended. Can you or others speak more about this? I was taught that verifying function calls for spies/mocks was good practice. But, I encounter…

What you want to spy on are side-effects that are part of the function's contract.

If you have a function that fetches data, you shouldn't test that its hitting the data layer, only that the correct data is returned. This way when you improve the function to not hit the data layer at all under some conditions, your tests will keep passing.

On the other hand, if that function is supposed to log metrics or details about its execution, you should test that ,as it is part of its contract and can't be inferred from the return value.

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

#75
The Smalltalk feedback/living-in-the-debugger coding style. I was happily coding in Python, C#, Java etc when I ran into Squeak, and then Pharo and Dolphin Smalltalks.

This style presents the smallest barrier between idea and working code for me.

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

#76
post #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 feat…

This sounds similar to my journey with Python. For years, I used it as a go to for programs that were bigger than a bash script but smaller than an application or service. I mostly wrote single .py files with maybe the odd module and avoided setuptools and friends. In the last year, I’ve been working on a larger library in Python, which has meant getting into the packaging and deployment tool chain and structuring a project with dozens of files, tests, etc. My background has been in mainline languages such as Java and C#, with excursions into Clojure, F#, etc. We adopted the new Python type annotations and they seem to increase the visual clutter of the language without delivering many benefits in terms of confidence or ease of development/code completion. Our library is aimed at data science, so I’m sure not many users will actually bother setting up the tools to do type checking.

I do still appreciate Python, but I wonder whether my issues are due to our approach, my current level of familiarity with Python and the ecosystem or the fact that we’re working in the data science world which is new to me as well.

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

#77

I used to dislike Java, then recently I discovered java streams, and some of the nice features with newer versions like more immutable types. After that I found Java a whole lot more enjoyable to use.

Now check this out: http://www.vavr.io

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

#78
post #28

Earlier quoted context omitted.

> 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 Stack…

I'm using jquery for certain layout libraries that I need unless you have another library that provides it. Also I'm using datatables. I don't think there's an alternative to datatables that even comes close to being as well put together. There's just a huge number of libraries around that depend on jquery, and are rock solid with continuing support. I would prefer to use something proven than something that will be…

> I don't think there's an alternative to datatables that even comes close to being as well put together.

One of my projects uses ag-Grid[1]. It works very well and doesn't depend on jQuery. There are lots of others to choose from, including FancyGrid[2] and a vanilla-JS version of datatables[3].

ag-Grid has paying enterprise clients that contractually obligate the developers to continue support. As a guarantee of future support, that's as good as it gets in the open-source world.

> rock solid with continuing support

It looks like jQuery itself is not very actively developed anymore[4].

> I don't want to come across as unappreciative, but there's still reasons to use jquery.

It's completely fine to disagree. That's what makes HN interesting. I didn't take it personally.

1. https://www.ag-grid.com/

2. https://fancygrid.com/

3. https://github.com/Mobius1/Vanilla-DataTables

4. https://github.com/jquery/jquery/issues/3886

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

#79
post #6

Using it. I try to learn a new platform every once in a while. The best way to learn is to do. So I pick a project from my list and try it out. That's how I learned I didn't like Meteor and Angular when they came out and were hyper hyped but I enjoy Go very much but only for certain things. Or how I learned I disliked PHP or loved working with Python, or that MongoDB is ok for some things and less so for others (or t…

Totally agreed. I started respecting dynamic languages after I got a job writing Python. I'd underestimated a lot of the upsides and overestimated a lot of the downsides.

Ditto JS (and web apps in general), testing, functional(ish) design, package management and code autoformatters. Containers to a lesser extent. A bit of getting used to it, and then a very clear sense that actually this does make my life easier, that the benefits aren't just propaganda.

For a counterexample, I "used" and rolled my eyes at daily stand-ups, close in-team communication and project management process, and now that I'm working on a team that doesn't do any of that I miss it a lot.

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

#80
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…

90% of my dislike for C comes from a) that it is too tedious to work with strings and b) the non-existing standardized module/build system. The C language itself is _beautiful_ but I am missing a beautiful standard library! Things which are trivial one-liners in other languages are sometimes 10-20 lines of brittle boilerplate code in C. If the standard library would have a bit more batteries included it would make tr…

What’s hard about adding a library? You include the header, tell the linker about it, and update the library/include patches if it’s not already on it. Job done.
Post reply on HN