New around here? Register your SA Forums Account here!

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
mystes
May 31, 2006

Sorry, the thread title must contain at least one number and at least one emoji.

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

'javascript' < 'the worst thing there is'

mystes
May 31, 2006

MALE SHOEGAZE posted:

a space exploration startup whose only goal is to send elon musk to the kuiper belt
Maybe start with sending elon musk into the sun as an MVP?

mystes
May 31, 2006

gonadic io posted:

have you tried `cat` op? (it's called `type`) in Windows cmd

Finster Dexter posted:

cat b.txt >> a.txt
I think you guys missed the "b.Except(a)" part. You could do this with grep on linux but on windows I don't think you could do this with just the command interpreter; you would probably have to use powershell.

code:
$b = gc b.txt
gc a.txt | ? {$_ -notin $b}

mystes
May 31, 2006

redleader posted:

i once spent an hour on a friday afternoon coding in papyrus. it was somewhat amusing
Just wait until you discover the stupid ligature fonts.

mystes
May 31, 2006

Doom Mathematic posted:

It is? I thought it was like a mildly well-known industry term. That's how I use it at work anyway.
Well, keep working at it and maybe it will be!

mystes
May 31, 2006

Anyway it should be real term.

I'll go make the "The pee lang is real!" hats.

mystes
May 31, 2006

MALE SHOEGAZE posted:

rats (get it, cats in rust)
I don't know, there's got to be a dumber rust/cats pun out there somewhere. Feral?

mystes
May 31, 2006

Phobeste posted:

- 6.5 figgies means whatever you want it to mean above 100k
Lies! But this is the terrible programmer thread so I guess it's ok.

mystes
May 31, 2006

Mahatma Goonsay posted:

i will teach you the ways of ~MAGIC~ if you can teach me how to escape this place. MAGIC $T is the one that is kind of like mumps, everything is a B tree. there is also magic fs which is terrible in completely different ways.

Here is something in $t that will print the fibonacci numbers under 10000. Note the left to right assignment using a ^, which looks like a little arrow in a magic terminal. # is a "prefix", which just outputs things to the terminal.

0^X,1^Y,D(13,10)^#,DO{X<10000 X^Z_D(13,10)^#,X+Y^X,Z^Y}

edit: the D(13,10) are just cr-lfs i put in there so that it would print out real pretty.
"X^Z_D(13,10)^#" is like
code:
print(str(x) + "\r\n")
z=x
or something?

mystes
May 31, 2006

prisoner of waffles posted:

I think part of why people hate on go so much is because perhaps too many of the people now writing blogposts about how "it's so fweaking awesome" are not much more insightful than the crowd succinctly mocked by the "mongodb is webscale" computer-generated voiceover vids?

like a good answer to that stackoverflow question is "what the gently caress are you doing? why aren't you using the stdlib database package?" and if indeed their usecase requires that they have a different interface and be able to unmarshal into any struct, then indeed they do need reflection, there's no way to git'r'dun without reflection

trash-tier programming and thinking happens regardless of programming language
It's just annoying that despite go coming after a lot of better languages, everyone was acting like it was god's gift to mankind.

All the other languages should have won but somehow all have managed to shoot themselves in the foot in various ways so we're left with languages like python and go winning.

mystes
May 31, 2006

anthonypants posted:

isn't "serverless" just when you get the client machine to do everything e.g. javascript
No, serverless is CGI. Sorry, I mean Amazon Lambda.

mystes
May 31, 2006

NihilCredo posted:

yeah, we have f# and c# script files (actually f# scripting predates powershell by a year), they're way better than pshell for writing scripts longer than two lines.

all they really need is a decent sysdamin / web client / file munching library to be imported by default, and the c# / f# interpreters to be shipped by default with the runtime and imported into PATH by default

pshell should have focused entirely on being a modern replacement for cmd.exe with a focus on discoverability (check), consistency (meh) and usability (bleah)
It's funny because powershell has been very successful at achieving its goal of being a .net-based dynamically typed replacement for unix shells, and it's better than bash IMO, but basically the fundamental goal of trying to be like unix shells was misguided. It would have been so much less effort for them to try to make c# more suitable for the sort of thing people normally do using shell scripting and the result would have so much better.

akadajet posted:

people say this, but i've never seen anybody use f#
It's a nice language but you basically already have to know c# and ocaml to learn it, and Microsoft doesn't seem that serious about it so there are frequently issues with the tooling. It's sort of frustrating for these reasons, so in most cases it's easier just to use c#.

mystes
May 31, 2006

Incidentally, I think one thing Powershell has really done a good job of proving is that piping objects between commands works much better than piping text. It's too bad there haven't been any serious efforts to make something like powershell but statically typed (for some reason it seems like whenever people try to make shell-like environments for other programming languages, they are determined to stick to piping around text whenever possible).

mystes
May 31, 2006

gonadic io posted:

lots of static typed langs have a repl and a command api
It's mostly an issue of ergonomics. It's pretty inconvenient to do simple shell-script like stuff in most languages. Powershell is cool because just poking around in directories, moving stuff, etc. is just as fast as in bash.

There are some repl environments for python that are sort of the right idea, but what I really want is something similar for a statically typed language that has good type inference. Also, I want proper tab completion in the shell. I'm not aware of anything right now that checks all these boxes.

I think c# could be made to work but I don't think the current repls are suitable right now.

mystes
May 31, 2006

gonadic io posted:

This is build with that in mind, tab completion would depend on your editor though as it's regular haskell types
http://www.haskellforall.com/2015/01/use-haskell-for-shell-scripting.html?m=1
I haven't tried Turtle but it seems to just be oriented around running unix commands. I guess maybe I should try it because at the least that would make it easier to explain why it's not what I'm looking for.

mystes
May 31, 2006

OK, I tried turtle.

Finding the total size of the most recent 5 files in powershell and turtle (admittedly I suck at haskell so the haskell version is probably not the best solution).

Powershell:
code:
dir | Sort-Object -Descending -Property LastWriteTime | select -first 5| Measure-Object -Property length -sum | select -expand sum
Turtle:
code:
{-# LANGUAGE OverloadedStrings #-}

import Turtle

import qualified Control.Foldl as Fold
import Data.List

toList :: MonadIO io => Shell a -> io [a]
toList s = fold s Fold.list

getStat x = (\y -> (x, y)) <$> (stat x)

compareFiles (x, y) (x', y') = compare (modificationTime y') (modificationTime y)

main :: IO()
main = do
    l <- toList (ls ".")
    l2 <- sequence (map getStat l)
    let l3 = take 5 (sortBy compareFiles l2)
    let sizes = map (\(x, y) -> fileSize y) l3
    print (sum sizes)
I don't think I'm going to use turtle as my normal shell for simple scripting any time soon.

mystes
May 31, 2006

While I'm messing around with Haskell, is there any new advice on the best plugin to use for vs code at the moment? I was using haskelly last time I tried haskell, but as always when I went to try it again this time it was broken and this time I ended up giving up after half an hour of trying to get it working and just using the repl. This is possibly my biggest issue with haskell since it somehow happens every single time.

If there's a better ide to use instead of vs code I'm open to that too, I guess.

mystes
May 31, 2006

gonadic io posted:

pretend I 1-lined this because it's definitely possible
something like
code:
ls "." >>= mapM getStat >>= (sum . map (fileSize . snd) . take 5 . sortBy (compare `on` modificationTime)) >>= print
Lol that's a lot shorter.

Also, I just realized that I never needed the filenames again anyway so I didn't need to use tuples at all.

mystes fucked around with this message at 23:23 on Sep 5, 2018

mystes
May 31, 2006

gonadic io posted:

pretend I 1-lined this because it's definitely possible
something like
code:
ls "." >>= mapM getStat >>= (sum . map (fileSize . snd) . take 5 . sortBy (compare `on` modificationTime)) >>= print
Do you know why the following doesn't work?
code:
Prelude Turtle> ls "." >>= mapM stat

<interactive>:25:12: error:
    • Couldn't match type ‘Turtle.FilePath’ with ‘t Turtle.FilePath’
      Expected type: Turtle.FilePath -> Shell (t FileStatus)
        Actual type: t Turtle.FilePath -> Shell (t FileStatus)
    • In the second argument of ‘(>>=)’, namely ‘mapM stat’
      In the expression: ls "." >>= mapM stat
      In an equation for ‘it’: it = ls "." >>= mapM stat
    • Relevant bindings include
        it :: Shell (t FileStatus) (bound at <interactive>:25:1)
Prelude Turtle> :t (mapM stat)
(mapM stat)
  :: (MonadIO m, Traversable t) =>
     t Turtle.FilePath -> m (t FileStatus)
Prelude Turtle> :t (mapM)
(mapM) :: (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b)
Is the problem that Shell isn't traversable?

mystes
May 31, 2006

NihilCredo posted:

for comparison, this is its cousin f# interactive:


and c# interactive


sure would be nice if we didn't need the boilerplate imports or the double semicolons, and had a few basic aliases like ls and run

oh, and didn't need to pay attention to case
I feel like c# and f# are like 95% there already, which makes it weirder that Microsoft felt the need to create powershell. Seriously can someone just create a repl that shows the current path and imports useful stuff automatically?

Also, I should probably use f# more. I wish there was an interpreter/repl for it for .net core.

mystes fucked around with this message at 15:53 on Sep 6, 2018

mystes
May 31, 2006

Oh another haskell thing: there's a new "Simple GHC (Haskell) Integration" plugin for vscode that has no dependencies (it just uses ghc). It's a little bit buggy but I can at least get it to work mostly which is more than I can say about the older pugins that use intero, etc.

(What's funny is i looked on r/haskell to see what IDEs people are using now, and the most popular recommendation now seems to give up on the idea of getting syntax error highlighting and type information in the IDE and use ghcid in a separate window which I think is a good illustration of how loving horrible the haskell tooling situation is.)

Also, it's funny that if you try to google how to add dependencies to a stack project, pretty much every site says to add it to the Cabal file, but apparently now you have to add it to the package.yaml file instead.

mystes fucked around with this message at 16:01 on Sep 6, 2018

mystes
May 31, 2006

NihilCredo posted:

i deactivated every haskell plugin i had and activated that one. it does absolutely nothing for me, it doesn't even seem to recognize .hs files (they say 'Plain text' in the bottom right and when i searched the marketplace for extensions supporting it, simple ghc did not show up). adding the ghci folder to PATH didn't seem to help either
I think you also need to have the haskell syntax highlighting plugin installed even though it isn't included as a dependency.

By default it autodetects whether you're using stack based on the presence of package.yaml and you shouldn't need the ghc executable to be located in a folder in your path in that case (it will run it via stack). However, it doesn't seem to show any errors if it has trouble running ghc for some reason.

It seems to be alpha quality but I still prefer it to the alternatives.

mystes fucked around with this message at 17:46 on Sep 6, 2018

mystes
May 31, 2006

NihilCredo posted:

installed that plugin, the syntax highlighting works but no type integration yet

i'm in the folder of a stack project that builds (stack new HelloWorld yesod-sqlite).

fake edit: ok, i found a 'GHC' entry under terminals where the following lines appear when I open a new .hs file:


i'm guessing the hspec dependency is being a problem? any idea how i can fix that?
I don't understand the haskell tooling well enough to say why this is happening, but it looks like you can fix this by forcing stack to get some additional dependencies:
code:
stack build hspec
stack build yesod-test
These are presumably dependencies of the project and not the plugin, so I don't understand why these are needed when the plugin tries to run ghci but not for stack build; are these associated with different targets than the executable or something? (I assume that this may partly be a bug with the plugin in that it doesn't run stack ghci with the proper command to pull in the packages for some reason?)

mystes
May 31, 2006

NihilCredo posted:

thank you! did you find the solution on google? after i fixed the hspec dep, it did indeed require yesod-test as well, but i hadn't posted that
No, I just tried it myself after your post.

quote:

no type lens yet but at least errors and completions work
For me the types work, but as with all the other vscode plugins for haskell, you can't see them until you get rid of all errors in the file.

mystes
May 31, 2006

Finster Dexter posted:

cjs: trying to run Go tests and bypass the cached test results, i.e. force the tests to run even if no code change was detected.

I looked through the docs and nothing is listed as a way to disable the test caching. Oh but I found a github issue where someone asked this and after being told that github isn't an appropriate place to learn go, was directed to the release notes for Go 1.10.


How the flying gently caress is -count=1 ~~idiomatic~~? That's about as idiomatic as those knucklehead git commands posted a few pages back.

There's a light at the end of this tunnel though... as we might be ending this horrible Go excursion and go back to the original .net core platform we were originally going to use. I won't go into exhaustive detail, but the Russian contractors managed to pull their heads out of their asses and fix some of their broken-rear end .net poo poo so we might have a usable codebase from them.

I am so seriously sick of Go's "idiomatic" bullshit right now.
To be fair:

quote:

id·i·om
ˈidēəm
noun
1. a group of words established by usage as having a meaning not deducible from those of the individual words (e.g., rain cats and dogs, see the light ).

mystes
May 31, 2006

Now that you jerks got me to try haskell again, I figured I might as well attempt to use it for a codingame problem, but it involves lots of IO of course so I'm trying to use StateT and stuff and it's pretty confusing.

mystes
May 31, 2006

gonadic io posted:

will happily review code. i found lens simplifies StateT use because you can more easily pair a `StateT Int a` and a `StateT Int (a, b)` and stuff.

in general all your game functions should be pure and then the io only really happens in the main loop

draw :: GameState -> IO ()
update :: float -> GameState -> Input -> GameState
where the float is dt or something

here's a half-finished example with Gloss that I did back in my heavy haskell days: https://github.com/djmcgill/Fight-puck
I got it to compile, but I realized the way I was doing it was dumb, and I probably should have just used recursion or something so I could keep all the io in the main function like you said. I don't think I actually needed StateT, it just occurred to me as a way to translate an obvious way to organize the code similarly to how one might do so in an imperative language.

Anyway, I realized I misread the problem anyway and the correct version of it sort of seems like too much of a pain to do in haskell for me right now, so I'll probably do a different one, but I'm glad I got the monad practice anyway.

Thanks for offering to review the code; I'll probably take you up on that offer on whatever I try next.

mystes
May 31, 2006

Chalks posted:

code:
10.20 * 100
1019.9999999999999
Thanks javascript.

Thavascript
That's not really a javascript thing; it's how floating point arithmetic works in all languages, although some languages also have built-in arbitrary precision decimal types.

mystes
May 31, 2006

Finster Dexter posted:

The good langs do.
If you put it like this, languages like Rust that try to have as little in the core language as possible will never be "good langs" though.

I personally prefer to have a bit more stuff built in, but in 2018 I'm not sure you can decide whether a language is good or bad based on whether you have to pull in extra packages for stuff like this.

Of course for javascript in the browser it's more of an issue.

mystes
May 31, 2006

This doesn't even loving break anything and yet all these crazy people are getting upset that python isn't going to use the word slave any more.

mystes
May 31, 2006

Symbolic Butt posted:

the1percent/the99percent
Capitalist/proletariat

mystes
May 31, 2006

My favorite OS

mystes
May 31, 2006

It must be difficult for Facebook employees to choose between not-javascript, not-ocaml, and not-PHP now.

mystes
May 31, 2006

Vscode also appears to work to some degree for rust if you're willing to wait 5 minutes every time you stop typing for errors to appear.

mystes
May 31, 2006

white sauce posted:

let's say I want to make a program that inputs the number of days, weeks, and years and outputs that time into minutes. I wrote this thing


The code runs, but I'm concerned that the result could be more accurate, since we know that there's 525,949.20 minutes in a year...

should I worry about this decimal in the amount of minutes in a year? How can I fix my code so it works with that fraction?
Don't write your own date/time handling code. The number of minutes in a year varies.

mystes
May 31, 2006

The_Franz posted:

i'm guessing the op's teacher won't accept that
OK, I guess if it's a homework assignment that's different, but this is one of those things that people should know that they shouldn't try to implement themselves in real life.

It's like trying to roll your own crypto.

mystes
May 31, 2006

They should add status code 420 (Bad Decision by CEO)

mystes
May 31, 2006

CRIP EATIN BREAD posted:

plus its a real ide, and not some electron-based text editor nightmare
And yet it's somehow way slower than vs code.

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

code:

blacklisted_names, "blacklisted_names", ["foo", "bar", "baz", "quux"] => Vec<String>)
Quick, somebody do a pr to add master and slave.

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