/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1543316519648.png (1280x720, 818K)

Other urls found in this thread:

people.cs.aau.dk/~normark/prog3-03/html/notes/oop-scheme_themes-classes-objects-sec.html
en.wikipedia.org/wiki/Edit_distance
twitter.com/SFWRedditVideos

nth for nim!

Haskell is cute!

Attached: 1537985908896.png (1075x1518, 1.76M)

Writing a reporting engine in Go

>announcing your (engine's) reports

For anyone interested for purely theoretic reasons,
∃n≥1. T × (T 1)n
is an example of a (linear) type that can only be dropped if T can be cloned

Whoops, that should be T -> 1. Surprised the other unicode characters worked desu.

i wrote a compiler for an untyped garbage collected functional programming language and decided i can finally call myself a programmer - i wrote it using python and C

now i want job, so i looked at some ads and a lot of them ask for 'front end developers' using js libs like action and node and whatever
OR they want java and C# shit
there is also some python here and there

what do?
should i learn the front end shit (ill make quick work of it, already know a bit webdev) and go for that
should i learn C# or java, which one then

oh, and i don't have a degree in anything [spoiler] except nursing [/spoiler]

>i wrote a compiler for an untyped garbage collected functional programming language
>now i want job

Attached: 36743.gif (500x281, 855K)

I made a text version of minesweeper in C in one day

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

TypeScript paper

I dont get it whats the difference between a function and a class?

Attached: Paper+beats+rock+scissor+beats+paper_8a8f85_3912987.jpg (640x480, 23K)

one serves alcohol.

sand him down dumbass

It literally has nothing in common, learn what a class is

A class describes an object, it can have variables and functions

a function can be an object and a class
an object can be a function

No, you can just slap some shitty syntax on top of those to make them look like each other.
A function and data are different things.

depends on the language what a class and a function is

in a language where functions are first class objects they can easily be classes too, use inheritance and all that

Are you that guy that said "all languages are basically the same" from yesterday?

Anime won the dpt thread wars

no
but concretely, functions and classes depends on the language, obviously
how can i be claiming they are all 'basically the same'

i am literally avoiding generalizing and making a concrete statement

the thread wars never end

I just meant, he was pretty brazen with his Mt. Stupid shit just like you are right now.
also I'd like to see a language that lets a FUNCTION be a class.
note, i said FUNCTION, nothing else.

scheme
functions can have local state as variables
inheritance works by creating an instance of the parent (as local state) and calling it's functions as methods when needed

>certain lambda expressions will be regarded as classes, and certain closures will be seen as objects.
>Due to (1) the first class status of functions, and due to (2) the use of static binding of free names, it is possible to interpret a closure as an object
>With this interpretation, it is possible to regard certain function definitions as classes
people.cs.aau.dk/~normark/prog3-03/html/notes/oop-scheme_themes-classes-objects-sec.html
zzzzz

with a baby high level language maybe

yeah, as you said it literally 'lets a FUNCTION be a class'

it's literally what you said here

function pointers != function

Java ditz from yesterday with a question _>_
I currently fill my Array list by adding the objects one by one, i want to fill it using a for each loop but i can't understand how to format it, pls sned help.

Engineer one = new Engineer("Lucy", 0);

ArrayList engList = new ArrayList();

for (Engineer e : engList){
engList.add(e);
}

I have ten objects in total if that helps, thank you to whoever helps me.

so your argument is that scheme doesn't actually have closures and functions, it just has function pointers
so the thing you quoted here is actually irrelevant to your argument (it actually contradicted you) and im supposed to forget you even posted it

so next time i load up my scheme i will make sure to remember to think of the function pointers, the environment pointers to the heap and the garbage collector using the pointers to do its job, because it's not functions, but function pointers

Lisp is the worst programming language.

No I'm merely saying function pointers aren't the same thing as functions. So your original comment was wrong. and closure classes are fucking stupid.

haskell is not a functional programming language
it's a pointer-to-functions programming language

and closure classes may be stupid, slow, garbage, whatever you decide, but they do exist in some languages
>your original comment
what comment, i made a lot of comments
unlike you, i try to quote precisely where you said something i disagree with

>haskell is not a functional programming language
Peak retardation on Jow Forums today

Haskell is a programming language that most would consider of the "Functional" type, yes.
Granted I'm being a pedantic faggot because I knew what you meant the whole time. LIsp isn't the only language with FCF. But you should be precise, especially when i give you extra warning. So you can avoid dumb conversations like these.

Haskell is not a functional programming language
Haskell is a fun programming language

Attached: karen haskell.png (1280x719, 818K)

can't spell functional without F U N

>when you spend more time posting anime girls reading SICP than programming

please do not bully

Attached: 1529888535943.jpg (1920x1080, 290K)

I never used any of these books and I'm a better programmer than most people here. Read actual code instead of these shitty books.

i don't actually read these books user

Attached: 1541009643199.png (460x460, 634K)

You actually can.

>I'm a better programmer than most people here.
do you believe this is a high standard, or something to aim for

I'll bully you all I want you trendy fucking CS student who thinks they're a computer wizard because they read a book instead of ever actually writing a program

"F U N".lower.trimWhitespace

Attached: 1495863346797.png (441x421, 176K)

Holy shit my mom walked into my room right as I clicked on this image. Now she thinks I'm a pedophile. FUCK YOU. FUCK THIS SITE

owned

Attached: required reading for (You).png (528x528, 381K)

vimtutor is so boring. Any other way to learn vim that's fun and doesn't require attention?

Vim requires autism to learn,you're outta luck

Yeah, start using it you lazy ass faggot.

AAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHH

I think i'll just stick with Vscode. It's superior to that trash anyway and I'll spend my time becoming a better programming instead of wasting it on learning ancient technology.

sourgrapes.jpg

What makes you think that Vscode is superior to vim?

Learn Emacs, user. It's superior to vim and easier to learn.

What is the point even of the self parameter in Python? Why not implicitly add it to every class method if I can't even call the method without it? I mean even if I want a method to be static I still have to explicitly add @staticmethod to it.

What is the added value of having to add self to every parameter list?

It works and has everything you need, unlike Vim.

and "self'"is confusing. Why not just call it "object"?

>It works
I started vim and it works just fine.
>everything you need
Tell me, what does Vscode offer that vim doesn't?

python is a retarded language for retarded babies

in other words, perfect for you

fuck you.

Haskell is not a functional programming language.
It's a 1 gigabytes of garbage per second programming language.

Because it's the syntax they went with for allowing what is basically the equivalent of a static function.
class test:
def foo(self):
print("foo")

def bar():
print("bar")

var = test()
var.foo()

test.bar()

You made the right choice

Not him but VSC just requires a lot less setup, no external config, no third party plugin manager. Has much saner and streamlined default behavior. Which is not really Vim's fault, as it's selling point is incredibly minimal and makes zero assumptions about what you want. And then you have to spend an afternoon planning out, testing, and refining your binds. And thinking about what other basic functionality you're overlooking. While VSC has 75% of what you want already and everything else is a few keybinds away, and you don't have to re-source a config. On top of having several vim extensions to get the superfluous binds that makes vim so great.
tldr: VSC is great for short term productivity, vim takes quite awhile to get there.
t. someone bouncing between the two right now

What's the difference between a static and nonstatic function? I see that in java but I have no clue what it means.

>Not him but VSC just requires a lot less setup, no external config, no third party plugin manager.
I agree that out-of-the-box VSC comes with more features than vim (including spyware). The default vim configuration is the bare minimum. So it requires more time and effort to set it up to your liking. However, that's the power of vim. You can shape it to be your dream editor. Either packed with features, or a more minimalist approach. VSC doesn't even come close to this level of configuration.
>While VSC has 75% of what you want already and everything else is a few keybinds away
Not everything is accessible with keybindings.
>On top of having several vim extensions to get the superfluous binds that makes vim so great.
I tried a vim plugin in VSC, but there was a noticeable lag when moving the cursor.
t. someone who used vim for ages and VSC for half a year.

A normal method is associated with an instance of a class (therefore it takes the self parameter).
A "static" (java terminology) method is associated with the class itself, but not any particular instance of a class, so it doesn't take a self parameter. It's basically just acts like a normal function.

>VSC doesn't even come close to this level of configuration
Like what? Give a concrete example

- Customizing the status bar
- Customizing the tree explorer

Trying to get into programming, working on some exercises:

Alphabet A = a, b, c
Seq. 1 over A = bccabcb
Seq. 2 over A = aac
ED = 5

I need to find the shortest third sequence Seq. 3 which has an edit distance ED of 5 or lower to both Seq. 1 and Seq. 2.. All edit distance operation weights are 1.

How the hell do I approach this? Just brute-force by starting with test sequences like a, b, c, ab, ac, bc etc.?

what else do you want on the status bar?
And what else would you even want to do with tree view?

That's a pretty intense problem for someone "trying to get into programming".
There is a well-established algorithm for that problem. Just read en.wikipedia.org/wiki/Edit_distance and the places it links to.

We were talking about the level of configuration, not whether the default is sufficient for your particular needs or not.

well just because you can change X doesn't make it a feature by itself.
If you can change X to gain Y functionality, then that's a feature.
The only thing I can think of that was decent, was I had some Vim plugin that would show the error from my linter below my terminal. Granted if the terminal would auto-scroll by default, I really wouldn't have needed it. But I can't think of anything for tree-view. But I guess VS Code has editor groups you can scroll between, but I never use it.

Technically with long strings you can cast a smaller type (char) to a larger type (say a 32-bit int) and AND the bits. You have to do a bunch of work to make sure you don't reach out of bounds, or just pad the string to check with enough 0's to fill it out.

A slightly faster check (that works at char level) would see what you start with, and then increment to the next letter and check the next. If b was the first, you'd check for c following. If it does, you have two in a row. Depending on what you're looking for, it's much cheaper to start with what you have, and then follow from there. Even more, you can selectively test what you're looking for and record the relevant information.

Your question uses a bunch of non-standard phrasing: "edit distance"? "sequence"?

does anyone here know a thing about javafx?

how do i display a specified part of a scene and crop out the rest?

Okay, Wagner-Fisher seems like a good place to start to at least calculate ED. Then I'll move on to whatever this Ukkonen guy did.

Edit distance is linked above by user. Sequence is just a regular old string.

I hadn't heard edit-distance before, seems it's a rather specific thing open to a lot of numerical interpretation.

Sequence imo refers to a specific pattern. If you say you have a "sequence" without saying what the pattern is, it'd be a useless statement. Normally we refer to a bunch of letters/symbols as a string. Just my opinion tho.

>well just because you can change X doesn't make it a feature by itself.
That's true, but the ability to change X gives you much more flexibility in writing plugins. This allows for more features.
>If you can change X to gain Y functionality, then that's a feature.
This is incorrect. Losing functionality can also be considered a feature. e.g. a less cluttered window.
>The only thing I can think of that was decent, was I had some Vim plugin that would show the error from my linter below my terminal.
Which can be provided if X can be changed to your liking.

That sounds right, I should've just called it a string.

Not him, I've been looking for some "basic" features of a text editor:
>multiple panes, horizontal, don't need vertical orientation
>updates each window
>detects filechanges
>preferably syntax highlighting for C and Perl, not necessary
>if syntax highlighting is available, customizable theming that doesn't require recompiling the whole piece of shit or using a different system than the fucking built-in themes use (looking at you fucking notepad++)
I have literally only known of Epsilon to support all these. Tried Atom 2, it doesn't detect file changes (the plug-in doesn't work), when it's fucking git-oriented. Very few editors support more than two panes and pane-separate tabs.

I assume the old gnu based crap like vim could support it but it's beneath them to support a fucking "press a key and get the character" on the screen interface.

If a function has state, it's a procedure. If a procedure can be instanced, it's a class.

Not that hard.

Vim has an auto-saver plugin.
and once you swap esc and caps, you get used to normal/insert mode
The only mild pain, is you'll want to re-bind the action to switch focus from a terminal back to normal mode. Because the default one is p

Could I just not have the shit command interface? I seriously never found a use for bullshit like swapping and copying lines and randomly dropping out of editing characters back into the command interface.

What the fuck? What/where are you learning from?

sure, just use VSC or something.
But normal mode is pretty cool once you get used to dd y and p, instead of slowing down to hit ctrl to copy and paste. Don't know how you never use line swapping though, It's really handy.

Is it possible in C++ to have a template specialization on a single member only?
for example:
enum Type{
CHAR,
INT,
STRING
};
template
struct Foo{
T foo;
Type get_type();
}

so Foo::get_type() return CHAR when T is char, INT when T is int, and STRING when T is char const *,
and compilation error on type other than those 3

Guys how do I use a terminal inside vim like how
I could in vscode?

Why is this a member function? I'm trying to understand the context for this.

esc :terminal
add this to your config and remap ; to whatever you want. Or change to
:nnoremap ; :split:terminal

it will make split your current pane and add a horizontal terminal to the bottom. So if you have nerdtree, remember to switch out of it first. also install neovim.

the for loop in your sample code isn't actually doing anything because the array list: engList, is empty so the for loop will exit immediately. In other words you are iterating over an empty list.

you don't really need a for each loop to accomplish what you want:you can have a regular for loop going from 0 to 10 (make a 10 a variable so that it's easy to change if need be) and fill the array that way.

is there a reason you want to use a for each loop?

you'll also want this for when you want to switch out of your terminal most likely.
:tnoremap p

been a while since i've worked with fx, but there should be something like a viewport for your scene, or stage or whatever it's called, that you can set the size for, if that's what you're looking for

hope it helps

you can have a static assert on top of your struct, or have a template parameter check in the template declaration itself to check whether the given template type corresponds to what you need it to be and cause a compile error if it doesn't

This doesn't work.