Distro "I'm not a programmer" Tube: Hey lemme make an app real quick and show my viewers on UA-cam how it's done. For real tho, this is some really cool stuff. Good on ya!
When we are taught to write at school, we don't worry about whether or not we are or will become a writer. Learning to code makes someone a programmer to the same extent as millions of people are writers, artists or musicians. Being a career or professional in a field is unfortunately often described with the same word.
Great video! I’ve been programming in Haskell for a while now but only terminal apps so it’s nice to see that gtk isn’t quite as intimidating as I thought. A little note on programming: On your next project, you REALLY don’t wanna copy and paste as much as you did, especially if you’re gonna make something bigger. Instead of putting everything in main, you could’ve, for example, created a function for creating a button and, instead of repeating the code 7 times, just call that function 7 times with different parameters. Might seem like a bit more work but it makes the code a lot more organised and easier to maintain.
If it's a very small project, I lay out the blueprints in the main function and write enough code to know what blocks of code are eligible to be extracted as a function and what can stay in the main function. That way, I can see what state is essential to be localized and what could be "global state" as a code smell I have to fix. State aware programming > KISS programming > OOP >>>>>> Class oriented programming
@@p4trickb4tem4n value/values that decide what have happen in the program. Like if you have a game that sum up die throws. State is all outcomes of the die thrown, and/or the sum of all die throws. So when you throw one more die, the state will be changed, that is the list of die thrown/total sum of all die throws. So it is what the program will calculate, from start value and all the changes that the program does to the state until the program is finished.
@@oddmerlin9797 Figure of speech. I was making a point. Emphasizing my agreement. Didn't actually scroll through all the way to the bottom to see every damn comment and who liked what.
This example was closer to coding and scripting, than programming. Once you use simulations, optimization, proof systems, semantic analysis, macros and etc for your code, then you become a real programmer. And then there are the domains, eg hardware, software, and theoretical. I am not a programmer.
Hey DT you probably should not create a binary for your repo or at the very least, you need to think about how to do it. Haskell dynamic libs tend to need a lot of rebuilds and you would also probably need to package a few of the libraries you use. So I would say that if you are going to you should use a static binary
Hey, DT! In programming, copying some chunk of code is kinda meaningless, you could just define a function 'btnWithCaption' accepting the name of button (caption), path to image file, row-column coordinates and callback function; returning the button object (which have image inside it) and the lable (caption) object and call it seven times instead of writing all the boilerplate code every time you want to create a button
Some languages make that sort of thing much easier than others. I don't suspect Haskell to be one of the easy ones... Sometimes you just need to make it work, and you can figure out the "correct" way latter. (especially if you aren't sure that "correct" is even possible, yet). Programmers are pretty good at over-complicating things sometimes ;) ...I think, usually, while the deduplication "function" can be pretty useful, writing the inlined version first helps you understand what the function actually needs in order to do its thing, anyway.
I'm not sure what the pattern would look like in Haskell, but there's a lot of repeated code here. I would recommend looping over an array of some structure that has all the information about a button (image path, label text, onclick function), and create them and add them to the grid in the loop. Also, it might be worth thinking about some more descriptive variable names - for example, btn1 doesn't tell me much about the variable, other than that it's a button. A name like cancelBtn, for example, tells the reader more about what that variable is used for when they encounter it elsewhere in the code. Edit: regardless, this is a great video showing the process of creating a GTK app in Haskell that is accessible even to people who have never used either. Thanks!
GObject introspection is great when moving around languages. If you know the format the function names appear in a language, you can basically translate all glib function names and so on in your head and just use them.
DT as a dev my self, always import your namespace/packages with a name like your Gtk var. this make it easy to fix bugs in your code when some time pass. it is a thing all Pro Devs do now, and in JS they make it the only way, it will save you so much time.
@@sc0or it what a ref. to the dt code, but what i am talking about is ex. import ThisPart from './file' or import {ThisPart, andThis} from './file' in JS the problem is a lot of languages let you drop all from a namespace(NS)/module/package in to your current scope, and a lot of the time you get stuff with the same name, when you call the one from NS 1 and then NS 2 is update and got a function with the same name, sometime it is a problem the language will tell you sometime not, sometime it will keep calling from NS 1 but where if you remove NS 1 and you think you get a error for all the places it was you, but not the place with this call because it is calling NS 2 now. there is a lot of other reasons you should always name your imports.
@@zeocamo So, you mean import {Button} from '@mui/material' and import {Button} from 'react-bootstrap'? If "yes" this is not a problem. First, you can choose a different alias WHEN you start using a different import, and secondly, this happens once per 500 projects. Yet more thing... How people switch from one import to another? Do they delete all "import" statements and then add new ones? I think no. They apply 'replace in files' for ...form "" endings. How a custom alias can help in this case, I have no idea.
@@sc0or i said JS got it right from start, you can only things the right way in JS but in other languages like c or c# you can drop all classes or functions in your local scope, with out a alias
As a haskell dev, I'm mildly surprised by you making this! But please write reusable code! Define a function that takes the image url, the putStr str, command, and then returns the button and label.
While as a programmer I totally agree with you, I believe he might have done this on purpose not to overload new to programming viewers with sophisticated concepts such as functions
@@heinwol "... programming viewers with sophisticated concepts such as functions ...." Yeah, functions are very complex, use calculus 2 up to 3 to make one, and very confusing, especially in Haskell.
yad --center --undecorated --skip-taskbar --timeout="5" --timeout-indicator="top" --button="Cancel:1" --button="Restart:reboot" --button="Shutdown:shutdown now" --button="Logout:killall openbox" ###logout will vary as to your WM
I'm just starting with DTOS, looks great so far 😊 One thing I'd love to do is put an html file as the background. Is there a way to do it with xmonad, or do I need to work with the root window? I can build a neutralino.js app that renders that file (with access to os functions) if that'd help.
@DistroTube Hello! I am programmer & I watch your vids about every day last few months! I learned a lot from you. Anyway, I have a recommendation for you: IPFS. I looked your older videos and id not find any about IPFS. It would be great, if you find some time for It. Keep the good job! Bye :)
What version of haskell GHC are you on? I get an error that it could install because of "Failed to build haskell-gi-base-0.26.0" and "cabal.exe: The pkg-config package 'gobject-2.0' version >=2.42 is required but it could not be found". Anyone with the same problem?
would be nice a second part refactoring the code to dynamically load config from a JSON file instead, containing [{ label, icon, command }] and replacing $user with the effective user name from the command string
I think the tool is great, the only thing I would add is the ability to type the escape key to exit the program. Does anyone know how to add a keyboardEventHandler in haskell? If so please share the boiler plate code.
`stack build` failed for me "while building package haskell-gi-base-0.26.0". I'm brand-new to haskell, so I'm not sure where the relevant error message is, but I also got "haskell-gi-base > version >=2.42 is required but it could not be found". I'm using macOS FWIW. Thank you!!!
The moment when he named his grid "grid" and said no need for long and complicated name... I saw it already in my mind how long and complicated grid name would be dt. Or gr. Haha.
So, in programming you are working inside a virtual environment when you setup stack. That is why GCC gets compiled inside that environment. I'm sure you are aware of this, but the technical way of saying this is that you are creating a virtual environment. Some programming languages have the capability to set-up a virtual environment, and others you have to set up a Docker environment or something similar.
No need for stack or aur. Just use the standard arch packages. The issue your having is haskell-gi-gtk is version 4. You need to remove that and install haskell-gi-gtk3 and then simply compile with ghc -dynaic Main.hs and your good to go. Assuming you installed the other needed arch packages haskell-gi and gobject-introspection
Whats the point of doing stuff like that in Haskell? The whole video you just was writing some imperative code that actually feels object-oriented and holds lots of state, just with getters and setters as separate functions.
Imperative? That's the harsh reality of working with a C library through cffi in a foreign language. That said, unlike python, you can easily compile your gtk app to a native binary in haskell.
Does cabal ensure the package versions you use are compatible and compatible with the GHC version your using? That’s really the reason stack exists. To avoid the ol’ cabal hell problem.
Why did you waste your time on learning vim, emacs and other marginal stuff that is useless in any team these days? “When I’ll be on an inhabitant island, and there will be x486 PC there...” is not a reason ;)
Distro "I'm not a programmer" Tube: Hey lemme make an app real quick and show my viewers on UA-cam how it's done.
For real tho, this is some really cool stuff. Good on ya!
"I'm not a category theorist by trait"
*Proceeds to define an endofunctor in Hask*
When we are taught to write at school, we don't worry about whether or not we are or will become a writer. Learning to code makes someone a programmer to the same extent as millions of people are writers, artists or musicians. Being a career or professional in a field is unfortunately often described with the same word.
Using GTK, straight code, no glade. You're a savage.
Mad respects.
Great video! I’ve been programming in Haskell for a while now but only terminal apps so it’s nice to see that gtk isn’t quite as intimidating as I thought.
A little note on programming: On your next project, you REALLY don’t wanna copy and paste as much as you did, especially if you’re gonna make something bigger. Instead of putting everything in main, you could’ve, for example, created a function for creating a button and, instead of repeating the code 7 times, just call that function 7 times with different parameters. Might seem like a bit more work but it makes the code a lot more organised and easier to maintain.
If it's a very small project, I lay out the blueprints in the main function and write enough code to know what blocks of code are eligible to be extracted as a function and what can stay in the main function. That way, I can see what state is essential to be localized and what could be "global state" as a code smell I have to fix.
State aware programming > KISS programming > OOP >>>>>> Class oriented programming
@@SimGunther what is state
@@p4trickb4tem4n value/values that decide what have happen in the program.
Like if you have a game that sum up die throws. State is all outcomes of the die thrown, and/or the sum of all die throws.
So when you throw one more die, the state will be changed, that is the list of die thrown/total sum of all die throws.
So it is what the program will calculate, from start value and all the changes that the program does to the state until the program is finished.
Nothing like turning an idea into a functional application. Very rewarding! Well done DT, more of these pls.
Distrotube has evolved from editing config files to making his own apps
"Well... here is how I do it"
Emacs lsp-haskell mode is nice for that. Auto completion, quick help are basically what you need.
22:00 GTK actually has a lot of built-in icons that you can scale and use :)
You're officially a programmer, meaning that you are on your way to knowing how impossible it is to be good at programming.
Well this is a relatively simple app. Follow his pattern and you’ll notice it. He did good tho
Underrated comment.
@@nassirmreyoud4415 but its currently the highest liked comment?
@@oddmerlin9797 Figure of speech. I was making a point. Emphasizing my agreement. Didn't actually scroll through all the way to the bottom to see every damn comment and who liked what.
This example was closer to coding and scripting, than programming. Once you use simulations, optimization, proof systems, semantic analysis, macros and etc for your code, then you become a real programmer. And then there are the domains, eg hardware, software, and theoretical. I am not a programmer.
GUI Haskell content is so lacking, this is amazing!!
really enjoying how you are making gui apps in haskell and making it looking like you've been doing it for a decade laying it out so simply
fantastic video!!
I know a little bit of Haskell and I really enjoyed this and also learned something new. Great video!
Ey yo sup! Happy to see the video up! :D
Hey DT you probably should not create a binary for your repo or at the very least, you need to think about how to do it.
Haskell dynamic libs tend to need a lot of rebuilds and you would also probably need to package a few of the libraries you use.
So I would say that if you are going to you should use a static binary
Nice video! I would very much enjoy seeing more programming and Haskell in the future!
Really liking this gtk tutorials :D thanks for the content!
Thanks for all your hard work my friend. You have inspired me to start a channel dedicated to game and simulator development on Linux. Wish me luck!
Well, this is it
This is the time when I implode from finally learning Haskell via this as my first project
Do it!
Saving this for later. Nice dude!!
Thanks, DT, very cool!
Hey, DT! In programming, copying some chunk of code is kinda meaningless, you could just define a function 'btnWithCaption' accepting the name of button (caption), path to image file, row-column coordinates and callback function; returning the button object (which have image inside it) and the lable (caption) object and call it seven times instead of writing all the boilerplate code every time you want to create a button
Some languages make that sort of thing much easier than others. I don't suspect Haskell to be one of the easy ones... Sometimes you just need to make it work, and you can figure out the "correct" way latter. (especially if you aren't sure that "correct" is even possible, yet). Programmers are pretty good at over-complicating things sometimes ;)
...I think, usually, while the deduplication "function" can be pretty useful, writing the inlined version first helps you understand what the function actually needs in order to do its thing, anyway.
More programming videos dt. they are really nice and entertaining(+u enjoy them, we enjoy them so why not)
I did that with Rofi. It looks cool for a minimal looking WM. I also have keybindings defined for each of those actions
Haskell content? I'm gonna smash that thumbs up button before playing the video
I'm not sure what the pattern would look like in Haskell, but there's a lot of repeated code here. I would recommend looping over an array of some structure that has all the information about a button (image path, label text, onclick function), and create them and add them to the grid in the loop.
Also, it might be worth thinking about some more descriptive variable names - for example, btn1 doesn't tell me much about the variable, other than that it's a button. A name like cancelBtn, for example, tells the reader more about what that variable is used for when they encounter it elsewhere in the code.
Edit: regardless, this is a great video showing the process of creating a GTK app in Haskell that is accessible even to people who have never used either. Thanks!
I think the idea here is that people should be able to read it. The code is verbose but terse haskell can be very intimidating.
@@harryhead100 In that case, the variable names could be better to improve readability (see the second point in my original comment).
This will be fun
I have to admit....this was fun little project.
GObject introspection is great when moving around languages. If you know the format the function names appear in a language, you can basically translate all glib function names and so on in your head and just use them.
its so impressive that gtk has haskell bindings :D
A most useful video
Glad you think so!
Great 👍!
cant think of a better infotube than distrotube. thnx man you teach me a lot
After looking at the Title and video length I'd say....
*Seems Legit*
Very Nice.
DT as a dev my self, always import your namespace/packages with a name like your Gtk var. this make it easy to fix bugs in your code when some time pass. it is a thing all Pro Devs do now, and in JS they make it the only way, it will save you so much time.
What is “Gtk var” pls? In JS you can import {thisWay}, or import thatWay, or even import {thisWay as otherWay}, or finally import from silently
@@sc0or it what a ref. to the dt code, but what i am talking about is ex. import ThisPart from './file' or import {ThisPart, andThis} from './file' in JS the problem is a lot of languages let you drop all from a namespace(NS)/module/package in to your current scope, and a lot of the time you get stuff with the same name, when you call the one from NS 1 and then NS 2 is update and got a function with the same name, sometime it is a problem the language will tell you sometime not, sometime it will keep calling from NS 1 but where if you remove NS 1 and you think you get a error for all the places it was you, but not the place with this call because it is calling NS 2 now.
there is a lot of other reasons you should always name your imports.
@@sc0or tl;dr always name your imports
@@zeocamo So, you mean import {Button} from '@mui/material' and import {Button} from 'react-bootstrap'? If "yes" this is not a problem. First, you can choose a different alias WHEN you start using a different import, and secondly, this happens once per 500 projects. Yet more thing... How people switch from one import to another? Do they delete all "import" statements and then add new ones? I think no. They apply 'replace in files' for ...form "" endings. How a custom alias can help in this case, I have no idea.
@@sc0or i said JS got it right from start, you can only things the right way in JS but in other languages like c or c# you can drop all classes or functions in your local scope, with out a alias
As a haskell dev, I'm mildly surprised by you making this!
But please write reusable code!
Define a function that takes the image url, the putStr str, command, and then returns the button and label.
While as a programmer I totally agree with you, I believe he might have done this on purpose not to overload new to programming viewers with sophisticated concepts such as functions
@@heinwol
"... programming viewers with sophisticated concepts such as functions ...."
Yeah, functions are very complex, use calculus 2 up to 3 to make one, and very confusing, especially in Haskell.
very good! thank you
Glad you liked it!
Bro... I've been working on a gtk widget lately. Nice timing 🙂
I love your content
That's a lot
yad --center --undecorated --skip-taskbar --timeout="5" --timeout-indicator="top" --button="Cancel:1" --button="Restart:reboot" --button="Shutdown:shutdown now" --button="Logout:killall openbox" ###logout will vary as to your WM
Wow wow wow WHAT? I was looking for something like that
With gtk you have to use the glade ui builder. It produces an xml file that you use at runtime to create gui
Nice video! Thanx! Can you explain some Haskell concept like monads?
I'm just starting with DTOS, looks great so far 😊
One thing I'd love to do is put an html file as the background. Is there a way to do it with xmonad, or do I need to work with the root window?
I can build a neutralino.js app that renders that file (with access to os functions) if that'd help.
I would actually love to learn haskell programming from you 🙏🏽
Great tutorial, I never used GTK but i was excited for it. Can you make more Haskell web application coding exercise.? Thanks
@DistroTube Hello! I am programmer & I watch your vids about every day last few months! I learned a lot from you. Anyway, I have a recommendation for you: IPFS. I looked your older videos and id not find any about IPFS. It would be great, if you find some time for It. Keep the good job! Bye :)
GTK Games! Yes :D
What version of haskell GHC are you on? I get an error that it could install because of "Failed to build haskell-gi-base-0.26.0" and "cabal.exe: The pkg-config package 'gobject-2.0' version >=2.42 is required but
it could not be found". Anyone with the same problem?
would be nice a second part refactoring the code to dynamically load config from a JSON file instead, containing [{ label, icon, command }] and replacing $user with the effective user name from the command string
W
First own Theme
Then own Distro
Then own software
Soon Derek will build his own kernel 💪🤣
When will Derek build his own grains of sand lol
I think the tool is great, the only thing I would add is the ability to type the escape key to exit the program. Does anyone know how to add a keyboardEventHandler in haskell? If so please share the boiler plate code.
`stack build` failed for me "while building package haskell-gi-base-0.26.0". I'm brand-new to haskell, so I'm not sure where the relevant error message is, but I also got "haskell-gi-base > version >=2.42 is required but it could not be found". I'm using macOS FWIW. Thank you!!!
😍😍
thank you
You're welcome. Stay tuned. Another video on Haskell/GTK and continuing with this app...coming in a few days. ;')
@@DistroTube I'm looking forward to the video.
thanks dt
Appreciate that! :D
Hey DT, have ever tried the stow tool to manage your dotfiles?
I think he made a video about it. I don’t know if he uses it or not but either that or git bare repo is the one he mentioned he uses
The moment when he named his grid "grid" and said no need for long and complicated name... I saw it already in my mind how long and complicated grid name would be dt. Or gr. Haha.
Hey, what icon gtk icon set are you using?
Personally been writing a Python script to parse and display Orgmode docs at work due to not being allowed to use EMACS 🥺
Why are you not allowed to use Emacs at work?
@@simponic not an approved open source software 🥱
stack is basically npm for haskell
I liked the icons on dt's application better.
Hi!
So, in programming you are working inside a virtual environment when you setup stack. That is why GCC gets compiled inside that environment. I'm sure you are aware of this, but the technical way of saying this is that you are creating a virtual environment. Some programming languages have the capability to set-up a virtual environment, and others you have to set up a Docker environment or something similar.
More like this
How come you are using Google when you made videos about not to use Google?
The best way to learn something is to create a tutorial.
You are a software developer, Harry.
i prefer gtk over qt. gtkmm is dope.
No need for stack or aur. Just use the standard arch packages. The issue your having is haskell-gi-gtk is version 4. You need to remove that and install haskell-gi-gtk3 and then simply compile with ghc -dynaic Main.hs and your good to go. Assuming you installed the other needed arch packages haskell-gi and gobject-introspection
Me who uses Rofi as a logout menu :D
Now make the same app in Golang! Thank me later...
i don't like haskell so i re created it in python
Whats the point of doing stuff like that in Haskell? The whole video you just was writing some imperative code that actually feels object-oriented and holds lots of state, just with getters and setters as separate functions.
Imperative? That's the harsh reality of working with a C library through cffi in a foreign language. That said, unlike python, you can easily compile your gtk app to a native binary in haskell.
@@l2ubio Yeah I think there should have been declarative wrapper for it that is more idiomatic to Haskell
i think your tshirt is on backwards
haskell is actually weird, but whatever xD
Nowadays stack is not necessary, as cabal does it all.
Does cabal ensure the package versions you use are compatible and compatible with the GHC version your using? That’s really the reason stack exists. To avoid the ol’ cabal hell problem.
@@sbditto85 yes, that is basic feature
Why did you waste your time on learning vim, emacs and other marginal stuff that is useless in any team these days?
“When I’ll be on an inhabitant island, and there will be x486 PC there...” is not a reason ;)
Gtk.init returns a monad, that you then changes. That is what do keywork does, manipulate monades.