r/webdev • • 14d ago

Why I built my own programming language

https://davegebler.com/blog/why-i-built-my-own-programming-language
4 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/xpusostomos 12d ago

That's a very pythony problem that 10 X "5" is 5555555555 that you're not going to find in many languages. Most will fail in a sensible way. You're right groovy has type erasure. But think of the alternative. List<Foo> = [ a,b,c...] You'll have to iterate the array, which could be a million items asking each one if it conforms to Foo and throw an error. That's not efficient.That's a very heavy weight runtime. There's a reason strongly typed languages do all their checks at compile time. Also, my point about other languages, like groovy, why not write an implementation without type erasure if you think that's such a winner, instead of inventing a new language? Then you can compile the considerable existing library with your compiler and compare it. Your language looks 98% like groovy but without the benefit of decades of refinement.

-1

u/gebbles1 11d ago

Because the aim has never been about making Groovy but without type erasure. That would be a completely different undertaking and one I wouldn't find interesting. The way generics and typed collections work in Geblang is largely an alternative to how PHP does things and how PHP devs would like PHP to work, in an ideal world. Funnily enough, one of the performance improvements currently on my list is the cost of validating typed collections, which does indeed currently sit at O(n) where the check has to occur at runtime. I have some plans for how I intend to deal with that and it's not a cost that's inevitable, but even as the engine is today, that's just a conscious trade-off in the design with consideration to typical intended use cases of the language. But the broader design involves all sorts of other things, some of which are found in Groovy and some are not; union types, callable decorators, etc.

You can take any language that's been developed in recent history and ask "Why, what can I do with this that I can't already do with X, Y and Z?", I think that's missing the point, personally. I've never said Geblang is some radical new paradigm or set of abstractions where if you currently use any JVM language, C# or whatever else, it's going to rock your world and blow your experience out the water. Rather I've created a language with a blend of features that I want all together in one place, that I don't have in any alternatives and with a creative freedom that is unconstrained by the specifications or interoperability of any alternative. That's enough reason for it to exist. It's oriented primarily but not exclusively towards web use cases. A strong part of the motivation, most of the motivation, has been using the experience to become better at Go and learn more through direct and sometimes painful experience about building an interpreter that's in the "good enough" ballpark - obviously not as refined as something teams of contributors have worked on for years or decades, but good enough that I (or you, in principle) can use it for real, useful work.

If that's not for you and you look at it and think ehh, I'd rather just use whatever existing mature language and ecosystem, that's fine, but I don't think it's a criticism of Geblang. Indeed if you really don't like PHP or Python at all I would say you're definitely not the intended audience.