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

Sometimes I feel that, instead of APL/J/K being standalone languages, we should standardize a mini-language like we did with printf, date formatting or regexes, and embed it in all general purpose languages.


Why a mini language instead of a library?

Python has Numpy to satisfy most array programming needs, for example.


Good point, and I'm not a big fan of DSL. I think most of the time, we should make a better API.

But for regexes, it has been a success: they are rarely used, but when they are, you are glad you have them.

In fact you probably need to do both: re in Python is a library. A library that implements the regex DSL.

Maybe there is a way to create an API around numpy that translates a J/K/APL like DSL into numpy operations.

Just like regexes, this is not something you want to use often.

But I assume that, just like I don't want to describe a whole parser when I just need to match/split/extract text, people doing array processing probably don't want to describe every single steps for very common operations in some cases.


I did exactly that a couple of years ago, turned out it wasn't hard to translate J expressions into the equivalent numpy code and then eval it in the current context. I'm afraid I've lost the code, otherwise I'd post it.


Numpy is a mini-language, effectively a DSL. It's just that Python offers some features which allow for embedding the DSL into the language, making it an internal DSL. In languages with less flexible/overridable syntax - for example, if indexing would be limited to a single expression only - you'd have to write all the indexing, searching, and assignment operations "long-hand", with method calls. Well, depending on the API this may still be workable, but it would be much less convenient, slower, and more error-prone. The external DSLs are a way around this.

TL;DR: if the language is permissive enough, a library may well provide a DSL for whatever it's doing, it's not an "either lib or DSL" situation.


To me, you get a DSL either by having a different parser, or by using a macro system.

If you just use the flexibility of your language syntax, you just create an API, not a DSL.

The L in DSL stands for language, which numpy is, IMO, not.


Well then, what is the difference between a DSL made using a macro system, and one made with dynamic language features, reflection, operator overloading, and similar? Both approaches embed a sub-language into its parent language: both are DSLs, of the internal kind. A quick google for "internal DSL" returns, for example, this article from Martin Fowler: https://www.martinfowler.com/bliki/InternalDslStyle.html which seems to support my take on this.

> The L in DSL stands for language

I think you use a too narrow definition of a language, then. Any (sub)set of semantics can be called a language, with or without syntax. DSLs encode a set of semantic rules which are best suited for expressing solutions to problems in a given domain. Once you have semantics worked out, you have to think about the environment where the language will be used. Sometimes it's useful to have the DSL code separate, in which case you end up with an external DSL, like HTML or YAML. On the other hand, sometimes you need tighter integration with some environment, in which case you end up with an internal DSL, like JSX, Datalog, Kanren, Rake, Gradle, Gulp, various URL dispatchers, BDD testing frameworks, and yes, Numpy.

The syntax of a DSL ("a different parser" vs. not) is secondary at best, and the implementation strategy (macros vs. runtime code generation vs. reflection and syntax overloading) is simply irrelevant to something being a DSL or not.

Take a look at PyParsing or LPEG (for Lua) or scala.util.parsing or Parsec (for Haskell). These are all embedded DSLs meant for creating parsers. You work with them in exactly the same way you'd use YACC: you describe the grammar and get a parser for that grammar. That grammar description is done with a language, in all cases. That language - implemented either externally, or internally with host language features - is a DSL.


So, you don't use open("w"), do you ? You use the non magic open(os.O_WRONLY) of course.

Because magic strings are bad.


I will now - thanks for the tip! :)

And, moreover, this will inspire me to ask "How many other traditional magic numbers/strings/etc have I gotten used to that might be defined more readably?" strcmp, I'm looking at you!

I know your post was sarcastic/snarky but it was genuinely helpful


f.tell(offset, os.SEEK_CUR) over f.tell(offset, 1)

https://docs.python.org/3/library/os.html#os.SEEK_CUR

I wish the docs on f.tell at least mentioned the option

https://docs.python.org/3/tutorial/inputoutput.html#methods-...


Except it wasn't, os.O_WRONLY is for os.open() (equivalent of open syscall, takes numeric flags), not the built-in open() (equivalent of C fopen, takes "w" and similar strings).


Python 3.8 has typing.Literal for this.


That's a fair point, and I'll be sure to keep an eye out for that type of magic-string usage going forward. Though most "magic string" usages are not nearly as official as the one you mention and usually occur in business-level code written by ordinary developers that may not be disciplined or experienced. Those spots most certainly need all the assistance they can get instead of relying on magic-strings, hence my comment of magic strings being bad.


You would have to use os.open


I would also have to pass the path as a first param. This was not meant to be correct, just teasy.


When they moved from Unity to Gnome shell, you could read all over the OMGUbuntu comments that people actually liked Unity and wished they would keep it.

It's always the same, you hear people complaining the most.

Ubuntu has been a success because they took some risk.

The first one has been to make installing proprietary drivers easy. Something they got a lot of heat for.

And since they managed to become the most popular Linux distro ever, I think critics should maybe ask themselves why.


I'm using Ubuntu 20.04 with Unity right now. Unity wasn't bad. I disliked it at first because it lacked features and it wasn't polished. After some time a lot of people started liking it.

But they messed up with Unity 8 and Mir. They didn't want to work with the community, they didn't care if they were working on stuff that already existed. Instead of working with the upstream devs, they worked alone. Where did they end up? Back to Gnome Shell with a lot of years of effort down the drain.

And this is even worse. More info here: https://news.ycombinator.com/item?id=23433794


EDIT: As a reply to this pointed out, these predate the things I claimed were created from NIH syndrome. Please disregard.

Original comment:

They also created their own init system Upstart, only to replace it with systemd later. They have their own source control system, Bazaar.

I really appreciated Ubuntu back in '06 when my laptop's wifi and graphics drivers just worked out of the box. I've used Ubuntu in various forms for a long time. But their management has some serious NIH problems.


> They also created their own init system Upstart, only to replace it with systemd later. They have their own source control system, Bazaar... their management has some serious NIH problems.

Citing these as a case of NIH is inaccurate -- Upstart and Bazaar predate Systemd and Git, respectively.

It's fairer to say that Canonical's technology, for whatever reason, often doesn't seem to catch on with the broader FOSS community.


Ah! That's my error; thank you for pointing that out. I hadn't realized that. I'll edit my comment.


I would agree with you in this about snaps IF snap were somewhere close to production level software.

Nobody can assemble some new kind of app packaging, slowing the starting speed to 5-10 seconds and call that "good rounded software"

"It is just a couple of seconds more sometimes, not a big deal" isn't going to cut it. Most of the Internet using Ubuntu, already knows that.

I think Canonical is again in denial.

It already happened a couple of times: MIR, Unity (buried by not being community driven probably), Unity8, the mobile project or something, all but forgotten now.

This snap thing is probable the pet project from a couple top guys in Canonical. Maybe hundreds of powerpoint presentations have been watched about some "big strategy" for the next years, but they didn't know the thing (snap) is unbearable slow.


Apt sucked when it started. Give it some time.

It's a complicated endavior, and it will need many iterations before becomming a decent solution. That's why we have to start ASAP.


I was annoyed at many of the moves Ubuntu made and voiced that, but at the end of the day, I kept using it. When 20.04 came out, I uninstalled snap. If I'm forced to use snap, I'm gone.

There's no comparison.

The recent I ran Debian and now Ubuntu will be gone. Evaporated in a poof of smoke. I'll be elsewhere. Probably back to Debian.


Statistically, proprietary software is regular software.

But yeah, snaps is a great solution for that, espacially because getting a non FOSS software is not possible in official distro repos, and hosting your own repo is HARD.

And that's what's happening. I installed Telegram using a snap because of this.


> Statistically, proprietary software is regular software.

Statistically, proprietary software in the world of Linux is a black swan. Free software is the rule, proprietary software the exception to the rule which tends to be used only when there are no alternatives.


There is an opt out feature: diversity.

You can always use only the system package manager, or use a distro that doesn't use snap.

All those complaints feel so moot.

It's really hard to be in FOSS nowaday: you can't make a move without your users judging you all along the way, because a lot of them are idealists that expect a lot from you, yet don't think about the non tech saavy users.

It's way easier to make proprietary software: most of your users don't criticise any single decision you make, you don't have to justify yourself, you get much more users, and you make money out of it.


> It's way easier to make proprietary software: most of your users don't criticise any single decision you make, you don't have to justify yourself, you get much more users, and you make money out of it.

Why on Earth would you think that users of proprietary software don't criticize it? I'm pretty sure that Windows gets more criticism than Ubuntu...


Take zoom: in HN we heard a lot of complains for ethical reasons, but the biggest part of the user base doesn't care and are just happy with it.

On FOSS, you'll have complains about the software it self AND ethics from most of your users, because they are mostly technical, and contains way more idealists than the average user sample.


Something can be both.

And we can enjoy the bright side of it, while not being naive.


I can only say - be very careful in how you approach these issues. Similar actions in india resulted in not so great outcomes from the government and corporations. And we are still stuck with the prejudice and discrimination - for some even greater than before.


I've been using Linux for 15 years as my daily OS, I love the package system, but this point of view is missing the point.

Those arguments are always from very tech saavy people.

They are a good exemple of purity over practicality, completly ignoring all the problems apt/yum have for the average user or dev publishing software.

If you are looking for reasons as why Linux on the destkop never happen, well, this is one of them.


It's assuming the police will do anything about it.

But the probability they even take the time to listen to the old man story is pretty slim.


I have a friend of mine that has been beaten up badly, twice.

10 years ago by his neighbours, in front of a witness. He got his jaw broken.

5 years ago by a random guy in the street, in front of a security camera that caught the dude car's plate. He got his nose broken.

In both cases, the police at best did nothing, at worst tried to activaly prevent action (loosing the case file, not registering it, not passing it around, or asking my friend to not go further).

So I'm expecting that for an old guy receiving pizzas, they have zero incentive to even think about it.


Where is this? (Btw, if your friend is getting beaten up every 5 years and the last time was 5 years ago I'd tell him to hide or stay low for a while.)


France, which shares lot of similarities with Belgium.

And franckly, this comments feels loaded with assumptions.


Indeed, It was a joke. My bad.


Happens to me all the time. Hard to convey tone using text only.


I think it's a joke..


Arf, an emoji would have helped.


Several possibilities I can imagine:

- they don't handle ordering and delivery: those are outsourced, and so they don't get the address. Or they do manage ordering, but not delivery, and the ordering system has a bug.

- they benefit from those fake sales because they are laundering money through their restaurant

- they benefit from those fake sales because they have an insurance that pays for those

- they are using those addresses, that they know don't cause problems, to test something.

- they use the pizza delivery as an excuse to be here, and do something illegal (surveillance, delivering drugs, territorial presence, etc).

- it's a fake/exagerated article/testimony


A relatively famous example of the fourth option was the Four Square Laundry in Belfast in the 1970s, which was actually a security services front which tested clothes for traces of gunpowder and explosives.

They had to run a book of initial 'customers' in order to capture the interesting trade.

Eventually it was outed with fatal results, but until then it had turned up a lot of intelligence.


That would be a lot of testing for the fourth option. :)


Indeed.

But the testing may have nothing to do with the pizza business itself.

Maybe it's a way to do hiring.

Maybe they test delivery gears.

Maybe they test the time it takes to delivery using said vehicule on one terrain.

Maybe they test the time it takes for some kind of product to be cold, or not tasteful anymore.

A serious test must be down for a long time, accross terrains and seasons.

And if you test a lot of thing, you will need a lot of deliveries for a long time.


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

Search: