Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

At least a good readme, which is always a good sign.


While there are a few DSL that won the war, like CSS or SQL, it is very unlikely that your DSL will prove worth it. 99% of the time, what you need is a good high level library/API to deal with the problem with your current technology.

Here is why:

First, you need to design it properly, and most devs are not good language designers. The chances your DSL is going to be good is very low.

Second, unless you are incredibly talented and have little constraints, you will not even remotely provide 1% of the tooling existing languages already have for free. I've seen so many DSL without basic syntax highlighting nor linter it's not even funny, but you need much more to be productive with a new language. Even if you are using macros and claim to be able to use the tooling for the main language you come from, stop a second and think about the last time you had fun debugging a complicated macro magic.

Third you need to test it and document it. Do you even do it properly for your regular code? It takes time and resources. A lot of it. Which could be better spend on the project, or on the library/API you should be writing about.

Fourth, what about training? Because you can hire somebody for language X. But for your DSL, you'll need to train them.

Then of course, you plan to support it for as long as it's used. Right? Right?


Good time to urge people to comment on the article, not on a term you saw in the headline.

> 99% of the time, what you need is a good high level library/API to deal with the problem with your current technology.

TFA exactly describes a solution based on current technology available in Lua.

> First, you need to design it properly, and most devs are not good language designers.

A lot of languages are small and obvious, like the one described in TFA.

> Second, unless you are incredibly talented and have little constraints, you will not even remotely provide 1% of the tooling existing languages already have for free. I've seen so many DSL without basic syntax highlighting nor linter it's not even funny, but you need much more to be productive with a new language. Even if you are using macros and claim to be able to use the tooling for the main language you come from, stop a second and think about the last time you had fun debugging a complicated macro magic.

TFA addresses this not by macros or an entirely custom language, but by using Lua grammar for it entirely.

> Third you need to test it and document it. Do you even do it properly for your regular code? It takes time and resources. A lot of it. Which could be better spend on the project, or on the library/API you should be writing about.

"You need to test your code" is not a problem unique to DSLs

> Fourth, what about training? Because you can hire somebody for language X. But for your DSL, you'll need to train them.

I've skimmed the article for a total of maybe 45 seconds and I know the ins and outs of the DSL it describes. "You need to understand your code to work with it" is again not a DSL specific problem.

> Then of course, you plan to support it for as long as it's used. Right? Right?

Another code-in-general remark.


Completely agree with your replies here, but there are internal DSL's that stray so far away from the regular syntax/semantics that your skills in the host language don't apply when writing in the DSL. (Scala SBT I'm looking at you)


I think that the syntax of a DSL should make a problem easier to work with, like CLISP's format macro. Yeah it's kind of crazy having to learn a whole mini-language just to use a certain library, but my experience with CLISP assures me that this madness is worth it. I prefer to manipulate strings using format rather than try to do it in a real LISP.


That is the difference between an internal and external DSL. See https://martinfowler.com/dsl.html


I don't see the difference.


IMO, your comments belie the entire experience of library developers in "DSL-friendly" languages; those with a system of language features that compose well to create what humans perceive as "sub-languages". Ruby and Haskell come to mind immediately, each with a very different set of DSL-enabling attributes.

"The chances your DSL is going to be good is very low." – Nonsense? Yes, API design can be hard. But DSL design at the scale of embedded, ergonomic DSLs is most commonly exactly the same scale as API design. Moreover, there are plentiful examples to draw from these days, especially around builder-type APIs as illustrated in the article. We have quite a suite of well-established patterns to draw from, and they're just not that hard to apply well.

Notably, "language design" doesn't come into it. Almost all proper "language design" decisions for these kind of DSLs are made by the host language – that's why embedded DSLs are so appealing in the first place. There are exceptions when the "language" is really a language (e.g. embedding a Prolog in Haskell or whatever), but most of the DSL examples in the wild end up simply being nice ways to construct rich data structures for consumption/interpretation by some utility library.


SQL is not a “DSL”.

It’s a “Declarative Programming” language and arguably the most popular one.

https://en.m.wikipedia.org/wiki/Declarative_programming


Declarative, functional, imperative, stack-based, array-based, etc is a description of the language itself, or rather the primary computational abstraction; DSL is a description of its usecase and purpose. The opposite is a general-purpose language. The two concepts are orthogonal.

For example, your Wikipedia page defines regexes as also a declarative language, and yet it is also the quintessential DSL.

And in terms of it's domain... SQL has a very a restricted domain it was meant for, and is generally used for. You could argue its domain has expanded slightly with things like LINQ, but it's clearly wrong to describe it as an alternative to say python, or c#, as a language, in purpose or usage.


a language being a DPL doesn't preclude it from being a DSL


I’m not certain that is true.

With a DPL, you describe what output you want without describing how to produce the output.

With a DSL, you have to describe how to produce the output.


No, there is no requirement that a DSL be imperative rather than declarative.


I don't think it should be "exception vs returned value".

First, if you are using a dynamic language, then exceptions make sense. You want to get there quickly, not handle every corner cases.

At the opposite spectrum, if you are writing rust, of course you want something very explicit and extremely aggressive to deal with errors.

They just serve different needs.

Also, exceptions don't have to be implicit, difficulties arise when the code you are using do not or cannot declare what can of exception can happen when you call it.

But if the language let you declare all the stuff you can raise, then there is not much difference.


I started my career as a php dev 15 years ago, and yes, there was plenty of wrong with php. Messy Api, terrible default, wonky typing, no namespace, etc.

It succeeded, as it's often the case in IT, not because it was the best, or even very good, but because it was easy to adopt and had a killer feature.


> there was plenty of wrong with php. Messy Api, terrible default, wonky typing, no namespace, etc.

"Messy Api" is discussed above ("it came down to people complaining about some function names / param orders as if it were the end of the world") so I won't comment.

"terrible default": would be interested in specifics here

"wonky typing": every scripting language had wonky typing 15 years ago, and many of them still do today. This has never been a valid criticism of PHP when comparing to it's primary competitors.

"no namespace": THIS is a very valid criticism. PHP really wasn't a sane language before they added namespaces. But... they added namespaces 11 years ago.


"Messy Api" isn't just parameters. For instance "Fatal" errors and regular errors going to two different logs was very messy and would byte you if you didn't pay special attention to it.

Or multi-byte compliant methods that are a variants, and not the standard method, thus biting anyone who just thought utf-8 would be default.

"terrible default": the poster child for this is register globals, which it took ages to have off by defaults. That's just a single line to set it properly, but that was part of the boilerplate that could have been avoided way earlier.

Overall developing for PHP meant to defensively remember a ton a weird stuff, just like javascript was for a while. I am so glad we mostly got past that, even if I am not in PHP anymore.


Fatal errors is fair enough; though I only ever experienced this with parse errors, PHP being stateless did make this less likely to be caught until well into runtime, so it could be an issue.

String encoding though is, again, something other languages had similar gotchas with. Remember we're comparing PHP to its popular alternatives at the time, not to our hypthetical ideal runtime.

The bad defaults you and a sibling commenter are referring to (magic quotes) are, again, from 11 years ago.

Sure, 15 years ago PHP had serious issues, but here we are today acting as if they didn't fix most of them over a decade ago.


> but here we are today acting as if they didn't fix most of them over a decade ago.

Recall that the defense of PHP in this tree leads with "There was never anything wrong with PHP, really."


> The bad defaults you and a sibling commenter are referring to (magic quotes) are, again, from 11 years ago.

That's because the context was the state of PHP 15 years ago.


> would be interested in specifics here

Magic quotes would be the first one I can think of off the top of my head, which incidentally, was made a default because the mysql api in PHP was so prone to sql injections, that PHP decided to automatically escape all user input as a way to protect inexperienced programmers.

Pretty much everyone agrees magic quotes were a bad idea and they were eventually deprecated in 5.3 and removed entirely in 5.4.


Yes, and you can do it with import hooks as well.

The reason you don't see it in python much is more a matter of culture: we don't like too much magic nor DSL.

With the new generation of coders incomming, it may change though.

Hope not, as most devs are terrible at designing magic or languages and equally terrible at admitting they are.

It took a decade for the trend of monkey patching things in ruby and js to disapear and I don't regret that time one bit. Bad habits die hard.


Probably not so much a matter of culture, but more that the mechanism is a) garbage b) high effort.

I bet if either of those two weren't true, you'd see a lot more of it.


I think you might be putting the cart before the horse so to speak. The culture of python doesn't value these things so the only mechanism is high effort garbage.


There is truth in that, but also a bit of "he who can't do what he wants must want what he can do". The only reason python still matters (more than ruby) is because of its dominance in ML/datascience. And this ecosystem is full of nasty syntactic hacks.


I can't speak for other people but the only reason I still use Python is because of it's syntax (but the "one way to do it" is slowly changing). You get much better concurrency with Golang and even better parallelism with Julia.

It is dominant in data science but still some people use it for other things because the syntax is so simple (Scheme is a close second for me).


If you mean the pseudo-code like quality that (sadly) remains a distinguishing feature, I completely agree.

Simplicity, as in terms of specifying the grammar though? Python's grammar is exceedingly gnarly by now and I'm pretty sure Go, Lua, Prolog, Smalltalk and pretty much every Wirth language are massively simpler, syntactically.


Yes, I meant the pseudo-code quality of Python (I wish Wikipedia would use Python as it's pseudocode :)).

I completely agree that Python is pretty hard to implement. Perhaps you have heard that simple doesn't mean easy ? I could easily implement a Forth (or assembly) interpreter. But it isn't that easy to understand a big complex Forth program (compared to Python). Simple languages like Forth and assembly are too unstructured for me.


I'm sceptical of the idea that the good things about python make it hard to implement. Compared to forth – sure! But most of the non-simplicity beyond what's attributable to not being an ultra-bare bones languages comes from organic growth and bad design decisions.

From the top of my head, here's a list of things that were awesome in python's design:

1. Clean and concise syntax (whitespace, slices, rest and kwargs, multiline and raw strings, although both badly designed were ahead of the time)

2. good default builtin datatypes, with decent API (cf garbage like cons cells or STL)

3. in particular strings as immutable vector of bytes, no seperate character type (this got screwed up in python3 of course)

4. comparison on compound datatypes works out of the box

5. relative uniformity no value vs reference type; objects mostly just dicts, modules as well

6. repr and repl (both gimped, compared to lisp, but good enough to be super helpful in development), good tracebacks

7. anti-footgun conventions (notably: mutating functions return None convention; mutable -> no __hash__ convention; slicing copies convention)

Nothing in this list seems particularly hard on the implementor, but it's of course hardly exhaustive or unbiased. What things that you really like about python do you think are rather hard to implement?


Implementing a minimal Python is pretty easy (even with the huge standard library) but implementing a complete Python implementation is a herculean task. And even after that there is no guarantee that every Python library will run on your implementation (Pypy).

I don't know about you but I would rather make hundreds of Scheme and Forth implementations then one Python interpreter. But I don't really see that as a downside. I mean who decides on a language based on how easy it is to implement ?


Well, all things being equal a cleaner and more understandable language is going to be easier to implement, so I don't think difficulty of implementation should be dismissed so easily. Especially when the difficulty of implementation is not due to advanced features such as a fast runtime, resumable exceptions, proper tail calls, multi-method dispatch, pattern matching, powerful concurrency abstractions, SMP...


> What the original commenter is saying, and what I will agree will happen, is that the behavior of automatically trusting video as evidence will go away.

This is doubtful. People still believe in pictures despite it's so easy to forge. People believe obvious oral lies. Hell, people believe tweets.

The video medium is incredibly powerful, and the damage it can do is huge.

We are going to suffer for this, and most people won't even understand why.


>The video medium is incredibly powerful, and the damage it can do is huge.

I fully agree. Even if rationally, one rejects a video is fake, it does have the potential to influence the subconscious.


I am observing increasing number of people is now seriously believe in "Moon Hoax". Definitely more than back in 70-80th. Why is that? Generation of YouTube? Deliberate propaganda?


OK, but are there actually more people who believe in this now, or are you just more aware of it?


Don't forget the Flat Earth movement.

I don't think anything about that is "deliberate propaganda".

It's just nutjobs gathering and gatherings of nutjobs creating more nutjobs. It's much easier these days with "social" media.


What is the actual social impact of the flat earth thing, though? Is flat earth creating new nutjobs? Does it really have the power to draw from the ranks of the rational, or is it drawing in people who would have fallen for something absurd eventually? I'd be curious to find out what social conditions predispose people to believing it.


They have big conferences about it, as long as no one is hurt all good with that, but truly doubt that people aren't being hurt by this delusion.

It's an illness that demands rejection of overwhelming proof, it leads down dark paths, much like how arsonists become murderers these things need to be cutoff at the stem. There's nothing wrong with that


This might not be a popular answer, but I think the hope is that a rube would "fall for" something positive that happens to be correct and/or beneficial. eg, suppose somebody believes in modern physics, not because they understand it all, but because they know this is the "right" idea.

This is obviously less ideal than someone actually understanding an idea they profess to hold, but it's far better to have support around beneficial ideas. It's not hard to imagine a lot of important issues fitting into this: support for liberalism and demoracy, support for global warming, support for coherent ideas about vaccines, etc. These all require broad public support, and the truth of the matter is that many people generally don't spend much time evaluating why they believe what they do.

I understand this is not a perfect point of view: eg, who gets to decide what the "best" ideas are.


Well, it's also the fact that people have learned how to monetize this stuff effectively. I mean, even the first fakes were monetized (stuff like shocking photos of fairies would be sold, the people who took them would travel the country and speak about their 'amazing discoveries) but, nowadays, you can just write a book about the Earth being flat because all you need to make money off of it is a few contrarian people or conspiracy theorists.

Even Alex Jones, a figure so obviously deranged with claims that sound like satire, has been selling supplements and merch. All because these days anybody has a platform and monetizing lies is easier than ever. People will believe anything, especially if it's 'published in a scientific magazine', nevermind that the publication has no credibility, reliable sources, or academic integrity. This is how anti-vaxxers got their start, after all.


I heard this argument for the 35h work week in France. 10 years later, it proved baseless.


it proved baseless.

Structurally high youth unemployment was the consequence. The French system is fantastic once you are over the hurdle of actually getting a permanent contract, but the barrier to entry is much higher than in comparable economies such as the UK. It just depends which segment of the population you are optimising for.


It's more about the fact we can't fire anybody, so hiring is a scary game.


Back in the old days the English really knew how to keep youth employment high


uh, not sure that using france as an example is smart as france has been a laggard in terms of economic performance for the past decade. this meant it being basically leapfrogged by a number of countries from across the world. end result? better quality of life, better infrastructure, etc etc outside of france than inside.


I live there. I've lived in many other countries as well. And I keep traveling.

I experienced the total opposite of your comment.

I've seen the road in the US. I've seen the health care in the UK. I've seen the internet in Spain. I've seen the cost of life in Switzerland. Heck, I've worked in Asia and Africa.

There are not a lot of countries where life felt as good as in France: germany, sweden, etc.

There are also not a lot of countries where people complain more than the French. It's a national sport.


> There are also not a lot of countries where people complain more than the French. It's a national sport.

Sounds like it's working


Clearly you have not lived in France :D

We complain about the US politics. We complain about the weather. We complain about how much we complain.

I'm pretty sure the gov cancels your citizenship if you don't reach your weekly complain quota. It's a matter of national identity.


"# check if frame is None" is indeed a good example of comments you should not write. It's weird that someone has the skill to create what seems such a complete lib and yet produces what most would qualify as a beginner structure.

If the project holds up, it's definitely a teaching moment for me.


I noticed reading some of the comments here that they don't get into what a "good" comment is. Many critiques on HN will try to identify best practices, but with comments, and writing generally, it's more a skill you have to learn.

The weirdness you mention can be explained, I think, by the fact that the project has a single contributor.[1]

A person learns which patterns work or not when patterns clearly work or fail. Since bad comments are something that affects maintenance without breaking the code, it wouldn't be surprising if the internals are solid while the code is less maintainable.

And I predict that if it takes off, you'd see other contributors pushing back against the extraneous comments, and Abhishek's style in commenting evolve.

[1]: https://github.com/abhiTronix/vidgear/graphs/contributors


Also a good example where 3.8 would be handy:

    while (frame_stab := stream_stab.read()) and (stream_org := stream_org.read()): 
iter() works with all stable versions of Python though, but it's a bit exotic. When I use it, I tend to make aliases to make it clearer because most Python devs don't know about it, let alone this alternative form.

    stab_frames = iter(stream_stab.read, None)
    org_frames = iter(stream_org.read, None)
    for frame_stab, frame_org in zip(stab_frames, org_frames):


    stab_frames = iter(stream_stab.read, None)
    org_frames = iter(stream_org.read, None)
    for frame_stab, frame_org in zip(stab_frames, org_frames):
wow, I did'nt knew about this. Thanks for posting. I'm definetly adding this in the next release.


Indeed. Migraines for 30 years. Painkillers allows you to keep up with whatever wrong you are doing.

So if you have migraines, it is not normal. It is not incurable either. Use pain killers when you must, but keep looking for a solution.

The solution can be different for everybody. Start with diet, it's a very common cause for it. Don't limit yourself to what you think is right. Try things, even weird ones. Took me 3 decades of trials and errors to not need pain killers.


If pain killers worked for your migraines, they were extremely mild migraine.

OTC pain killers (and even prescribed pain killers) don't really do anything for the 3 people I know that get migraines. These people have to lay down under their sheets to block all sun light, they can not do absolutely anything at all during the episode but block sunlight and hope whatever medicine sort of worked last time will work this time.

Preaching and generalizing from your mild case helps no one.


Thanks for sharing about it taking thirty years. I can only imagine that it becomes so much harder of a problem to solve when the symptoms are as severe as a migraine.

Unfortunately, I don't think people understand how long it takes to get a grasp on everything we ingest. Someone in a sibling comment mentioned giving up after just a few months of "logging" their diet.

It took me years to narrow down an allergy/sensitivity to tannins. And it also took years to recognize the full extent of sugars' effect on my body.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: