DEV Community

Discussion on: The broken promise of static typing

Collapse
 
joelbennett profile image
Joel Bennett

This is interesting. I'm normally of the static typing camp, but I get it. It's one thing to write code that a computer can understand, and it's a whole other thing to write code that another person can understand. More easily understood code = less chance for bugs.

When I first started programming, it was in C++. I then learned Java in college, as well as VB.Net and C#. My first few programming jobs were .Net, and now I'm working in Python. Every once in a while I'll fire up Visual Studio at home, and do a little C#, and the difference between it and Python is quite interesting. I'm definitely not working on the same kind of projects between work (Python) and home (C#), but there's some things that I really wish were easier in .Net. For example, to make an HTTP web request in Python is maybe - maybe - half a dozen lines. The same thing in C# is probably 1.5x to 2x as much code. Same sort of deal for something like reading/writing a file.

That being said, there's some definite proverbial rat's nest code that I've seen in Python. All the manual type checking in the world won't save you from bugs if you aren't being smart about things.

I wonder how much of this is also the experience of the programmers. I don't really know any Go, Scala, Haskell, or Erlang programmers. Perhaps these languages attract a more mature programmer? I wonder if that Stack Overflow data would should a correlation between languages used and years spent programming...

Collapse
 
danlebrero profile image
Dan Lebrero

Hi Joel,

In Rich Hickey's terms, I would say Python is an easy but not simple language.

Also, a lot of people seems to miss it, but Go is a static typed language. So maybe it is not about dynamic vs static, maybe it complex vs simple.

I would recommend to watch Rob Pike and Rich Hickey presentations that I link in the article.

Thanks for reading!

Daniel

Collapse
 
theodesp profile image
Theofanis Despoudis

I like Python. The main problem with Python is though that although it favors simplicity
"Simple is better than complex." most of the time you end up with anti-patterns and complex code.

It assumes that we are all responsible programmers and we are not messing about.

In practice I've seen a lot of times this gets violated in favor of convenience.

Collapse
 
bbttss profile image
bbttss

Hey, regarding calling REST API from C# take a look at DalSoft.RestClient

dynamic client = new RestClient("http://jsonplaceholder.typicode.com");

await client.Users.Get();
Enter fullscreen mode Exit fullscreen mode

or try using HttpClient

var httpClient = new HttpClient();
var content = await httpClient.GetStringAsync(uri);
return await Task.Run(() => JsonObject.Parse(content));
Enter fullscreen mode Exit fullscreen mode

Hope it helps!