Showing posts with label haskell. Show all posts
Showing posts with label haskell. Show all posts

2020-05-23

Programming languages you should learn in 2021

This kind of title appears once in a while in feeds and in search results about languages (I do search for languages trends).

I want to make my own list. I am not going to suggest a language because they can give you a job, high salary, or because it’s what all the buzz is about. These factors mean nothing.

I am not going to explain why you should learn something about all those languages: you will get it once you study them!

2019-04-14

Nested functions

Some languages allow nested functions (or procedures, or subroutines, or whatever you prefer to call them), others don't.

I think those can be useful and I wonder why they aren't embraced by all living programming languages.

2019-01-13

“Dynamic overloading” in other languages (not C++)

In a previous post I've imagined that future C++ could dynamically dispatch a call to a proper function/method according to the derived types of its arguments — that is, dynamic overloading, whereas notoriously in C++ overloading is a compile time feature.

Now the question is: what about other languages?

2018-04-10

To be fair with Haskell

Fairy Tales

In Java 8, functional style and efficiency I have shown how bad Haskell performs at the silly task I was using as test.

But there's a detail which makes the test unfair: the problem with the given code is that the factorial function I've written isn't tail recursive.

2017-09-11

Overloading so much

I suppose that my average readers know what overloading is, but let me give a quick definition: overloading is a feature which allows to reuse (overload) a function name provided that each signature makes each function distinguishable. According to the signature the compiler can pick the right actual code to execute.

2015-05-02

Two puzzles from an italian magazine

There's an italian weekly magazine (La settimana enigmistica) that once in a while publishes “A puzzle with Susi”. Susi is a cute and smart girl who accepts to solve challenges her friend Gianni is used to throw to her.

In one of my italian blog I've tackled two (so far) of these puzzles using Prolog and Haskell.

2012-03-25

C++11

To me the most interesting feature of C++11 I am aware of are lambda functions. Though, I think also the general direction taken by C++ is leading it to a very obscure path, where other languages shine since the beginning, and where the need to use C++ rather than those other languages is not clear to say the least. Differently speaking, the most interesting features could be the one programmer could use less, simply because when you need to use them in all their beauty, you are on the edge of considering sticking to another language to do the same thing.
Moreover, C++ syntax is someway cumbersome and not clean. In some cases (not so much to be worth noting, yet they jumped in my sight) it is misleading; I believe the usage of the same keyword to mean two different things is not good (C too has this flaw, e.g. the keyword static), and if the previous standard had a third meaning for it, the situation could be confusing (I am thinking about auto). Yes, it's not a hokum but it gives the impression of something too layered and hard to handle. Modern languages without a heavy heritage have less or nothing at all of this kind of flaws.

Anyway, let's see an example of folding done with the use of a lambda function.



Not particularly useful, but it shows the equivalent in C++11 of what in other languages we can write. E.g.

Smalltalk



Common Lisp




Haskell



Erlang



Perl5



Python



All these snippets run effortlessly and without the need of adding other lines of code; C++ needs "boilerplate" code, though the working line is as simple as



(note the use of -> here, which is not syntactic sugar for (*ptr_to_obj). as it is in other contexts).

It could be funny to use some of the new C++11 features; sometimes it could be even useful; but most of the time I believe it won't be a need and C++ is becoming one of the languages with a very large set of (maybe interesting) features which are even the most misunderstood, misused, or simply ignored.