HN user

grdvnl

141 karma

Software Engineer, PhD Candidate[Research area: static and dynamic analysis of programs to improve testing tools and mutant generating mechanisms]

Currently I spend my spare time understanding and programming in Clojure and its implementation on the JVM.

Blog: http://devanla.com Linkedin: http://lnkd.in/zPja7t Twitter: https://twitter.com/grdvnl

Posts7
Comments61
View on HN

There is an interesting line in the end

All in all, I guess this is the result of a company that has more money than they possibly know what to do with. I wonder how long this utopian "do no evil" culture can last. Wealth creates power, and power corrupts. And boy, have I seen a lot of power this last week.

"May you live in interesting times."

Now, juxtapose that with the authors other recent post: https://social.clawhammer.net/blog/posts/2024-01-10-GoogleEx...

Interesting times in deed!

I am curious. Why do you think it helps it doing things on the stack. For me, I understand this to provide more generic type level checks on the size/shape of values. Perhaps, I am oversimplifying this?

Why Use F#? 8 years ago

Can you eloborate on what kind of projects you work on which has made the move easy from Python to OCaml. While I love OCaml I have not heard positive things about the library eco-system in terms of variety and maintenance. Perhaps, you could throw some light on that based on your experience, especially after giving up the eco-system Python provides you.

This is a sincere question and would love to find good excuses to adopt OCaml as my primary language of choice.

Have you considered using ipython as your REPL? I use ipython and in my profile, I have the following setting. This enables auto-reload and it works almost all the time.

Here is the option I have in my profile file. You can run this command inside the ipython session as well:

%autoreload 2

The times I have seen auto-reload fail is when there is lot of class creation magic going on or while dealing with global connection objects which sql alchemy might be creating. But, other than that it works very nicely.

I already see some good responses to your question.

As for me, before this course, learning a language was a mechanical process. I learn the syntax, learn some idioms and go with it. But, after this course, as the other commenter put it, I started learning every language as a set of features. That opens up a whole new world. For instance, when learning a new language, you seek out the features your are interested in and then figure out how that language lets you use it. For example, does a language support abstract data types, what paradigms of programming does it support, is it imperative or functional, lazy or strict, is the language supposed to be used as a bunch of statements or expressions, can common idioms be implemented as simple language functions or do I need the language to support it internally etc, does it support lambdas, does it do lexical or dynamic binding etc. The course also takes you through ML, Racket and Ruby and gradually exposes you through this concepts and in parallel explains what the trade-offs are as you give up once paradigm for another.

So, after the course, next time if you open up a beginners guide to any language, you will be seeking our answers to high level questions. The syntax to use will be learned automatically as you use those 'concepts'

Dan Grossman is a an excellent teacher. His passion for programming languages can be seen in his teachings. The homeworks are very relevant and helps you solidify the concepts. I am thankful to him for offering this course.

Hope this makes sense.

It doesn't have to be. The stricter version is called 'applicative-order' Y-combinator. The article talks about both versions as well.

That is a nice description of how to arrive at the Y-combinator.

There was a talk using similar examples which I think is very educational.

https://www.infoq.com/presentations/Y-Combinator

I wrote down the examples used in the video (given the poor quality of video) to help myself learn about the Y-Combinator

https://gist.github.com/gdevanla/9171085

Recently, I presented this topic to my team and wrote down a Python equivalent of this example.

https://gist.github.com/gdevanla/07a08d99e183f494d036c6d6fe6...

The benefit of State and IO monads is not that you can use them everywhere so you now have an imperative language. The benefit is you can explicitly delimit their use, and you still get the "easier to reason about" for the rest of the code.

It is also important to note that apart from providing the ability to write imperative code, monads encapsulate computation. In my understanding, this is where their use shines. Getting to wrap values in such contexts in certain imperative languages could be tedious. Using a monad, one passes around the value within the context of the monad. There is a computation(aka context) that is associated with the value in the monad and that computation is performed before a value is yielded.

The example you quoted is probably the very basic of operators and idioms being used. These operators have standard meaning in terms of fmap and applicatives.

But, I agree with you that there are obscure operators scattered around the code base and I have to keep jumping away from that point to lookup what the particular operator means in that context.

I work on Python and the Pandas data frame is one of the core data structure that is used in the implementation. I have been thinking of how I can translate this code in a more robust type checking language such as Haskell, without loosing some of the conveniences Pandas provides. Do you have any suggestions or pointers to this?

I would love to encode the business logic into types. But, I am always afraid I might end up in type hell!

Actually, I think a search engine's capability directly adds value to SO. Even, before SO, there were different forums and searching (Google and before that alta vista) could help you find at least a few answers, though not as comprehensive as SO in some respects.

Python metaclasses 11 years ago

I do not think it would work with sub-classing. With the approach we have it is just easier to add the 'new' method name to test into the list argument of the meta class. The meta class would generate a `test` method with the passed in function name.

With the subclass approach you are required to implement a new class and essentially write repetitive code, or reuse existing functions. Reusing existing test methods does not provide good error reporting as I had stated earlier. It is late in the day. Shortly, I will try to post a gist example of what I am talking about, if you are still interested.

Python metaclasses 11 years ago

We use meta-classes extensively. One of the simpler examples I have used are as follows:

We have a class that has different methods that performs numerical analysis/computations of financial models. These methods need to be tested with different subsets of data. The number of combinations of tests and test-data are huge, whereas the 'testing code' is simple and repetitive. Having these tests in a loop is not useful due to way test errors get reported.

Therefore, we generate a test class using the meta classes, that creates 'test_*' methods that are eventually executed. With such methods in place, we have around 100 tests generated within less than 100 lines of code, without loosing the detailed error reporting in case of failing tests.

All the comments in the thread are focussing on comparing Microsoft's contribution to Facebook or Google for one project and giving credit to Microsoft. But, it is important to remember that Google and Facebook contribute to OSS in different forms. For example, Google spends regularly on Google Summer of Code. There may be other example for Facebook as well.

I am not a fan/employee of any of these companies. I am just putting the contribution into a different perspective.

Better still, if you want to execute a command and if you approximately know what it could be called as, you get list of potential commands in an alternative buffer, by Alt-x, and then start typing part of the command. This I feel is great to explore commands as you need them, before binding new keys to those commands.

Without getting into emacs vs vim war, the author would be impressed in a bigger way once the emacs documentation is explored!