Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

prisoner of waffles posted:

tell us what language has "real modules" and we'll try to figure out how they are different from packages

yeah i dont have a good definition of what a module is. but i think go packages are not a good substitute for modules/namespaces because go packages are closer to objects since they are initialized with state.

Adbot
ADBOT LOVES YOU

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





prisoner of waffles posted:

tell us what language has "real modules" and we'll try to figure out how they are different from packages

ML

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

So what problems can you solve with ML modules? They do their generics using modules parameterized with the generic types? Cool but like, what else do they get used for?

(Would legit prefer to have someone tell me over learning this on my own lol)

Athas
Aug 6, 2007

fuck that joker

prisoner of waffles posted:

So what problems can you solve with ML modules? They do their generics using modules parameterized with the generic types? Cool but like, what else do they get used for?

(Would legit prefer to have someone tell me over learning this on my own lol)

Modules allow you to parametrise over types, values/functions, and other modules. That's it. It's an powerful technique (if somewhat verbose). What more do you want? It is used for bog-standard generic programming, but also for nice tricks like pairing an arbitrary regex frontend to an arbitrary regex backend, so you can get the syntax and operational behaviour you want. (I never see this used much in practise.)

However, the ML module system does not directly deal with how programs are split into files. That's done by the ML Basis system, which is a pretty lightweight mechanism. This notion of abstracting over the practical fact that all programs are split into files is a relic of older languages, I think.

Sapozhnik
Jan 2, 2005

Nap Ghost

prisoner of waffles posted:

If nothing else, Go gives a good example of what a modernized C looks like, has surprisingly pleasant tooling (gofmt and godoc, e.g.), and a standard library that actually includes things like http and json

There are lots of domains that you probably wouldn't want to use it for and I dunno what kind of work you do or consider important. I'm against the mindset of treating PLs as anything other than tools but rah rah go use whatever language you like

edit: dumb ways of adding generics to Go are dumb. Good Go programs still get written without generics, sometimes with interface{} aka void* sins committed under the covers

Perfection (in a standard library) is achieved not when there is nothing left to add, but when there is nothing left to take away

For everything else, there is the standard package manager and its open source repository

Sapozhnik
Jan 2, 2005

Nap Ghost
God help me and my deepening case of brain worms but I am actually starting to like JavaScript. Triple equals really seems to solve a lot of its worst bullshit. and things like destructuring and async/await are very hard to do without once you get used to them

AggressivelyStupid
Jan 9, 2012

Sapozhnik posted:

God help me and my deepening case of brain worms but I am actually starting to like JavaScript. Triple equals really seems to solve a lot of its worst bullshit. and things like destructuring and async/await are very hard to do without once you get used to them

danger, pull up

pull up

brap
Aug 23, 2004

Grimey Drawer
Replace JavaScript with Typescript and you're all good

Workaday Wizard
Oct 23, 2009

by Pragmatica

fleshweasel posted:

Replace JavaScript with Typescript and you're all good

tef
May 30, 2004

-> some l-system crap ->

Athas posted:

This notion of abstracting over the practical fact that all programs are split into files is a relic of older languages, I think.

Personally I can't wait until all software is written in a format somewhere between pdf files and swf

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
modern ecmascript hits a good sweet spot in a python-like without being too python

but then they made it go waaaaaaay too far so i dont tend to use any of the super modern stuff

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
ml does not get to own the term “module system” just because they started out thinking about modularity before getting distracted designing a generics system

it’s an interesting feature but it doesn’t really even try to address the top-level issues with organizing code into reusable libraries

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Athas posted:

pairing an arbitrary regex frontend to an arbitrary regex backend, so you can get the syntax and operational behaviour you want

this seems like a bad idea

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Powaqoatse posted:

this seems like a bad idea

wouldn't it just amount to "write a dsl that compiles to standard regexes"? not particularly dangerous imo

kinda narrow in appeal because most people who want to write regexes will have had to learn standard syntax anyway (same reason alternative syntaxes for SQL never caught up). but i could see some uses like eg enabling static type checking

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Sapozhnik posted:

God help me and my deepening case of brain worms but I am actually starting to like JavaScript. Triple equals really seems to solve a lot of its worst bullshit. and things like destructuring and async/await are very hard to do without once you get used to them
So go use a good language that has those features?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



NihilCredo posted:

wouldn't it just amount to "write a dsl that compiles to standard regexes"? not particularly dangerous imo

kinda narrow in appeal because most people who want to write regexes will have had to learn standard syntax anyway (same reason alternative syntaxes for SQL never caught up). but i could see some uses like eg enabling static type checking

just seems like yet another way to make your code unreadable

I mean what gain could ever justify that?

Vanadium
Jan 8, 2005

As someone who habitually tries to use regexps in vim/grep/sed/random webapp search forms, I think "standard regexp syntax" sounds like a splendid idea.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



the standard is PCRE :colbert:

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Powaqoatse posted:

just seems like yet another way to make your code unreadable

I mean what gain could ever justify that?

like i said, static type checking is one that comes to mind. have the compiler guarantee that your regex is actually valid is a pretty big deal. not coincidentally it's pretty much the only defensible reason for people bother with stuff like LINQ-to-SQL and other such leaky abstractions instead of writing straight SQL

now, that doesn't necessarily require an alternative syntax, but having one (a la VerbalExpressions) means you can implement it as a simple library instead of requiring the compiler to explicitly interact with a regex parser. (you also get autocomplete support and become readable to people who don't speak regex, but like I said I doubt that's a significant audience)

or, if you have fancier tools like dependent typing or type providers, you can also have the compiler automatically infer your regex captures at compile time, which is real neat

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
go would be sw8 for say a microcontroller but it has a GC built-in and that's not cool

also RAII owns bones for my dumbass Arduino projects.

gonadic io
Feb 16, 2011

>>=

Malcolm XML posted:

go would be sw8 for say a microcontroller but it has a GC built-in and that's not cool

also RAII owns bones for my dumbass Arduino projects.

Hence my current rust-arduino library project

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

gonadic io posted:

Hence my current rust-arduino library project

i just read through part of this today: https://japaric.github.io/discovery/README.html

and then i ordered the reccomended hardware stuff on taobao for like $20 and im gonna try it out. i've never really done any embedded stuff before

gonadic io
Feb 16, 2011

>>=

fart simpson posted:

i just read through part of this today: https://japaric.github.io/discovery/README.html

and then i ordered the reccomended hardware stuff on taobao for like $20 and im gonna try it out. i've never really done any embedded stuff before

Aww yeah!
I hadn't either before I started something similar. The two main things are 1) lots of writing to specific memory addresses that you have to calculate from various parts of documentation, and 2) no heap or dynamic allocation which rust supports via no_std

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

my work firewall is either too stupid or too wise:

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

NihilCredo posted:

my work firewall is either too stupid or too wise:

haskell is porn for nerds for whom concepts like bijection & tail recursion make all turgid --WONTFIX

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

i was reading this paper about WebAssembly where it says "Adding threads and a memory model is the subject of ongoing work beyond the scope of this paper."

this seems kind of odd from the standpoint of the vibe i get from the rest of the paper...namely that WebAssembly is the best-designed and best-planned thing ever conceived.

my naive thought is that going back and adding threads later will lead to compromises in their design. am i wrong?

Athas
Aug 6, 2007

fuck that joker
Retrofitting threads is hard for a system where it was not originally conceived (lol python), but it is not too bad if you built the original design such that it could eventually be extended. From what I know of WebAssembly, there is not really a reason why it would be particularly hard to add.

tef
May 30, 2004

-> some l-system crap ->

Powaqoatse posted:

the standard is PCRE :colbert:

unironically this

crazypenguin
Mar 9, 2005
nothing witty here, move along

MALE SHOEGAZE posted:

my favorite go quirk is that imports are file-scoped. so if you import fmt in one file you'll need to reimport it in another file in the same package.

however, file scope isn't really a thing otherwise. all other identifiers (even private ones) will be shared between files. which is super annoying because go has a serious problem with namespace collision due to the lack of generics and lack of any kind of module or namespacing system.

so there's a weird situation where imports are file-local but private variables declared in a file are package-local. it makes no sense.

what makes this even weirder is the fact that imports are mutable and maintain a global state.

IDK about the state part but this isn't really a quirk? It's the same for Java, for instance.

I'm guessing that maybe Java just has a culture of importing specific classes out of a package instead of *, whereas Go doesn't? Otherwise, I'm not sure how these are different

e: or maybe the "namespace collision" part is just because in Java everything is forced into a class, so there's less opportunity to collide?

Cybernetic Vermin
Apr 18, 2005

Powaqoatse posted:

the standard is PCRE :colbert:

re2 is the only one i would recommend anything new to rely on, a lot of janky things in pcre (inheritance from perl), and the usual catastrophic performance issues which people love to forget about

the fact that neither has much of a specification is unfortunate also, but re2 at least limits the scope a lot in a rather sensible way

JawnV6
Jul 4, 2004

So hot ...

Cybernetic Vermin posted:

the usual catastrophic performance issues which people love to forget about

oh no, this toy case with a billion back references takes minutes, who could live under these conditions

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

crazypenguin posted:

IDK about the state part but this isn't really a quirk? It's the same for Java, for instance.

I'm guessing that maybe Java just has a culture of importing specific classes out of a package instead of *, whereas Go doesn't? Otherwise, I'm not sure how these are different

e: or maybe the "namespace collision" part is just because in Java everything is forced into a class, so there's less opportunity to collide?

Java packages and golang packages are very different so the scoping rules arent really comparable. One major difference is that functions and variables are allowed at the top level of a golang package. also, packages will be initialized once at runtime, and have mutable state, so it's more accurate to think of them as objects (this is why you can't import a single identifier from a go package -- that identifier is tied implicitly to the package because it might rely on the state of the package, so it doesn't make sense to be able to import a single identifier).

the end result of this is that go makes it very difficult to organize your code, which is especially an issue in a language that has no generics and demands that you have lots of functions named add_int32, add_int64, etc.

add issues with cyclic dependencies on top of this, and you have a real poo poo show. at least in my experience. i was clearly not arranging my go code properly because i had lots of problems.

also i could be wrong on any of this. it's been quite a while since i've written any go.

DONT THREAD ON ME fucked around with this message at 19:52 on Sep 18, 2017

VikingofRock
Aug 24, 2008




JawnV6 posted:

oh no, this toy case with a billion back references takes minutes, who could live under these conditions

the beast with a billion back references

Cybernetic Vermin
Apr 18, 2005

JawnV6 posted:

oh no, this toy case with a billion back references takes minutes, who could live under these conditions

pcre like most implementations in perls footsteps does backtracking search to match the regex, without back references it is still exponential time in the worst case. the toy example is just ^(a*)*$ which on the string aa....ab will make exponentially many match attempts, but it is non-trivial to avoid cases where multiple ways of matching show up. for example any union (E|F)* will take O(n^2) to match if there exists any string in the intersection between the languages matched by E and F

re2 employs a table parsing technique which avoid this issue. perl itself has some flag these days to store additional info to mostly avoid these situations, but that is then more expensive, not least incurring non-trivial additional memory usage, than the re2 approach

Cybernetic Vermin fucked around with this message at 20:32 on Sep 18, 2017

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
my favorite regex syntax is the equivalent dfa diagram :twisted:

tef
May 30, 2004

-> some l-system crap ->

Cybernetic Vermin posted:

pcre like most implementations in perls footsteps does backtracking search to match the regex, without back references it is still exponential time in the worst case. the toy example is just ^(a*)*$ which on the string aa....ab will make exponentially many match attempts, but it is non-trivial to avoid cases where multiple ways of matching show up. for example any union (E|F)* will take O(n^2) to match if there exists any string in the intersection between the languages matched by E and F

re2 employs a table parsing technique which avoid this issue. perl itself has some flag these days to store additional info to mostly avoid these situations, but that is then more expensive, not least incurring non-trivial additional memory usage, than the re2 approach

rob pike: "Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)"

JewKiller 3000
Nov 28, 2006

by Lowtax
that quote is from back when rob pike was sane

JawnV6
Jul 4, 2004

So hot ...

VikingofRock posted:

the beast with a billion back references

JawnV6
Jul 4, 2004

So hot ...

Cybernetic Vermin posted:

pcre like most implementations in perls footsteps does backtracking search to match the regex, without back references it is still exponential time in the worst case. the toy example is just ^(a*)*$ which on the string aa....ab will make exponentially many match attempts, but it is non-trivial to avoid cases where multiple ways of matching show up. for example any union (E|F)* will take O(n^2) to match if there exists any string in the intersection between the languages matched by E and F

re2 employs a table parsing technique which avoid this issue. perl itself has some flag these days to store additional info to mostly avoid these situations, but that is then more expensive, not least incurring non-trivial additional memory usage, than the re2 approach

also yeah ive never had to put a regex in some perf critical CDN control plane but for mashing text from a data sheet into friendly #def's with vim/sed they're needs-suiting as heck and ive never had to care if it was exponentially matching MODULE_ or not

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015

JawnV6 posted:

also yeah ive never had to put a regex in some perf critical CDN control plane but for mashing text from a data sheet into friendly #def's with vim/sed they're needs-suiting as heck and ive never had to care if it was exponentially matching MODULE_ or not

The thing basically is that with properly implemented regexes, you can mostly trivially* expose regex-supporting search field to public without opening yourself to easy denial-of-service attack.

* If you allow PCRE notation, you will need to somewhat limit the x in a{1, x}.


tef posted:

rob pike: "Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)"

RE2 actually uses older and simpler algorithm for the core functionality than PCRE, most of its fanciness is SW engineering (arena allocators, on-the-fly NFA-DFA conversion, etc) and figuring out how to break down most of PCRE back into proper finita automata. :v:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply