/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1546625417644.jpg (480x440, 77K)

Other urls found in this thread:

mywiki.wooledge.org/WordSplitting
mywiki.wooledge.org/BashFAQ
rosettacode.org/wiki/FizzBuzz#Haskell
youtube.com/watch?v=f84n5oFoZBc
stackoverflow.com/questions/13913174/encapsulation-vs-information-hiding
twitter.com/NSFWRedditVideo

Lisp is the most powerful programming language.

Not anime, fuck off.

nth for Nim!

What is it, if not anime?

is yegor trolling or clueless?

New thread when?

>No its not, because the two are inseperable.

the most important concept in programming and computer science is abstraction. Read SICP.

yes

thought so

Who's yegor?

yegor256 or yegor265 i forget which

pretty much

>oh im so smart i escaped the blub i switched from java to c#

based and redpilled

any fun web app project ideas for me to tackle this weekend?

yes

Anonymous gay dating site

I am developing a text boars in python

I'm choosing a format to use for my data (loads of experimental mixed-type data, mostly float32, strings, and ints, one data element might be a large array of float32 with a random amount of any set of datatypes).
Currently I use hdf5 because it just werks in python with pytables, but it's not portable across languages and the one implementation of hdf5 is really obscure on some points (notably strings).
The only real alternative I'm aware of is using the file system, deciding on an endianess, and using tar + mmap + binary dumping.
One concern with this is that I would like to compress the data (the arrays often don't fit in memory at all, and still represent a decent chunk of space on disk).
Finally, I want to explore using other languages than python since it has historically been a bottleneck for us.

- Where should compression be installed in this scheme?
- How do I deal with my data in common lisp? cl-ana and hdf-cffi don't work with strings at all and fail to read any of the data completely if strings are used.
- What about tar + mmap + ? There's an mmap cl implementation and a tar one, but would they play nice together? Can a stream be created from the memory pointer given by the mmap library?
- Do other languages play nice with that kind of scheme? Might be a mess in C or C++ for example. What are the tools for these there? Then again, hdf5 is basically unusable outside python, java, julia and matlab.

java isn't so bad. I mean it's not great but it's decent language to get things done
now call me a pajeet

Or be a man and get them done in C++

haskell isn't so bad. I mean it's not great but it's decent language to get things done

*board

It's really not. For small projects you're spending 3x more time than in shitlangs like python because of boilerplate. For exploratory work you're wasting infinite time due to the build-run-close-edit cycle. For high-performance you're fucked by the gc.
Poo somewhere else pajeet.

>*segfaults*
heh, nothing personnel, kid

error messages longer than actual code

What is your %time breakdown of actually creating something vs. debugging? I have been recently conned at work into writing my own code for some things and generally just bang my head against it until it works, maybe 20% creating, 80% debugging. People that I work with that are actual programmers say that isn't unusual. What does your time look like?

What important things should I learn about Bash?

Idris is much better for both small projects and exploratory work.

>"downloading" a language
>having to install a McAfee
>write hindi boilerplate
>get NullPointerExceptions
>Oracle owns your "program" if it runs
yeah no

>haskell
Been a few years...
What's the situation like with stack and cabal now? Is it still shit?

How come you spend so much time debugging? Do you actually know what you are doing or you just bang the keyboard with your head until the bug fixes?

If you can live with the disk space, what about using something berkeley db? There's probably bindings for most languages. tar + mmap seems like a pain in the ass, especially the tar part. You can store the files on a compressed filesystem.

mywiki.wooledge.org/WordSplitting
mywiki.wooledge.org/BashFAQ

She said C not C++

>How come you spend so much time debugging?
Because that is required to turn my nonfunctional work into functional work
>Do you actually know what you are doing
Not really
>you just bang the keyboard with your head until the bug fixes?
I typically start by writing a script that does everything I want to do, none of it works, then I start dividing pieces of it until I get one tiny part to work, then work back through everything else. Is this not normal?

I SAVED THE COMPILER
All I had to do was replace if else syntax with guard syntax. Now I don’t need an ugly return keyword and can complete the no AST challenge.

Attached: A3084549-8840-4E14-BFF7-42A32CA01AD2.gif (500x443, 495K)

I am thinking of making a simple cross platform gui for lldb (llvm version of gdb). The only other gui versions exist only as part of a bloated IDE or some shitty web interface, but the terminal interface for debuggers are essentially unusuable.

Any reason that's bad idea?

What is better/faster in java?
for (int i = 0; i < 10000000; i++)
System.out.println(i);
}

or
String msg;
for (int i = 0; i < 10000000; i++)
msg += i + "\n";
}
System.out.print(msg);

I know that in C++ a million cout calls is way slower than one string stream and one cout call

>system i/o is somehow fundamentally different b/w langs
last time I was in India, I remember a StringBuffer class

measure it

well one of these generates a ton of garbage so not that one

On average it should hit 50/50 for professionals. But that depends on the specific activity. Some problems are so well specified you'll never be debugging, and some are so ill specified you'll basically be doing bug-driven development.

>debugging
lmao, just do TDD, rajeesh

Fizzbuzz in Haskell, please.

tar can be opened in-memory to consult the contents of the file as if it was a normal directory. But combining this, compression and mmap all together isn't as simple unless language facilities or libraries help with this. And it would be counterproductive to have to do a lot of work in many languages to share data.
While I would avoid anything related to oracle due to very bad experience in the past with their offerings, I considered using a DB.
The problem is the translation between language object text (-> query) db representation can be cumbersome, slow and errorprone.
It's a decent solution if using the filesystem is not as language-portable as I first thought.

It's not. You usually do a small part, test that it kinda works, move on, find out it broke because of something, go back to debug it, and continue.
Even in top-down programming, you would write stubs for everything and work on one functionality at a time.

Yeah documentation says its faster so ill try it out
No time
Wait which one?

>Yeah documentation says its faster so ill try it out
>Wait which one?
learn how strings work under the hood, and what a buffer is

If you're coding against some real hardware or even against some API, then yeah, what you expect and what actually happens may be two very, very different things. If it's integrating something into an existing system with tight constraints I mostly spend most of the time thinking where and how I would fit what I need to do in it. But if I do something new and it's all on me, I usually do lots of exploratory work. I try to see what works, looks, feels better.
In any case, you have to divide the problem into feasible parts, all of which you can attack. Basically what said

>I know that in C++ a million cout calls is way slower than one string stream and one cout call
are you using endl instead of '\n' on every call?
that will slow things down horribly, since endl forces flushing the current buffer to the screen immediately

In Java, what does the following mean? Why is it within curly braces?
static { RuntimeMetaData.checkVersion("4.6", RuntimeMetaData.VERSION); }

Static block. gets executed when the class is initialized, ie at the same time that the static fields are initialized.

That's a static initialization block. You can place it in a class to automatically execute that code when the class that contains it is loaded.

Thanks.

>tar can be opened in-memory to consult the contents of the file as if it was a normal directory
You can do that with bdb too, it's basically an optimized on-disk hash table.

>While I would avoid anything related to oracle due to very bad experience in the past with their offerings, I considered using a DB.
It's free software, it goes back to way before oracle. It was original created by BSD to replace the patented AT&T UNIX db.

>The problem is the translation between language object text (-> query) db representation can be cumbersome, slow and errorprone.
In bdb you have to handle serialization yourself but it is fast, like for your large arrays when it's native endianess in C it's just (type *arr = data). You could have optimized routines for converting data too.

It's something to consider instead of flat files or tar.

>You can do that with bdb too, it's basically an optimized on-disk hash table.
Yes, I was trying to point out that tar itself is not the bottleneck in terms of usability here.
>It's free software, it goes back to way before oracle.
The same is true of most oracle offering, but in our experience, they offer buggy, memory leaking, slow software with very enterprisey-focused APIs which are not appropriate for our use cases.

Eitherway, I guess that's another possibility to evaluate.

There are better JVM languages though.

People learned stuff since Java was first released.

{-# LANGUAGE MonadComprehensions #-}

import Data.Foldable
import Data.Maybe
import Data.Monoid

fizz :: Int -> Maybe String
fizz i = [ "Fizz" | i `mod` 3 == 0 ]

buzz :: Int -> Maybe String
buzz i = [ "Buzz" | i `mod` 5 == 0 ]

fizzbuzz :: Int -> String
fizzbuzz i = fromMaybe (show i) $ fizz i buzz i

main :: IO ()
main = traverse_ (putStrLn . fizzbuzz) [1..100]

>I have been recently conned at work into writing my own code for some things
lol I love this phrasing

Rosetta Code is good for this sort of question.
rosettacode.org/wiki/FizzBuzz#Haskell

i bought an esp32 but don't really know what to do with it. I wanted to do a botnet thing tracker that would record SSIDs nearby, send them immediately once an open network is found (not an issue where I live) and then I would look the networks up in the Google botnet for a location

youtube.com/watch?v=f84n5oFoZBc

Ok added scrolling. It slows if you do anything greater than ~10000 though

Attached: Screenshot_20190202-174500.png (1080x1920, 250K)

That's an interesting use of list comprehensions.

I don't underst syntax. I haven't gotten up to learning about monads yet.

Is it possible to do it with Prelude only?

is semigroup append.
>Is it possible to do it with Prelude only?
main :: IO ()
main = do
putStrLn "1"
putStrLn "2"
putStrLn "Fizz"
putStrLn "4"

etc.

Entirely subjective. Reliance on abstraction and moving further away from hardware has consequences more nuanced than simple performance concerns. Ideally a balance should be struck between providing common macros and subroutines, while still keeping the programmer mindful that they are working with a stateful machine.

On top of that, in this context, you are wrong. Function pointers are an explicitly provided abstraction that exist solely to allow the interpretation of data as code. Methods do not abstract this any further.

never had an issue with cabal, but that's just me. I heard stack is the second coming of god or some shit, but I've never used it.

What do you guys think of Ruby on Rails?

Who?

Ruby is the best scripting language
idk about rails

>Ruby is the best scripting language
Why?

I've worked in javascrip, perl and ruby. Of those three I had most fun with js and the most miserable time with ruby.

Ruby is a painful language with its stupid loops, weird syntax and implicit returns. Python and JS are so superior to Ruby that it's not even funny. Even PHP or memes like Lua are better.

Finally started going through the tour of Go and exploring some language features today. I'm honestly liking what I'm seeing so far.

>why?
everything is an object; blocks; chaining methods; functional aspects; optional parentheses; multiple ways to do things; POLA; great regex etc.

Ruby is goat
Ruby on Rails is gay

StringBuffer is useful if it needs to be threadsafe, but string builder is otherwise faster.

That said, the Java will usually optimize away multiple concatenations into a stringbuilder automatically.

What is the difference between "encapsulation" and "information hiding" in the context of abstract datatypes? I don't understand. I thought they were the same thing.

why does this matter? and who's been messing with your head, user?

stringbuilder
then print

thx for summarizing all the previous posts

It matters because I'm taking a course, and one of the assignments insists that i should understand the difference.

>Encapsulation
> How did you encapsulate the code for the data representation and its associated operations inside a programming language construct?
>Information hiding
> How did you hide the internal data representations and non-interface functions associated with your implementations from the user?

>Note: Make sure you understand what the concepts mean, especially the difference between encapsulation and information hiding

I don't understand.

encapsulate: dog can give a paw handshake and pee

information hiding: anyone can ask him for a paw handshake, but peeing is a private thing

Just doing some babby shit on exercism.io to learn ruby better
also practicing lots of LeetCode/HackerRank/Codility stuff since I'm unemployed and have interviews coming up

stackoverflow.com/questions/13913174/encapsulation-vs-information-hiding

Encapsulation

Ensures that the behavior of an object can only be affected through its API. It lets us control how much a change to one object will impact other parts of the system by ensuring that there are no unexpected dependencies between unrelated components.


Information hiding

Conceals how an object implements its functionality behind the abstraction of its API. It lets us work with higher abstractions by ignoring lower-level details that are unrelated to the task at hand.


Such a trivial inconsequential difference. Maybe change schools if this is the focus lol.

What?

>Maybe change schools if this is the focus lol.
The quality of the teachers doesn't depend much at all on the quality of the school. MIT is not a good school because the teachers are good. It's a good school, because the students are really smart.

The more I read about Nim the more I am overwhelmed with possibilities it gives, especially as I'm coming from a java background.
Will Nim ever gain serious traction?

I honestly still don't understand the difference.

The only way to ensure that the behavior of an object can only be affected through its API is to conceal everything that's not the API. And vice versa.

1.0 RC is coming out fairly soon so probably.

basically the same, without the fancy monad comprehensions
fizz n = case (n `mod` 3) of
0 -> Just "fizz"
_ -> Nothing

buzz n = case (n `mod` 5) of
0 -> Just "buzz"
_ -> Nothing

fb n = f (fizz n `mappend` buzz n)
where f (Just xs) = xs
f _ = show n

fizzbuzz = mapM_ (print . fb) [1..100]

>I honestly still don't understand the difference.
cuz it's literally splitting hairs

just go with:

objects encapsulate: by using private scope info hiding

I'd hire the guy with the my little pony resume over a typical /dpt/ poster.

Cool. Thanks. I understand most of that.

But I thought Haskell was supposed to be terse.

Haskell is a neat language, in that there's so many ways to do things, you can usually tell someones skill-level by how terse their haskell is.

>1.0 RC is coming out fairly soon
[citation needed]

Why is this mess being shilled for constantly here? That looks utterly horrible.