Better HN
topnewbestaskshowjobs
Log inSign up

deterministic

2,860 karma · joined Feb 27, 2013 (13y ago) · 3,465 submissions

Submissions

comment 4y ago · link · parent

Yep. The compiler generates code that works the same way that an experienced C programmer would hand optimise alloc/free calls and manually keep track of shared data by increasing/reducing a reference counter. There is no separate mark/sweep or whatever step.

comment 4y ago · link · parent

The compiler uses arrays for lists instead of linked lists. It is a performance improvement compared with how functional compilers usually do it. And the language is designed in such a way that rule writers manipulate whole lists at a time instead of one element at a time. A bit like array languages. It changes how the code is written compared with traditional functional code.

comment 4y ago · link · parent

Agree. I can’t even come up with an example that couldn’t be done better without them.

comment 4y ago · link · parent

Just to clarify: it is not a framework. It is a whole program optimisation pass done by the compiler before lowering the intermediate code to LLVM and then generating machine code.

comment 4y ago · link · parent

Yep the code is not open source so I can’t provide that. However I am happy to explain exactly how it works down to the lowest level details. Perhaps somebody gets inspired to implement it themselves as open source? That would be neat.

comment 4y ago · link · parent

No each thread does it’s own alloc/free. I reduce the locking to a minimum by using per-thread caching and memorisation. I had to implement that to make the code scale linearly with number of cores. Without per-thread caching it would only scale to about 3 cores. Now it scales very cleanly. Which is nice.

comment 4y ago · link · parent

The language has zero data cycles by design. It turns out that we didn’t need it. Thinking about it, I can’t remember even a single situation in my 30+ years career where I needed a data structure with data cycles. There are usually better ways to do it in my experience.

comment 4y ago · link · parent

Yep you are quite right. The optimiser basically does what an experienced C++ optimisation experts would (tediously) do by hand: it carefully reduces the number of reference counter modifications to an absolute minimum by symbolically evaluating the full executing flow of the code. It is something that is doable in a pure functional language like this one. I am not sure if it is possible to do the same in C++ (because of the aliasing rules).

comment 4y ago · link · parent

The C++ code I am referring to was hand optimised and maintained for 10+ years before the compiler I am maintaining was fast enough to take over. I never looked at the C++ code myself. I simply use it as the milestone to beat. When I took over the maintenance of the compiler it was 25x slower than the C++ code. It took a lot of work to finally make it faster. I also used the C++ code to compare the output of the compiler and the C++ code. I found quite a few bugs in the C++ code doing that by the way.

comment 4y ago · link · parent

The compiler uses arrays not linked lists. One of the big mistakes that other functional compilers make (IMHO) is that they use linked lists. It is a huge performance problem. There is a reason why high-performance software written in C++ and C always use arrays and not linked lists. Memory access patterns is the #1 thing to optimise for on modern CPUs.

comment 4y ago · link · parent

You are 100% right. At some point I measured smart_ptr to be 25x slower than raw pointers. The compiler I am maintaining is not using C++ style smart pointers. It is using a global whole program optimisation pass to reduce reference manipulation to a minimum. Basically what a world class C++ programmer with years of experience optimising performance would do. It is just done automatically.

comment 4y ago · link · parent

The code is not open source unfortunately so I can’t provide evidence. But I have nothing to sell or promote (unlike the V language guys who has a clear motivation to inflate what they are selling). What the compiler does differently is that it does a whole program optimisation pass where it minimises the code manipulating the reference counters to an absolute minimum. This is something you can’t do in a C++ compiler. Which is one of the reason why the resulting machine code is faster. Also, I am using LLVM as the backend. So I am getting the same low-level optimisations that C++ compilers get. However the most important optimisations are done before lowering the code to LLVM. Function specialisation for example is huge (generating multiple versions of the same function with the arguments unlined and optimised away). I am doing quite a few high level optimisations like that before even lowering it to LLVM.

comment 4y ago · link · parent

It is a Haskell inspired language but not Haskell. The syntax is similar but it is eagerly evaluated and has no IO and no data cycles. It is used 100% for evaluating complex optimisation and business rules within a client application. The language was carefully crafted to maximise rules writer productivity and execution performance.

comment 4y ago · link · parent

Nope. The compiler does a full program optimisation, reducing the reference counting to an absolute minimum. There is close to zero overhead passing data around. It does not work like C++ shared_pre. shared_ptr is slow.

comment 4y ago · link · parent

And your reply game me a chuckle :) The code is unfortunately not open source so I can’t provide the evidence. You believe what you want to believe of course. However I am happy to answer any questions on how it is implemented down to the lowest-level nitty gritty details.

comment 4y ago · link · parent

All that tells me is that the Swift implementation is different from the one I implemented.

comment 4y ago · link · parent

Not my experience at all. I am maintaining a very high performance JIT compiler for a Haskell like programming language used in production at large enterprises around the world. So I am used to very carefully analyse performance. And reference counting is never the bottleneck. You might be right in theory but not in practice.

comment 4y ago · link · parent

I am the maintainer of a very high-performance JIT compiler for a Haskell like rules programming language used by large enterprises around the world. It uses reference counting + a global optimisation step to reduce the reference count updates to an absolute minimum. The result is compiled code that runs faster than C++ code carefully hand optimised by C++ experts over a 10 year period. There are zero GC pauses. Unless you claim that a C++ alloc/feee call is “garbage collection”. Which is not common terminology. It also (BTW) scales linearly the more cores you throw at it.

comment 4y ago · link · parent

You have a problem. So you choose Microservices. Now you have N distributed problems and a system that is K times slower. Well done.

comment 4y ago · link · parent

On the contrary. Using libraries with clearly defined interfaces makes it easier to combine those libraries into a single executable, reducing deployment and debugging complexity. It also dramatically improves performance given the lack of intermediate encoding/decoding protocol code and TCP/UDP hops. Experienced seasoned Architects knows this and work hard to remove unnecessary distributed complexity from systems they design. While “beginner experts” always pick the most complex “solution” for the job at hand. The worst spaghetti code I have ever seen in my 30+ year career is a 20+ years old Microservices architecture. So I can’t wait to read the future “We had a problem so we chose micro-services. Now we have N distributed problems + K impossible to debug obscure timing issues” articles.

comment 4y ago · link · parent

If you don’t have the skills to implement a well structured and easy to maintain monolith then you most definitely don’t have the skills to implement a distributed more complex implementation of the same system.

comment 4y ago · link · parent

A friend of mine is working on a 20 years old Microservices application. It is literally the worst piece of garbage system I have ever heard about. I am sure my friend would have loved for it to be a monolith instead of 50+ services with massively complicated distributed dependencies and timing issues.

comment 4y ago · link · parent

As detailed as needed for the client to understand exactly what they will get delivered. However 100% focused on solving the biz problem not UI details or whatever.

comment 4y ago · link · parent

I am doing similar things in C++, Java, C# and Typescript. You don’t need LISP style macros to do it. All you need is a way to declare your intent (what the end result should be) and then code that transforms the intent into running code. You can do it offline (generating code) and/or online (running an “interpreter” that “runs” your intent live).

comment 4y ago · link · parent

1. I have deep long discussions with the customer to understand the business problem they want solved. Usually over a nice coffee in a relaxed environment.

2. I document it in a Spec and make sure the customer reviews and understands exactly what they will get. Again, while enjoying good coffee!

3. The customer pays up front for this initial Spec work. If they don’t want to pay up front I walk away. I don’t work with customers who doesn’t understand that work costs money.

4. If they are happy with the spec I then negotiate a contract and payment terms. This always includes an upfront payment. Usually 10%. If they don’t want to pay a percentage upfront I walk away. Cheap customers are not worth the pain. The rest is paid based on milestone deliverables. I always make sure that milestones are backend heavy so that I have a time buffer if needed.

5. I quickly implement what I call the “skeleton” of the application. All use cases are implemented with a minimum ugly/super simple UI and an in-memory hash map “database” for storage. Test cases cover all use cases end-to-end. I use an in-house code generator to make this step fast (80% of the code is usually generated).

6. I then iterate, refine, and improve the whole application step by step until it is done. With regular demos to the customer getting feedback on progress.

It works well. It isn’t perfect (what is?) but it has been successful for me.

comment 4y ago · link · parent

If you fire your “top talent” and things get better then your “top talent” clearly wasn’t actually your “top talent”.

comment 4y ago · link · parent

That makes me think that formally proving the code correct using a proof assistant would actually be faster than the process you describe.

1378.

Using Lightweight Formal Methods (2021)(dl.acm.org ↗)

2 points · by mbrodersen · 4y ago · discuss

comment 4y ago · link · parent

A great developer can make the difference between your company getting that $ million contract or not. So the value of a great developer can be extremely high compared with the average developer. Also, great developers will often inspire the rest to do better, and remove any “we can’t do that” thinking from the organisation. Managers who doesn’t understand this simple fact should be fired for incompetency.

comment 4y ago · link · parent

30+ years of software development experience here and I agree 100%.
1
454647
116