| ▲ | Show HN: I implemented generics in my programming language(axe-docs.pages.dev) | |
| 22 points by death_eternal 4 days ago | 6 comments | ||
It took a while to implement, though now I have generic functions working in Axe. Documentation, repository and site attached. | ||
| ▲ | Imustaskforhelp 2 minutes ago | parent | next [-] | |
I saw your programming language on reddit and now here too. To me first looking at it, I think its built straight for parallelism, Didn't know you were on hackernews too, interesting stuff and I will try to keep an eye out hopefully for this language but what are some stuff where you think it can be really useful for? | ||
| ▲ | Philip-J-Fry 6 minutes ago | parent | prev | next [-] | |
If your function changes it's behaviour based on the type, then it's not generic. Your list_contains function should be able to just do a == comparison regardless of whether it's an int or a string. This is effectively no different than adding a parameter to one of your non-"generic" functions and just swapping behaviour based on that? | ||
| ▲ | p0w3n3d an hour ago | parent | prev | next [-] | |
This are merely instanceof switches. Generics mean that you write
and if the a + b is doable, it will be done. You don't need to specify the list of types that accepts this syntax. The difference between this and duck typing is that you can also specify interfaces (or traits in c++) that will say that this type is quackable so
is reusable. What is the difference between this and simple interface implementation? It took me some time to find this example in the narrowest version possible.
The generic renders this code reusable, so if only you can create a new type, let's say vector, that supports +,-, and multiply you can have complex algebra on those vectors | ||
| ▲ | one-punch an hour ago | parent | prev | next [-] | |
You have implemented a form of ‘ad-hoc polymorphism’. This is different from ‘parametric polymorphism’, which is what people call generics. | ||
| ▲ | mrkeen an hour ago | parent | prev | next [-] | |
You implemented Specifics. One of my pet-hates is fellow developers who call an implementation 'generic', but when you peek inside, there's just if-statements that (at best) cover the already-known input types. Usually I point to Generics as an example of what "generic" actually means: You peek inside List<T>, it doesn't know about your type, it does the right thing anyway. | ||
| ▲ | miellaby 43 minutes ago | parent | prev [-] | |
You should consider change the name, it looks like a lot like https://haxe.org/ | ||